Exemplo n.º 1
0
 void this_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
 {
     P2PVPNForm form = MainForm as P2PVPNForm; //My derived form type
     //form.LoadFile(e.CommandLine[1]);
     if (e.CommandLine.Count() >= 2)
     {
         string sourceDir = "";
         for (int i = 1; i < e.CommandLine.Count(); i++)
         {
             sourceDir += e.CommandLine[i] + " ";
         }
         sourceDir = sourceDir.Trim();
         Settings settings = Settings.Get();
         if (!string.IsNullOrWhiteSpace(settings.ExcludedFolderFromMediaTransfer))
         {
             if (sourceDir.Contains(settings.ExcludedFolderFromMediaTransfer)) return;
         }
         form.bwTorrentDownloadComplete.RunWorkerAsync(sourceDir);
     }
     //else if (e.CommandLine.Count() == 3)
     //{
     //    string sourceDir = e.CommandLine[1] +" " + e.CommandLine[2];
     //    form.bwTorrentDownloadComplete.RunWorkerAsync(sourceDir);
     //}
     e.BringToForeground = true;
 }
Exemplo n.º 2
0
 static void _myapp_StartupNextInstance(object sender, Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs e)
 {
     //e.CommandLine contains the new commandline arguments
     // this is where you do what you want with the new commandline arguments
     // if you want it the window to come to the front:
     e.BringToForeground = true;
 }
Exemplo n.º 3
0
 static void StartupNextInstanceHandler(object sender, StartupNextInstanceEventArgs e)
 {
     frm_Main form = (Application.OpenForms[0] as frm_Main);
     if (!form.Visible)
         form.Visible = true;
     form.Activate();
 }
        protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
        {
            base.OnStartupNextInstance(eventArgs);

            App.ActivateMainWindow();
            App.ProcessArgs(eventArgs.CommandLine.ToArray(), false);
        }
Exemplo n.º 5
0
 protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
 {
     base.OnStartupNextInstance(eventArgs);
     app.Activate();
     //提示已经运行
     MessageBox.Show("推送系统已经在运行!", "确定", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
 }
Exemplo n.º 6
0
 protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
 {
     /* if some files opened from the Explorer, open them */
     if (eventArgs.CommandLine.Count > 0)
         MainForm = FormController.Instance.OpenFiles(eventArgs.CommandLine);
     base.OnStartupNextInstance(eventArgs);
 }
Exemplo n.º 7
0
        void Program_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
        {
            e.BringToForeground = true;

            var form = (TabbedMain) MainForm;
            form.Start(e.CommandLine.Skip(1));
        }
Exemplo n.º 8
0
        static void StartupNextInstanceHandler(object sender, StartupNextInstanceEventArgs e)
        {
            SingleInstanceApplication app = (SingleInstanceApplication)sender;
            MainForm form = (MainForm)app.AppMainForm;

            processCommandLine(form, e.CommandLine);
        }
Exemplo n.º 9
0
        protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs) {
            eventArgs.BringToForeground = true;

            ((MainForm)MainForm).RestoreWindowState();

            base.OnStartupNextInstance(eventArgs);
        }
Exemplo n.º 10
0
 void SingleInstanceManager_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
 {
     string[] args = new string[e.CommandLine.Count];
     e.CommandLine.CopyTo(args, 0);
     mainForm.ProcessArgs(args);
     mainForm.Show();
 }
Exemplo n.º 11
0
 // called on subsequent runs
 protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
 {
     base.OnStartupNextInstance(eventArgs);
     if (Settings.Default.FocusMainInstance)
     {
         ((MainWindow)app.MainWindow).SetVisible();
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Overrides the OnStartupNextInstance Method from Base.
 /// On subsequent startup, restore the current application instance and passes any command line arguments to it
 /// </summary>
 /// <param name="eventArgs"></param>
 protected override void OnStartupNextInstance(
     StartupNextInstanceEventArgs eventArgs)
 {
     base.OnStartupNextInstance(eventArgs);
     App.main.Activate();
     App.main.RestoreWindow();
     App.ProcessArgs(eventArgs.CommandLine.ToArray());
 }
        void this_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
        {
            var form = MainForm as Workbench;

            form.OpenImage(e.CommandLine[0]);

            Splasher.Close();
        }
Exemplo n.º 14
0
 /// <summary>
 /// Gets called when subsequent application launches occur.  The subsequent app launch will result in this function getting called
 /// and then the subsequent instances will just exit.  You might use this method to open the requested doc, or whatever
 /// </summary>
 /// <param name="eventArgs"></param>
 protected override void OnStartupNextInstance(MsVB.StartupNextInstanceEventArgs eventArgs)
 {
     base.OnStartupNextInstance(eventArgs);
     eventArgs.BringToForeground = true;
     if (eventArgs.CommandLine.Count > 0)
     {
         (this.MainForm as BSABrowser).OpenArchive(eventArgs.CommandLine[0], true);
     }
 }
Exemplo n.º 15
0
        void SingleInstanceController_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
        {
            RemoteDesktopClient rdc = (RemoteDesktopClient)this.MainForm;

            string[] args = new string[e.CommandLine.Count];
            e.CommandLine.CopyTo(args, 0);

            rdc.DoArguments(args);
        }
Exemplo n.º 16
0
        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
            this.MainForm.Show();
        }
Exemplo n.º 17
0
            void onNextInstance(object sender, StartupNextInstanceEventArgs e)
            {
                // args = e.CommandLine - any other instances that is not the first
                // very useful: http://www.hanselman.com/blog/TheWeeklySourceCode31SingleInstanceWinFormsAndMicrosoftVisualBasicdll.aspx
                if (e.CommandLine.Count < 1) { return; }

                Form1 form = MainForm as Form1;
                form.handleUri(e.CommandLine[0]);
            }
Exemplo n.º 18
0
 protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
 {
     foreach (System.Windows.Window _win in win.Windows)
     {
         if (_win.Visibility == System.Windows.Visibility.Visible)
         {
             _win.Activate();
         }
     }
 }
 void this_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
 {
     Main form = MainForm as Main;
     if (form != null)
     {
         form.Show();
         form.Focus();
         form.Activate();
     }
 }
Exemplo n.º 20
0
 protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
 {
     if (MainForm.WindowState == FormWindowState.Minimized)
     {
         MainForm.WindowState = FormWindowState.Normal;
         MainForm.WindowState = FormWindowState.Maximized;
     }
     MainForm.Activate();
     MainForm.BringToFront();
 }
        static void app_StartupNextInstance(object sender, Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs e)
        {
            SingleInstanceApplication app = (SingleInstanceApplication)sender;
            Form mainForm = (Form)app.MainForm;

            if (mainForm != null)
            {
                mainForm.Show();
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// 应用已存在,切换到启动的应用
        /// </summary>
        /// <param name="e"></param>
        protected override void OnStartupNextInstance(StartupNextInstanceEventArgs e)
        {
            if (_app.IsNull())
            {
                return;
            }
            _app.Activate();

            base.OnStartupNextInstance(e);
        }
Exemplo n.º 23
0
 public void Activate(StartupNextInstanceEventArgs eventArgs )
 {
     // Reactivate application's main window
     this.MainWindow.Show();
     this.MainWindow.Activate();
     if (eventArgs.CommandLine.Count>0)
     {
         string szTargetPaht =eventArgs.CommandLine[0];
         mainWnd.SwitchPath(szTargetPaht);
     }
 }
Exemplo n.º 24
0
 private static void StartupNextInstanceHandler(object sender, StartupNextInstanceEventArgs e)
 {
     frm_Main form = Application.OpenForms[0] as frm_Main;
     if (form != null)
     {
         if (!form.Visible)
         {
             form.Visible = true;
         }
         form.Activate();
     }
 }
Exemplo n.º 25
0
 void this_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
 {
     SebWindowsClientForm form = MainForm as SebWindowsClientForm; //My derived form type
     if (e.CommandLine.Count() > 1)
     {
         string es = string.Join(", ", e.CommandLine);
         Logger.AddInformation("StartupNextInstanceEventArgs: " + es);
         if (!form.LoadFile(e.CommandLine[1]))
         {
             Logger.AddError("LoadFile() from StartupNextInstanceEvent failed!", null, null);
         }
     }
 }
Exemplo n.º 26
0
 // The handler when attempting to start another instance of this application
 // We can customize the logic here for which form to activate in different
 // conditions. Like in this sample, we will be selectively activate the LoginForm
 // or MainForm based on the login state of the user.
 static void StartNewInstance(object sender, StartupNextInstanceEventArgs e)
 {
     FormCollection forms = Application.OpenForms;
     if (forms["LoginForm"] != null && forms["LoginForm"].WindowState== FormWindowState.Minimized)
     {
         forms["LoginForm"].WindowState = FormWindowState.Normal;
         forms["LoginForm"].Activate();
     }
     else if (forms["LoginForm"] == null && GlobalData.IsUserLoggedIn == false)
     {
         LoginForm f = new LoginForm();
         f.ShowDialog();
     }
 }
Exemplo n.º 27
0
        protected override void OnStartupNextInstance(StartupNextInstanceEventArgs args)
        {
            //each other initialization
            base.OnStartupNextInstance(args);

            _instance.Activate();

            var cmdline = String.Concat("Inbox2.exe ", String.Join(" ", args.CommandLine.ToArray()));
            var commandline = CommandLine.Parse(cmdline);

            // Publish event if we have been activated by a system mailto call
            if (!String.IsNullOrEmpty(commandline.Mailto))
                EventBroker.Publish(AppEvents.New, commandline.Mailto);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Handles the StartupNextInstance event of the this control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs"/> instance containing the event data.</param>
        private static void SingleInstanceController_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
        {
            if (e.CommandLine.Count <= 0 || string.IsNullOrEmpty(e.CommandLine[0]))
            {
                return;
            }

            var extractedUrl = ProtocolHelper.ProccesArguments(e.CommandLine[0]);

            if (!string.IsNullOrEmpty(extractedUrl))
            {
                Clipboard.SetText(extractedUrl);
            }
        }
Exemplo n.º 29
0
        static void NewInstanceHandler(object sender, StartupNextInstanceEventArgs e)
        {
            e.BringToForeground = true;

            if (e.CommandLine.Count == 1)
            {
                MessageBox.Show(SingleInstanceApplication.Form, "0 arguments");
            }
            else if (e.CommandLine[1].StartsWith("stat://"))
            {
                String protocolArg = String.Join(" ", e.CommandLine.Where((x, i) => i > 0));
                MessageBox.Show(SingleInstanceApplication.Form, protocolArg);
            }
        }
Exemplo n.º 30
0
            /// <summary>
            /// This is called for additional instances. The application model will call this 
            /// function, and terminate the additional instance when this returns.
            /// </summary>
            /// <param name="eventArgs"></param>
            protected void SIApp_StartupNextInstance(object sender, StartupNextInstanceEventArgs eventArgs)
            {
              // Copy the arguments to a string array
              string[] args = new string[eventArgs.CommandLine.Count];
              eventArgs.CommandLine.CopyTo(args, 0);

              // Create an argument array for the Invoke method
              object[] parameters = new object[2];
              parameters[0] = this.MainForm;
              parameters[1] = args;

              // Need to use invoke to b/c this is being called from another thread.
              this.MainForm.Invoke(new MainForm.ProcessParametersDelegate(
                  ((MainForm)this.MainForm).ProcessParameters),
                  parameters);
            }
        protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
        {
            if (eventArgs.CommandLine.Count > 0)
            {
                _wpfApp.ProcessArguments(eventArgs.CommandLine.ToList());
            }
            if (_wpfApp.MainWindow.WindowState == System.Windows.WindowState.Minimized)
            {
                _wpfApp.MainWindow.WindowState = System.Windows.WindowState.Normal;
            }

            _wpfApp.MainWindow.Show();
            _wpfApp.MainWindow.ShowInTaskbar = true;
            _wpfApp.MainWindow.WindowState = System.Windows.WindowState.Normal;
            _wpfApp.MainWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
        }
Exemplo n.º 32
0
 public static void NewInstanceHandler(object sender, StartupNextInstanceEventArgs e)
 {
     if (e.CommandLine.Count == 3)
     {
         MainForm.AddFile(e.CommandLine[1], e.CommandLine[2]);
     }
     else if (e.CommandLine.Count == 2)
     {
         if (e.CommandLine[1] == "ForceClosed")
             MainForm.ForceClosedApp();
         else if (e.CommandLine[1] == "MoveFailedUploadAudios")
             MainForm.MoveFailedUploadAudios();
         else
             MainForm.AddFile(e.CommandLine[1]);
     }
     e.BringToForeground = false;
 }
 /// <summary>
 /// Event handler to override the default application next instance startup
 /// </summary>
 /// <param name="eventArgs">Arguments supplied with the event</param>
 protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
 {
     // On subsequent launches activate already running instances of the application
     base.OnStartupNextInstance(eventArgs);
     if (this.app != null && this.app.MainWindow != null)
     {
         try
         {
             this.app.MainWindow.Topmost = true;
             this.app.MainWindow.Activate();
             this.app.MainWindow.Topmost = false;
         }
         catch (ArgumentException)
         {
             // Ignore error that comes when setting window topmost
         }
     }
 }
Exemplo n.º 34
0
        protected override async void OnStartupNextInstance(MsVB.StartupNextInstanceEventArgs eventArgs)
        {
            base.OnStartupNextInstance(eventArgs);

            var parsed = new ParsedArguments(eventArgs.CommandLine);

            if (parsed.Extract)
            {
                this.Extract(parsed.ExtractFile, parsed.ExtractDestination);
            }
            else
            {
                if (this.MainForm == null)
                {
                    this.MainForm = new BSABrowser(parsed.Files.ToArray());
                }
                else
                {
                    this.MainForm.Activate();
                    await(this.MainForm as BSABrowser).OpenArchives(true, parsed.Files);
                }
            }
        }
Exemplo n.º 35
0
        protected override void OnStartupNextInstance(Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs eventArgs)
        {
            base.OnStartupNextInstance(eventArgs);

            _app.MainWindow.Activate();
        }
Exemplo n.º 36
0
 protected override void OnStartupNextInstance(Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs eventArgs)
 {
 }
Exemplo n.º 37
0
 protected override void OnStartupNextInstance(VB.StartupNextInstanceEventArgs eventArgs)
 {
     eventArgs.BringToForeground = true;
     app.MainWindow.Activate();
 }