Esempio n. 1
0
 public override int GetHashCode()
 {
     return(RecoveryDate.GetHashCode()
            ^ HowDetected.GetHashCode()
            ^ Impacts?.GetHashCode() ?? 0
            ^ OcurrenceDate.GetHashCode()
            ^ RecoverySteps?.GetHashCode() ?? 0
            ^ RootCauses?.GetHashCode() ?? 0
            ^ Symptoms?.GetHashCode() ?? 0
            ^ MonitorName?.GetHashCode() ?? 0);
 }
Esempio n. 2
0
        static void processStartEvent_EventArrived(object sender, EventArrivedEventArgs e)
        {
            try
            {
                string processName = e.NewEvent.Properties["ProcessName"].Value.ToString();

                if (processName.ToLower() == ProgramName.ToLower())
                {
                    using (EventLog eventLog = new EventLog("Application"))
                    {
                        eventLog.Source = "Application";
                        eventLog.WriteEntry($"{ProgramName} started. Repositioning.", EventLogEntryType.Information, 101, 1);
                    }

                    int processID = Convert.ToInt32(e.NewEvent.Properties["ProcessID"].Value);

                    Process process = Process.GetProcessById(processID);

                    IntPtr ptr     = process.MainWindowHandle;
                    Rect   posRect = new Rect();
                    GetWindowRect(ptr, ref posRect);

                    Screen destinationMonitor;
                    if (!string.IsNullOrEmpty(MonitorName))
                    {
                        destinationMonitor = Screen.AllScreens.Where(f => f.DeviceName.ToLower() == MonitorName.ToLower()).First();
                    }
                    else
                    {
                        destinationMonitor = Screen.AllScreens[MonitorNumber - 1];
                    }

                    if (FullScreen)
                    {
                        MoveWindow(ptr, destinationMonitor.WorkingArea.X, destinationMonitor.WorkingArea.Y, destinationMonitor.WorkingArea.Width, destinationMonitor.WorkingArea.Height, true);
                    }
                    else
                    {
                        MoveWindow(ptr, destinationMonitor.WorkingArea.X, destinationMonitor.WorkingArea.Y, destinationMonitor.WorkingArea.Width, destinationMonitor.WorkingArea.Height, true);
                        MoveWindow(ptr, destinationMonitor.WorkingArea.X, destinationMonitor.WorkingArea.Y, Width, Height, true);
                    }


                    using (EventLog eventLog = new EventLog("Application"))
                    {
                        eventLog.Source = "Application";
                        eventLog.WriteEntry($"Finished repositioning {ProgramName} to monitor {MonitorNumber}.", EventLogEntryType.Information, 101, 1);
                    }
                }
            }
            catch (Exception ex)
            {
                using (EventLog eventLog = new EventLog("Application"))
                {
                    eventLog.Source = "Application";
                    eventLog.WriteEntry(ex.Message, EventLogEntryType.Error, 101, 1);
                }

                throw;
            }
            finally
            {
                e.NewEvent.Dispose();
            }
        }