/// <summary>
        /// *Creates* the icon and gives it some data
        /// </summary>
        /// <param name="systemTrayIconData"></param>
        public void BuildIcon(string iconPath, IntPtr mainWindowHandle)
        {
            _iconPath         = iconPath;
            _mainWindowHandle = mainWindowHandle;

            var trayIconData = _iconDataFactory();

            // Call C++ dll and create the icon.
            _iconPointer = CoreDLL.CreateSystemTrayIcon(mainWindowHandle, iconPath, trayIconData, trayIconData.Length);
        }
示例#2
0
        /// <summary>
        /// Closes a process tree
        /// </summary>
        /// <returns></returns>
        public bool CloseProcessTree()
        {
            // Check to see if the process is already closed
            if (IsRunning == false)
            {
                return(false);
            }

            CoreDLL.CloseProcessTree(ProcessID);

            // Set process PID back to 0
            ProcessID = 0;

            return(true);
        }
示例#3
0
        /// <summary>
        /// Close this process
        /// </summary>
        /// <returns></returns>
        public bool CloseProcess()
        {
            // Check to see if the process is already closed
            if (IsRunning == false)
            {
                return(false);
            }

            // Call WinApi function that closes this process
            CoreDLL.CloseProcess(ProcessID);

            // Set process PID back to 0
            ProcessID = 0;

            return(true);
        }
示例#4
0
        /// <summary>
        /// Hides a process from the user
        /// </summary>
        /// <returns></returns>
        public bool HideProcess()
        {
            bool result = CoreDLL.HideProcess(ProcessID);

            // If ShowWindow function was called succesfuly
            if (result == true)
            {
                ProcessVisibilityState = ProcessVisibilityState.Hidden;

                // Invoke event
                ProcessVisibilityStateChanged?.Invoke(ProcessVisibilityState);
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#5
0
        /// <summary>
        /// Run the current process
        /// </summary>
        /// <returns></returns>
        public bool RunProcess()
        {
            // Check if the process if currently running
            if (IsRunning == true)
            {
                return(false);
            }

            if (RunAsConsole)
            {
                // Call WinApi function to create the process and set the process ID
                bool result = Test(StartInDirectory, ConsoleScript, ProcessClosedEvent, VisibleOnStartup, out ulong pid);

                if (result == false)
                {
                    ProcessID = pid;
                }
                else
                {
                    ProcessID = pid;
                }

                ProcessInitializedEvent?.Invoke();

                return(result);
            }
            else
            {
                // Call WinApi function to create the process and set the process ID
                ulong processID = CoreDLL.RunProcess(ProcessPath, ProcessArgs, ProcessClosedEvent, VisibleOnStartup);
                ProcessID = processID;
            };

            // If process ID returned as 0 it means process creation failed
            if (ProcessID != 0 ? true : false)
            {
                ProcessInitializedEvent?.Invoke();
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// Removes the icon from System Tray. Should be called when app closes
 /// </summary>
 public void RemoveIcon()
 {
     CoreDLL.RemoveSystemTrayIcon(_iconPointer);
 }
 /// <summary>
 /// Shows the icon after it was created
 /// </summary>
 public void ShowIcon()
 {
     CoreDLL.ShowSystemTrayIcon(_iconPointer);
 }