Ejemplo n.º 1
0
        /// <summary>
        /// Hides the notebook and switches to paned mode
        /// </summary>
        /// <param name='newalign'>
        /// Newalign.
        /// </param>
        public void hideNotebook(ItemAlignment newalign)
        {
            List <Widget> widgets = new List <Widget>(20);

            for (int i = (notebook.NPages - 1); i > -1; i--)
            {
                Widget w = notebook.GetNthPage(i);
                notebook.RemovePage(i);
                w.Parent = null;
                widgets.Add(w);
            }


            notebook.Visible = false;
            PanedBox.removeItem(notebook);

            foreach (Widget w in widgets)
            {
                DockItemContainer dc = w as DockItemContainer;
                if (dc != null)
                {
                    dc.CurrentContainer = null;
                    addItem(dc, newalign);
                }
            }

            Mode = ViewMode.PanedBox;
        }
Ejemplo n.º 2
0
        void HandleBtnDockClicked(object sender, EventArgs e)
        {
            Gtk.Widget w;
            if (CurrentContainer.FrameNotebook.Visible == true)
            {
                w = CurrentContainer.removePage(this);                  //remove Page
                //Console.WriteLine(w.GetType().ToString());
            }
            else
            {
                w = PanedBox.removeItem(this);                 //remove Item
                //Console.WriteLine(w.GetType().ToString());
            }

            DockItemContainer container = (w as DockItemContainer);

            MainWindow.Instance.removeWidget(container.CurrentWidget as DockableWidget);

            DockItemContainer dc = w as DockItemContainer;

            Widget cw = dc.CurrentWidget;

            dc.removeCurrentWidget();
            cw.Parent = null;
            MainWindow.Instance.showAsPopupWindow(cw as DockableWidget);

            w.Destroy();
        }
Ejemplo n.º 3
0
        public void addPage(DockItemContainer itemcontainer, ItemAlignment align)
        {
            if ((itemcontainer.CurrentContainer != null) && (itemcontainer.CurrentContainer == this))
            {
                if (align != ItemAlignment.Center)
                {
                    if (notebook.Visible)
                    {
                        hideNotebook(align);
                        //setAlign(align);
                        return;
                    }
                }

//				if (align == ItemAlignment.Center)
//				{
//					addPages();
//					return;
//				}
            }
            else
            {
                itemcontainer.CurrentContainer = this;

                String title = itemcontainer.Name;
                if (itemcontainer.CurrentWidget != null)
                {
                    if (itemcontainer.CurrentWidget is DockableWidget)
                    {
                        if (!String.IsNullOrEmpty(((DockableWidget)itemcontainer.CurrentWidget).Title))
                        {
                            title = ((DockableWidget)itemcontainer.CurrentWidget).Title;
                        }
                    }
                }

                Gtk.Label lbl = new Gtk.Label(title);
                notebook.InsertPage(itemcontainer, lbl, notebook.NPages + 1);
            }

            if (OnItemAdded != null)
            {
                OnItemAdded(itemcontainer.CurrentWidget, new EventArgs());
            }
        }
Ejemplo n.º 4
0
        public void addItem(DockItemContainer item, ItemAlignment align, bool left = false)
        {
            items.Add(item);

            DockFramePosition pos = DockFramePosition.None;

            if (lastposition.ContainsKey(item.CurrentWidget.GetType().ToString()))
            {
                pos = lastposition[item.CurrentWidget.GetType().ToString()];
            }

            switch (pos)
            {
            case DockFramePosition.Left:
                left = true;
                break;

            case DockFramePosition.Right:
                left = false;
                break;
            }

            if (left)
            {
                if (dock1.Mode == ViewMode.Notebook)
                {
                    dock1.addPage(item, align);
                }
                else
                {
                    dock1.addItem(item, align);
                }
            }
            else
            {
                if (dock2.Mode == ViewMode.Notebook)
                {
                    dock2.addPage(item, align);
                }
                else
                {
                    dock2.addItem(item, align);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// adds a new item to the itemcontainer
        /// </summary>
        /// <param name='itemcontainer'>
        /// Itemcontainer.
        /// </param>
        /// <param name='align'>
        /// Align.
        /// </param>
        public void addItem(DockItemContainer itemcontainer, ItemAlignment align)
        {
            if ((itemcontainer.CurrentWidget != null) && (itemcontainer.CurrentWidget is DockcontainerWidget))
            {
                if (this == (itemcontainer.CurrentWidget as DockcontainerWidget).Dock)
                {
                    return;
                }
            }

            //itemcontainer.ParentWindow
            if ((itemcontainer.CurrentContainer != null) && (itemcontainer.CurrentContainer == this))
            {
                //containing this item
                if (align != ItemAlignment.Center)
                {
                    if (notebook.Visible)
                    {
                        hideNotebook(align);
                        setAlign(align);
                        return;
                    }
                }

                if (align == ItemAlignment.Center)
                {
                    addPages();
                    return;
                }
            }
            else
            {
                //Console.WriteLine("add new item: " + itemcontainer.Name);
                //add a new item
                itemcontainer.CurrentContainer = this;
                AddItem(itemcontainer);
                setAlign(align);
            }

            if (OnItemAdded != null)
            {
                OnItemAdded(itemcontainer.CurrentWidget, new EventArgs());
            }
        }         //addItem
Ejemplo n.º 6
0
        void HandleBtnCloseClicked(object sender, EventArgs e)
        {
            Gtk.Widget w;
            if (CurrentContainer.FrameNotebook.Visible == true)
            {
                w = CurrentContainer.removePage(this);                  //remove Page
                //Console.WriteLine(w.GetType().ToString());
            }
            else
            {
                w = PanedBox.removeItem(this);                 //remove Item
                //Console.WriteLine(w.GetType().ToString());
            }

            DockItemContainer container = (w as DockItemContainer);

            MainWindow.Instance.removeWidget(container.CurrentWidget as DockableWidget);
            w.Destroy();
        }
Ejemplo n.º 7
0
        public void addItem(DockItemContainer item,ItemAlignment align,bool left=false)
        {
            items.Add(item);

            DockFramePosition pos = DockFramePosition.None;
            if (lastposition.ContainsKey(item.CurrentWidget.GetType().ToString()))
            {
                pos = lastposition[item.CurrentWidget.GetType().ToString()];
            }

            switch (pos) {
                case DockFramePosition.Left:
                    left = true;
                    break;
                case DockFramePosition.Right:
                    left = false;
                    break;
            }

            if (left)
            {
                if (dock1.Mode == ViewMode.Notebook)
                {
                    dock1.addPage(item,align);
                } else {
                  dock1.addItem(item,align);
                }
            } else
            {
                if (dock2.Mode == ViewMode.Notebook)
                {
                    dock2.addPage(item,align);
                } else {
                  dock2.addItem(item,align);
                }
            }
        }
Ejemplo n.º 8
0
        protected override void doReadXml(XmlReader reader)
        {
            String   mode = reader["Mode"];
            ViewMode md   = ViewMode.PanedBox;

            Enum.TryParse <ViewMode>(mode, out md);
            this.Mode = md;

            base.doReadXml(reader);

            if (this.Widget1 != null)
            {
                DockItemContainer container = (this.Widget1 as DockItemContainer);
                if (container != null)
                {
                    container.CurrentContainer = this;
                }
            }

            foreach (Widget w in ChildWidgets)
            {
                DockItemContainer container = (w as DockItemContainer);
                if (container != null)
                {
                    container.CurrentContainer = this;
                }
            }


            while (reader.LocalName != "pages" && reader.Read())
            {
                ;
            }
            if (reader.LocalName == "pages")
            {
                if (!reader.IsEmptyElement)
                {
                    int pos = 0;
                    while (reader.Read())                     // Skip ahead to next node
                    //while (reader.LocalName != "page" && reader.Read());

                    //while (reader.LocalName == "page")
                    {
                        String label = reader["label"];

                        reader.Read();                         //move to content element
                        if (!reader.IsEmptyElement)
                        {
                            String assembly = reader["assembly"];
                            if (!String.IsNullOrEmpty(assembly))
                            {
                                String tp = reader.LocalName + "," + assembly;
                                Widget w  = (Widget)Sharpend.Utils.Reflection.createInstance(Type.GetType(tp));

                                DockItemContainer container = (w as DockItemContainer);
                                if (container != null)
                                {
                                    container.CurrentContainer = this;
                                }


                                IXmlSerializable xs = w as IXmlSerializable;
                                if (xs != null)
                                {
                                    xs.ReadXml(reader);
                                }
                                notebook.InsertPage(w, new Gtk.Label(label), pos);
                                pos++;
                            }
                            else
                            {
                                break;
                            }
                            while (reader.LocalName != "page" && reader.Read())
                            {
                                ;
                            }
                        }
                    }

                    AddItem(notebook);
                    notebook.Page      = 0;
                    Mode               = ViewMode.Notebook;
                    notebook.Visible   = true;
                    container1.Visible = true;
                    //container2.Visible  = true;
                }
                else
                {
                    reader.Read();                     //skip pages
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// switch to notebook mode
        /// </summary>
        /// <exception cref='Exception'>
        /// Represents errors that occur during application execution.
        /// </exception>
        protected void addPages()
        {
            if (notebook.Visible)
            {
                throw new Exception("this should not happen");                 //TODO
            }
            else
            {
                //Console.WriteLine("addPages()");
                List <PanedBox> lst = ChildBoxes;

                int pos = 0;

                notebook.Visible = false;

                foreach (PanedBox pb in lst)
                {
                    Widget w = PanedBox.removeItem(pb.Widget1);
                    if (w != null)
                    {
                        String            title = w.Name;
                        DockItemContainer dc    = w as DockItemContainer;
                        if (dc != null)
                        {
                            if (dc.CurrentWidget != null)
                            {
                                if (dc.CurrentWidget is DockableWidget)
                                {
                                    if (!String.IsNullOrEmpty(((DockableWidget)dc.CurrentWidget).Title))
                                    {
                                        title = ((DockableWidget)dc.CurrentWidget).Title;
                                    }
                                }
                            }
                        }

                        Gtk.Label lbl2 = new Gtk.Label(title);
                        //w.Parent = null;
                        //w.Reparent(notebook);
                        Gtk.Container c = (w.Parent as Gtk.Container);
                        if (c != null)
                        {
                            c.Remove(w);
                        }

                        //Console.WriteLine("insert page: " + w.Name + " visible: " + w.Visible);
                        //Console.WriteLine("notebook: " + notebook.Visible);
                        notebook.InsertPage(w, lbl2, pos);

                        pos++;
                    }
                    else
                    {
                        throw new Exception("item " + w.Name + "is to in the panedbox");
                    }
                }

                Widget first = removeItem(Widget1);

                String tt2 = first.Name;
                if (first is DockItemContainer)
                {
                    DockItemContainer dc = first as DockItemContainer;

                    if (!String.IsNullOrEmpty(((DockableWidget)dc.CurrentWidget).Title))
                    {
                        tt2 = ((DockableWidget)dc.CurrentWidget).Title;
                    }
                }

                Gtk.Label lbl = new Gtk.Label(tt2);

                notebook.Visible = true;
                //Console.WriteLine("insert page: " + first.Name + " visible: " + first.Visible);
                //Console.WriteLine("notebook: " + notebook.Visible);
                notebook.InsertPage(first, lbl, pos);

                AddItem(notebook);
                notebook.Page = 0;
                Mode          = ViewMode.Notebook;
            }
        }
Ejemplo n.º 10
0
        public void addPage(DockItemContainer itemcontainer, ItemAlignment align)
        {
            if ((itemcontainer.CurrentContainer != null) && (itemcontainer.CurrentContainer == this))
            {
                if (align != ItemAlignment.Center)
                {
                    if (notebook.Visible)
                    {
                        hideNotebook(align);
                        //setAlign(align);
                        return;
                    }
                }

            //				if (align == ItemAlignment.Center)
            //				{
            //					addPages();
            //					return;
            //				}
            } else
            {
                itemcontainer.CurrentContainer = this;

                String title = itemcontainer.Name;
                if (itemcontainer.CurrentWidget != null)
                {
                    if (itemcontainer.CurrentWidget is DockableWidget)
                    {
                        if (!String.IsNullOrEmpty(((DockableWidget)itemcontainer.CurrentWidget).Title))
                        {
                            title = ((DockableWidget)itemcontainer.CurrentWidget).Title;
                        }
                    }
                }

                Gtk.Label lbl = new Gtk.Label(title);
                notebook.InsertPage(itemcontainer,lbl,notebook.NPages+1);
            }

            if (OnItemAdded != null)
            {
                OnItemAdded(itemcontainer.CurrentWidget,new EventArgs());
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// adds a new item to the itemcontainer
        /// </summary>
        /// <param name='itemcontainer'>
        /// Itemcontainer.
        /// </param>
        /// <param name='align'>
        /// Align.
        /// </param>
        public void addItem(DockItemContainer itemcontainer, ItemAlignment align)
        {
            if ((itemcontainer.CurrentWidget != null) && (itemcontainer.CurrentWidget is DockcontainerWidget))
            {
                if (this == (itemcontainer.CurrentWidget as DockcontainerWidget).Dock)
                {
                    return;
                }
            }

            //itemcontainer.ParentWindow
            if ((itemcontainer.CurrentContainer != null) && (itemcontainer.CurrentContainer == this))
            {
                //containing this item
                if (align != ItemAlignment.Center)
                {
                    if (notebook.Visible)
                    {
                        hideNotebook(align);
                        setAlign(align);
                        return;
                    }
                }

                if (align == ItemAlignment.Center)
                {
                    addPages();
                    return;
                }
            } else
            {
                //Console.WriteLine("add new item: " + itemcontainer.Name);
                //add a new item
                itemcontainer.CurrentContainer = this;
                AddItem(itemcontainer);
                setAlign(align);
            }

            if (OnItemAdded != null)
            {
                OnItemAdded(itemcontainer.CurrentWidget,new EventArgs());
            }
        }