Ejemplo n.º 1
0
        private ProgramForm(bool startup, String processName)
        {
            _startup     = startup;
            _processName = processName;

            _wmShowMe = ProgramForm.RegisterShowMe(_processName);

            String condition = @"TargetInstance ISA 'Win32_Process' 
                             AND TargetInstance.Name = '{processName}'".Inject(new { processName = _processName });

            _watcher = new ManagementEventWatcher(new WqlEventQuery("__InstanceCreationEvent", new TimeSpan(10), condition));
            _watcher.Options.Timeout = new TimeSpan(0, 1, 0);
            _watcher.EventArrived   += Watcher_EventArrived;
            _watcher.Start();

            _notifyIcon                  = new NotifyIcon();
            _notifyIcon.Icon             = this.Icon;
            _notifyIcon.Text             = "Tabbed Anything";
            _notifyIcon.Visible          = true;
            _notifyIcon.DoubleClick     += NotifyIcon_DoubleClick;
            _notifyIcon.ContextMenuStrip = new ContextMenuStrip();

            ToolStripItem openItem = _notifyIcon.ContextMenuStrip.Items.Add("Open");

            openItem.Click += OpenNotifyIconMenuItem_Click;
            ToolStripItem exitItem = _notifyIcon.ContextMenuStrip.Items.Add("Exit");

            exitItem.Click += ExitNotifyIconMenuItem_Click;

            this.FormClosing += ProgramForm_FormClosing;

            this.CreateHandle();
        }
Ejemplo n.º 2
0
 public static ProgramForm Create(bool startup, String processName)
 {
     if (Instance == null)
     {
         Instance = new ProgramForm(startup, processName);
     }
     return(Instance);
 }
Ejemplo n.º 3
0
        static void Main(String[] args)
        {
            LOG.DebugFormat("Application Startup - Args: {0}", String.Join(", ", args));
            LOG.DebugFormat("Version: {0}", Assembly.GetExecutingAssembly().GetName().Version);

            Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            if (!TabbedAnythingUtil.VerifyAssemblyVersions())
            {
                return;
            }

            Arguments a = new Arguments();

            if (CommandLine.Parser.Default.ParseArguments(args, a))
            {
                Mutex mutex = new Mutex(true, "{3a39a5c1-fac2-4059-81d4-5018abfa5142}+" + a.ProcessName);

                if (mutex.WaitOne(TimeSpan.Zero, true))
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    LOG.Debug("Starting Tabbed Anything");
                    Application.Run(ProgramForm.Create(a.Startup, a.ProcessName));
                    mutex.ReleaseMutex();
                }
                else
                {
                    LOG.Debug("Tabbed Anything instance already exists");
                    ProgramForm.ShowMe(a.ProcessName);
                }
            }

            LOG.Debug("Application End");
        }
Ejemplo n.º 4
0
        public static void ShowMe(String processName)
        {
            int wmShowMe = ProgramForm.RegisterShowMe(processName);

            Native.PostMessage((IntPtr)Native.HWND_BROADCAST, wmShowMe, IntPtr.Zero, IntPtr.Zero);
        }