/// <summary> /// Add a word to the list box. The item can optionally be animated. /// </summary> /// <param name="text"></param> /// <param name="animate"></param> private void AddItem(string text, bool animate, bool refreshSearch = false) { ListBoxItem i = new ListBoxItem(); i.Content = text; i.Style = listBox.FindResource("DictionaryEntry") as Style; if (animate) { if (Settings.AnimationsEnabled) { AnimationHelpers.LoadAnimation load = new AnimationHelpers.LoadAnimation(i); if (refreshSearch) { load.OnAnimationCompletedEvent += load_OnAnimationCompletedEvent; } load.Animate(26); // Hard-coded value of height } else if (refreshSearch) { // // Refresh search results, if applicable // Search(); } } listBox.Items.Insert(listBox.Items.Count - 1, i); }
private void AddTask(UserTask task, TreeViewItem group, bool animate = false, int insertIndex = -1) { TreeViewItem existingGroup = tasksTreeView.ContainsHeader(group.Header.ToString()); TreeViewItem taskItem = new TreeViewItem(); taskItem.MouseDoubleClick += taskItem_MouseDoubleClick; taskItem.Header = task; if (task.IsOverdue && task.Status != UserTask.StatusPhase.Completed) { taskItem.Foreground = new SolidColorBrush(Color.FromArgb(255, 218, 17, 17)); } if (existingGroup == null) { AddGroupContextMenu(group); tasksTreeView.SmartInsert(group); group.Tag = task.DueDate; if (insertIndex == -1) { group.Items.Add(taskItem); } else { group.Items.Insert(insertIndex, taskItem); } if (group.Header.ToString() == "Today") { group.IsExpanded = true; } else { group.IsExpanded = false; } } else { if (insertIndex == -1) { existingGroup.Items.Add(taskItem); } else { existingGroup.Items.Insert(insertIndex, taskItem); } if (group.Header.ToString() == "Today") { group.IsExpanded = true; } else { group.IsExpanded = false; } } if (animate && Settings.AnimationsEnabled) { AnimationHelpers.LoadAnimation anim = new AnimationHelpers.LoadAnimation(taskItem); // // BAD PROGRAMMING: Find out how to get render size of element before showing it. // anim.Animate(23); } if (Settings.AnimationsEnabled) { new AnimationHelpers.Fade(statusText, AnimationHelpers.FadeDirection.Out, true); } else { statusText.Visibility = Visibility.Hidden; } }