コード例 #1
0
ファイル: Window.cs プロジェクト: BackupTheBerlios/nyiv
        // ========================================
        // PUBLIC Constructors
        // ========================================
        public Window() : base(Info.Name + " " + Info.Version)
        {
            // Initialize Window Properties
            this.SetDefaultSize(500, 300);
            DefaultIcon       = StockIcons.GetPixbuf("NyIVIcon");
            this.DeleteEvent += new DeleteEventHandler(OnWindowDelete);

            // Initialize VBox
            this.vbox = new Gtk.VBox(false, 0);
            this.Add(this.vbox);

            // Initialize Menu & Toolbar
            this.uiMenuManager            = new UiMenuManager();
            this.uiMenuManager.Activated += new EventHandler(OnMenuActivated);
            this.AddAccelGroup(this.uiMenuManager.AccelGroup);

            // Initialize MenuBar
            Gtk.MenuBar menubar = this.MenuBar;
            this.vbox.PackStart(menubar, false, false, 0);

            // Initialize ToolBar
            Gtk.Toolbar toolbar = this.ToolBar;
            toolbar.ToolbarStyle = ToolbarStyle.Both;
            toolbar.IconSize     = IconSize.LargeToolbar;
            this.vbox.PackStart(toolbar, false, false, 0);

            // Initialize Viewer
            this.viewer = new Viewer();
            this.vbox.PackStart(this.viewer, true, true, 2);

            // Initialize StatusBar
            this.statusBar = new Gtk.Statusbar();
            this.vbox.PackEnd(this.statusBar, false, false, 0);

            // Set Sensitive Menu
            SetSensitiveImageMenu(false);
        }
コード例 #2
0
ファイル: Window.cs プロジェクト: BackupTheBerlios/nyiv
        private void OnMenuActivated(object sender, EventArgs args)
        {
            Action    action   = sender as Action;
            string    filename = null;
            ImageList imageList;

            Gtk.Application.Invoke(delegate {
                switch (action.Name)
                {
                // File
                case "OpenImage":
                    filename = OpenImage();
                    if (filename != null)
                    {
                        LoadImage(filename, true);
                    }
                    break;

                case "OpenWebImage":
                    LoadWebImage();
                    break;

                case "ProxySettings":
                    SetProxy();
                    break;

                case "Quit":
                    Gtk.Application.Quit();
                    break;

                // View
                case "Fullscreen":
                    if (isFullscreen == true)
                    {
                        Unfullscreen();
                    }
                    else
                    {
                        Fullscreen();
                    }
                    DefaultIcon  = StockIcons.GetPixbuf("NyIVIcon");
                    isFullscreen = !isFullscreen;
                    break;

                // Image
                case "ZoomIn":
                    this.viewer.ZoomIn();
                    SetStatusBarImageInfo();
                    break;

                case "ZoomOut":
                    this.viewer.ZoomOut();
                    SetStatusBarImageInfo();
                    break;

                case "Zoom100":
                    this.viewer.Zoom100();
                    SetStatusBarImageInfo();
                    break;

                case "ZoomFit":
                    this.viewer.ZoomFit();
                    SetStatusBarImageInfo();
                    break;

                // Go
                case "GoBack":
                    imageList = new ImageList();
                    if (this.viewer.ImageInfo == null)
                    {
                        filename = imageList.GetLast();
                    }
                    else
                    {
                        filename = imageList.GoBack(this.viewer.ImageInfo.FullName);
                    }
                    if (filename != null)
                    {
                        LoadImage(filename, true);
                    }
                    break;

                case "GoForward":
                    imageList = new ImageList();
                    if (this.viewer.ImageInfo == null)
                    {
                        filename = imageList.GetFirst();
                    }
                    else
                    {
                        filename = imageList.GoForward(this.viewer.ImageInfo.FullName);
                    }
                    if (filename != null)
                    {
                        LoadImage(filename, true);
                    }
                    break;

                // Help
                case "About":
                    new Dialogs.About();
                    break;
                }
            });
        }