Ejemplo n.º 1
0
        private void ToggleDetailExpansionCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var gridContext = DataGridControl.GetDataGridContext(this);
            var destContext = DataGridControl.GetDataGridContext(this.DestContainer);
            var destItem    = this.DestContainer.DataContext;

            var isExpanded = gridContext.AreDetailsExpanded(this.DataContext);

            if (isExpanded == true)
            {
                destContext.ExpandDetails(destItem);
            }
            else
            {
                destContext.CollapseDetails(destItem);
            }
            (gridContext.DataGridControl as DiffDataGridControl).InvokeDetailsToggledEvent();
            (destContext.DataGridControl as DiffDataGridControl).InvokeDetailsToggledEvent();

            if (DiffUndoService.GetUndoService(this) is IUndoService undoService)
            {
                undoService.Push(new DetailsToggledAction(gridContext, this.DataContext, destContext, destItem, isExpanded));
            }
            this.Dispatcher.InvokeAsync(this.SetSelectionProperty, DispatcherPriority.Render);
        }
Ejemplo n.º 2
0
 public void Resolve()
 {
     try
     {
         var undoService = DiffUndoService.GetUndoService(this);
         this.Source.Resolve();
         undoService.Clear();
     }
     catch (Exception e)
     {
         AppMessageBox.ShowError(e);
         return;
     }
 }
Ejemplo n.º 3
0
        private void CopyPropertyToLeftSide_Execute(object sender, ExecutedRoutedEventArgs e)
        {
            var undoService = DiffUndoService.GetUndoService(this);

            if (this.Source != null && e.Parameter is string propertyName)
            {
                if (propertyName == nameof(CremaDataTable.Name))
                {
                    if (this.Source.ItemName1 != this.Source.ItemName2)
                    {
                        var oldValue   = this.Source.ItemName1;
                        var redoAction = new Action(() => this.Source.ItemName1 = this.Source.ItemName2);
                        var undoAction = new Action(() => this.Source.ItemName1 = oldValue);
                        undoService.Execute(new DelegateUndoAction(nameof(CremaDataTable.Name), redoAction, undoAction));
                    }
                }
                else if (propertyName == nameof(CremaDataTable.Tags))
                {
                    if (this.Source.Tags1 != this.Source.Tags1)
                    {
                        var oldValue   = this.Source.Tags1;
                        var redoAction = new Action(() => this.Source.Tags1 = this.Source.Tags2);
                        var undoAction = new Action(() => this.Source.Tags1 = oldValue);
                        undoService.Execute(new DelegateUndoAction(nameof(CremaDataTable.Tags), redoAction, undoAction));
                    }
                }
                else if (propertyName == nameof(CremaDataTable.Comment))
                {
                    if (this.Source.Comment1 != this.Source.Comment2)
                    {
                        var oldValue   = this.Source.Comment1;
                        var redoAction = new Action(() => this.Source.Comment1 = this.Source.Comment2);
                        var undoAction = new Action(() => this.Source.Comment1 = oldValue);
                        undoService.Execute(new DelegateUndoAction(nameof(CremaDataTable.Comment), redoAction, undoAction));
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void CopyPropertyToRightSide_Execute(object sender, ExecutedRoutedEventArgs e)
        {
            var undoService = DiffUndoService.GetUndoService(this);

            if (this.Source != null && e.Parameter is string propertyName)
            {
                if (propertyName == nameof(CremaDataType.Name))
                {
                    if (this.Source.ItemName2 != this.Source.ItemName1)
                    {
                        var oldValue   = this.Source.ItemName2;
                        var redoAction = new Action(() => this.Source.ItemName2 = this.Source.ItemName1);
                        var undoAction = new Action(() => this.Source.ItemName2 = oldValue);
                        undoService.Execute(new DelegateUndoAction(nameof(CremaDataType.Name), redoAction, undoAction));
                    }
                }
                else if (propertyName == nameof(CremaDataType.IsFlag))
                {
                    if (this.Source.IsFlag2 != this.Source.IsFlag1)
                    {
                        var oldValue   = this.Source.IsFlag2;
                        var redoAction = new Action(() => this.Source.IsFlag2 = this.Source.IsFlag1);
                        var undoAction = new Action(() => this.Source.IsFlag2 = oldValue);
                        undoService.Execute(new DelegateUndoAction(nameof(CremaDataType.IsFlag), redoAction, undoAction));
                    }
                }
                else if (propertyName == nameof(CremaDataType.Comment))
                {
                    if (this.Source.Comment2 != this.Source.Comment1)
                    {
                        var oldValue   = this.Source.Comment2;
                        var redoAction = new Action(() => this.Source.Comment2 = this.Source.Comment1);
                        var undoAction = new Action(() => this.Source.Comment2 = oldValue);
                        undoService.Execute(new DelegateUndoAction(nameof(CremaDataType.Comment), redoAction, undoAction));
                    }
                }
            }
        }
Ejemplo n.º 5
0
        protected override void OnRowDrop(ModernDragEventArgs e)
        {
            var undoService = DiffUndoService.GetUndoService(this);

            if (undoService != null)
            {
                var action = new SetIndexAction(e.Item)
                {
                    Selector     = DiffUndoService.GetSelector(this),
                    SelectedItem = this.DataContext
                };
                base.OnRowDrop(e);
                if (e.Handled == true)
                {
                    action.Complete();
                    undoService.Push(action);
                }
            }
            else
            {
                base.OnRowDrop(e);
            }
        }