Ejemplo n.º 1
0
        static void Main(string [] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Form applicationMainWindow = new frmMainWindow();

            ApplicationSettings.ApplicationMainForm = applicationMainWindow;

            if (Debugger.IsAttached)
            {
                LogWriter = new DebugLogger();
                LogWriter.Log("DebugLogger wurde aktiviert!");
            }
            else
            {
                LogWriter = new LoggerMock();
            }

            SingleInstanceHelper.RegisterRemotingService();

            if (ApplicationSettings.RuninSingleInstanceMode)
            {
                bool  onlyInstance = false;
                Mutex mutex        = new Mutex(true, "PuttyServerManager", out onlyInstance);

                LogWriter.Log("Running in single instance mode - is first instance: {0}", onlyInstance);
                if (!onlyInstance)
                {
                    SingleInstanceHelper.LaunchInExistingInstance(args);
                    Environment.Exit(0);
                }
            }



            Application.Run(applicationMainWindow);
        }
Ejemplo n.º 2
0
        public static void Initialize(string[] args)
        {
            Log.InfoFormat(
                "Initializing.  Version={0}, UserSettings={1}, SettingsFolder={2}",
                Version, Settings.SettingsFilePath, Settings.SettingsFolder);

            if (!SuperPuTTY.IsFirstRun)
            {
                // parse command line args
                CommandLine = new CommandLineOptions(args);

                // display help if --help specified
                if (CommandLine.Help)
                {
                    if (DialogResult.Cancel == MessageBox.Show(CommandLineOptions.Usage(), "SuperPutty CLI Help", MessageBoxButtons.OKCancel))
                    {
                        Environment.Exit(0);
                    }
                }

                // load data
                LoadLayouts();
                LoadSessions();
                Images = LoadImageList("default");

                // determine starting layout, if any.  CLI has priority
                if (CommandLine.IsValid)
                {
                    if (CommandLine.Layout != null)
                    {
                        StartingLayout = FindLayout(CommandLine.Layout);
                        if (StartingLayout != null)
                        {
                            Log.InfoFormat("Starting with layout from command line, {0}", CommandLine.Layout);
                        }
                    }
                    else
                    {
                        // ad-hoc session specified
                        SessionDataStartInfo sessionStartInfo = CommandLine.ToSessionStartInfo();
                        if (sessionStartInfo != null)
                        {
                            StartingSession = sessionStartInfo;
                            Log.InfoFormat("Starting adhoc Session from command line, {0}", StartingSession.Session.SessionId);
                        }
                    }
                }

                // if nothing specified, then try the default layout
                if (StartingLayout == null && StartingSession == null)
                {
                    StartingLayout = FindLayout(Settings.DefaultLayoutName);
                    if (StartingLayout != null)
                    {
                        Log.InfoFormat("Starting with default layout, {0}", Settings.DefaultLayoutName);
                    }
                }
            }

            // Register IpcChanncel for single instance support
            SingleInstanceHelper.RegisterRemotingService();

            Log.Info("Initialized");
        }