private void GestureButton_TouchDown(object sender, TouchEventArgs e)
        {
            // 找到目标窗口
            _hwnd = WindowsHandler.FindTopmostWindow();

            // 初始化起始点
            int   id    = e.TouchDevice.Id;
            Point start = this.PointToScreen(new Point(e.GetTouchPoint(this).Position.X, e.GetTouchPoint(this).Position.Y));

            if (finger1.Count == 0)
            {
                finger1.Add(id, new List <YTPoint>()
                {
                    new YTPoint(start.X, start.Y)
                });
                _watch1 = Stopwatch.StartNew();
            }
            else
            {
                finger2.Add(id, new List <YTPoint>()
                {
                    new YTPoint(start.X, start.Y)
                });
                _watch2 = Stopwatch.StartNew();
            }

            // 初始化点击时间
            _watch1 = Stopwatch.StartNew();
            _watch2 = Stopwatch.StartNew();
        }
Exemplo n.º 2
0
        public void OnGui()
        {
            //Window ID's - Doesn't include "random" offset.
            //Connection window: 6702
            //Status window: 6703
            //Chat window: 6704
            //Debug window: 6705
            //Mod windw: 6706
            //Craft library window: 6707
            //Craft upload window: 6708
            //Screenshot window: 6710
            //Options window: 6711
            //Converter window: 6712
            //Disclaimer window: 6713
            //Servers window: 6714

            var startClock = Profiler.LmpReferenceTime.ElapsedTicks;

            if (ShowGui && (ToolbarShowGui || HighLogic.LoadedScene == GameScenes.MAINMENU))
            {
                WindowsHandler.OnGui();
            }

            Profiler.GuiData.ReportTime(startClock);
        }
        public Menu()
        {
            InitializeComponent();
            this.Width  = WindowsHandler.GetScreenWidth() * WindowsHandler.WRATIO;
            this.Height = WindowsHandler.GetScreenHeight() * WindowsHandler.HRATIO;

            Client client = new Client("192.168.5.130", 1234);

            TaskManager.getInstance().menu = this;
            _MovingComponent = new YTMenuMovingComponent(this, MovingMode.X);
        }
 private void GestureButton_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
 {
     if (_bManipulating1 && _bManipulating2)
     {
         double translate_x = e.DeltaManipulation.Translation.X * 2;
         double translate_y = e.DeltaManipulation.Translation.Y * 2;
         double scale_x     = e.DeltaManipulation.Scale.X;
         double scale_y     = e.DeltaManipulation.Scale.Y;
         WindowsHandler.MoveWindow(_hwnd, (int)translate_x, (int)translate_y);
         //WindowsHandler.ScaleWindow(_hwnd, scale_x, scale_y);
         e.Handled = true;
     }
 }
Exemplo n.º 5
0
        private void AppItemList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            IntPtr hwnd = WindowsHandler.GetHandleFromTitle(appTitles[AppItemList.SelectedIndex]);

            foreach (Process process in Process.GetProcesses())
            {
                if (process.MainWindowTitle == appTitles[AppItemList.SelectedIndex])
                {
                    WinApiManager.SwitchToThisWindow(process.MainWindowHandle, true);
                }
            }
            Menu.CloseAppListWindow();
        }
 /// <summary>
 /// Toggle whiteboard.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void WhiteBoardIcon_TouchDown(object sender, TouchEventArgs e)
 {
     if (!WindowsHandler.IsWindowOpen <WhiteBoard>())
     {
         _whiteBoard = new WhiteBoard();
         _whiteBoard.Show();
         WhiteBoardIcon.Source = new BitmapImage(new Uri(@"/Images/新建_高光.png", UriKind.RelativeOrAbsolute));
     }
     else
     {
         _whiteBoard.Close();
         _whiteBoard           = null;
         WhiteBoardIcon.Source = new BitmapImage(new Uri(@"/Images/新建.png", UriKind.RelativeOrAbsolute));
     }
 }
        private void GestureButton_TouchUp(object sender, TouchEventArgs e)
        {
            if (_bSwipe1 && _bSwipe2)
            {
                if (finger1.Count != 0 && finger2.Count != 0)
                {
                    var list1 = finger1.ElementAt(0).Value;
                    var list2 = finger2.ElementAt(0).Value;

                    int n1 = list1.Count;
                    int n2 = list2.Count;
                    if (list1[n1 - 1].Y - list1[0].Y > SWIPE_THRESHOLD && list2[n2 - 1].Y - list2[0].Y > SWIPE_THRESHOLD && Math.Abs(list1[n1 - 1].X - list1[0].X) < SWIPE_LIMITED && Math.Abs(list2[n2 - 1].X - list2[0].X) < SWIPE_LIMITED)
                    {
                        Console.WriteLine("双指下滑");
                        WindowsHandler.MinimizeWindow(_hwnd);
                    }
                    else if (list1[0].Y - list1[n1 - 1].Y > SWIPE_THRESHOLD && list2[0].Y - list2[n2 - 1].Y > SWIPE_THRESHOLD && Math.Abs(list1[n1 - 1].X - list1[0].X) < SWIPE_LIMITED && Math.Abs(list2[n2 - 1].X - list2[0].X) < SWIPE_LIMITED)
                    {
                        Console.WriteLine("双指上滑");
                        WindowsHandler.MaximizeWindow(_hwnd);
                    }
                    else if (list1[n1 - 1].X - list1[0].X > SWIPE_THRESHOLD && list2[n2 - 1].X - list2[0].X > SWIPE_THRESHOLD && Math.Abs(list1[n1 - 1].Y - list1[0].Y) < SWIPE_LIMITED && Math.Abs(list2[n2 - 1].Y - list2[0].Y) < SWIPE_LIMITED)
                    {
                        Console.WriteLine("双指右滑");
                        //WindowsHandler.RestoreWindow(_hwnd);
                    }
                    else if (list1[0].X - list1[n1 - 1].X > SWIPE_THRESHOLD && list2[0].X - list2[n2 - 1].X > SWIPE_THRESHOLD && Math.Abs(list1[n1 - 1].Y - list1[0].Y) < SWIPE_LIMITED && Math.Abs(list2[n2 - 1].Y - list2[0].Y) < SWIPE_LIMITED)
                    {
                        Console.WriteLine("双指左滑");
                        WindowsHandler.CloseWindow(_hwnd);
                    }
                }
            }
            finger1         = new Dictionary <int, List <YTPoint> >();
            finger2         = new Dictionary <int, List <YTPoint> >();
            _bSwipe1        = false;
            _bSwipe2        = false;
            _bManipulating1 = false;
            _bManipulating2 = false;
            _hwnd           = IntPtr.Zero;
        }
        private void Background_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyStates == Keyboard.GetKeyStates(Key.Q))
            {
                WindowsHandler.AcquirePriortyofScreenTouch();
            }

            if (e.KeyStates == Keyboard.GetKeyStates(Key.W))
            {
                WindowsHandler.BlockingScreenTouch();
            }

            if (e.KeyStates == Keyboard.GetKeyStates(Key.E))
            {
                YTDataDecoder.run();
            }

            if (e.KeyStates == Keyboard.GetKeyStates(Key.R))
            {
                Console.WriteLine(BrightnessAdjuster.getInstance().Brightness);
            }
        }
Exemplo n.º 9
0
        private void GenerateData()
        {
            var apps = WindowsHandler.EnumerateWindow();

            appTitles = new List <string>();
            List <AppItem> items = new List <AppItem>();

            foreach (IntPtr hwnd in apps)
            {
                string      title  = WindowsHandler.GetWindowTitle(hwnd);
                ImageSource source = WindowsHandler.GetAppIcon(hwnd);
                AppItem     item   = new AppItem()
                {
                    Title = title, Source = source
                };
                items.Add(item);
                appTitles.Add(title);
            }

            //EventManager.RegisterClassHandler(typeof(ListBoxItem), ListBoxItem.TouchLeaveEvent, new RoutedEventHandler(OnTouchUpEvent));
            AppItemList.ItemsSource = items;
        }
Exemplo n.º 10
0
        private void OnTouchUpEvent(object sender, RoutedEventArgs e)
        {
            int index = AppItemList.ItemContainerGenerator.IndexFromContainer(sender as ListBoxItem);

            if (index >= appTitles.Count)
            {
                return;
            }

            Console.WriteLine(index);
            IntPtr hwnd      = WindowsHandler.GetHandleFromTitle(appTitles[index]);
            var    processes = Process.GetProcesses();

            foreach (Process process in processes)
            {
                if (process.MainWindowTitle == appTitles[index])
                {
                    WinApiManager.BringWindowToTop(process.MainWindowHandle);
                }
            }

            Menu.CloseAppListWindow();
        }
Exemplo n.º 11
0
        public override void Update()
        {
            base.Update();
            var startClock = Profiler.LmpReferenceTime.ElapsedTicks;

            if (!Enabled)
            {
                return;
            }

            try
            {
                if (HighLogic.LoadedScene == GameScenes.MAINMENU)
                {
                    if (!ModSystem.Singleton.DllListBuilt)
                    {
                        ModSystem.Singleton.DllListBuilt = true;
                        ModSystem.Singleton.BuildDllFileList();
                    }
                    if (!LmpSaveChecked)
                    {
                        LmpSaveChecked = true;
                        SetupBlankGameIfNeeded();
                    }
                }


                HandleWindowEvents();
                SystemsHandler.Update();
                WindowsHandler.Update();

                //Force quit
                if (ForceQuit)
                {
                    ForceQuit   = false;
                    GameRunning = false;
                    FireReset   = true;
                    StopGame();
                }

                if (DisplayDisconnectMessage)
                {
                    ShowDisconnectMessage();
                }

                //Normal quit
                if (GameRunning)
                {
                    if (HighLogic.LoadedScene == GameScenes.MAINMENU)
                    {
                        GameRunning = false;
                        FireReset   = true;
                        ToolbarSystem.Singleton.Enabled = false; //Always disable toolbar in main menu
                        NetworkConnection.Disconnect("Quit to main menu");
                    }

                    if (HighLogic.CurrentGame.flagURL != SettingsSystem.CurrentSettings.SelectedFlag)
                    {
                        Debug.Log("[LMP]: Saving Selected flag");
                        SettingsSystem.CurrentSettings.SelectedFlag = HighLogic.CurrentGame.flagURL;
                        SettingsSystem.Singleton.SaveSettings();
                        FlagSystem.Singleton.FlagChangeEvent = true;
                    }

                    // save every GeeASL from each body in FlightGlobals
                    if ((HighLogic.LoadedScene == GameScenes.FLIGHT) && (BodiesGees.Count == 0))
                    {
                        foreach (var body in FlightGlobals.Bodies)
                        {
                            BodiesGees.Add(body, body.GeeASL);
                        }
                    }

                    //handle use of cheats
                    if (!SettingsSystem.ServerSettings.AllowCheats)
                    {
                        CheatOptions.InfinitePropellant = false;
                        CheatOptions.NoCrashDamage      = false;

                        foreach (var gravityEntry in BodiesGees)
                        {
                            gravityEntry.Key.GeeASL = gravityEntry.Value;
                        }
                    }

                    if ((HighLogic.LoadedScene == GameScenes.FLIGHT) && FlightGlobals.ready)
                    {
                        HighLogic.CurrentGame.Parameters.Flight.CanLeaveToSpaceCenter = PauseMenu.canSaveAndExit == ClearToSaveStatus.CLEAR;
                    }
                    else
                    {
                        HighLogic.CurrentGame.Parameters.Flight.CanLeaveToSpaceCenter = true;
                    }
                }

                if (FireReset)
                {
                    FireReset = false;
                    SystemsHandler.KillAllSystems();
                }

                if (StartGame)
                {
                    StartGame = false;
                    StartGameNow();
                }
            }
            catch (Exception e)
            {
                HandleException(e, "Main system- update");
            }
            Profiler.UpdateData.ReportTime(startClock);
        }
Exemplo n.º 12
0
 public MinimizeCommader(WindowsHandler recevier)
 {
     this.recevier = recevier;
 }
Exemplo n.º 13
0
 public void ThenWidgetShouldSucessfullyUpload()
 {
     WindowsHandler.SearchFile(_filePath.DefaultPath, _filePath.DefaultWidget);
     new WidgetUploadPage(WebDriver.driver).Success.Should().NotBeNull("file failed to upload.");
 }
 private void DesktopIcon_TouchDown(object sender, TouchEventArgs e)
 {
     WindowsHandler.ReturnToDesktop();
 }