Beispiel #1
0
        protected void HideSplashScreen()
        {
            var Expression = m_SplashLock;

            ObjectFlowControl.CheckForSyncLockOnValueType(Expression);
            var lockTaken = false;

            try
            {
                Monitor.Enter(Expression, ref lockTaken);
                if (MainForm != null)
                {
                    new UIPermission(UIPermissionWindow.AllWindows).Assert();
                    MainForm.Activate();
                    PermissionSet.RevertAssert();
                }
                if (m_SplashScreen == null || m_SplashScreen.IsDisposed)
                {
                    return;
                }
                m_SplashScreen.Invoke(new DisposeDelegate(((Component)m_SplashScreen).Dispose));
                m_SplashScreen = null;
            }
            finally
            {
                if (lockTaken)
                {
                    Monitor.Exit(Expression);
                }
            }
        }
Beispiel #2
0
        static void showMainForm(object sender, EventArgs e)
        {
            var mainForm = new MainForm();

            mainForm.Show();
            mainForm.Activate();
        }
Beispiel #3
0
            protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
            {
                // Subsequent launches


                base.OnStartupNextInstance(eventArgs);
                app.Activate();
                app.Show();
                // MessageBox.Show(Application.ProductName + " 已经在运行了,不能重复运行", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);//给个对话框提示
            }
Beispiel #4
0
 private void FindInTheText()
 {
     if (_downRB == null)
     {
         FindDown();
         _mainForm.Activate();
     }
     else
     {
         if (_downRB.Checked)
         {
             FindDown();
         }
         else
         {
             FindUp();
         }
         _mainForm.Activate();
     }
 }
Beispiel #5
0
 private static void MainForm_LoadCompleted(object sender, EventArgs e)
 {
     if (SplashForm == null || SplashForm.Disposing || SplashForm.IsDisposed)
     {
         return;
     }
     SplashForm.Invoke(new Action(() => { SplashForm.Close(); }));
     SplashForm.Dispose();
     SplashForm = null;
     MainForm.Activate();
 }
 protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
 {
     try
     {
         MainForm?.Activate();
     }
     catch (Exception ex)
     {
         PremadeDialogs.GenericError(ex);
     }
 }
Beispiel #7
0
        private static void ActivationTimerExpired(object state)
        {
            try
            {
                if (TheForm == null)
                {
                    TheForm = new MainForm();
                }

                if (TheForm.InvokeRequired)
                {
                    TheForm.Invoke(new Action <object>(ActivationTimerExpired), new object());
                    return;
                }

                lock (InteropLockObj)
                {
                    if (_activationTimer == null)
                    {
                        return;
                    }

                    // Activate.
                    TheForm.Visible = true;
                    TheForm.BringToFront();
                    TheForm.Activate();

                    OpenNETCF.Windows.Forms.ApplicationEx.DoEvents();
                    TheForm.Invoke(new Action(TheForm.RefreshData));

                    _activationTimer.Dispose();
                    _activationTimer = null;
                }
            }
            catch (Exception)
            {
                return;
            }
        }
        void this_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
        {
            // Here you get the control when any other instance is
            // invoked apart from the first one.
            // You have args here in e.CommandLine.

            // You custom code which should be run on other instances
            if (MainForm != null)
            {
                MainForm.Activate();
                MainForm.BringToFront();
            }
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            string path = null;

            if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null && AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null)
            {
                path = System.Web.HttpUtility.UrlDecode(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]).Substring(8);
            }
            //SecurityClient.ResetActivation();
            MainForm.Activate();
            if (MainForm.IsActivated)
            {
                Application.Run(new MainForm(path));
            }
        }
Beispiel #10
0
        protected virtual void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
        {
            var instanceEventHandler = StartupNextInstance;

            if (instanceEventHandler != null)
            {
                instanceEventHandler(this, eventArgs);
            }
            new UIPermission(UIPermissionWindow.AllWindows).Assert();
            if (!eventArgs.BringToForeground || MainForm == null)
            {
                return;
            }
            if (MainForm.WindowState == FormWindowState.Minimized)
            {
                MainForm.WindowState = FormWindowState.Normal;
            }
            MainForm.Activate();
        }
        protected void Program_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
        {
            // if the window is currently minimized, then restore it.
            if (MainForm.WindowState == FormWindowState.Minimized)
            {
                MainForm.WindowState = FormWindowState.Normal;
            }

            // activate the current instance of the app, so that it's shown.
            MainForm.Activate();

            // Create an argument array for the Invoke method
            object[] parameters = new object[] { ParseCommandLine(e.CommandLine) };

            // Need to use invoke to b/c this is being called
            // from another thread.
            MainForm.Invoke(new ProcessArgumentsDelegate(
                                ((NAntGuiForm)MainForm).ProcessArguments), parameters);
        }
Beispiel #12
0
        private void DestroyStatusDialog(StatusProgressForm dlg)
        {
            if (dlg != null)
            {
                MainForm mfOwner = ((m_fOwner != null) ? (m_fOwner as MainForm) : null);
                if ((m_bUseThread == false) && (mfOwner != null))
                {
                    mfOwner.RedirectActivationPop();
                    mfOwner.UIBlockInteraction(false);
                }

                dlg.EndLogging();
                dlg.Close();
                dlg.Dispose();

                if (mfOwner != null)
                {
                    mfOwner.Activate();                                 // Prevent disappearing
                }
            }
        }
Beispiel #13
0
 private static void Activate(IApplicationForm form)
 {
     if (form == null)
     {
         if (MainForm != null)
         {
             MainForm.Activate();
             MainForm.BringToFront();
         }
         return;
     }
     if (ModalFormCount > 0)
     {
         return;
     }
     if (m_FormList.IndexOf(form) >= 0)
     {
         form.Activate();
         ((Control)form).BringToFront();
         m_CurrentForm = form;
     }
 }
Beispiel #14
0
    protected void Init()
    {
        var background = new DimBackground {
            Size = ContainingForm.Size, Location = ContainingForm.Location, StartPosition = FormStartPosition.Manual
        };

        Controls.Add(HeaderLabel);
        // Add the title bar AFTER the header, so that they don't fight over docking priority.
        InitTitleBar(this, "");
        TitleBar.BackColor = BackColor;

        StartPosition      = FormStartPosition.Manual;
        FormBorderStyle    = FormBorderStyle.None;
        BackColor          = Constants.UiConstants.UiColor;
        TitleBar.BackColor = Constants.UiConstants.UiColor;
        ShowInTaskbar      = false;
        Draggable          = false;
        TopMost            = false;

        Owner            = ContainingForm;
        background.Owner = ContainingForm;
        background.Show();

        Closed += OnClose;

        void OnClose(object b, object a)
        {
            Closed -= OnClose;
            background.Close();
            // Workaround for the background form closing the containing form on the background form's close.
            ContainingForm.Activate();
            ContainingForm.Focus();
        }

        Location = new Point(
            ContainingForm.Location.X + (ContainingForm.Size.Width - Size.Width) / 2,
            ContainingForm.Location.Y + (ContainingForm.Size.Height - Size.Height) / 2 - TitleBar.Height);
    }
Beispiel #15
0
        static void MainFormLoad(object sender, EventArgs e)
        {
            if (SplashScreen != null)
            {
                SplashScreen.Invoke(new Action(SplashScreen.Close));
                SplashScreen.Dispose();
            }

            MainForm form = (MainForm)sender;

            form.BringToFront();
            form.Activate();

            if (Arguments.Setwindow)
            {
                form.Left   = Arguments.Position_x;
                form.Top    = Arguments.Position_y;
                form.Width  = Arguments.Size_w;
                form.Height = Arguments.Size_h;

                form.WindowState = (FormWindowState)Arguments.Window_s;
            }
        }
Beispiel #16
0
        private void OnShowConfig(object sender, EventArgs e)
        {
            bool created = false;

            if (MainForm == null)
            {
                MainForm              = new ConfigForm(_HotkeyManager, _KneeboardManager, _AltCodes);
                MainForm.FormClosing += MainForm_FormClosing;
                MainForm.Resize      += MainForm_Resize;
                created = true;
            }

            MainForm.Show();
            MainForm.Activate();

            if (MainForm.WindowState == FormWindowState.Minimized)
            {
                MainForm.WindowState = FormWindowState.Normal;
            }
            else if (!created)
            {
                MainForm.BringToFront(true);
            }
        }
Beispiel #17
0
 public void MainFormActivate()
 {
     MainForm.Activate();
 }
 void Show(object sender, EventArgs e)
 {
     _mainForm.Show();
     _mainForm.Activate();
 }