/// <summary> /// Add one Dock to the List /// </summary> /// <param name="c"></param> /// <param name="first"></param> void AddDockItem(Ambertation.Windows.Forms.DockPanel c, bool first) { ToolStripMenuItem mi = new ToolStripMenuItem(c.Text); if (first) { miWindow.DropDownItems.Add("-"); } mi.Image = c.TabImage; mi.Click += new EventHandler(Activate_miWindowDocks); mi.Tag = c; mi.Checked = c.IsOpen; if (c.Tag != null) { if (c.Tag is System.Windows.Forms.Shortcut) { LoadFileWrappersExt.SetShurtcutKey(mi, (System.Windows.Forms.Shortcut)c.Tag); } } /*c.VisibleChanged += new EventHandler(CloseDockControl); * c.Closed += new EventHandler(CloseDockControl);*/ c.OpenedStateChanged += new EventHandler(CloseDockControl); c.Tag = mi; miWindow.DropDownItems.Add(mi); }
/// <summary> /// Show/Hide a given Dock /// </summary> /// <param name="doc"></param> /// <param name="hide"></param> public static void ShowDock(Ambertation.Windows.Forms.DockPanel doc, bool hide) { if (sdd == null) { return; } sdd(doc, hide); }
MyButtonItem(ToolStripMenuItem item, string name) : base() { if (name == "") { name = "AButtonItem_" + namect; namect++; } refitem = item; if (item != null) { this.Image = item.Image; this.Visible = (item.Image != null); if (this.Image == null) { this.Text = item.Text; } this.ToolTipText = item.Text.Replace("&", ""); this.Enabled = item.Enabled; this.Click += new EventHandler(MyButtonItem_Activate); item.CheckedChanged += new EventHandler(item_CheckedChanged); item.EnabledChanged += new EventHandler(item_EnabledChanged); this.ToolTipText = item.Text; this.Enabled = item.Enabled; this.Checked = item.Checked; havedock = false; ToolMenuItemExt tmie = item as ToolMenuItemExt; if (tmie != null) { this.name = tmie.Name; } else { Ambertation.Windows.Forms.DockPanel dw = item.Tag as Ambertation.Windows.Forms.DockPanel; if (dw != null) { this.name = dw.Name; havedock = true; } else { this.name = "Button_" + (counter++); } } } else { havedock = false; this.name = name; } }
/// <summary> /// Called when a close Event was sent to a DockControl /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CloseDockControl(object sender, EventArgs e) { if (sender is Ambertation.Windows.Forms.DockPanel) { Ambertation.Windows.Forms.DockPanel c = (Ambertation.Windows.Forms.DockPanel)sender; if (c.Tag is ToolStripMenuItem) { ToolStripMenuItem mi = (ToolStripMenuItem)c.Tag; mi.Checked = c.IsOpen; } } }
/// <summary> /// this will update the Checked State of a Dock menu Item /// </summary> void UpdateDockMenus() { foreach (object o in miWindow.DropDownItems) { ToolStripMenuItem mi = o as ToolStripMenuItem; if (mi == null) { continue; } if (mi.Tag is Ambertation.Windows.Forms.DockPanel) { Ambertation.Windows.Forms.DockPanel c = (Ambertation.Windows.Forms.DockPanel)mi.Tag; mi.Checked = c.IsDocked || c.IsFloating; } } }
/// <summary> /// Reload the Layout from the Registry /// </summary> void ReloadLayout() { this.SuspendLayout(); //store defaults if (defaultlayout == null) { defaultlayout = Ambertation.Windows.Forms.Serializer.Global.ToStream(); } try { Ambertation.Windows.Forms.Serializer.Global.FromFile(Helper.DataFolder.SimPeLayout); } catch (Exception ex) { Helper.ExceptionMessage(ex); } resourceViewManager1.RestoreLayout(); UpdateDockMenus(); MyButtonItem.GetLayoutInformations(this); FixCheckedState(tbTools); FixCheckedState(toolBar1); foreach (ToolStripItem tsi in miWindow.DropDownItems) { ToolStripMenuItem tsmi = tsi as ToolStripMenuItem; if (tsmi == null) { continue; } if (tsmi.Tag == null) { continue; } Ambertation.Windows.Forms.DockPanel dp = tsmi.Tag as Ambertation.Windows.Forms.DockPanel; if (dp != null) { tsmi.Checked = dp.IsOpen; } } this.ResumeLayout(); }
void LoadDocks(Ambertation.Windows.Forms.DockContainer dc, LoadedPackage lp) { foreach (SimPe.Interfaces.IDockableTool idt in FileTable.ToolRegistry.Docks) { Ambertation.Windows.Forms.DockPanel dctrl = idt.GetDockableControl(); if (dctrl != null) { dctrl.Name = "dc." + idt.GetType().Namespace + "." + idt.GetType().Name; dctrl.Manager = dc.Manager; dc.Controls.Add(dctrl); //dctrl.DockNextTo(dc); ChangedGuiResourceEvent += new SimPe.Events.ChangedResourceEvent(idt.RefreshDock); dctrl.Tag = idt.Shortcut; idt.RefreshDock(this, new SimPe.Events.ResourceEventArgs(lp)); } } }
/// <summary> /// Called when a MenuItem that represents a Dock is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Activate_miWindowDocks(object sender, EventArgs e) { if (sender is ToolStripMenuItem) { ToolStripMenuItem mi = (ToolStripMenuItem)sender; if (mi.Tag is Ambertation.Windows.Forms.DockPanel) { Ambertation.Windows.Forms.DockPanel c = (Ambertation.Windows.Forms.DockPanel)mi.Tag; if (mi.Checked) { c.Close(); mi.Checked = c.IsOpen; } else { c.Open(); mi.Checked = c.IsOpen; plugger.ChangedGuiResourceEventHandler(); } } } }
/// <summary> /// Make a doc Visible or Hide it /// </summary> /// <param name="doc">The Doc you want to show/hide</param> public void ShowDock(Ambertation.Windows.Forms.DockPanel doc, bool hide) { if (hide && (doc.IsOpen)) { doc.Close(); } if (!hide) { if (!doc.IsOpen) { doc.OpenFloating(); } if (doc.Collapsed) { doc.Expand(false); } doc.EnsureVisible(); if (!(doc.IsOpen)) { plugger.ChangedGuiResourceEventHandler(); } } foreach (object o in docs.DropDownItems) { System.Windows.Forms.ToolStripMenuItem mi = o as System.Windows.Forms.ToolStripMenuItem; if (mi == null) { continue; } if (mi.Tag as Ambertation.Windows.Forms.DockPanel == doc) { mi.Checked = doc.IsOpen; } } }