示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parent"></param>
        public override DialogResult Show(Form parent = null, bool setup = false)
        {
            ImgDst = ImgSrc;

            if (fm == null)
            {
                fm                 = new CropForm(this);
                fm.host            = Host;
                fm.Text            = DisplayName;
                fm.FormBorderStyle = FormBorderStyle.FixedToolWindow;
                fm.MaximizeBox     = false;
                fm.MinimizeBox     = false;
                fm.ShowIcon        = false;
                fm.ShowInTaskbar   = false;
                fm.StartPosition   = FormStartPosition.CenterParent;

                Translate(fm);
                SetParams(fm, ImgSrc);
                Host.OnCommandPropertiesChange(new CommandPropertiesChangeEventArgs(AddinCommand.GetImageSelection, 0));
            }
            var result = fm.ShowDialog();

            if (result == DialogResult.OK)
            {
                _success = true;
                GetParams(fm);
                if (!setup)
                {
                    ImgDst = Apply(ImgSrc);
                    Host.OnCommandPropertiesChange(new CommandPropertiesChangeEventArgs(AddinCommand.SetImageSelection, new RectangleF(0, 0, 0, 0)));
                }
            }
            else
            {
                _success = false;
            }
            if (fm != null)
            {
                fm.Dispose();
                fm = null;
            }
            return(result);
        }
示例#2
0
        public static void Init(Controller controller)
        {
            // Create a new ConfigForm
            configForm             = new ConfigForm();
            configForm.FormClosed += (s, e) => Application.Exit();
            configForm.Load       += async(s, e) => await controller.RestoreProviders();

            // If there are any registered providers, the config will be hidden
            // Else the config will be closed (along with the whole application)
            configForm.FormClosing += (s, e) =>
            {
                if (e.CloseReason == CloseReason.UserClosing && ProviderService.RegisteredProviders.Count > 0)
                {
                    e.Cancel = true;
                    configForm.Hide();
                }
            };

            // Show crop forms if the config is hidden
            configForm.VisibleChanged += (s, e) =>
            {
                if (!configForm.Visible)
                {
                    ShowCropForms();
                }
            };

            // Create a CropForm for every screen and show them
            for (var i = 0; i < Screen.AllScreens.Length; i++)
            {
                var screen = Screen.AllScreens[i];
                var form   = new CropForm(controller, screen.Bounds, i);

                form.FormClosed += (s, e) => Application.Exit();

                cropForms.Add(form);
            }
        }