예제 #1
0
        private Rectangle ValidateAndAdjustNewBounds(Form owner, Rectangle newClientBounds, Rectangle defaultClientBounds)
        {
            Rectangle rectangle3;

            System.Windows.Forms.Screen primaryScreen;
            Rectangle rect = base.ClientBoundsToWindowBounds(newClientBounds);
            bool      flag = false;

            foreach (System.Windows.Forms.Screen screen2 in System.Windows.Forms.Screen.AllScreens)
            {
                flag |= screen2.Bounds.IntersectsWith(rect);
            }
            if (flag)
            {
                rectangle3 = newClientBounds;
            }
            else
            {
                rectangle3 = defaultClientBounds;
            }
            if (owner != null)
            {
                primaryScreen = System.Windows.Forms.Screen.FromControl(owner);
            }
            else
            {
                primaryScreen = System.Windows.Forms.Screen.PrimaryScreen;
            }
            Rectangle bounds       = base.ClientBoundsToWindowBounds(rectangle3);
            Rectangle windowBounds = PdnBaseForm.EnsureRectIsOnScreen(primaryScreen, bounds);

            return(base.WindowBoundsToClientBounds(windowBounds));
        }
예제 #2
0
 public ViewMenu()
 {
     InitializeComponent();
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.OemMinus, OnOemMinusShortcut);
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.Oemplus, OnOemPlusShortcut);
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.Alt | Keys.D0, OnCtrlAltZero);
 }
예제 #3
0
 public EditMenu()
 {
     PdnBaseForm.RegisterFormHotKey(Keys.Back, OnBackspaceTyped);
     PdnBaseForm.RegisterFormHotKey(Keys.Shift | Keys.Delete, OnLeftHandedCutHotKey);
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.Insert, OnLeftHandedCopyHotKey);
     PdnBaseForm.RegisterFormHotKey(Keys.Shift | Keys.Insert, OnLeftHandedPasteHotKey);
     InitializeComponent();
 }
예제 #4
0
 public ViewMenu()
 {
     this.InitializeComponent();
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.OemMinus, new Func<Keys, bool>(this.OnCtrlOemMinusShortcut));
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.Oemplus, new Func<Keys, bool>(this.OnCtrlOemPlusShortcut));
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.D0, new Func<Keys, bool>(this.OnCtrlZero));
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.NumPad0, new Func<Keys, bool>(this.OnCtrlNumPad0));
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.Shift | Keys.A, new Func<Keys, bool>(this.OnCtrlShiftA));
 }
예제 #5
0
 public EditMenu()
 {
     PdnBaseForm.RegisterFormHotKey(Keys.Back, new Func <Keys, bool>(this.OnBackspaceTyped));
     PdnBaseForm.RegisterFormHotKey(Keys.Shift | Keys.Back, new Func <Keys, bool>(this.OnBackspaceTyped));
     PdnBaseForm.RegisterFormHotKey(Keys.Shift | Keys.Delete, new Func <Keys, bool>(this.OnLeftHandedCutHotKey));
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.Insert, new Func <Keys, bool>(this.OnLeftHandedCopyHotKey));
     PdnBaseForm.RegisterFormHotKey(Keys.Shift | Keys.Insert, new Func <Keys, bool>(this.OnLeftHandedPasteHotKey));
     this.InitializeComponent();
 }
예제 #6
0
 public PdnAuxMenu()
 {
     this.InitializeComponent();
     PdnBaseForm.RegisterFormHotKey(Keys.F5, new Func <Keys, bool>(this.OnToolsHotKeyPressed));
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.Shift | Keys.F5, new Func <Keys, bool>(this.OnToolsResetHotKeyPressed));
     PdnBaseForm.RegisterFormHotKey(Keys.F6, new Func <Keys, bool>(this.OnHistoryHotKeyPressed));
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.Shift | Keys.F6, new Func <Keys, bool>(this.OnHistoryResetHotKeyPressed));
     PdnBaseForm.RegisterFormHotKey(Keys.F7, new Func <Keys, bool>(this.OnLayersHotKeyPressed));
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.Shift | Keys.F7, new Func <Keys, bool>(this.OnLayersResetHotKeyPressed));
     PdnBaseForm.RegisterFormHotKey(Keys.F8, new Func <Keys, bool>(this.OnColorsHotKeyPressed));
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.Shift | Keys.F8, new Func <Keys, bool>(this.OnColorsResetHotKeyPressed));
     PdnBaseForm.RegisterFormHotKey(Keys.Alt | Keys.X, new Func <Keys, bool>(this.OnSettingsHotKeyPressed));
 }
예제 #7
0
        protected override void OnTextChanged(EventArgs e)
        {
            if (this.registeredHotKey != Keys.None)
            {
                PdnBaseForm.UnregisterFormHotKey(this.registeredHotKey, new Func <Keys, bool>(this.OnAccessHotKeyPressed));
            }
            char mnemonic = this.Mnemonic;

            if ((mnemonic != '\0') && !base.IsOnDropDown)
            {
                Keys keys = KeysUtil.FromLetterOrDigitChar(mnemonic);
                PdnBaseForm.RegisterFormHotKey(Keys.Alt | keys, new Func <Keys, bool>(this.OnAccessHotKeyPressed));
            }
            base.OnTextChanged(e);
        }
예제 #8
0
 public DocumentStrip()
 {
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.Tab, new Func <Keys, bool>(this.OnNextTabHotKeyPressed));
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.Shift | Keys.Tab, new Func <Keys, bool>(this.OnPreviousTabHotKeyPressed));
     using (ISynchronizationContext context = SynchronizationContextDispatcher.CreateRef())
     {
         this.thumbnailManager = new ThumbnailManager(context);
     }
     base.Name = "DocumentStrip";
     for (int i = 1; i <= 9; i++)
     {
         Keys keys = KeysUtil.FromLetterOrDigitChar((char)(i + 0x30));
         PdnBaseForm.RegisterFormHotKey(Keys.Control | keys, new Func <Keys, bool>(this.OnDigitHotKeyPressed));
         PdnBaseForm.RegisterFormHotKey(Keys.Alt | keys, new Func <Keys, bool>(this.OnDigitHotKeyPressed));
     }
     base.ShowCloseButtons = true;
 }
예제 #9
0
 protected override void OnQueryEndSession(CancelEventArgs e)
 {
     if (!PdnBaseForm.IsInThreadModalLoop)
     {
         this.OnClosing(e);
     }
     else
     {
         foreach (Form form in Application.OpenForms)
         {
             PdnBaseForm form2 = form as PdnBaseForm;
             if (form2 != null)
             {
                 form2.Flash();
             }
         }
         e.Cancel = true;
     }
     base.OnQueryEndSession(e);
 }
예제 #10
0
 public FileMenu()
 {
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.F4, OnCtrlF4Typed);
     InitializeComponent();
 }
        private void OnStateBegin(object sender, EventArgs <State> e)
        {
            if (e.Data is Updates.UpdateAvailableState && this.updatesDialog == null)
            {
                bool showDialogNow = true;

                // If no other modal window is on top of us, then go ahead and present
                // the updates dialog. Otherwise, set a timer to check every few seconds
                // and only when there's no other dialog sitting on top of us will we
                // present the dialog.

                Form        ourForm = AppWorkspace.FindForm();
                PdnBaseForm asPBF   = ourForm as PdnBaseForm;

                if (asPBF != null)
                {
                    if (!asPBF.IsCurrentModalForm)
                    {
                        showDialogNow = false;
                    }
                }

                if (showDialogNow)
                {
                    ShowUpdatesDialog();
                }
                else
                {
                    if (this.retryDialogTimer != null)
                    {
                        this.retryDialogTimer.Enabled = false;
                        this.retryDialogTimer.Dispose();
                        this.retryDialogTimer = null;
                    }

                    this.retryDialogTimer          = new System.Windows.Forms.Timer();
                    this.retryDialogTimer.Interval = 3000;

                    this.retryDialogTimer.Tick +=
                        delegate(object sender2, EventArgs e2)
                    {
                        bool done = false;

                        if (IsDisposed)
                        {
                            done = true;
                        }

                        Form        ourForm2 = AppWorkspace.FindForm();
                        PdnBaseForm asPBF2   = ourForm2 as PdnBaseForm;

                        if (asPBF2 == null)
                        {
                            done = true;
                        }
                        else
                        {
                            if (this.updatesDialog != null)
                            {
                                // Updates dialog is already visible.
                                done = true;
                            }
                            else if (asPBF2.IsCurrentModalForm && asPBF2.Enabled)
                            {
                                ShowUpdatesDialog();
                                done = true;
                            }
                        }

                        if (done && this.retryDialogTimer != null)
                        {
                            this.retryDialogTimer.Enabled = false;
                            this.retryDialogTimer.Dispose();
                            this.retryDialogTimer = null;
                        }
                    };

                    this.retryDialogTimer.Enabled = true;
                }
            }
            else if (e.Data is Updates.ReadyToCheckState)
            {
                if (this.updatesDialog == null)
                {
                    DisposeUpdates();
                }
            }
        }
        public override void PerformAction(AppWorkspace appWorkspace)
        {
            DocumentWorkspace originalDW = appWorkspace.ActiveDocumentWorkspace;

            int oldLatency = 10;

            try
            {
                oldLatency = appWorkspace.Widgets.DocumentStrip.ThumbnailUpdateLatency;
                appWorkspace.Widgets.DocumentStrip.ThumbnailUpdateLatency = 0;
            }

            catch (NullReferenceException)
            {
                // See bug #2544
            }

            List <DocumentWorkspace> unsavedDocs = new List <DocumentWorkspace>();

            foreach (DocumentWorkspace dw in appWorkspace.DocumentWorkspaces)
            {
                if (dw.Document != null && dw.Document.Dirty)
                {
                    unsavedDocs.Add(dw);
                }
            }

            if (unsavedDocs.Count == 1)
            {
                CloseWorkspaceAction cwa = new CloseWorkspaceAction(unsavedDocs[0]);
                cwa.PerformAction(appWorkspace);
                this.cancelled = cwa.Cancelled;
            }
            else if (unsavedDocs.Count > 1)
            {
                using (UnsavedChangesDialog dialog = new UnsavedChangesDialog())
                {
                    dialog.DocumentClicked += (s, e2) => { appWorkspace.ActiveDocumentWorkspace = e2.Data; };

                    dialog.Documents = unsavedDocs.ToArray();

                    if (appWorkspace.ActiveDocumentWorkspace.Document.Dirty)
                    {
                        dialog.SelectedDocument = appWorkspace.ActiveDocumentWorkspace;
                    }

                    Form mainForm = appWorkspace.FindForm();
                    if (mainForm != null)
                    {
                        PdnBaseForm asPDF = mainForm as PdnBaseForm;

                        if (asPDF != null)
                        {
                            asPDF.RestoreWindow();
                        }
                    }

                    DialogResult dr = Utility.ShowDialog(dialog, appWorkspace);

                    switch (dr)
                    {
                    case DialogResult.Yes:
                    {
                        foreach (DocumentWorkspace dw in unsavedDocs)
                        {
                            appWorkspace.ActiveDocumentWorkspace = dw;
                            bool result = dw.DoSave();

                            if (result)
                            {
                                appWorkspace.RemoveDocumentWorkspace(dw);
                            }
                            else
                            {
                                this.cancelled = true;
                                break;
                            }
                        }
                    }
                    break;

                    case DialogResult.No:
                        this.cancelled = false;
                        break;

                    case DialogResult.Cancel:
                        this.cancelled = true;
                        break;

                    default:
                        throw new InvalidEnumArgumentException();
                    }
                }
            }

            try
            {
                appWorkspace.Widgets.DocumentStrip.ThumbnailUpdateLatency = oldLatency;
            }

            catch (NullReferenceException)
            {
                // See bug #2544
            }

            if (this.cancelled)
            {
                if (appWorkspace.ActiveDocumentWorkspace != originalDW &&
                    !originalDW.IsDisposed)
                {
                    appWorkspace.ActiveDocumentWorkspace = originalDW;
                }
            }
            else
            {
                UI.SuspendControlPainting(appWorkspace);

                foreach (DocumentWorkspace dw in appWorkspace.DocumentWorkspaces)
                {
                    appWorkspace.RemoveDocumentWorkspace(dw);
                }

                UI.ResumeControlPainting(appWorkspace);
                appWorkspace.Invalidate(true);
            }
        }
예제 #13
0
        public override void PerformAction(AppWorkspace appWorkspace)
        {
            DocumentWorkspace dw;

            if (this.closeMe == null)
            {
                dw = appWorkspace.ActiveDocumentWorkspace;
            }
            else
            {
                dw = this.closeMe;
            }

            if (dw != null)
            {
                if (dw.Document == null)
                {
                    appWorkspace.RemoveDocumentWorkspace(dw);
                }
                else if (!dw.Document.Dirty)
                {
                    appWorkspace.RemoveDocumentWorkspace(dw);
                }
                else
                {
                    appWorkspace.ActiveDocumentWorkspace = dw;

                    TaskButton saveTB = new TaskButton(
                        ImageResource.Get("Icons.MenuFileSaveIcon.png").Reference,
                        PdnResources.GetString("CloseWorkspaceAction.SaveButton.ActionText"),
                        PdnResources.GetString("CloseWorkspaceAction.SaveButton.ExplanationText"));

                    TaskButton dontSaveTB = new TaskButton(
                        ImageResource.Get("Icons.MenuFileCloseIcon.png").Reference,
                        PdnResources.GetString("CloseWorkspaceAction.DontSaveButton.ActionText"),
                        PdnResources.GetString("CloseWorkspaceAction.DontSaveButton.ExplanationText"));

                    TaskButton cancelTB = new TaskButton(
                        ImageResource.Get("Icons.CancelIcon.png").Reference,
                        PdnResources.GetString("CloseWorkspaceAction.CancelButton.ActionText"),
                        PdnResources.GetString("CloseWorkspaceAction.CancelButton.ExplanationText"));

                    string title           = PdnResources.GetString("CloseWorkspaceAction.Title");
                    string introTextFormat = PdnResources.GetString("CloseWorkspaceAction.IntroText.Format");
                    string introText       = string.Format(introTextFormat, dw.GetFriendlyName());

                    Image  thumb     = appWorkspace.GetDocumentWorkspaceThumbnail(dw);
                    Bitmap taskImage = new Bitmap(thumb.Width + 2, thumb.Height + 2, PixelFormat.Format32bppArgb);

                    using (Graphics g = Graphics.FromImage(taskImage))
                    {
                        g.Clear(Color.Transparent);

                        g.DrawImage(
                            thumb,
                            new Rectangle(1, 1, thumb.Width, thumb.Height),
                            new Rectangle(0, 0, thumb.Width, thumb.Height),
                            GraphicsUnit.Pixel);

                        Utility.DrawDropShadow1px(g, new Rectangle(0, 0, taskImage.Width, taskImage.Height));
                    }

                    Form mainForm = appWorkspace.FindForm();
                    if (mainForm != null)
                    {
                        PdnBaseForm asPDF = mainForm as PdnBaseForm;

                        if (asPDF != null)
                        {
                            asPDF.RestoreWindow();
                        }
                    }

                    TaskButton clickedTB = TaskDialog.Show(
                        appWorkspace,
                        Utility.ImageToIcon(ImageResource.Get("Icons.WarningIcon.png").Reference, false),
                        title,
                        taskImage,
                        false,
                        introText,
                        new TaskButton[] { saveTB, dontSaveTB, cancelTB },
                        saveTB,
                        cancelTB,
                        340);

                    if (clickedTB == saveTB)
                    {
                        if (dw.DoSave())
                        {
                            this.cancelled = false;
                            appWorkspace.RemoveDocumentWorkspace(dw);
                        }
                        else
                        {
                            this.cancelled = true;
                        }
                    }
                    else if (clickedTB == dontSaveTB)
                    {
                        this.cancelled = false;
                        appWorkspace.RemoveDocumentWorkspace(dw);
                    }
                    else
                    {
                        this.cancelled = true;
                    }
                }
            }

            Utility.GCFullCollect();
        }
예제 #14
0
        private void HandleEffectException(AppWorkspace appWorkspace, Effect effect, Exception ex)
        {
            try
            {
                AppWorkspace.Widgets.StatusBarProgress.ResetProgressStatusBar();
                AppWorkspace.Widgets.StatusBarProgress.EraseProgressStatusBar();
            }

            catch (Exception)
            {
            }

            // Figure out if it's a built-in effect, or a plug-in
            bool builtIn = IsBuiltInEffect(effect);

            if (builtIn)
            {
                // For built-in effects, tear down Paint.NET which will result in a crash log
                throw new ApplicationException("Effect threw an exception", ex);
            }
            else
            {
                Icon formIcon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.BugWarning.png").Reference);

                string formTitle = PdnResources.GetString("Effect.PluginErrorDialog.Title");

                Image taskImage = null;

                string introText = PdnResources.GetString("Effect.PluginErrorDialog.IntroText");

                TaskButton restartTB = new TaskButton(
                    PdnResources.GetImageResource("Icons.RightArrowBlue.png").Reference,
                    PdnResources.GetString("Effect.PluginErrorDialog.RestartTB.ActionText"),
                    PdnResources.GetString("Effect.PluginErrorDialog.RestartTB.ExplanationText"));

                TaskButton doNotRestartTB = new TaskButton(
                    PdnResources.GetImageResource("Icons.WarningIcon.png").Reference,
                    PdnResources.GetString("Effect.PluginErrorDialog.DoNotRestartTB.ActionText"),
                    PdnResources.GetString("Effect.PluginErrorDialog.DoNotRestartTB.ExplanationText"));

                string auxButtonText = PdnResources.GetString("Effect.PluginErrorDialog.AuxButton1.Text");

                EventHandler auxButtonClickHandler =
                    delegate(object sender, EventArgs e)
                    {
                        using (PdnBaseForm textBoxForm = new PdnBaseForm())
                        {
                            textBoxForm.Name = "EffectCrash";

                            TextBox exceptionBox = new TextBox();

                            textBoxForm.Icon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.WarningIcon.png").Reference);
                            textBoxForm.Text = PdnResources.GetString("Effect.PluginErrorDialog.Title");

                            exceptionBox.Dock = DockStyle.Fill;
                            exceptionBox.ReadOnly = true;
                            exceptionBox.Multiline = true;

                            string exceptionText = AppWorkspace.GetLocalizedEffectErrorMessage(effect.GetType().Assembly, effect.GetType(), ex);

                            exceptionBox.Font = new Font(FontFamily.GenericMonospace, exceptionBox.Font.Size);
                            exceptionBox.Text = exceptionText;
                            exceptionBox.ScrollBars = ScrollBars.Vertical;

                            textBoxForm.StartPosition = FormStartPosition.CenterParent;
                            textBoxForm.ShowInTaskbar = false;
                            textBoxForm.MinimizeBox = false;
                            textBoxForm.Controls.Add(exceptionBox);
                            textBoxForm.Width = UI.ScaleWidth(700);

                            textBoxForm.ShowDialog();
                        }
                    };

                TaskButton clickedTB = TaskDialog.Show(
                    appWorkspace,
                    formIcon,
                    formTitle,
                    taskImage,
                    true,
                    introText,
                    new TaskButton[] { restartTB, doNotRestartTB },
                    restartTB,
                    doNotRestartTB,
                    TaskDialog.DefaultPixelWidth96Dpi * 2,
                    auxButtonText,
                    auxButtonClickHandler);

                if (clickedTB == restartTB)
                {
                    // Next, apply restart logic
                    CloseAllWorkspacesAction cawa = new CloseAllWorkspacesAction();
                    cawa.PerformAction(appWorkspace);

                    if (!cawa.Cancelled)
                    {
                        SystemLayer.Shell.RestartApplication();
                        Startup.CloseApplication();
                    }
                }
            }
        }
예제 #15
0
        private void HandleEffectException(AppWorkspace appWorkspace, Effect effect, Exception ex)
        {
            try
            {
                AppWorkspace.Widgets.StatusBarProgress.ResetProgressStatusBar();
                AppWorkspace.Widgets.StatusBarProgress.EraseProgressStatusBar();
            }

            catch (Exception)
            {
            }

            // Figure out if it's a built-in effect, or a plug-in
            if (IsBuiltInEffect(effect))
            {
                // For built-in effects, tear down Paint.NET which will result in a crash log
                throw new ApplicationException("Effect threw an exception", ex);
            }
            else
            {
                Icon formIcon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.BugWarning.png").Reference);

                string formTitle = PdnResources.GetString("Effect.PluginErrorDialog.Title");

                Image taskImage = null;

                string introText = PdnResources.GetString("Effect.PluginErrorDialog.IntroText");

                TaskButton restartTB = new TaskButton(
                    PdnResources.GetImageResource("Icons.RightArrowBlue.png").Reference,
                    PdnResources.GetString("Effect.PluginErrorDialog.RestartTB.ActionText"),
                    PdnResources.GetString("Effect.PluginErrorDialog.RestartTB.ExplanationText"));

                TaskButton doNotRestartTB = new TaskButton(
                    PdnResources.GetImageResource("Icons.WarningIcon.png").Reference,
                    PdnResources.GetString("Effect.PluginErrorDialog.DoNotRestartTB.ActionText"),
                    PdnResources.GetString("Effect.PluginErrorDialog.DoNotRestartTB.ExplanationText"));

                string auxButtonText = PdnResources.GetString("Effect.PluginErrorDialog.AuxButton1.Text");

                void AuxButtonClickHandler(object sender, EventArgs e)
                {
                    using (PdnBaseForm textBoxForm = new PdnBaseForm())
                    {
                        textBoxForm.Name = "EffectCrash";

                        TextBox exceptionBox = new TextBox();

                        textBoxForm.Icon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.WarningIcon.png").Reference);
                        textBoxForm.Text = PdnResources.GetString("Effect.PluginErrorDialog.Title");

                        exceptionBox.Dock      = DockStyle.Fill;
                        exceptionBox.ReadOnly  = true;
                        exceptionBox.Multiline = true;

                        string exceptionText = AppWorkspace.GetLocalizedEffectErrorMessage(effect.GetType().Assembly, effect.GetType(), ex);

                        exceptionBox.Font       = new Font(FontFamily.GenericMonospace, exceptionBox.Font.Size);
                        exceptionBox.Text       = exceptionText;
                        exceptionBox.ScrollBars = ScrollBars.Vertical;

                        textBoxForm.StartPosition = FormStartPosition.CenterParent;
                        textBoxForm.ShowInTaskbar = false;
                        textBoxForm.MinimizeBox   = false;
                        textBoxForm.Controls.Add(exceptionBox);
                        textBoxForm.Width = UI.ScaleWidth(700);

                        textBoxForm.ShowDialog();
                    }
                }

                TaskButton clickedTB = TaskDialog.Show(
                    appWorkspace,
                    formIcon,
                    formTitle,
                    taskImage,
                    true,
                    introText,
                    new TaskButton[] { restartTB, doNotRestartTB },
                    restartTB,
                    doNotRestartTB,
                    TaskDialog.DefaultPixelWidth96Dpi * 2,
                    auxButtonText,
                    AuxButtonClickHandler);

                if (clickedTB == restartTB)
                {
                    // Next, apply restart logic
                    CloseAllWorkspacesAction cawa = new CloseAllWorkspacesAction();
                    cawa.PerformAction(appWorkspace);

                    if (!cawa.Cancelled)
                    {
                        SystemLayer.Shell.RestartApplication();
                        Startup.CloseApplication();
                    }
                }
            }
        }
예제 #16
0
        private void OnZoomAmountButtonClick(object sender, EventArgs e)
        {
            PdnBaseForm typeZoomTextForm = new PdnBaseForm {
                FormBorderStyle = FormBorderStyle.None,
                StartPosition   = FormStartPosition.Manual,
                ShowInTaskbar   = false
            };
            TextBox zoomTextBox = new TextBox {
                Text  = this.scaleFactor.ToString(),
                Width = UIUtil.ScaleWidth(0x30)
            };

            typeZoomTextForm.Controls.Add(zoomTextBox);
            zoomTextBox.PerformLayout();
            typeZoomTextForm.Size = zoomTextBox.Size;
            zoomTextBox.KeyPress += delegate(object sender2, KeyPressEventArgs e2) {
                if ((e2.KeyChar == '\r') || (e2.KeyChar == '\n'))
                {
                    PaintDotNet.ScaleFactor factor;
                    if (PaintDotNet.ScaleFactor.TryParse(zoomTextBox.Text, out factor))
                    {
                        this.ZoomBasis   = PaintDotNet.ZoomBasis.ScaleFactor;
                        this.ScaleFactor = factor;
                        typeZoomTextForm.Close();
                    }
                    else
                    {
                        SystemSounds.Beep.Play();
                    }
                }
                else if (e2.KeyChar == '\x001b')
                {
                    typeZoomTextForm.Close();
                }
            };
            Rectangle rectangle  = base.RectangleToScreen(this.zoomAmountButton.Bounds);
            Rectangle rectangle2 = new Rectangle(rectangle.X + ((rectangle.Width - typeZoomTextForm.Width) / 2), rectangle.Y - typeZoomTextForm.Height, typeZoomTextForm.Width, typeZoomTextForm.Height);

            typeZoomTextForm.Bounds = rectangle2;
            typeZoomTextForm.Load  += delegate(object sender2, EventArgs e2) {
                typeZoomTextForm.Size = zoomTextBox.Size;
                zoomTextBox.Select();
                zoomTextBox.SelectAll();
            };
            typeZoomTextForm.Deactivate += delegate(object sender2, EventArgs e2) {
                if (this.IsHandleCreated)
                {
                    this.BeginInvoke(delegate {
                        try
                        {
                            typeZoomTextForm.Close();
                        }
                        catch (Exception)
                        {
                        }
                    });
                }
                else
                {
                    typeZoomTextForm.Close();
                }
            };
            typeZoomTextForm.FormClosed += (sender2, e2) => typeZoomTextForm.Dispose();
            typeZoomTextForm.Show();
        }
예제 #17
0
 public FileMenu()
 {
     PdnBaseForm.RegisterFormHotKey(Keys.Control | Keys.F4, new Func <Keys, bool>(this.OnCtrlF4Typed));
     this.InitializeComponent();
 }