/// <summary>
        /// set window to 2 locations
        /// </summary>
        public void SetLocations(int numMonitor)
        {
            try
            {
                switch (numMonitor)
                {
                case 2:
                    MoveWindow(VrManagerName, 0);
                    MoveWindow(PlayerWinName, 1);
                    App.LockDisplayWindow.ChangeDisplay(1);
                    App.CurentVideoMonitor = 1;
                    break;

                case 1:

                    MoveWindow(VrManagerName, 1);
                    MoveWindow(PlayerWinName, 0);
                    App.LockDisplayWindow.ChangeDisplay(0);
                    App.CurentVideoMonitor = 0;
                    break;
                }
                System.Windows.Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() => { })).Wait();
            }
            catch (Exception ex)
            {
                App.SendException(ex);
            }
        }
Beispiel #2
0
        private static void SetVisibility(bool show)
        {
            try
            {
                IntPtr taskBarWnd = FindWindow("Shell_TrayWnd", null);

                IntPtr startWnd = FindWindowEx(taskBarWnd, IntPtr.Zero, "Button", "Start");

                if (startWnd == IntPtr.Zero)
                {
                    startWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, (IntPtr)0xC017, "Start");
                }

                if (startWnd == IntPtr.Zero)
                {
                    startWnd = FindWindow("Button", null);

                    if (startWnd == IntPtr.Zero)
                    {
                        startWnd = GetVistaStartMenuWnd(taskBarWnd);
                    }
                }

                ShowWindow(taskBarWnd, show ? SW_SHOW : SW_HIDE);
                ShowWindow(startWnd, show ? SW_SHOW : SW_HIDE);
            }
            catch (Exception ex)
            {
                App.SendException(ex);
            }
        }
 public MonitorManager()
 {
     try {
         ConnectedMonitors = new List <Monitor>();
         foreach (Screen screen in Screen.AllScreens)
         {
             Monitor monitor = new Monitor
             {
                 NameScreen = screen.DeviceName,
                 Coord      = new Coordinates
                 {
                     X = screen.WorkingArea.X,
                     Y = screen.WorkingArea.Y
                 },
                 Size = new Coordinates
                 {
                     X = screen.Bounds.Size.Width,
                     Y = screen.Bounds.Size.Height
                 }
             };
             ConnectedMonitors.Add(monitor);
         }
     }
     catch (Exception ex)
     {
         App.SendException(ex);
     }
 }
 public static void CenteredCursorInRight()
 {
     try
     {
         System.Windows.Forms.Cursor.Position = new System.Drawing.Point(
             getMonitorCordX(App.Setting.NumberRightMonitor) + (int)(getMonitorCord(App.Setting.NumberRightMonitor).Size.X / 2)
             , getMonitorCordY(App.Setting.NumberRightMonitor) + (int)(getMonitorCord(App.Setting.NumberRightMonitor).Size.Y / 2));
     }
     catch (Exception ex)
     {
         App.SendException(ex);
     }
 }
 public static void Serilize(OptionData serializeObject)
 { // получаем поток, куда будем записывать сериализованный объект
     try
     {
         using (FileStream fs = new FileStream("OptionData.xml", FileMode.OpenOrCreate))
         {
             formatter.Serialize(fs, serializeObject);
         }
     }
     catch (Exception ex)
     {
         App.SendException(ex);
     }
 }
 public static void MoveWindow(string titleWindow, int monitorId)
 {
     try
     {
         Monitor monit  = getMonitorCord(monitorId);
         IntPtr  intPrt = FindWindow(null, titleWindow);
         MoveWindow(intPrt, monit.Coord.X, monit.Coord.Y, monit.Size.X, monit.Size.Y, true);
         System.Windows.Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() => { })).Wait();
     }
     catch (Exception ex)
     {
         App.SendException(ex);
     }
 }
 public void ChangeDisplay(int numberMonitor)
 {
     try
     {
         MonitorManager.MoveWindow(LockScreenWindowName, numberMonitor);
         //WindowState = WindowState.Normal;
         //WindowState = WindowState.Maximized;
         Topmost = false;
         //Hide();
     }
     catch (Exception ex)
     {
         App.SendException(ex);
     }
 }
 public static OptionData Desirialize()
 {
     try
     {
         using (FileStream fs = new FileStream("OptionData.xml", FileMode.OpenOrCreate))
         {
             OptionData email = (OptionData)formatter.Deserialize(fs);
             return(email);
         }
     }
     catch (Exception ex)
     {
         App.SendException(ex);
         return(null);
     }
 }
 public static void RestartPositionWindows()
 {
     try
     {
         App.LockDisplayWindow.WindowState = WindowState.Normal;
         App.LockDisplayWindow.WindowState = WindowState.Maximized;
         App.MainWnd.WindowState           = WindowState.Normal;
         App.MainWnd.WindowState           = WindowState.Maximized;
         MoveWindow(App.LockDisplayWindow.Title, App.Setting.NumberLeftMonitor);
         MoveWindow(App.MainWnd.Title, App.Setting.NumberRightMonitor);
     }
     catch (Exception ex)
     {
         App.SendException(ex);
     }
 }
 public static int getMonitorCordY(int id)
 {
     try
     {
         if (id < ConnectedMonitors.Count)
         {
             return(ConnectedMonitors[id].Coord.Y);
         }
         else
         {
             throw new Exception("Monitor not finded");
         }
     }
     catch (Exception ex)
     {
         App.SendException(ex);
         return(0);
     }
 }
        public bool IsWindowPlayerExist()
        {
            try
            {
                IntPtr findedWindow = FindWindow(null, PlayerWinName);

                if (findedWindow.ToString() != "0")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                App.SendException(ex);
                return(false);
            }
        }
Beispiel #12
0
 private static bool MyEnumThreadWindowsProc(IntPtr hWnd, IntPtr lParam)
 {
     try
     {
         StringBuilder buffer = new StringBuilder(256);
         if (GetWindowText(hWnd, buffer, buffer.Capacity) > 0)
         {
             Console.WriteLine(buffer);
             if (buffer.ToString() == VistaStartMenuCaption)
             {
                 vistaStartMenuWnd = hWnd;
                 return(false);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         App.SendException(ex);
         return(false);
     }
 }
Beispiel #13
0
        private static IntPtr GetVistaStartMenuWnd(IntPtr taskBarWnd)
        {
            try
            {
                int procId;
                GetWindowThreadProcessId(taskBarWnd, out procId);

                Process p = Process.GetProcessById(procId);
                if (p != null)
                {
                    foreach (ProcessThread t in p.Threads)
                    {
                        EnumThreadWindows(t.Id, MyEnumThreadWindowsProc, IntPtr.Zero);
                    }
                }
                return(vistaStartMenuWnd);
            }
            catch (Exception ex)
            {
                App.SendException(ex);
                return(new IntPtr());
            }
        }
        public void Application_Startup(object sender, StartupEventArgs e)
        {
            try
            {
                log4net.Config.XmlConfigurator.Configure();

                Logger.Info("Start seanse in VrManager!!!!!");
                var a = App.Repository.Setting;
            }
            catch (Exception ex)
            {
                App.Logger.Error($"exeption {ex.Message} (Пожалуста установите Microsoft SQL Server Compact 4.0) ||| in class {nameof(App)} and method {GetStackTraseMethod().GetMethod().Name}");
                MessageBox.Show("Пожалуста установите Microsoft SQL Server Compact 4.0");
                return;
            }
            try
            {
                // MainWnd = new MainWindow();

                var _rep = App.Repository;

                ScreenManagerInit();


                if (_rep.Setting.FirstOrDefault() == null)
                {
                    _rep.FirstExecute();
                }
                else
                {
                    Setting.Import();
                }

                ObserverUserActivity.StartActivityObserv();

                if (App.Setting.IsKioskMode)
                {
                    Taskbar.Hide();
                    MainWnd.Topmost = true;
                }
                else
                {
                    MainWnd.Topmost = false;
                }

                ShowWindows();

                MonitorManager.RestartPositionWindows();
                CommandInvoker <NavigateToCommand> .Command.Execute(nameof(StartUpPage));
            }
            catch (Exception ex)
            {
                try
                {
                    MainWnd.Show();
                }
                catch
                {
                    App.SendException(ex);
                    MessageBox.Show("Подключите оккулус или второй монитор");
                }

                CommandInvoker <NavigateToCommand> .Command.Execute(nameof(MainSettingPage));
            }
        }