public static void addWindows(Container parent = null) { if (parent == null) { addWindows(MainWindow.Instance); } else { DockableWidget wnd = parent as DockableWidget; if (wnd != null) { if (!MainWindow.Instance.WindowList.ContainsKey(wnd.ID)) { MainWindow.Instance.WindowList.Add(wnd.ID, wnd); //wnd.hookDelegates(); //not needed because the hookDelegates call in hookDelegates() above ?? } } if (parent.Children != null) { foreach (Widget w in parent.Children) { Container c = w as Container; if (c != null) { addWindows(c); } } } } }
/// <summary> /// creates a dockable widget by classname /// /// uses parameters and delegates from the windows.config file /// </summary> /// <returns> /// The dockable widget. /// </returns> /// <param name='classname'> /// Classname. /// </param> public DockableWidget createDockableWidget(String classname) { XmlNode nd = Configuration.ConfigurationManager.getValue("windows.config", "//window[@class = '" + classname + "']"); if (nd != null) { return(DockableWidget.CreateInstance(nd)); } return(null); }
/// <summary> /// called when a popup window is destoryed ... then we have to remove it from the windowlist /// </summary> /// <param name='sender'> /// Sender. /// </param> /// <param name='e'> /// E. /// </param> void HandlePwDestroyed(object sender, EventArgs e) { PopupWindow pw = (sender as PopupWindow); if (pw != null) { DockableWidget dw = (pw.CurrentWidget as DockableWidget); if (dw != null) { windowlist.Remove(dw.ID); } } }
/// <summary> /// add a new dockable widegt to the mainwindow /// </summary> /// <param name='widget'> /// Widget. /// </param> protected void addWidget(DockableWidget widget) { if (!windowlist.ContainsKey(widget.ID)) { windowlist.Add(widget.ID, widget); widget.Visible = true; frame.addItem(new DockItemContainer(frame, widget), ItemAlignment.Top, true); } else { Console.WriteLine("Window is already in list: " + widget.ID); //TODO logging } }
void HandleOnClose(object o, EventArgs e) { Console.WriteLine("HandleOnClose" + o); PopupWindow pw = (o as PopupWindow); if (pw != null) { Console.WriteLine("HandleOnClose CW" + pw.CurrentWidget); DockableWidget dw = (pw.CurrentWidget as DockableWidget); if (dw != null) { windowlist.Remove(dw.ID); } } }
void HandleDeleteEvent(object o, DeleteEventArgs args) { Console.WriteLine("HandleDeleteEvent: " + o); PopupWindow pw = (o as PopupWindow); if (pw != null) { Console.WriteLine("HandleDeleteEvent: " + pw.CurrentWidget); DockableWidget dw = (pw.CurrentWidget as DockableWidget); if (dw != null) { windowlist.Remove(dw.ID); } } }
public static DockableWidget createWindow(ParameterSet param, DelegateSet delegates) { ConstructorInfo ci = param.BaseType.GetConstructor(param.Types); object o = ci.Invoke(param.Data); if (o != null) { DockableWidget wnd = (DockableWidget)o; wnd.Params = param; wnd.Delegates = delegates; wnd.hookDelegates(); wnd.afterInit(); return(wnd); } return(null); }
/// <summary> /// show a dockable widget as popup window /// </summary> /// <param name='widget'> /// Widget. /// </param> public void showAsPopupWindow(DockableWidget widget) { if (!windowlist.ContainsKey(widget.ID)) { PopupWindow pw = new PopupWindow(widget); windowlist.Add(widget.ID, widget); pw.SetSizeRequest(640, 480); pw.WindowPosition = WindowPosition.CenterOnParent; //pw.Destroyed += HandlePwDestroyed; pw.DeleteEvent += HandleDeleteEvent; pw.OnClose += HandleOnClose; //pw.Destroyed += HandleDestroyed; pw.ShowAll(); } }
public void createPopupWindow(ParameterSet param) { Console.WriteLine("createPopupWindow"); DockableWidget wnd = DockableWidget.createWindow(param, null); //addWidget(wnd); PopupWindow pw = new PopupWindow(wnd); windowlist.Add(wnd.ID, wnd); pw.SetSizeRequest(640, 480); pw.WindowPosition = WindowPosition.CenterAlways; //pw.Destroyed += HandlePwDestroyed; pw.DeleteEvent += HandleDeleteEvent; pw.OnClose += HandleOnClose; //pw.DestroyEvent += HandleDestroyEvent; pw.Shown += HandlePwShown; pw.ShowAll(); }
//TODO nameing ... functionnames upper or lowercase ? public void createPopupWindow(String classname) { //String configfile = Configuration.ConfigurationManager.AppSettings["windows_config"]; XmlNode nd = Configuration.ConfigurationManager.getValue("windows.config", "//window[@class = '" + classname + "']"); if (nd != null) { DockableWidget wnd = DockableWidget.CreateInstance(nd); //addWidget(wnd); showAsPopupWindow(wnd); } else { //TODO exception or logging ?? Console.WriteLine("Window " + classname + " has no entry in windows.config"); } }
private void CreateWindow(XmlNode node) { DockableWidget wnd = DockableWidget.CreateInstance(node); addWidget(wnd); }
public void removeWidget(DockableWidget widget) { widget.unHookDelegates(); windowlist.Remove(widget.ID); }