예제 #1
0
        private void StartPart2()
        {
            // Set up locale / resource details
            string locale = Settings.CurrentUser.GetString(SettingNames.LanguageName, null);

            if (locale == null)
            {
                locale = Settings.SystemWide.GetString(SettingNames.LanguageName, null);
            }

            if (locale != null)
            {
                try
                {
                    CultureInfo ci = new CultureInfo(locale, true);
                    Thread.CurrentThread.CurrentUICulture = ci;
                }

                catch (Exception)
                {
                    // Don't want bad culture name to crash us
                }
            }

            // Check system requirements
            if (!OS.CheckOSRequirement())
            {
                string message = PdnResources.GetString("Error.OSRequirement");
                Utility.ErrorBox(null, message);
                return;
            }

            // Parse command-line arguments
            if (this.args.Length == 1 && 
                this.args[0] == Updates.UpdatesOptionsDialog.CommandLineParameter)
            {
                Updates.UpdatesOptionsDialog.ShowUpdateOptionsDialog(null, false);
            }
            else
            {
                SingleInstanceManager singleInstanceManager = new SingleInstanceManager(InvariantStrings.SingleInstanceMonikerName);

                // If this is not the first instance of PDN.exe, then forward the command-line
                // parameters over to the first instance.
                if (!singleInstanceManager.IsFirstInstance)
                {
                    singleInstanceManager.FocusFirstInstance();

                    foreach (string arg in this.args)
                    {
                        singleInstanceManager.SendInstanceMessage(arg, 30);
                    }

                    singleInstanceManager.Dispose();
                    singleInstanceManager = null;

                    return;
                }

                // Create main window
                this.mainForm = new MainForm(this.args);

                this.mainForm.SingleInstanceManager = singleInstanceManager;
                singleInstanceManager = null; // mainForm owns it now

                // 3 2 1 go
                Application.Run(this.mainForm);

                try
                {
                    this.mainForm.Dispose();
                }

                catch (Exception)
                {
                }

                this.mainForm = null;
            }
        }
예제 #2
0
        private void StartPart2()
        {
            // Set up locale / resource details
            string locale = Settings.CurrentUser.GetString(PdnSettings.LanguageName, null);

            if (locale == null)
            {
                locale = Settings.SystemWide.GetString(PdnSettings.LanguageName, null);
            }

            if (locale != null)
            {
                CultureInfo ci = new CultureInfo(locale, true);
                Thread.CurrentThread.CurrentUICulture = ci;
            }

            // Check system requirements
            if (!OS.CheckOSRequirement())
            {
                string message = PdnResources.GetString("Error.OSRequirement");
                Utility.ErrorBox(null, message);
                return;
            }

            // Parse command-line arguments
            if (this.args.Length == 1 &&
                this.args[0] == Updates.UpdatesOptionsDialog.CommandLineParameter)
            {
                Updates.UpdatesOptionsDialog.ShowUpdateOptionsDialog(null, false);
            }
            else
            {
                SingleInstanceManager singleInstanceManager = new SingleInstanceManager("PaintDotNet");

                // If this is not the first instance of PDN.exe, then forward the command-line
                // parameters over to the first instance.
                if (!singleInstanceManager.IsFirstInstance)
                {
                    singleInstanceManager.FocusFirstInstance();

                    foreach (string arg in this.args)
                    {
                        singleInstanceManager.SendInstanceMessage(arg, 30);
                    }

                    singleInstanceManager.Dispose();
                    singleInstanceManager = null;

                    return;
                }

                // Create main window
                this.mainForm = new MainForm(this.args);

                // if the display is set to a portrait mode (tall), then orient the PDN window the same way
                if (this.mainForm.ScreenAspect < 1.0)
                {
                    int width = mainForm.Width;
                    int height = mainForm.Height;

                    this.mainForm.Width = height;
                    this.mainForm.Height = width;
                }

                // if the window opens and part of it is off screen, correct this
                Screen screen = Screen.FromControl(this.mainForm);

                Rectangle intersect = Rectangle.Intersect(screen.Bounds, mainForm.Bounds);
                if (intersect.Width == 0 || intersect.Height == 0)
                {
                    mainForm.Location = new Point(screen.Bounds.Left + 16, screen.Bounds.Top + 16);
                }

                // if the window is not big enough, correct this
                if (this.mainForm.Width < 200)
                {
                    this.mainForm.Width = 200; // this value was chosen arbitrarily
                }

                if (this.mainForm.Height < 200)
                {
                    this.mainForm.Height = 200; // this value was chosen arbitrarily
                }

                this.mainForm.SingleInstanceManager = singleInstanceManager;
                singleInstanceManager = null; // mainForm owns it now

                // 3 2 1 go
                Application.Run(this.mainForm);

                this.mainForm.Dispose();
                this.mainForm = null;
            }
        }