Exemplo n.º 1
0
        /// <summary>
        /// Restore state from selection history.
        /// </summary>
        /// <remarks>
        /// <para>Base functionality should be invoked when method is overridden.</para>
        /// </remarks>
        /// <example>
        /// <para>The following source code demonstrates how to restore additional data:</para>
        /// <code language="csharp"><![CDATA[
        /// public override void RestoreSelectionHistoryState(SelectionHistory.State state)
        /// {
        ///     base.RestoreSelectionHistoryState(state);
        ///
        ///     CustomHistoryState customState = (CustomHistoryState)state;
        ///     this.ShowCustomToolbar = customState.ShowCustomToolbar;
        /// }
        /// ]]></code>
        /// </example>
        /// <param name="state">Selection history state.</param>
        /// <seealso cref="CreateHistoryState"/>
        /// <seealso cref="UpdateHistoryState"/>
        public virtual void RestoreHistoryState(HistoryManager.State state)
        {
            var historyState = state as HistoryState;

            if (historyState == null)
            {
                return;
            }

            this.viewScrollPosition          = historyState.ScrollPosition;
            this.scrollingExtendedProperties = historyState.ExtendedPropertiesScrollPosition;
        }
        private void OnSelectedObjectChanged()
        {
            // Finish up with previous brush editor.
            this.UnloadDesignerView();

            if (this.SelectedObject is Brush)
            {
                this.LoadBrushDesignerView();

                if (!this.IsLocked)
                {
                    // Make sure that brush is shown in brush list.
                    this.BrushListModel.SelectedBrush = this.SelectedObject as Brush;
                    ToolUtility.RevealBrush(this.BrushListModel.SelectedBrush, false);
                }
            }
            else if (this.SelectedObject is Tileset)
            {
                this.LoadTilesetDesignerView();

                if (!this.IsLocked)
                {
                    // Make sure that tileset is shown in brush list.
                    this.BrushListModel.View            = BrushListView.Tileset;
                    this.BrushListModel.SelectedTileset = this.SelectedObject as Tileset;
                }
            }

            if (!this.History.IsNavigating)
            {
                if (this.designerView != null && this.SelectedObject != null && this.SelectedObject.Exists)
                {
                    this.currentState = this.designerView.CreateHistoryState();
                    this.History.AddToRecent(this.SelectedObject);
                }
            }

            // Clear active input control.
            this._clearFocusControl = true;

            this.Repaint();
        }
 void IHistoryManagerContext.OnNavigateBack(HistoryManager.State state)
 {
     this.OnNavigate(state);
 }
 /// <summary>
 /// Invoked when history manager navigates back or forward.
 /// </summary>
 /// <param name="state">New current state.</param>
 private void OnNavigate(HistoryManager.State state)
 {
     this.currentState   = state;
     this.SelectedObject = state.Object as IDesignableObject;
     this.designerView.RestoreHistoryState(state);
 }
 void IHistoryManagerContext.OnNavigateForward(HistoryManager.State state)
 {
     this.OnNavigate(state);
 }