예제 #1
0
        private void AddHighlightCommandExecute([NotNull] object obj)
        {
            Assert.ArgumentNotNull(obj, "obj");

            var highlightToAdd      = new HighlightViewModel(Groups, Groups.First(g => g.IsBuildIn), new Highlight());
            var highlightEditDialog = new HighlightEditDialog {
                DataContext = highlightToAdd, Owner = (Window)obj
            };

            highlightEditDialog.Show();
            highlightEditDialog.Closed += (s, e) => {
                if (highlightEditDialog.Save)
                {
                    highlightToAdd.HighlightGroup.AddHighlight(highlightToAdd);
                }
            };
        }
예제 #2
0
        private void EditHighlightCommandExecute([NotNull] object obj)
        {
            Assert.ArgumentNotNull(obj, "obj");

            if (SelectedHighlight == null)
            {
                return;
            }

            var originalHighlight   = SelectedHighlight;
            var highlightEditDialog = new HighlightEditDialog {
                DataContext = originalHighlight.Clone(), Owner = (Window)obj
            };

            highlightEditDialog.Show();
            highlightEditDialog.Closed += (s, e) => {
                if (!highlightEditDialog.Save)
                {
                    return;
                }

                var changedHighlight = (HighlightViewModel)highlightEditDialog.DataContext;
                if (originalHighlight.HighlightGroup == changedHighlight.HighlightGroup)
                {
                    var originalIndex = originalHighlight.HighlightGroup.Highlights.IndexOf(originalHighlight);
                    originalHighlight.HighlightGroup.InsertHighlight(originalIndex, changedHighlight);
                }
                else
                {
                    changedHighlight.HighlightGroup.AddHighlight(changedHighlight);
                }

                originalHighlight.HighlightGroup.RemoveHighlight(originalHighlight);
                SelectedHighlight = (HighlightViewModel)highlightEditDialog.DataContext;
            };
        }
예제 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="index"></param>
 /// <param name="highlightToAdd"></param>
 public void InsertHighlight(int index, [NotNull] HighlightViewModel highlightToAdd)
 {
     Assert.ArgumentNotNull(highlightToAdd, "highlightToAdd");
     Group.Highlights.Insert(index, highlightToAdd.Highlight);
     _highlights.Insert(index, highlightToAdd);
 }
예제 #4
0
 /// <summary>
 /// Removes the highlight.
 /// </summary>
 /// <param name="highlightToRemove">The highlight to remove.</param>
 public void RemoveHighlight([NotNull] HighlightViewModel highlightToRemove)
 {
     Assert.ArgumentNotNull(highlightToRemove, "highlightToRemove");
     Group.Highlights.Remove(highlightToRemove.Highlight);
     _highlights.Remove(highlightToRemove);
 }
예제 #5
0
 /// <summary>
 /// Adds the highlight.
 /// </summary>
 /// <param name="highlightToAdd">The highlight to add.</param>
 public void AddHighlight([NotNull] HighlightViewModel highlightToAdd)
 {
     Assert.ArgumentNotNull(highlightToAdd, "highlightToAdd");
     Group.Highlights.Add(highlightToAdd.Highlight);
     _highlights.Add(highlightToAdd);
 }