Esempio n. 1
0
        /// <summary>
        /// Handles a change to the IsLayoutFrozen dependency property.
        /// </summary>
        /// <param name="dependencyObject">The object that owns the property.</param>
        /// <param name="dependencyPropertyChangedEventArgs">A description of the changed property.</param>
        private static void OnIsLayoutFrozenChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            // The layout controls the relative size of the row and column headers.
            UndoObject undoObject = new UndoObject(dependencyPropertyChangedEventArgs.OldValue, dependencyPropertyChangedEventArgs.NewValue, UndoAction.Create);

            DynamicReport.SetIsLayoutFrozen.Execute(undoObject, dependencyObject as DynamicReport);
        }
Esempio n. 2
0
        /// <summary>
        /// Freezes or unfreezes the layout of the column and row header panels.
        /// </summary>
        /// <param name="sender">The object that originated the routed event.</param>
        /// <param name="routedEventArgs">The routed event arguments.</param>
        public void OnSetIsLayoutFrozen(Object sender, RoutedEventArgs routedEventArgs)
        {
            // The idea is to extract the parameters from the event data and set frozen state of the panel layout based on the
            // values provided.
            ExecutedRoutedEventArgs executedRoutedEventArgs = routedEventArgs as ExecutedRoutedEventArgs;

            // The simplest form for this command simply passes in a value.  The command parameter is burpped back up to the
            // property which then issues a command back here with the proper Undo information encoded in the command.  The idea is
            // to simplify the calling parameters for an externally invoked command while still maintaining a consistent format
            // internally for handling the undo/redo operations.
            if (executedRoutedEventArgs.Parameter is Boolean)
            {
                SetValue(DynamicReport.IsLayoutFrozenProperty, (Boolean)executedRoutedEventArgs.Parameter);
            }

            // This parameter format handles the undo/redo logic.
            if (this.reportGrid != null && executedRoutedEventArgs.Parameter is UndoObject)
            {
                // Extract the parameter and do the actual work involved with freezing the panes.
                UndoObject undoObject = executedRoutedEventArgs.Parameter as UndoObject;
                this.reportGrid.FreezePanes((Boolean)undoObject.NewValue, undoObject.UndoAction);

                // Once the command is finished, this will broadcast the event.  The primary consumer is the Undo logic which will
                // save the event data on the Undo or Redo stack and can replay it when needed.
                RaiseEvent(new UndoPropertyChangedEventArgs(DynamicReport.UndoPropertyChangedEvent, undoObject.UndoAction,
                                                            DynamicReport.IsLayoutFrozenProperty, undoObject.OldValue, undoObject.NewValue));

                // The property must be set when this operation is called from the Undo or Redo methods.  However, setting the
                // value will lead the logic right back here.  This will inhibit the command processing while the Undone or Redone
                // value is restored.
                if (undoObject.UndoAction == UndoAction.Undo || undoObject.UndoAction == UndoAction.Redo)
                {
                    this.CommandBindings.Remove(this.reportGrid.commandBingingMap[DynamicReport.SetIsLayoutFrozen]);
                    SetValue(DynamicReport.IsLayoutFrozenProperty, undoObject.NewValue);
                    this.CommandBindings.Add(this.reportGrid.commandBingingMap[DynamicReport.SetIsLayoutFrozen]);
                }
            }
        }