Exemple #1
0
 private void SaveLogButton_Click(object sender, EventArgs e)
 {
     using (var dialog = new SaveFileDialog())
     {
         dialog.Title            = Resources.Save;
         dialog.Filter           = Resources.LogFileFilter;
         dialog.RestoreDirectory = true;
         dialog.FileName         = Observer.Title;
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 File.WriteAllText(dialog.FileName, Observer.Log);
             }
             catch (Exception exception)
             {
                 Console.WriteLine(exception);
                 using (var centerAligner = new DialogCenterAligner(ParentForm))
                 {
                     MessageBox.Show(Resources.FailedSaveFile, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
     }
 }
Exemple #2
0
        private void AddObserversFromFile(string path)
        {
            var observerSettingsList = ObserversFile.Load(path);

            if (observerSettingsList.Count == 0)
            {
                using (var centerAligner = new DialogCenterAligner(this))
                {
                    MessageBox.Show(Resources.FailedOpenFile + "\n" + path, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            if (!RecentFiles.Exists || RecentFiles.CanWrite)
            {
                RecentFiles.Add(path);
            }
            var tabPages = new TabPage[observerSettingsList.Count];

            for (int i = 0; i < observerSettingsList.Count; i++)
            {
                var observer = new Observer(ObservedProcess, observerSettingsList[i]);
                Observers.Add(observer);
                var observerTabPage = new ObserverTabPage(Observers.Count - 1, observer);
                tabPages[i] = observerTabPage;
            }
            ObserverTabControl.TabPages.AddRange(tabPages);
        }
Exemple #3
0
 private void SaveObserversToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var dialog = new SaveFileDialog())
     {
         dialog.Title            = Resources.Save;
         dialog.Filter           = Resources.ObserversFileFilter;
         dialog.RestoreDirectory = true;
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             if (ObserversFile.Save(Observers, dialog.FileName))
             {
                 if (!RecentFiles.Exists || RecentFiles.CanWrite)
                 {
                     RecentFiles.Add(dialog.FileName);
                 }
             }
             else
             {
                 using (var centerAligner = new DialogCenterAligner(this))
                 {
                     MessageBox.Show(Resources.FailedSaveFile, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
     }
 }
Exemple #4
0
 private void ObservedProcess_ProcessExited()
 {
     StopAllButton.PerformClick();
     using (var centerAligner = new DialogCenterAligner(this))
     {
         MessageBox.Show(Resources.ProcessHasExit, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     ProcessLabel.Text = ObservedProcess.ProcessInfo;
     RefreshView();
 }
Exemple #5
0
        private void OpenNoticesButton_Click(object sender, EventArgs e)
        {
            string path = Environment.CurrentDirectory + "/Docs/notices.html";

            if (File.Exists(path))
            {
                Process.Start(path);
            }
            else
            {
                using (var centerAligner = new DialogCenterAligner(this))
                {
                    MessageBox.Show(this, Resources.FailedOpenFile, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #6
0
 private void SelectProcessButton_Click(object sender, EventArgs e)
 {
     using (var dialog = new SelectProcessDialog())
     {
         if (dialog.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         if (!ObservedProcess.Open(dialog.ProcessId))
         {
             using (var centerAligner = new DialogCenterAligner(this))
             {
                 MessageBox.Show(Resources.ProcessOpenError, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         ProcessLabel.Text = ObservedProcess.ProcessInfo;
         RefreshView();
     }
 }
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            var screen = Screen.FromPoint(new Point(Observer.CaptureX, Observer.CaptureY));
            var area   = new Rectangle(Observer.CaptureX, Observer.CaptureY, Observer.CaptureWidth, Observer.CaptureHeight);

            if (screen.Bounds.IntersectsWith(area))
            {
                using (var dialog = new ConfirmAreaDialog(screen, area))
                {
                    ParentForm.Hide();
                    dialog.ShowDialog(ParentForm);
                    ParentForm.Show();
                }
            }
            else
            {
                using (var centerAligner = new DialogCenterAligner(ParentForm))
                {
                    MessageBox.Show(ParentForm, Resources.AreaOutOfRange, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }