Esempio n. 1
0
        public void RemoveDocument(Document doc)
        {
            // Remove from our list of actions
            RadioAction act = OpenWindows.Where(p => p.Name == doc.Guid.ToString()).FirstOrDefault();

            OpenWindows.Remove(act);
            act.Dispose();

            window_menu.HideAll();

            // Remove all the menu items from the menu
            foreach (var item in action_menu_items.Values)
            {
                window_menu.Remove(item);
                item.Dispose();
            }

            action_menu_items.Clear();

            // Recreate all of our menu items
            // I tried simply changing the accelerators, but could
            // no get it to work.
            CheckMenuItem menuitem;

            for (int i = 0; i < OpenWindows.Count; i++)
            {
                RadioAction action = OpenWindows[i];

                if (i < 9)
                {
                    menuitem = action.CreateAcceleratedMenuItem(IntegerToNumKey(i + 1), Gdk.ModifierType.Mod1Mask);
                }
                else
                {
                    menuitem = (CheckMenuItem)action.CreateMenuItem();
                }

                action_menu_items.Add(action, menuitem);
                window_menu.Add(menuitem);
            }

            window_menu.ShowAll();
        }
Esempio n. 2
0
        public RadioAction AddDocument(Document doc)
        {
            RadioAction action = new RadioAction(doc.Guid.ToString(), doc.Filename, string.Empty, null, 0);

            // Tie these all together as a radio group
            if (OpenWindows.Count > 0)
            {
                action.Group = OpenWindows[0].Group;
            }

            action.Active     = true;
            action.Activated += (o, e) => { if ((o as Gtk.ToggleAction).Active)
                                            {
                                                PintaCore.Workspace.SetActiveDocumentInternal(doc);
                                            }
            };

            OpenWindows.Add(action);
            CheckMenuItem menuitem;

            // We only assign accelerators up to Alt-9
            if (OpenWindows.Count < 10)
            {
                menuitem = action.CreateAcceleratedMenuItem(IntegerToNumKey(OpenWindows.Count), Gdk.ModifierType.Mod1Mask);
            }
            else
            {
                menuitem = (CheckMenuItem)action.CreateMenuItem();
            }

            action_menu_items.Add(action, menuitem);
            window_menu.Add(menuitem);

            doc.Renamed        += (o, e) => { UpdateMenuLabel(action, o as Document); };
            doc.IsDirtyChanged += (o, e) => { UpdateMenuLabel(action, o as Document); };

            return(action);
        }