public void NewPageViaScreenshot()
        {
            CheckApplicationLyingInWhichDisplay(this, new EventArgs());

            int applicationLyingDisplayIndex = int.Parse(Regex.Match(CurrentDisplay.DeviceName, @"\d+").ToString()) - 1;


            if (applicationLyingDisplayIndex == DisplayIndex)
            {
                WindowState       = System.Windows.WindowState.Minimized;
                CurrentScreenshot = BitmapHelper.SaveBitmapReturnPath(BitmapHelper.TakeScreenShot(DisplayIndex), SelectedPage);
                WindowState       = System.Windows.WindowState.Normal;
            }
            else
            {
                CurrentScreenshot = BitmapHelper.SaveBitmapReturnPath(BitmapHelper.TakeScreenShot(DisplayIndex), SelectedPage);
            }



            var newPage = new Page()
            {
                NoteId              = SelectedNote.Id,
                Name                = "Page",
                DateTime            = DateTime.Now.ToShortDateString(),
                ScreenshotByteArray = CurrentScreenshot,
                Version             = 0
            };

            newPage.ScreenshotByteArray = CurrentScreenshot;
            DatabaseHelper.Insert(newPage);
            ReadPages();
            NewPageViaScreenshotIsTaken(this, new EventArgs());
        }
        public void TakeScreenShot()
        {
            CheckApplicationLyingInWhichDisplay(this, new EventArgs());

            int applicationLyingDisplayIndex = int.Parse(Regex.Match(CurrentDisplay.DeviceName, @"\d+").ToString()) - 1;


            if (applicationLyingDisplayIndex == DisplayIndex)
            {
                WindowState       = System.Windows.WindowState.Minimized;
                CurrentScreenshot = BitmapHelper.SaveBitmapReturnPath(BitmapHelper.TakeScreenShot(DisplayIndex), SelectedPage);
                WindowState       = System.Windows.WindowState.Normal;
            }
            else
            {
                CurrentScreenshot = BitmapHelper.SaveBitmapReturnPath(BitmapHelper.TakeScreenShot(DisplayIndex), SelectedPage);
            }

            SelectedPage.ScreenshotByteArray        = CurrentScreenshot;
            SelectedPage.CroppedScreenshotByteArray = null;
            SelectedPage.Version++;
            DatabaseHelper.Update(SelectedPage);
            ReadPages();
            ScreenshotIsTaken(this, new EventArgs());
        }
Ejemplo n.º 3
0
 private void Load()
 {
     _windowTop    = Properties.Settings.Default.WindowTop;
     _windowLeft   = Properties.Settings.Default.WindowLeft;
     _windowHeight = Properties.Settings.Default.WindowHeight;
     _windowWidth  = Properties.Settings.Default.WindowWidth;
     _windowState  = Properties.Settings.Default.WindowState;
 }
Ejemplo n.º 4
0
 private void Load()
 {
     windowTop    = Properties.Settings.Default.WindowTop;
     windowLeft   = Properties.Settings.Default.WindowLeft;
     windowHeight = Properties.Settings.Default.WindowHeight;
     windowWidth  = Properties.Settings.Default.WindowWidth;
     windowState  = Properties.Settings.Default.WindowState;
     fileName     = Properties.Settings.Default.FileName;
 }
 private void Load()
 {
     this.WindowTop         = Properties.Settings.Default.WindowTop;
     this.WindowLeft        = Properties.Settings.Default.WindowLeft;
     this.WindowHeight      = Properties.Settings.Default.WindowHeight;
     this.WindowWidth       = Properties.Settings.Default.WindowWidth;
     this.WindowRightColumn = Properties.Settings.Default.RightColumnWidth;
     this.WindowLeftColumn  = Properties.Settings.Default.LeftColumnWidth;
     this.windowState       = Properties.Settings.Default.WindowState;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// IValueConverter.ConvertBack
 /// </summary>
 /// <param name="value"></param>
 /// <param name="targetType"></param>
 /// <param name="parameter"></param>
 /// <param name="culture"></param>
 /// <returns></returns>
 public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     System.Windows.WindowState val = (System.Windows.WindowState)value;
     if (val == System.Windows.WindowState.Maximized)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 7
0
            public void Update(double top, double left, double width, double height, System.Windows.WindowState state)
            {
                if (state != System.Windows.WindowState.Minimized)
                {
                    State = state;
                }
                if (state != System.Windows.WindowState.Normal)
                {
                    return;
                }

                Top    = top;
                Left   = left;
                Width  = width;
                Height = height;
            }
Ejemplo n.º 8
0
        public void LoadSettings_IsCalled_ShouldLoadMainWindowWindowState(System.Windows.WindowState expectedMainMainWindowWindowState)
        {
            // Arrange
            var appSettings = new Mock <IAppSettings>();

            appSettings.SetupAllProperties();
            appSettings.Setup(x => x.MainWindowWindowState).Returns(() => expectedMainMainWindowWindowState);

            var viewModel = GetViewModel(null, appSettings.Object);

            // Act
            viewModel.LoadSettings();

            // Assert
            Assert.Equal(expectedMainMainWindowWindowState, viewModel.MainWindowWindowState);
        }
Ejemplo n.º 9
0
 private void Load()
 {
     _windowTop       = Properties.Settings.Default.WindowTop;
     _windowLeft      = Properties.Settings.Default.WindowLeft;
     _windowHeight    = Properties.Settings.Default.WindowHeight;
     _windowWidth     = Properties.Settings.Default.WindowWidth;
     _windowState     = Properties.Settings.Default.WindowState;
     _workingFolder   = Properties.Settings.Default.WorkingFolder;
     _fontSize        = Properties.Settings.Default.FontSize;
     _fontFamily      = Properties.Settings.Default.FontFamily;
     _favoriteFolders = Properties.Settings.Default.FavoriteFolders;
     if (_favoriteFolders == null)
     {
         _favoriteFolders = new StringCollection();
     }
     _showStatusbar = Properties.Settings.Default.ShowStatusbar;
 }
Ejemplo n.º 10
0
        private void MaximizeWindow()
        {
            Size_was     = new Size((int)this.Width, (int)this.Height);
            Location_was = new Point((int)Left, (int)Top);
            state_old    = this.WindowState;

            this.WindowStyle                     = System.Windows.WindowStyle.None;
            this.WindowState                     = System.Windows.WindowState.Normal;
            this.WindowState                     = System.Windows.WindowState.Maximized;
            this.Top                             = 0;
            this.Left                            = 0;
            this.Width                           = Screen.PrimaryScreen.Bounds.Width;
            this.Height                          = Screen.PrimaryScreen.Bounds.Height;
            toolBar.Visibility                   = System.Windows.Visibility.Collapsed;
            scrollViewver_left.Visibility        = System.Windows.Visibility.Collapsed;
            gridSplitter_left.Visibility         = System.Windows.Visibility.Collapsed;
            column_width_old                     = grid_main.ColumnDefinitions[0].Width;
            grid_main.ColumnDefinitions[0].Width = new System.Windows.GridLength(0, System.Windows.GridUnitType.Auto);

            FullScrin = true;
            //ВРЕМЕННО УБРАЛ

            /*Adapt_Size_ofCont((IC_Control as System.Windows.Forms.Control), IC_Control.ImageWidth, IC_Control.ImageHeight, 0.8, 1);
             * FormatAdaptation(IMG_W_now, IMG_H_now);*/

            /*Size_was = this.Size;
             * Location_was = new Point(this.Location.X,this.Location.Y);
             *
             * this.FormBorderStyle = FormBorderStyle.None;
             * this.Location = new Point(0, 0);
             * this.Height = Screen.PrimaryScreen.Bounds.Height;
             * this.Width = Screen.PrimaryScreen.Bounds.Width;
             *
             * for (int i = 0; i < TLP_BasicPanel.ColumnStyles.Count; i++)
             *  Widths_Cols.Add(TLP_BasicPanel.ColumnStyles[i].Width);
             * for (int i = 0; i < TLP_BasicPanel.RowStyles.Count; i++)
             *  Heights_Rows.Add(TLP_BasicPanel.RowStyles[i].Height);
             * TLP_BasicPanel.ColumnStyles[0].Width = 0;
             * TLP_BasicPanel.ColumnStyles[1].Width = 100;
             * FullScrin = true;
             *
             *
             * Adapt_Size_ofCont((IC_Control as Control), IMG_W_now, IMG_H_now, 1, 1);
             * FormatAdaptation(IMG_W_now, IMG_H_now);*/
        }
Ejemplo n.º 11
0
 //System.Diagnostics.Stopwatch anotherTimer;
 public MainWindowViewModel()
 {
     timerObj = new MyTimerClass(
         (param) =>
     {
         Time = param.ToString();
     },
         () =>
     {
         WindowState = System.Windows.WindowState.Normal;     //таймер завершил работу
         Topmost     = true;
         IsEnable    = true;
         Stop        = true;
         //цвет?
     });
     IsEnable = true;
     Stop     = false;
 }
Ejemplo n.º 12
0
        public void SaveSettings_IsCalled_ShouldSaveMainWindowWindowState(System.Windows.WindowState expectedMainMainWindowWindowState)
        {
            // Arrange
            var appSettings = new Mock <IAppSettings>();

            appSettings.SetupAllProperties();

            var viewModel = GetViewModel(null, appSettings.Object);

            viewModel.MainWindowWindowState = expectedMainMainWindowWindowState;

            // Act
            viewModel.SaveSettings();

            // Assert
            Assert.Equal(expectedMainMainWindowWindowState, appSettings.Object.MainWindowWindowState);
            appSettings.Verify(x => x.Save(), Times.Once);
        }
Ejemplo n.º 13
0
        public void Start()
        {
            _KeepWorking = true;
            _KeepReading = true;

            FFWindowState = System.Windows.WindowState.Minimized;

            Task.Factory.StartNew(async() =>
            {
                try
                {
                    await EntryPoint();
                }
                catch (Exception e)
                {
                    Logger.WriteLog(e);
                }
            }, TaskCreationOptions.LongRunning);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 程序已经被启动显示当前主窗口
        /// </summary>
        /// <param name="eventArgs"></param>
        protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
        {
            // Subsequent launches
            base.OnStartupNextInstance(eventArgs);

            if (WPFApplication != null)
            {
                System.Windows.WindowState windowState = WPFApplication.MainWindow.WindowState;
                WPFApplication.MainWindow.WindowState = System.Windows.WindowState.Minimized;
                WPFApplication.MainWindow.Show();
                WPFApplication.MainWindow.Activate();
                WPFApplication.MainWindow.Focus();
                WPFApplication.MainWindow.WindowState = windowState;
            }
            else if (this.ApplicationContext.MainForm != null)
            {
                System.Windows.Forms.FormWindowState formWindowState = this.ApplicationContext.MainForm.WindowState;
                this.ApplicationContext.MainForm.WindowState = System.Windows.Forms.FormWindowState.Minimized;
                this.ApplicationContext.MainForm.Show();
                this.ApplicationContext.MainForm.Activate();
                this.ApplicationContext.MainForm.Focus();
                this.ApplicationContext.MainForm.WindowState = formWindowState;
            }
        }
        public MainVM()
        {
            if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject()))
            {
                Notes = new ObservableCollection <Note>();
                Notes.Add(new Note()
                {
                    Name = "note1", DateTime = DateTime.Now.ToShortDateString()
                });
                Notes.Add(new Note()
                {
                    Name = "note2", DateTime = DateTime.Now.ToShortDateString()
                });
                Notes.Add(new Note()
                {
                    Name = "note3", DateTime = DateTime.Now.ToShortDateString()
                });

                Pages = new ObservableCollection <Page>();
                Pages.Add(new Page()
                {
                    Name = "Screenshot", DateTime = DateTime.Now.ToShortDateString()
                });
                Pages.Add(new Page()
                {
                    Name = "Screenshot", DateTime = DateTime.Now.ToShortDateString()
                });
                Pages.Add(new Page()
                {
                    Name = "Screenshot", DateTime = DateTime.Now.ToShortDateString()
                });
                IsEditingNoteName = false;
                IsEditingVocab    = false;

                Vocabs = new ObservableCollection <Vocab>();
                Vocabs.Add(new Vocab()
                {
                    PageId = 1, Word = "123", Explaination = "321", Pronounciation = "aaa"
                });
                Vocabs.Add(new Vocab()
                {
                    PageId = 1, Word = "456", Explaination = "654", Pronounciation = "bbb"
                });
                Vocabs.Add(new Vocab()
                {
                    PageId = 1, Word = "789", Explaination = "987", Pronounciation = "ccc"
                });
            }
            else
            {
                WindowState                      = System.Windows.WindowState.Normal;
                NewNoteCommand                   = new NewNoteCommand(this);
                DeleteNoteCommand                = new DeleteNoteCommand(this);
                NewPageCommand                   = new NewPageCommand(this);
                DeletePageCommand                = new DeletePageCommand(this);
                RenameNoteCommand                = new RenameNoteCommand(this);
                ScreenCapCommand                 = new ScreenCapCommand(this);
                HasEditedNoteNameCommand         = new HasEditedNoteNameCommand(this);
                UsePreviousSelectionCommand      = new UsePreviousSelectionCommand(this);
                DoNotUsePreviousSelectionCommand = new DoNotUsePreviousSelectionCommand(this);
                CheckDictionaryCommand           = new CheckDictionaryCommand(this);
                GoogleTranslateCommand           = new GoogleTranslateCommand(this);
                DeleteVocabCommand               = new DeleteVocabCommand(this);
                NewVocabCommand                  = new NewVocabCommand(this);
                StartUpdateVocabCommand          = new StartUpdateVocabCommand(this);
                EndUpdateVocabCommand            = new EndUpdateVocabCommand(this);
                CropOriginalScreenshotCommand    = new CropOriginalScreenshotCommand(this);
                NewPageViaScreenshotCommand      = new NewPageViaScreenshotCommand(this);
                CaptureMoreTextCommand           = new CaptureMoreTextCommand(this);
                StartRenamePageCommand           = new StartRenamePageCommand(this);
                EndRenamePageCommand             = new EndRenamePageCommand(this);
                ToggleUpdateVocabCommand         = new ToggleUpdateVocabCommand(this);
                CheckDictionaryLittleDCommand    = new CheckDictionaryLittleDCommand(this);
                SyncVocabsCommand                = new SyncVocabsCommand(this);

                Notes  = new ObservableCollection <Note>();
                Pages  = new ObservableCollection <Page>();
                Vocabs = new ObservableCollection <Vocab>();
                ReadNotes();
                ReadPages();
                IsEditingNoteName              = false;
                IsEditingVocab                 = false;
                DisplayIndex                   = 0;
                DoUsePreviousSelection         = false;
                browserAddress                 = "";
                DictionaryBaseUrl_JapanDict    = "https://www.japandict.com/";
                DictionaryBaseUrl_littleD      = "http://dict.hjenglish.com/jp/jc/";
                SelectedPageIndex              = 0;
                NoPreviousCropButtonIsSelected = true;
                IsRenamingPage                 = false;
            }
        }
Ejemplo n.º 16
0
 private void Load()
 {
     _windowTop = Properties.Settings.Default.WindowTop;
     _windowLeft = Properties.Settings.Default.WindowLeft;
     _windowHeight = Properties.Settings.Default.WindowHeight;
     _windowWidth = Properties.Settings.Default.WindowWidth;
     _windowState = Properties.Settings.Default.WindowState;
     _workingFolder = Properties.Settings.Default.WorkingFolder;
     _fontSize = Properties.Settings.Default.FontSize;
     _fontFamily = Properties.Settings.Default.FontFamily;
     _favoriteFolders = Properties.Settings.Default.FavoriteFolders;
     if(_favoriteFolders == null)
         _favoriteFolders = new StringCollection();
     _showStatusbar = Properties.Settings.Default.ShowStatusbar;
 }
Ejemplo n.º 17
0
        private void CommandExe(string key, string value)
        {
            string report = "";

            if (StrCompare(key, "exit"))
            {
                mainWindow.Dispatcher.Invoke(() => { App.Current.Shutdown(); });
            }
            else if (StrCompare(key, "send"))
            {
                if (value == null)
                {
                    mainWindow.Dispatcher.Invoke(() =>
                    {
                        mainWindow.Text_Send_Click(null, null);
                    });
                }
                else
                {
                    if (value.ElementAt(0) == '"' && value.ElementAt(value.Length - 1) == '"')
                    {
                        ;
                    }
                    int newlineMark = value.IndexOf("\\n");

                    value = value.Replace("\\n", "\n");
                    value = value.Replace("\\r", "\r");
                    mainWindow.Dispatcher.Invoke(() =>
                    {
                        SelectedConnectionTab.SendData(value, DateTime.Now);
                    });
                }
            }
            else if (StrCompare(key, "clear"))
            {
                if (value == null)
                {
                    mainWindow.Dispatcher.Invoke(() =>
                    {
                        mainWindow.Button_ReceiveWindow_Clear_Click(null, null);
                    });
                }
            }
            else if (StrCompare(key, "freeze"))
            {
                if (value == null)
                {
                    mainWindow.Dispatcher.Invoke(() =>
                    {
                    });
                }
            }


            else if (StrCompare(key, "serial"))
            {
                if (SelectedConnectionTab == null)
                {
                    Debug.WriteLine("choose serial");

                    ConnectionTabData connection = null;
                    mainWindow.Dispatcher.Invoke(() =>
                    {
                        Debug.WriteLine("NewTab");
                        connection = ConnectionTabHelper.NewTab();
                        connection.TabItem.Title           = "ArduBlockly";
                        connection.ToolBarSetting.SendText = "測試";
                        SelectedConnectionTab = connection;
                        SelectedConnectionTab.ConnectionTypeChoose(0);
                    });
                }
                ((Connection.Serial.Settings)SelectedConnectionTab.ToolBarSetting.ConnectionSettings).ComPort = int.Parse(value);
                Debug.WriteLine("set comport");
            }

            else if (StrCompare(key, "disconnect"))
            {
                mainWindow.Dispatcher.Invoke(() => { SelectedConnectionTab.Disconnect(); });
            }
            else if (StrCompare(key, "connect"))
            {
                Debug.WriteLine("Connect");
                mainWindow.Dispatcher.Invoke(() => { SelectedConnectionTab.Connect(); });
            }
            else if (StrCompare(key, "text"))
            {
                if (value != null)
                {
                    value = value.Replace("\\n", "\n");
                    value = value.Replace("\\r", "\r");
                    mainWindow.Dispatcher.Invoke(() => { mainWindow.TextBox_Send_Text.Text = value; });
                }
            }
            else if (StrCompare(key, "auto_spilt"))
            {
                bool result     = false;
                bool successful = bool.TryParse(value, out result);
                if (successful)
                {
                    mainWindow.Dispatcher.Invoke(() => { mainWindow.Toggle_Receive_AutoSpilt.IsChecked = result; });
                }
            }
            else if (StrCompare(key, "show_time"))
            {
                bool result     = false;
                bool successful = bool.TryParse(value, out result);
                if (successful)
                {
                    mainWindow.Dispatcher.Invoke(() => { mainWindow.Toggle_Receive_ShowTime.IsChecked = result; });
                }
            }
            else if (StrCompare(key, "next_line"))
            {
                mainWindow.Dispatcher.Invoke(() => { mainWindow.Button_ReceiveWindow_PrintNewLine_Click(null, null); });
            }
            else if (StrCompare(key, "window"))
            {
                System.Windows.WindowState state = System.Windows.WindowState.Normal;
                if (StrCompare(value, "max"))
                {
                    state = System.Windows.WindowState.Maximized;
                }
                else if (StrCompare(value, "min"))
                {
                    state = System.Windows.WindowState.Minimized;
                }
                else if (StrCompare(value, "normal"))
                {
                    state = System.Windows.WindowState.Normal;
                }
                mainWindow.Dispatcher.Invoke(() =>
                {
                    mainWindow.WindowState = state;
                });
            }
            else if (StrCompare(key, "selectTabByName"))
            {
                ConnectionTabData tabData = ConnectionTabHelper.ConnectionTabDataList.Find((data) => { return(data.TabItem.Title == value); });
                if (tabData != null)
                {
                    SelectedConnectionTab = tabData;
                }
            }
            else if (StrCompare(key, "selectTabByIndex"))
            {
                uint index;
                if (uint.TryParse(value, out index))
                {
                    ConnectionTabData tabData = ConnectionTabHelper.ConnectionTabDataList.ElementAt((int)index);
                    if (tabData != null)
                    {
                        SelectedConnectionTab = tabData;
                    }
                }
            }
            else if (StrCompare(key, "focus"))
            {
                if (SelectedConnectionTab != null)
                {
                    SelectedConnectionTab.Focus();
                }
            }
            else if (StrCompare(key, "connected"))
            {
            }

            else
            {
                if (SelectedConnectionTab != null)
                {
                    SelectedConnectionTab.ToolBarSetting.ConnectionSettings.Parse(key, value, report);
                }
            }
        }
Ejemplo n.º 18
0
 public void PushWindowState(double width, double height, System.Windows.WindowState state)
 {
     botWindow.SetWindowState(width, height, state);
 }
Ejemplo n.º 19
0
        private void LoadV0or1(bool v1)
        {
            using (StreamReader file = File.OpenText(configPath))
            {
                JsonSerializer serializer = new JsonSerializer();
                List <object>  data       = serializer.Deserialize(file, typeof(List <object>)) as List <object>;

                string version = data[0] as string;
                Dictionary <int, List <GUITask> > tasks = (data[1] as JObject).ToObject(typeof(Dictionary <int, List <GUITask> >)) as Dictionary <int, List <GUITask> >;
                List <GUIUser> users = (data[2] as JArray).ToObject(typeof(List <GUIUser>)) as List <GUIUser>;;
                Dictionary <string, string> dataExchangeData = (data[3] as JObject).ToObject(typeof(Dictionary <string, string>)) as Dictionary <string, string>;

                //load images and push tasks
                foreach (KeyValuePair <int, List <GUITask> > canvas in tasks)
                {
                    foreach (GUITask task in canvas.Value)
                    {
                        Bitmap original, converted, dithered;
                        try
                        {
                            original  = LoadBitmap(Path.Combine(folderPath, "original", task.InternalId + ".png"));
                            converted = LoadBitmap(Path.Combine(folderPath, "converted", task.InternalId + ".png"));
                            dithered  = LoadBitmap(Path.Combine(folderPath, "dithered", task.InternalId + ".png"));
                        }
                        catch (FileNotFoundException)
                        {
                            return;
                        }
                        GUITask newTask = new GUITask(task.InternalId, task.Name, task.Enabled, task.X, task.Y, task.Dithering, task.KeepRepairing, original, converted, dithered);
                        dataExchange.PushNewTask(newTask, canvas.Key);
                    }
                }

                //push users
                foreach (GUIUser user in users)
                {
                    dataExchange.PushNewUser(user);
                }

                //parse parameters
                bool          overlayTasks        = bool.Parse(dataExchangeData["overlayTasks"]);
                bool          overlayAllTasks     = bool.Parse(dataExchangeData["overlayAllTasks"]);
                bool          overlaySelectedTask = bool.Parse(dataExchangeData["overlaySelectedTasks"]);
                double        overlayTranslucency = double.Parse(dataExchangeData["overlayTranslucency"], CultureInfo.InvariantCulture);
                int           canvasId            = int.Parse(dataExchangeData["canvasId"]);
                PlacementMode placementMode       = (PlacementMode)Enum.Parse(typeof(PlacementMode), dataExchangeData["placementMode"]);

                double placementSpeed = 11.2;
                if (v1)
                {
                    placementSpeed = double.Parse(dataExchangeData["placementSpeed"], CultureInfo.InvariantCulture);
                }

                double windowWidth  = double.Parse(dataExchangeData["windowWidth"], CultureInfo.InvariantCulture);
                double windowHeight = double.Parse(dataExchangeData["windowHeight"], CultureInfo.InvariantCulture);
                System.Windows.WindowState windowState = (System.Windows.WindowState)Enum.Parse(typeof(System.Windows.WindowState), dataExchangeData["windowState"]);

                dataExchange.PushSettings(overlayTasks, overlayAllTasks, overlaySelectedTask, overlayTranslucency, canvasId, placementMode, placementSpeed);
                dataExchange.PushWindowState(windowWidth, windowHeight, windowState);
            }
        }
Ejemplo n.º 20
0
        private void WatchFFWindowState()
        {
            Task.Factory.StartNew(async() =>
            {
                System.Windows.WindowState FFXIVPrevWindowState = System.Windows.WindowState.Minimized;
                FFWindowState = System.Windows.WindowState.Minimized;

                bool _isRunningPrev = false;
                while (_KeepWorking && _KeepReading)
                {
                    try
                    {
                        bool IsExclusionWindow = false;

                        System.Windows.WindowState FFXIVWindowState = System.Windows.WindowState.Normal;
                        var fgWindow = Win32Interfaces.GetForegroundWindow();

                        if (_FfXivProcess != null)
                        {
                            if (_FfXivProcess.MainWindowHandle != fgWindow)
                            {
                                FFXIVWindowState = System.Windows.WindowState.Minimized;
                            }
                            else
                            {
                                FFXIVWindowState = System.Windows.WindowState.Normal;
                            }
                        }

                        for (int i = 0; i < _ExclusionWindowHandlers.Count; i++)
                        {
                            if (fgWindow == _ExclusionWindowHandlers[i])
                            {
                                IsExclusionWindow = true;
                                break;
                            }
                        }

                        if (!IsExclusionWindow && fgWindow != IntPtr.Zero)
                        {
                            var oldValue = FFXIVPrevWindowState;

                            if (FFXIVWindowState != FFXIVPrevWindowState)
                            {
                                FFXIVPrevWindowState = FFXIVWindowState;

                                var ea = new WindowStateChangeEventArgs(this)
                                {
                                    OldWindowState = oldValue,
                                    NewWindowState = FFXIVPrevWindowState,

                                    IsRunningOld = _isRunningPrev,
                                    IsRunningNew = true,

                                    Text = ""
                                };

                                _FFWindowStateChanged.InvokeAsync(ea).Forget();
                            }

                            FFWindowState = FFXIVPrevWindowState;
                        }

                        Process[] processes = Process.GetProcessesByName(_FfProcessName);
                        if (processes.Length == 0)
                        {
                            System.Windows.WindowState oldState = System.Windows.WindowState.Normal;
                            var ea = new WindowStateChangeEventArgs(this)
                            {
                                OldWindowState = oldState,
                                NewWindowState = FFXIVPrevWindowState,

                                IsRunningOld = _isRunningPrev,
                                IsRunningNew = false,
                                Text         = ""
                            };

                            _FFWindowStateChanged.InvokeAsync(ea).Forget();

                            _KeepReading = false;

                            _isRunningPrev = false;

                            FFWindowState = System.Windows.WindowState.Minimized;

                            MemoryHandler.Instance.UnsetProcess();
                        }
                        else
                        {
                            if (_isRunningPrev == false)
                            {
                                System.Windows.WindowState oldState = System.Windows.WindowState.Minimized;
                                System.Windows.WindowState newState = System.Windows.WindowState.Normal;
                                var ea = new WindowStateChangeEventArgs(this)
                                {
                                    OldWindowState = oldState,
                                    NewWindowState = newState,

                                    IsRunningOld = _isRunningPrev,
                                    IsRunningNew = true,
                                    Text         = processes[0].ProcessName + ".exe" + "  PID: " + processes[0].Id.ToString()
                                };

                                _FFWindowStateChanged.InvokeAsync(ea).Forget();

                                FFWindowState = System.Windows.WindowState.Normal;
                            }

                            _isRunningPrev = true;
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.WriteLog(Convert.ToString(e));
                    }

                    await Task.Delay(GlobalSettings.MemoryReaderDelay);
                }
            }, TaskCreationOptions.LongRunning);
        }
Ejemplo n.º 21
0
 private void Load()
 {
     _windowTop = Properties.Settings.Default.WindowTop;
     _windowLeft = Properties.Settings.Default.WindowLeft;
     _windowHeight = Properties.Settings.Default.WindowHeight;
     _windowWidth = Properties.Settings.Default.WindowWidth;
     _windowState = Properties.Settings.Default.WindowState;
 }