Beispiel #1
0
        private void About()
        {
            var actions = new WindowManager.NewFormActions()
            {
                BeforeShow = (form) =>
                {
                    form.Height        = 500;
                    form.Width         = 800;
                    form.StartPosition = FormStartPosition.CenterParent;
                },
                AfterShow = (form) =>
                {
                    var sb = new StringBuilder();
                    sb.AppendLine($"betterpad by NeoSmart Technologies");
                    sb.AppendLine($"https://neosmart.net/betterpad/\r\n");
                    sb.AppendLine($"Version {ShortVersion} - build {BuildHash}\r\n");
                    sb.AppendLine($"Copyright © NeoSmart Technologies 2016-{DateTime.UtcNow.Year}");
                    sb.AppendLine("All rights reserved.\r\n\r\n");

                    form.text.Text       = sb.ToString();
                    form.text.ReadOnly   = true;
                    form._ignoreChanges  = true;
                    form.Text            = "betterpad by NeoSmart Technologies";
                    form._ignoreSettings = true;

                    form.text.SelectionStart = sb.Length;
                    form.text.SelectionFont  = new Font(form.text.Font.FontFamily, form.text.Font.Size, FontStyle.Italic);
                    form.text.SelectedText   = "> A better notepad. Still simple. Still fast.";
                    form.text.SelectionStart = 0;

                    form._shortcuts.Clear();
                    form._shortcuts.Add(Keys.Escape, () => form.Close());
                    form._shortcuts.Add(Keys.Control | Keys.W, () => form.Close());
                }
            };

            using (var about = new Form1())
            {
                actions.BeforeShow(about);

                about.mainMenu1.MenuItems.Clear();
                about.StartAction     = actions.AfterShow;
                about.FormBorderStyle = FormBorderStyle.FixedSingle;
                about.SizeGripStyle   = SizeGripStyle.Hide;
                about.ShowInTaskbar   = false;
                about.MaximizeBox     = false;
                about.MinimizeBox     = false;
                about.ShowDialog(this);
            }
        }
Beispiel #2
0
        private void OpenNew(string path, bool sameLocation)
        {
            var actions = new WindowManager.NewFormActions()
            {
                BeforeShow = (form) =>
                {
                    form.Size = Size;
                    if (sameLocation)
                    {
                        form.StartPosition = FormStartPosition.Manual;
                        form.Location      = Location;
                    }
                    form.Visible = false;
                },
                AfterShow = (form) =>
                {
                    form.Size = Size;
                    form.Hide();
                    if (string.IsNullOrEmpty(path))
                    {
                        if (!form.Open())
                        {
                            form.Close();
                            DecrementDocumentNumber();
                            return;
                        }
                    }
                    else
                    {
                        form.Open(path);
                        DecrementDocumentNumber();
                    }

                    form.Show();
                    form.Focus();
                    form.BringToFront();
                }
            };

            WindowManager.CreateNewWindow(actions);
        }