/// <summary> /// Deserialize layout /// </summary> /// <param name="manager">Dock manager for initing objects</param> /// <param name="node">Node to parse</param> /// <param name="handlerObject">Delegate used to get user defined dockable contents</param> public void Deserialize(DockManager manager, XmlNode node, GetContentFromTypeString handlerObject) { _size = (Size)TypeDescriptor.GetConverter(typeof(Size)).ConvertFromInvariantString(node.Attributes[ATTRIBUTE_NAME_SIZE].Value); _dockType = (Dock)Enum.Parse(typeof(Dock), node.Attributes[ATTRIBUTE_NAME_DOCK].Value); PaneState state = (PaneState)Enum.Parse(typeof(PaneState), node.Attributes[ATTRIBUTE_NAME_STATE].Value); State = (PaneState.FloatingWindow == state) ? PaneState.DockableWindow : state; // NOTE: for support old versions _ptFloatingWindow = (Point)System.ComponentModel.TypeDescriptor.GetConverter(typeof(Point)).ConvertFromInvariantString(node.Attributes[ATTRIBUTE_NAME_PTFLOATWND].Value); _szFloatingWindow = (Size)System.ComponentModel.TypeDescriptor.GetConverter(typeof(Size)).ConvertFromInvariantString(node.Attributes[ATTRIBUTE_NAME_SZFLOATWND].Value); DockableContent content = handlerObject(node.ChildNodes[0].Name); // set state content.DockManager = manager; _SetContent(content); if ((PaneState.Docked == State) || (PaneState.Hidden == State)) { Show(); } else { tbTitle.Text = _content.Title; cpClientWindowContent.Content = _content.Content; cpClientWindowContent.Visibility = Visibility.Visible; _CreateFloatingWindow(_state); _InitFloatingWindowPosition(); } }
/// <summary> /// Create and show a floating window hosting this pane /// </summary> private void _CreateAndShowFloatingWindow(PaneState state) { _CreateFloatingWindow(state); Debug.Assert(null != _wndFloating); _InitFloatingWindowPosition(); _wndFloating.Show(); }
/// <summary> /// Change pane internal state /// </summary> /// <param name="newState">New pane state</param> /// <remarks>OnStateChanged event is raised only if newState is different from State.</remarks> internal void ChangeState(PaneState newState) { if (State != newState) { SaveSize(); _lastState = _state; _state = newState; FireOnOnStateChanged(); } }
internal static string GetXmlValue(this PaneState state) { switch (state) { case PaneState.Split: return("split"); case PaneState.Frozen: return("frozen"); case PaneState.FrozenSplit: return("frozenSplit"); default: throw new ArgumentOutOfRangeException(nameof(state), "Invalid Pane State: " + state); } }
/// <summary> /// Change pane internal state /// </summary> /// <param name="newState">New pane state</param> /// <remarks>OnStateChanged event is raised only if newState is different from State.</remarks> public void ChangeState(PaneState newState) { if (State != newState) { StoreSize(); State = newState; if (PaneState.Docked == newState) { _content.DockManager.Add(this); } else { _content.DockManager.Remove(this); } } }
/// <summary> /// Create a floating window hosting this pane /// </summary> private void _CreateFloatingWindow(PaneState state) { Debug.Assert((PaneState.DockableWindow == state)); StoreSize(); State = state; if (null == _wndFloating) { _content.DockManager.Remove(this); ShowHeader = false; _wndFloating = new FloatingWindow(this); _wndFloating.Owner = _content.DockManager.ParentWindow; _wndFloating.Width = _szFloatingWindow.Width; _wndFloating.Height = _szFloatingWindow.Height; } }
public void TurnLeft() { switch (Direction) { case PaneState.MovingUpward: Direction = PaneState.MovingLeftward; break; case PaneState.MovingDownward: Direction = PaneState.MovingRightward; break; case PaneState.MovingLeftward: Direction = PaneState.MovingDownward; break; case PaneState.MovingRightward: Direction = PaneState.MovingUpward; break; } }
public override void Deserialize(DockManager managerToAttach, XmlNode node, GetContentFromTypeString getObjectHandler) { base.Deserialize(managerToAttach, node, getObjectHandler); _dock = (Dock)Enum.Parse(typeof(Dock), node.Attributes["Dock"].Value); _state = (PaneState)Enum.Parse(typeof(PaneState), node.Attributes["State"].Value); _lastState = (PaneState)Enum.Parse(typeof(PaneState), node.Attributes["LastState"].Value); ptFloatingWindow = (Point)System.ComponentModel.TypeDescriptor.GetConverter(typeof(Point)).ConvertFromInvariantString(node.Attributes["ptFloatingWindow"].Value); sizeFloatingWindow = (Size)System.ComponentModel.TypeDescriptor.GetConverter(typeof(Size)).ConvertFromInvariantString(node.Attributes["sizeFloatingWindow"].Value); if (State == PaneState.FloatingWindow) { FloatingWindow(); } else if (State == PaneState.DockableWindow) { DockableWindow(); } DockManager.AttachPaneEvents(this); }
public override void Deserialize(DockManager managerToAttach, XmlNode node, GetContentFromTypeString getObjectHandler) { base.Deserialize(managerToAttach, node, getObjectHandler); _dock = (Dock)Enum.Parse(typeof(Dock), node.Attributes["Dock"].Value); _state = (PaneState)Enum.Parse(typeof(PaneState), node.Attributes["State"].Value); _lastState = (PaneState)Enum.Parse(typeof(PaneState), node.Attributes["LastState"].Value); ptFloatingWindow = (Point)System.ComponentModel.TypeDescriptor.GetConverter(typeof(Point)).ConvertFromInvariantString(node.Attributes["ptFloatingWindow"].Value); sizeFloatingWindow = (Size)System.ComponentModel.TypeDescriptor.GetConverter(typeof(Size)).ConvertFromInvariantString(node.Attributes["sizeFloatingWindow"].Value); if (State == PaneState.FloatingWindow) FloatingWindow(); else if (State == PaneState.DockableWindow) DockableWindow(); DockManager.AttachPaneEvents(this); }
public void Mark() { this.BackgroundImage = Properties.Resources.Marked; this.State = PaneState.Marked; }
/// <summary> /// 打开一个小方块 /// </summary> public void Open() { if (this.HasMine) { //有地雷 this.BackgroundImage = Properties.Resources.Mine; this.Enabled = false; } else { switch (this.AroundMineCount) { case 0: this.BackgroundImage = null; this.Enabled = false; this.State = PaneState.Opened; break; case 1: this.BackgroundImage = Properties.Resources._01; this.Enabled = false; this.State = PaneState.Opened; break; case 2: this.BackgroundImage = Properties.Resources._02; this.Enabled = false; this.State = PaneState.Opened; break; case 3: this.BackgroundImage = Properties.Resources._03; this.Enabled = false; this.State = PaneState.Opened; break; case 4: this.BackgroundImage = Properties.Resources._04; this.Enabled = false; this.State = PaneState.Opened; break; case 5: this.BackgroundImage = Properties.Resources._05; this.Enabled = false; this.State = PaneState.Opened; break; case 6: this.BackgroundImage = Properties.Resources._06; this.Enabled = false; this.State = PaneState.Opened; break; case 7: this.BackgroundImage = Properties.Resources._07; this.Enabled = false; this.State = PaneState.Opened; break; case 8: this.BackgroundImage = Properties.Resources._08; this.Enabled = false; this.State = PaneState.Opened; break; } } }
public void Reset() { this.BackgroundImage = null; this.State = PaneState.Closed; }
/// <summary> /// Change pane internal state /// </summary> /// <param name="newState">New pane state</param> /// <remarks>OnStateChanged event is raised only if newState is different from State.</remarks> public void ChangeState(PaneState newState) { if (State != newState) { StoreSize(); State = newState; if (PaneState.Docked == newState) _content.DockManager.Add(this); else _content.DockManager.Remove(this); } }