Beispiel #1
0
        static void Main(string[] args)
        {
            // send log to console
            log4net.Config.BasicConfigurator.Configure();

            mutex = new Mutex(true, "SuperPutty", out var onlyInstance);

            Log.InfoFormat(
                "IsFirstRun={0}, SingleInstanceMode={1}, onlyInstance={2}",
                SuperPuTTY.IsFirstRun, SuperPuTTY.Settings.SingleInstanceMode, onlyInstance);
            if ((EnforceSingleInstance || SuperPuTTY.Settings.SingleInstanceMode) && !SuperPuTTY.IsFirstRun && !onlyInstance)
            {
                SingleInstanceHelper.LaunchInExistingInstance(args);
                Log.InfoFormat("Sent Command to Existing Instance: [{0}]", String.Join(" ", args));
                Environment.Exit(0);
            }

            // open full file
            log4net.Config.XmlConfigurator.Configure();

#if DEBUG
            Logger.OnLog += delegate(string logMessage)
            {
                //Console.WriteLine(logMessage);
                Log.Info(logMessage);
            };
#endif

            try
            {
                Log.Info("Starting");
                SuperPuTTY.Initialize(args);

                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                Application.ThreadException += Application_ThreadException;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                SuperPuttyForm mainForm = new SuperPuttyForm();
                SetDefaultIcon(mainForm);
                Application.Run(SuperPuTTY.MainForm = mainForm);
                SuperPuTTY.Shutdown();
            }
            catch (Exception ex)
            {
                Log.Error("Error in Main", ex);
            }
            finally
            {
                Log.Info("Shutdown");
            }
        }
Beispiel #2
0
        public ChildWindowFocusHelper(SuperPuttyForm form)
        {
            MainForm            = form;
            MainForm.ResizeEnd += HandleResizeEnd;

            foreach (IDockContent doc in MainForm.DockPanel.Contents)
            {
                if (doc is CtlPuttyPanel pp)
                {
                    childWindows.Add(pp.AppPanel.AppWindowHandle, pp);
                }
            }
            MainForm.DockPanel.ContentAdded   += DockPanel_ContentAdded;
            MainForm.DockPanel.ContentRemoved += DockPanel_ContentRemoved;
        }