示例#1
0
文件: Program.cs 项目: amka/Norka
        public static void Main(string[] args)
        {
            AutoDI.Generated.AutoDI.Init();
            Application.Init();

            var app = new Application("com.github.amka.norka", GLib.ApplicationFlags.None);

            app.Register(GLib.Cancellable.Current);

            Actions.SetupFormatActions(app);

            var win = new MainWindow(app);

            // Handle Quit action
            var actionQuit = new GLib.SimpleAction("quit", null);

            actionQuit.Activated += (object sender, GLib.ActivatedArgs args) =>
            {
                Application.Quit();
            };
            app.AddAction(actionQuit);

            win.ShowAll();
            Application.Run();
        }
示例#2
0
        public static void Main(string[] args)
        {
            Application.Init();

            App = new Application("local.SiKLink.SiKGuiGtk", GLib.ApplicationFlags.None);
            App.Register(GLib.Cancellable.Current);

            Win = new MainWindow();
            App.AddWindow(Win);

            var menu = new GLib.Menu();

            menu.AppendItem(new GLib.MenuItem("About", "app.about"));
            menu.AppendItem(new GLib.MenuItem("Quit", "app.quit"));
            App.AppMenu = menu;

            var aboutAction = new GLib.SimpleAction("about", null);

            aboutAction.Activated += AboutActivated;
            App.AddAction(aboutAction);

            var quitAction = new GLib.SimpleAction("quit", null);

            quitAction.Activated += QuitActivated;
            App.AddAction(quitAction);

            Win.ShowAll();
            Application.Run();
        }
示例#3
0
        public ViewActions()
        {
            ZoomIn          = new Command("ZoomIn", Translations.GetString("Zoom In"), null, Resources.StandardIcons.ZoomIn);
            ZoomOut         = new Command("ZoomOut", Translations.GetString("Zoom Out"), null, Resources.StandardIcons.ZoomOut);
            ZoomToWindow    = new Command("ZoomToWindow", Translations.GetString("Best Fit"), null, Resources.StandardIcons.ZoomFitBest);
            ZoomToSelection = new Command("ZoomToSelection", Translations.GetString("Zoom to Selection"), null, Resources.Icons.ViewZoomSelection);
            ActualSize      = new Command("ActualSize", Translations.GetString("Normal Size"), null, Resources.StandardIcons.ZoomOriginal);
            ToolBar         = new ToggleCommand("Toolbar", Translations.GetString("Toolbar"), null, null);
            ImageTabs       = new ToggleCommand("ImageTabs", Translations.GetString("Image Tabs"), null, null);
            PixelGrid       = new ToggleCommand("PixelGrid", Translations.GetString("Pixel Grid"), null, Resources.Icons.ViewGrid);
            StatusBar       = new ToggleCommand("Statusbar", Translations.GetString("Status Bar"), null, null);
            ToolBox         = new ToggleCommand("ToolBox", Translations.GetString("Tool Box"), null, null);
            Rulers          = new ToggleCommand("Rulers", Translations.GetString("Rulers"), null, Resources.Icons.ViewRulers);
            RulerMetric     = new GLib.SimpleAction("rulermetric", GLib.VariantType.Int32, new GLib.Variant(0));
            Fullscreen      = new Command("Fullscreen", Translations.GetString("Fullscreen"), null, Resources.StandardIcons.DocumentNew);

            ZoomCollection = new string[] {
                ToPercent(36),
                ToPercent(24),
                ToPercent(16),
                ToPercent(12),
                ToPercent(8),
                ToPercent(7),
                ToPercent(6),
                ToPercent(5),
                ToPercent(4),
                ToPercent(3),
                ToPercent(2),
                ToPercent(1.75),
                ToPercent(1.5),
                ToPercent(1.25),
                ToPercent(1),
                ToPercent(0.66),
                ToPercent(0.5),
                ToPercent(0.33),
                ToPercent(0.25),
                ToPercent(0.16),
                ToPercent(0.12),
                ToPercent(0.08),
                ToPercent(0.05),
                Translations.GetString("Window")
            };
            ZoomComboBox = new ToolBarComboBox(90, DefaultZoomIndex(), true, ZoomCollection)
            {
                Margin = 4
            };

            // The toolbar is shown by default.
            ToolBar.Value   = true;
            ImageTabs.Value = true;
            StatusBar.Value = true;
            ToolBox.Value   = true;
        }
示例#4
0
        public (string, Widget) CreateActionButton()
        {
            var sa = new GLib.SimpleAction("SampleAction", null);

            sa.Activated += (sender, e) => ApplicationOutput.WriteLine(sender, "SampleAction Activated");
            Program.App.AddAction(sa);

            var btn = new Button();

            btn.Label      = "SampleAction Button";
            btn.ActionName = "app.SampleAction";

            return("Action button:", btn);
        }
示例#5
0
        public static void Connect(string action, Command cmd)
        {
            var a = new GLib.SimpleAction(action, null);

            a.Activated += (o, args) =>
            {
                _popovermenu1.Hide();
                _popovermenu2.Hide();
                cmd.Execute();
            };

            cmd.EnabledChanged += (sender, e) => a.Enabled = cmd.Enabled;

            Global.Application.AddAction(a);
        }
示例#6
0
        public WindowActions()
        {
            SaveAll  = new Command("SaveAll", Translations.GetString("Save All"), null, Resources.StandardIcons.DocumentSave);
            CloseAll = new Command("CloseAll", Translations.GetString("Close All"), null, Resources.StandardIcons.WindowClose);

            active_doc_action = new GLib.SimpleAction(doc_action_id, GLib.VariantType.Int32, new GLib.Variant(-1));

            active_doc_action.Activated += (o, e) => {
                var idx = (int)e.P0;
                if (idx < PintaCore.Workspace.OpenDocuments.Count)
                {
                    PintaCore.Workspace.SetActiveDocumentInternal(PintaCore.Workspace.OpenDocuments[idx]);
                    active_doc_action.ChangeState(e.P0);
                }
            };
        }
示例#7
0
        public static void Main(string[] args)
        {
            Application.Init();

            App = new Application("org.Samples.Samples", GLib.ApplicationFlags.None);
            App.Register(GLib.Cancellable.Current);

            Win = new ConfigForm();
            App.AddWindow(Win);

            var menu = new GLib.Menu();

            menu.AppendItem(new GLib.MenuItem("Quit", "app.quit"));
            App.AppMenu = menu;

            var quitAction = new GLib.SimpleAction("quit", null);

            quitAction.Activated += QuitActivated;
            App.AddAction(quitAction);

            Win.ShowAll();
            Application.Run();
        }
示例#8
0
文件: MainWindow.cs 项目: amka/Norka
        void SetupActions()
        {
            // Format Actions
            var formatActions = new GLib.SimpleActionGroup();

            // Text styling
            var actionBold = new GLib.SimpleAction("bold", null);

            actionBold.Activated += (sender, args) => _editor.ToggleTag("bold");
            formatActions.AddAction(actionBold);

            var actionItalic = new GLib.SimpleAction("italic", null);

            actionItalic.Activated += (sender, args) => _editor.ToggleTag("italic");
            formatActions.AddAction(actionItalic);

            var actionUnderline = new GLib.SimpleAction("underline", null);

            actionUnderline.Activated += (sender, args) => _editor.ToggleTag("underline");
            formatActions.AddAction(actionUnderline);

            // Paragraph justifying
            var actionJustifyLeft = new GLib.SimpleAction("justify-left", null);

            actionJustifyLeft.Activated += (sender, args) => _editor.SetJustify("justify-left");
            formatActions.AddAction(actionJustifyLeft);

            var actionJustifyCenter = new GLib.SimpleAction("justify-center", null);

            actionJustifyCenter.Activated += (sender, args) => _editor.SetJustify("justify-center");
            formatActions.AddAction(actionJustifyCenter);

            var actionJustifyRight = new GLib.SimpleAction("justify-right", null);

            actionJustifyRight.Activated += (sender, args) => _editor.SetJustify("justify-right");
            formatActions.AddAction(actionJustifyRight);

            var actionJustifyFill = new GLib.SimpleAction("justify-fill", null);

            actionJustifyFill.Activated += (sender, args) => _editor.SetJustify("justify-fill");
            formatActions.AddAction(actionJustifyFill);

            // Font size

            // Clear styling
            var actionFormatClear = new GLib.SimpleAction("clear", null);

            actionFormatClear.Activated += (sender, args) => _editor.ClearTags();
            formatActions.AddAction(actionFormatClear);

            var actionFormatToggle = new GLib.SimpleAction("toggle", null);

            actionFormatToggle.Activated += (sender, args) => _editor.ToggleFormatBar();
            formatActions.AddAction(actionFormatToggle);

            InsertActionGroup("format", formatActions);

            // Document Actions
            var documentActions = new GLib.SimpleActionGroup();

            var actionDocumentOpen = new GLib.SimpleAction("create", null);

            actionDocumentOpen.Activated += (sender, args) => CreateDocument();
            documentActions.AddAction(actionDocumentOpen);

            var actionDocumentRemove = new GLib.SimpleAction("remove", null);

            actionDocumentRemove.Activated += (sender, args) => RemoveDocument();
            documentActions.AddAction(actionDocumentRemove);

            InsertActionGroup("document", documentActions);
        }