internal void Initialize(MainForm mainForm, CommandLineArgs commandLine)
        {
            if (!this.firstInstance)
                return;

            this.StartServer(mainForm, commandLine);
            // startupLock obtained in constructor, the server is now available to notifications
            this.startupLock.ReleaseMutex();
        }
Пример #2
0
 public void ForwardCommand(CommandLineArgs args)
 {
     this.mainForm.HandleCommandLineActions(args);
     this.mainForm.BringToFront();
     this.mainForm.Focus();
 }
Пример #3
0
 private static void StartMainForm(CommandLineArgs commandLine)
 {
     IPersistence persistence = Persistence.Instance;
     PersistenceErrorForm.RegisterDataEventHandler(persistence.Dispatcher);
     if (persistence.Security.Authenticate(RequestPassword.KnowsUserPassword))
         RunMainForm(commandLine);
 }
Пример #4
0
 private static void RunMainForm(CommandLineArgs commandLine)
 {
     var mainForm = new MainForm(Persistence.Instance);
     SingleInstanceApplication.Instance.Initialize(mainForm, commandLine);
     mainForm.HandleCommandLineActions(commandLine);
     Application.Run(mainForm);
 }
Пример #5
0
 private static CommandLineArgs ParseCommandline()
 {
     var commandline = new CommandLineArgs();
     String[] cmdLineArgs = Environment.GetCommandLineArgs();
     Parser.ParseArguments(cmdLineArgs, commandline);
     Settings.Instance.FileLocations.AssignCustomFileLocations(commandline.configFile,
         commandline.favoritesFile, commandline.credentialsFile);
     return commandline;
 }
Пример #6
0
 private void ConnectToFavorites(CommandLineArgs commandLineArgs, bool connectToConsole)
 {
     if (commandLineArgs.Favorites.Length > 0)
     {
         this.connectionsUiFactory.ConnectByFavoriteNames(commandLineArgs.Favorites, connectToConsole);
     }
 }
Пример #7
0
        internal void HandleCommandLineActions(CommandLineArgs commandLineArgs)
        {
            Boolean connectToConsole = commandLineArgs.console;
            this.FullScreen = commandLineArgs.fullscreen;
            if (commandLineArgs.HasUrlDefined)
                QuickConnect(commandLineArgs.UrlServer, commandLineArgs.UrlPort, connectToConsole);

            if (commandLineArgs.HasMachineDefined)
                QuickConnect(commandLineArgs.MachineName, commandLineArgs.Port, connectToConsole);

            this.ConnectToFavorites(commandLineArgs, connectToConsole);
        }
        /// <summary>
        /// If other instance is runing, then forwards the command line to it and returns true;
        /// otherwise returns false.
        /// </summary>
        internal bool NotifyExisting(CommandLineArgs args)
        {
            if (this.firstInstance)
               return false;

            return ForwardCommand(args);
        }
        private void StartServer(MainForm mainForm, CommandLineArgs commandLine)
        {
            if (!commandLine.SingleInstance)
                return;

            this.server = new CommandLineServer(mainForm);
            this.server.Open();
        }
 private bool ForwardCommand(CommandLineArgs args)
 {
     try
     {
         // wait until the main instance startup/shutdown ends
         this.startupLock.WaitOne();
         ICommandLineService client = CommandLineServer.CreateClient();
         client.ForwardCommand(args);
         return true;
     }
     catch
     {
         return false;
     }
     finally
     {
         this.startupLock.ReleaseMutex();
     }
 }
Пример #11
0
 /// <summary>
 ///     Check for available application updates
 /// </summary>
 public static void CheckForUpdates(CommandLineArgs commandLine)
 {
     ThreadPool.QueueUserWorkItem(PerformCheck, commandLine);
 }