当前位置: 首页>>代码示例>>C#>>正文


C# Window.AddAccelGroup方法代码示例

本文整理汇总了C#中Gtk.Window.AddAccelGroup方法的典型用法代码示例。如果您正苦于以下问题:C# Window.AddAccelGroup方法的具体用法?C# Window.AddAccelGroup怎么用?C# Window.AddAccelGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gtk.Window的用法示例。


在下文中一共展示了Window.AddAccelGroup方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

        public static Gtk.Window Create()
        {
            window = new Window ("Menus");

            AccelGroup accel_group = new AccelGroup ();
            window.AddAccelGroup (accel_group);

            VBox box1 = new VBox (false, 0);
            window.Add (box1);

            MenuBar menubar = new MenuBar ();
            box1.PackStart (menubar, false, false, 0);

            Menu menu = Create_Menu (2, true);
            MenuItem menuitem = new MenuItem ("foo");
            menuitem.Submenu = menu;
            menubar.Append (menuitem);

            menuitem = new MenuItem ("bar");
            menuitem.Submenu = Create_Menu (3, true);
            menubar.Append (menuitem);

            Image image = new Image (Stock.Help, IconSize.Menu);

            menuitem = new ImageMenuItem ("Help");
            ((ImageMenuItem) menuitem).Image = image;
            menuitem.Submenu = Create_Menu (4, true);
            menuitem.RightJustified = true;
            menubar.Append (menuitem);

            menubar = new MenuBar ();
            box1.PackStart (menubar, false, true, 0);

            menu = Create_Menu (2, true);

            menuitem = new MenuItem ("Second menu bar");
            menuitem.Submenu = menu;
            menubar.Append (menuitem);

            VBox box2 = new VBox (false, 10);
            box2.BorderWidth = 10;
            box1.PackStart (box2, true, true, 0);

            menu = Create_Menu (1, false);
            menu.AccelGroup = accel_group;

            menu.Append (new SeparatorMenuItem ());

            menuitem = new CheckMenuItem ("Accelerate Me");
            menu.Append (menuitem);
            menuitem.AddAccelerator ("activate", accel_group, 0xFFBE, 0, AccelFlags.Visible);

            menuitem = new CheckMenuItem ("Accelerator locked");
            menu.Append (menuitem);
            menuitem.AddAccelerator ("activate", accel_group, 0xFFBF, 0, AccelFlags.Visible | AccelFlags.Locked);

            menuitem = new CheckMenuItem ("Accelerator Frozen");
            menu.Append (menuitem);
            menuitem.AddAccelerator ("activate", accel_group, 0xFFBF, 0, AccelFlags.Visible);
            menuitem.AddAccelerator ("activate", accel_group, 0xFFC0, 0, AccelFlags.Visible);

            OptionMenu option_menu = new OptionMenu ();
            option_menu.Menu = menu;
            option_menu.SetHistory (3);
            box2.PackStart (option_menu, true, true, 0);

            box1.PackStart (new HSeparator (), false, false, 0);

            box2 = new VBox (false, 10);
            box2.BorderWidth = 10;
            box1.PackStart (box2, false, true, 0);

            Button close_button = new Button (Stock.Close);
            close_button.Clicked += new EventHandler (Close_Button);
            box2.PackStart (close_button, true, true, 0);

            close_button.CanDefault = true;
            close_button.GrabDefault ();

            window.ShowAll ();
            return window;
        }
开发者ID:saraa,项目名称:fishtastic,代码行数:82,代码来源:TestMenus.cs

示例2: Browser

	public Browser (string basedir, IEnumerable<string> sources, string engine)
	{
#if MACOS
		try {
			InitMacAppHandlers();
		} catch (Exception ex) {
			Console.Error.WriteLine ("Installing Mac AppleEvent handlers failed. Skipping.\n" + ex);
		}
#endif
	
		this.engine = engine;		
		ui = new Glade.XML (null, "browser.glade", "window1", null);
		ui.Autoconnect (this);

		MainWindow = (Gtk.Window) ui["window1"];
		MainWindow.DeleteEvent += new DeleteEventHandler (delete_event_cb);
                
		MainWindow.KeyPressEvent += new KeyPressEventHandler (keypress_event_cb);
		MainWindow.KeyReleaseEvent += new KeyReleaseEventHandler (keyrelease_event_cb);
                
		Stream icon = GetResourceImage ("monodoc.png");

		if (icon != null) {
			monodoc_pixbuf = new Gdk.Pixbuf (icon);
			MainWindow.Icon = monodoc_pixbuf;
		}

		//ellipsizing label for the title
		title_label = new ELabel ("");
		title_label.Xalign = 0;
		Pango.FontDescription fd = new Pango.FontDescription ();
		fd.Weight = Pango.Weight.Bold;
		title_label.ModifyFont (fd);
		title_label.Layout.FontDescription = fd;
		title_label_box.Add (title_label);
		title_label.Show ();
		
		//colour the bar according to the current style
		bar_style = bar_eb.Style.Copy ();
		bar_eb.Style = bar_style;
		MainWindow.StyleSet += new StyleSetHandler (BarStyleSet);
		BarStyleSet (null, null);

		help_tree = Driver.LoadTree (basedir, sources);
		tree_browser = new TreeBrowser (help_tree, reference_tree, this);
		
		// Bookmark Manager init;
		bookmark_manager = new BookmarkManager(this);
		
		//
		// Tab Notebook and first tab
		//
		tabs_nb = new Notebook(); //the Notebook that holds tabs
		tabs_nb.Scrollable = true;
		tabs_nb.SwitchPage += new SwitchPageHandler(ChangeTab);
		help_container.Add(tabs_nb);

		AddTab();
			
			
		if ((capabilities & Capabilities.Fonts) != 0) {
			// Add Menu entries for changing the font
			Menu aux = (Menu) view1.Submenu;
			MenuItem sep = new SeparatorMenuItem ();
			sep.Show ();
			aux.Append (sep);
			AccelGroup accel = new AccelGroup ();
			MainWindow.AddAccelGroup (accel);

			textLarger = new MenuItem ("_Larger text");
			textLarger.Activated += new EventHandler (TextLarger);
			textLarger.Show ();
			aux.Append (textLarger);
			AccelKey ak = new AccelKey (Gdk.Key.plus, Gdk.ModifierType.ControlMask, AccelFlags.Visible);
			textLarger.AddAccelerator ("activate", accel, ak);
		
			textSmaller = new MenuItem ("_Smaller text");
			textSmaller.Activated += new EventHandler (TextSmaller);
			textSmaller.Show ();
			aux.Append (textSmaller);
			ak = new AccelKey (Gdk.Key.minus, Gdk.ModifierType.ControlMask, AccelFlags.Visible);
			textSmaller.AddAccelerator ("activate", accel, ak);
	
			textNormal = new MenuItem ("_Original size");
			textNormal.Activated += new EventHandler (TextNormal);
			textNormal.Show ();
			aux.Append (textNormal);
			ak = new AccelKey (Gdk.Key.Key_0, Gdk.ModifierType.ControlMask, AccelFlags.Visible);
			textNormal.AddAccelerator ("activate", accel, ak);
		}

		// restore the editing setting
		editing1.Active = SettingsHandler.Settings.EnableEditing;

		comments1.Active = SettingsHandler.Settings.ShowComments;

		cut1.Sensitive = false;
		paste1.Sensitive = false;

		//
//.........这里部分代码省略.........
开发者ID:remobjects,项目名称:mono-tools,代码行数:101,代码来源:browser.cs

示例3: Client

        internal Client (bool loadFiles)
        {
            app_count++;

            Window = new Gtk.Window (Gtk.WindowType.Toplevel) { Title = Catalog.GetString ("PDF Mod") };
            Window.SetSizeRequest (640, 480);
            Window.DeleteEvent += delegate (object o, DeleteEventArgs args) {
                Quit ();
                args.RetVal = true;
            };

            // PDF Icon View
            IconView = new DocumentIconView (this);
            var iconview_sw = new Gtk.ScrolledWindow ();
            iconview_sw.AddWithViewport (IconView);

            query_box = new QueryBox (this) { NoShowAll = true };
            query_box.Hide ();

            // ActionManager
            ActionManager = new Hyena.Gui.ActionManager ();
            Window.AddAccelGroup (ActionManager.UIManager.AccelGroup);
            Actions = new Actions (this, ActionManager);

            // Status bar
            StatusBar = new Gtk.Statusbar () { HasResizeGrip = true };
            status_label = new Label () { Xalign = 0.0f };
            StatusBar.PackStart (status_label, true, true, 6);
            StatusBar.ReorderChild (status_label, 0);

            var zoom_slider = new ZoomSlider (this);
            StatusBar.PackEnd (zoom_slider, false, false, 0);
            StatusBar.ReorderChild (zoom_slider, 1);

            // Properties editor box
            EditorBox = new MetadataEditorBox (this) { NoShowAll = true };
            EditorBox.Hide ();

            // Menubar
            menu_bar = ActionManager.UIManager.GetWidget ("/MainMenu") as MenuBar;

            // Toolbar
            HeaderToolbar = ActionManager.UIManager.GetWidget ("/HeaderToolbar") as Gtk.Toolbar;
            HeaderToolbar.ShowArrow = false;
            HeaderToolbar.ToolbarStyle = ToolbarStyle.Icons;
            HeaderToolbar.Tooltips = true;
            HeaderToolbar.NoShowAll = true;
            HeaderToolbar.Visible = Configuration.ShowToolbar;

            // BookmarksView
            BookmarkView = new BookmarkView (this);
            BookmarkView.NoShowAll = true;
            BookmarkView.Visible = false;

            var vbox = new VBox ();
            vbox.PackStart (menu_bar, false, false, 0);
            vbox.PackStart (HeaderToolbar, false, false, 0);
            vbox.PackStart (EditorBox, false, false, 0);
            vbox.PackStart (query_box, false, false, 0);

            var hbox = new HPaned ();
            hbox.Add1 (BookmarkView);
            hbox.Add2 (iconview_sw);
            vbox.PackStart (hbox, true, true, 0);

            vbox.PackStart (StatusBar, false, true, 0);
            Window.Add (vbox);

            Window.ShowAll ();

            if (loadFiles) {
                RunIdle (LoadFiles);
                Application.Run ();
            }
        }
开发者ID:GNOME,项目名称:pdfmod,代码行数:75,代码来源:Client.cs

示例4: MainWindow

        public MainWindow()
        {
            ToolItem        spacerItem;
            FileSearchEntry searchEntry;
            ToolItem        searchEntryItem;
            Alignment       searchEntryBox;

            object[] attrs= Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), true);
            AssemblyTitleAttribute attr = (AssemblyTitleAttribute)attrs[0];
            AssemblyName asmName = Assembly.GetExecutingAssembly().GetName();

            string title = String.Format ("{0} (BETA) {1} (Protocol Version: {2})",
                                      attr.Title, asmName.Version,
                                      Core.ProtocolVersion);

            // Create the interface
            window = new Window (title);
            window.SetDefaultSize (850, 550);
            window.DeleteEvent += on_win_delete;
            window.ConfigureEvent += on_MainWindow_configure_event;
            window.FocusInEvent += window_FocusInEvent;

            ((ToggleAction)Runtime.BuiltinActions["ToggleMainToolbar"]).Active = Gui.Settings.ShowToolbar;
            Runtime.BuiltinActions["ToggleMainToolbar"].Activated += ToggleMainToolbar_Activated;

            ((ToggleAction)Runtime.BuiltinActions["ToggleMainStatusbar"]).Active = Gui.Settings.ShowStatusBar;
            Runtime.BuiltinActions["ToggleMainStatusbar"].Activated += ToggleMainStatusbar_Activated;
            window.AddAccelGroup (Runtime.UIManager.AccelGroup);

            mainVBox = new VBox ();
            window.Add (mainVBox);
            mainVBox.Show ();

            if (Common.OSName == "Darwin") {
                MenuBar menubar = (MenuBar) Runtime.UIManager.GetWidget ("/OSXAppMenu");

                Imendio.MacIntegration.Menu.SetMenuBar(menubar);

                MenuItem preferencesItem = (MenuItem) Runtime.UIManager.GetWidget ("/OSXAppMenu/NetworkMenu/Preferences");
                MenuItem aboutItem = (MenuItem) Runtime.UIManager.GetWidget ("/OSXAppMenu/NetworkMenu/About");

                IntPtr group = Imendio.MacIntegration.Menu.AddAppMenuGroup();

                Imendio.MacIntegration.Menu.AddAppMenuItem(group, aboutItem, "About Meshwork");

                group = Imendio.MacIntegration.Menu.AddAppMenuGroup();

                Imendio.MacIntegration.Menu.AddAppMenuItem(group, preferencesItem, "Preferences");

                MenuItem quitItem = (MenuItem) Runtime.UIManager.GetWidget ("/OSXAppMenu/NetworkMenu/Quit");
                Imendio.MacIntegration.Menu.SetQuitMenuItem(quitItem);
            } else {
                MenuBar menubar = (MenuBar) Runtime.UIManager.GetWidget ("/MainWindowMenuBar");
                mainVBox.PackStart (menubar, false, false, 0);
                menubar.Show ();
            }

            toolbar = (Toolbar) Runtime.UIManager.GetWidget ("/MainWindowToolbar");
            toolbar.ToolbarStyle = ToolbarStyle.BothHoriz;
            toolbar.IconSize = IconSize.LargeToolbar;

            spacerItem = new ToolItem();
            spacerItem.Expand = true;
            toolbar.Insert(spacerItem, -1);
            spacerItem.Show();

            searchEntry = new FileSearchEntry();

            searchEntryBox = new Alignment(0.5f, 0.5f, 0, 0);
            searchEntryBox.LeftPadding = 4;
            searchEntryBox.RightPadding = 1;
            searchEntryBox.Add(searchEntry);

            searchEntryItem = new ToolItem();
            searchEntryItem.Add(searchEntryBox);

            toolbar.Insert(searchEntryItem, -1);
            searchEntryItem.ShowAll();

            mainVBox.PackStart (toolbar, false, false, 0);

            mainPaned = new HPaned();
            mainPaned.Mapped += delegate (object sender, EventArgs args) {
                // XXX: Remember the user's last setting instead
                mainPaned.Position = 190;

                // Set some colors
                //infoBoxSeparator.ModifyBg(StateType.Normal, GtkHelper.DarkenColor (mainbar.Style.Background(StateType.Normal), 2));
                //infoSwitcherTree.ModifyBase(StateType.Normal, infoSwitcherTree.Style.Base(StateType.Active));
                //infoSwitcherTree.ModifyBase(StateType.Active, infoBoxSeparator.Style.Base(StateType.Selected));
            };
            mainPaned.Show();
            mainVBox.PackStart (mainPaned, true, true, 0);

            // Create page notebook
            pageNotebook = new Notebook();
            pageNotebook.ShowTabs = false;
            pageNotebook.ShowBorder = false;
            mainPaned.Pack2(pageNotebook, true, true);
            pageNotebook.ShowAll();
//.........这里部分代码省略.........
开发者ID:codebutler,项目名称:meshwork,代码行数:101,代码来源:MainWindow.cs

示例5: CreateWidget

        protected override Gtk.Widget CreateWidget(WindowContext context)
        {
            Window win;
            if(HasAttribute("dialog"))
            {
                Dialog dialog = new Dialog();
                dialog.AddAccelGroup(context.AccelGroup);
                SetWindowAttribs(dialog);
                if(Child != null)
                    dialog.VBox.Add(Child.Build(context));
                foreach(string s in GetAttribute<Array>("dialog"))
                {
                    string[] bits = s.Split(':');
                    string text = bits[0];
                    int response = 0;
                    if(bits.Length > 4)
                        throw new Exception("Neplatný počet parametrů tlačítka v poli tlačítek dialogu");
                    if(bits.Length > 1)
                        response = (int)IntLiteral.Parse(bits[1]);
                    Label l = new Label();
                    l.Markup = text;
                    Button btn;
                    if(bits.Length > 2 && !String.IsNullOrEmpty(bits[2]))
                    {
                        HBox hbox = new HBox(false, 0);
                        hbox.PackStart(ImageExpression.CreateImage(bits[2], IconSize.Button));
                        hbox.PackStart(l);
                        btn = new Button(hbox);
                    }
                    else
                        btn = new Button(l);
                    btn.ShowAll();
                    dialog.AddActionWidget(btn, response);
                    if(bits.Length > 3)
                    {
                        switch(bits[3].ToLower())
                        {
                        case "default":
                            btn.CanDefault = true;
                            dialog.Default = btn;
                            break;
                        case "cancel":
                            // set as cancel action - how?
                            break;
                        case "":
                        case "none":
                            break;
                        default:
                            throw new Exception("Neznámý příznak tlačítka dialogu");
                        }
                    }

                }
                win = dialog;
            }
            else
            {
                win = new Window(Gtk.WindowType.Toplevel);
                win.AddAccelGroup(context.AccelGroup);
                if(Child != null)
                    win.Add(Child.Build(context));
            }

            if(HasAttribute("iconset"))
            {
                IconSet icons = IconFactory.LookupDefault(GetAttribute<string>("iconset"));
                List<Gdk.Pixbuf> list = new List<Gdk.Pixbuf>();
                foreach(IconSize size in icons.Sizes)
                {
                    list.Add(icons.RenderIcon(win.Style, TextDirection.Ltr, StateType.Normal, size, win, ""));
                }
                win.IconList = list.ToArray();
            }

            return win;
        }
开发者ID:langpavel,项目名称:LPS-old,代码行数:76,代码来源:WindowExpression.cs


注:本文中的Gtk.Window.AddAccelGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。