예제 #1
0
        //
        // Window loaded
        //
        private void WindowTabletView_Loaded(object sender, RoutedEventArgs e)
        {
            double scaleX, scaleY;
            double aspectScreen, aspectTablet;
            double newHeight;

            // Canvas default size
            canvasTabletView.Width  = 1280;
            canvasTabletView.Height = 720;

            // Tablet renderer
            scaleX = canvasTabletView.Width / config.TabletAreas[0].Width;

            // Set canvas height
            newHeight               = config.TabletAreas[0].Height * scaleX;
            aspectScreen            = config.ScreenAreas[0].Width / config.ScreenAreas[0].Height;
            aspectTablet            = config.TabletAreas[0].Width / config.TabletAreas[0].Height;
            newHeight              *= aspectTablet / aspectScreen;
            scaleY                  = newHeight / config.TabletAreas[0].Height;
            canvasTabletView.Height = newHeight;

            // Set renderer scale
            tabletRenderer.ScaleX = scaleX;
            tabletRenderer.ScaleY = scaleY;

            // Timer
            timer.Start();

            // Enable state output
            driver.SendCommand("StateOutput true");
        }
예제 #2
0
 private void UpdateArea(Area newArea)
 {
     currentArea.Set(newArea);
     config.TabletArea?.Set(newArea);
     config.TabletAreas[0]?.Set(newArea);
     driver.SendCommand(GetCommandFromArea(newArea));
 }
예제 #3
0
 //
 // Draw area
 //
 private void ButtonDrawArea_Click(object sender, RoutedEventArgs e)
 {
     if (!isEnabledMeasurementToArea)
     {
         isEnabledMeasurementToArea = true;
         driver.SendCommand("Measure 2");
         SetStatus("Click the top left and the bottom right corners of the area with your tablet pen!");
         buttonDrawArea.IsEnabled = false;
     }
 }
예제 #4
0
        //
        // Constructor
        //
        public MainWindow()
        {
            // Set the current directory as TabletDriverGUI.exe's directory.
            try { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); } catch (Exception) { }

            //
            // Prevent triggering input field events
            //
            isLoadingSettings = true;

            // Initialize WPF
            InitializeComponent();

            // Version text
            textVersion.Text = this.Version;

            // Set culture to en-US to force decimal format and etc.
            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");


            // Create notify icon
            notifyIcon = new System.Windows.Forms.NotifyIcon
            {
                // Icon
                Icon = Properties.Resources.AppIcon,

                // Menu items
                ContextMenu = new System.Windows.Forms.ContextMenu(new System.Windows.Forms.MenuItem[]
                {
                    new System.Windows.Forms.MenuItem("TabletDriverGUI " + Version),
                    new System.Windows.Forms.MenuItem("Restart Driver", NotifyRestartDriver),
                    new System.Windows.Forms.MenuItem("Show", NotifyShowWindow),
                    new System.Windows.Forms.MenuItem("Exit", NotifyExit)
                })
            };
            notifyIcon.ContextMenu.MenuItems[0].Enabled = false;

            notifyIcon.Text         = "";
            notifyIcon.DoubleClick += NotifyIcon_DoubleClick;
            notifyIcon.Click       += NotifyIcon_DoubleClick;
            notifyIcon.Visible      = true;
            IsRealExit              = false;

            // Create command history list
            commandHistory = new List <string> {
                ""
            };
            commandHistoryIndex = 0;

            // Init tablet driver
            driver                  = new TabletDriver("TabletDriverService.exe");
            driverCommands          = new Dictionary <string, string>();
            driver.MessageReceived += OnDriverMessageReceived;
            driver.ErrorReceived   += OnDriverErrorReceived;
            driver.StatusReceived  += OnDriverStatusReceived;
            driver.Started         += OnDriverStarted;
            driver.Stopped         += OnDriverStopped;
            running                 = false;


            // Restart timer
            timerRestart = new DispatcherTimer
            {
                Interval = new TimeSpan(0, 0, 5)
            };
            timerRestart.Tick += TimerRestart_Tick;

            // Statusbar timer
            timerStatusbar = new DispatcherTimer
            {
                Interval = new TimeSpan(0, 0, 5)
            };
            timerStatusbar.Tick += TimerStatusbar_Tick;

            // Timer console update
            timerConsoleUpdate = new DispatcherTimer
            {
                Interval = new TimeSpan(0, 0, 0, 0, 200)
            };
            timerConsoleUpdate.Tick += TimerConsoleUpdate_Tick;

            // Tooltip timeout
            ToolTipService.ShowDurationProperty.OverrideMetadata(
                typeof(DependencyObject), new FrameworkPropertyMetadata(60000));

            if (App.exp_no_vmulti)
            {
                radioModeAbsolute.IsEnabled = radioModeDigitizer.IsEnabled = radioModeRelative.IsEnabled = false;
            }

            //
            // Buttom Map ComboBoxes
            //
            comboBoxButton1.Items.Clear();
            comboBoxButton2.Items.Clear();
            comboBoxButton3.Items.Clear();
            comboBoxButton1.Items.Add("Disable");
            comboBoxButton2.Items.Add("Disable");
            comboBoxButton3.Items.Add("Disable");
            for (int i = 1; i <= 5; i++)
            {
                comboBoxButton1.Items.Add("Mouse " + i);
                comboBoxButton2.Items.Add("Mouse " + i);
                comboBoxButton3.Items.Add("Mouse " + i);
            }
            comboBoxButton1.Items.Add("Extra");
            comboBoxButton2.Items.Add("Extra");
            comboBoxButton3.Items.Add("Extra");
            comboBoxButton1.SelectedIndex = 0;
            comboBoxButton2.SelectedIndex = 0;
            comboBoxButton3.SelectedIndex = 0;

            extraTipEventBox.Items.Clear();
            extraBottomEventBox.Items.Clear();
            extraTopEventBox.Items.Clear();
            extraTipEventBox.Items.Add("None");
            extraBottomEventBox.Items.Add("None");
            extraTopEventBox.Items.Add("None");
            extraTipEventBox.Items.Add("Mouse Wheel");
            extraBottomEventBox.Items.Add("Mouse Wheel");
            extraTopEventBox.Items.Add("Mouse Wheel");
            extraTipEventBox.Items.Add("Disable Tablet");
            extraBottomEventBox.Items.Add("Disable Tablet");
            extraTopEventBox.Items.Add("Disable Tablet");
            extraTipEventBox.Items.Add("Keyboard");
            extraBottomEventBox.Items.Add("Keyboard");
            extraTopEventBox.Items.Add("Keyboard");

            //
            // Smoothing rate ComboBox
            //
            comboBoxSmoothingRate.Items.Clear();
            for (int i = 1; i <= 8; i++)
            {
                comboBoxSmoothingRate.Items.Add((1000.0 / i).ToString("0") + " Hz");
            }
            comboBoxSmoothingRate.SelectedIndex = 3;

            // Process command line arguments
            ProcessCommandLineArguments();

            // Events
            Closing     += MainWindow_Closing;
            Loaded      += MainWindow_Loaded;
            SizeChanged += MainWindow_SizeChanged;

            switch (ConfigurationManager.Method)
            {
            case ConfigurationManager.ListenMethod.Stop: { disableAutoSwitch.IsChecked = true; break; }

            case ConfigurationManager.ListenMethod.Poll_L: { fdm_Poll.IsChecked = true; break; }

            case ConfigurationManager.ListenMethod.Poll_M: { fdm_PollH.IsChecked = true; break; }

            case ConfigurationManager.ListenMethod.Poll_X: { fdm_PollL.IsChecked = true; break; }

            case ConfigurationManager.ListenMethod.Callback_WinEventHook: { fdm_WEHook.IsChecked = true; break; }
            }
            //
            // Allow input field events
            //
            isLoadingSettings = false;

            ConfigurationManager.ConfigurationChanged += () => LoadSettingsFromConfiguration();
            ConfigurationManager.ConfigurationChanged += () => driver.SendCommand("status");
        }
예제 #5
0
        //
        // Send settings to the driver
        //
        public void SendToDriver(TabletDriver driver)
        {
            if (!driver.IsRunning)
            {
                return;
            }

            // Commands before settings
            if (CommandsBefore.Length > 0)
            {
                foreach (string command in CommandsBefore)
                {
                    string tmp = command.Trim();
                    if (tmp.Length > 0)
                    {
                        driver.SendCommand(tmp);
                    }
                }
            }


            // Desktop size
            driver.SendCommand("DesktopSize " + DesktopWidth + " " + DesktopHeight);


            // Screen area
            driver.SendCommand("ScreenArea " +
                               Utils.GetNumberString(ScreenArea.Width) + " " + Utils.GetNumberString(ScreenArea.Height) + " " +
                               Utils.GetNumberString(ScreenArea.X) + " " + Utils.GetNumberString(ScreenArea.Y)
                               );


            //
            // Tablet area
            //
            // Inverted
            if (Invert)
            {
                driver.SendCommand("TabletArea " +
                                   Utils.GetNumberString(TabletArea.Width) + " " +
                                   Utils.GetNumberString(TabletArea.Height) + " " +
                                   Utils.GetNumberString(TabletFullArea.Width - TabletArea.X) + " " +
                                   Utils.GetNumberString(TabletFullArea.Height - TabletArea.Y)
                                   );
                driver.SendCommand("Rotate " + Utils.GetNumberString(TabletArea.Rotation + 180));
            }
            // Normal
            else
            {
                driver.SendCommand("TabletArea " +
                                   Utils.GetNumberString(TabletArea.Width) + " " +
                                   Utils.GetNumberString(TabletArea.Height) + " " +
                                   Utils.GetNumberString(TabletArea.X) + " " +
                                   Utils.GetNumberString(TabletArea.Y)
                                   );
                driver.SendCommand("Rotate " + Utils.GetNumberString(TabletArea.Rotation));
            }


            // Output Mode
            switch (OutputMode)
            {
            case Configuration.OutputModes.Absolute:
                driver.SendCommand("Mode Absolute");
                break;

            case Configuration.OutputModes.Relative:
                driver.SendCommand("Mode Relative");
                driver.SendCommand("Sensitivity " + Utils.GetNumberString(ScreenArea.Width / TabletArea.Width));
                break;

            case Configuration.OutputModes.Digitizer:
                driver.SendCommand("Mode Digitizer");
                break;

            case Configuration.OutputModes.SendInput:
                driver.SendCommand("Mode sendinputabs");
                break;
            }


            // Button map
            if (DisableButtons)
            {
                driver.SendCommand("ButtonMap 0 0 0");
            }
            else
            {
                driver.SendCommand("ButtonMap " + String.Join(" ", ButtonMap));
            }

            // Smoothing filter
            if (SmoothingEnabled)
            {
                driver.SendCommand("FilterTimerInterval " + Utils.GetNumberString(SmoothingInterval));
                driver.SendCommand("Smoothing " + Utils.GetNumberString(SmoothingLatency));
            }
            else
            {
                driver.SendCommand("Smoothing 0");
            }

            // Noise filter
            if (NoiseFilterEnabled)
            {
                driver.SendCommand("Noise " + Utils.GetNumberString(NoiseFilterBuffer) + " " + Utils.GetNumberString(NoiseFilterThreshold));
            }
            else
            {
                driver.SendCommand("Noise 0");
            }

            // Anti-smoothing filter
            if (AntiSmoothingEnabled)
            {
                driver.SendCommand("AntiSmoothing " + Utils.GetNumberString(AntiSmoothingShape) + " " +
                                   Utils.GetNumberString(AntiSmoothingCompensation) + " " +
                                   (AntiSmoothingIgnoreWhenDragging ? "true" : "false"));
            }
            else
            {
                driver.SendCommand("AntiSmoothing 0");
            }

            // Extra Buttons
            driver.SendCommand("Extra 0 " + ExtraButtonEvents[0].ToString() + " " + ExtraButtonEventTag[0]);
            driver.SendCommand("Extra 1 " + ExtraButtonEvents[1].ToString() + " " + ExtraButtonEventTag[1]);
            driver.SendCommand("Extra 2 " + ExtraButtonEvents[2].ToString() + " " + ExtraButtonEventTag[2]);

            // Commands after settings
            if (CommandsAfter.Length > 0)
            {
                foreach (string command in CommandsAfter)
                {
                    string tmp = command.Trim();
                    if (tmp.Length > 0)
                    {
                        driver.SendCommand(tmp);
                    }
                }
            }
        }