public override void SetUp()
 {
     driver = new TabletDriver();
 }
 public override void SetUp()
 {
     driver = TabletDriver.Create();
 }
Пример #3
0
        //
        // Tablet View Constructor
        //
        public WindowTabletView(Configuration config, TabletDriver driver)
        {
            if (config.TabletView.Borderless)
            {
                WindowStyle = WindowStyle.None;
            }
            InitializeComponent();

            this.config = config;
            this.driver = driver;

            // Tablet renderer
            tabletRenderer = new TabletRenderer(config);
            canvasTabletView.Children.Add(tabletRenderer);

            // Offset texts
            Canvas.SetLeft(textTabletInfo, Canvas.GetLeft(textTabletInfo) + config.TabletView.OffsetText.X);
            Canvas.SetTop(textTabletInfo, Canvas.GetTop(textTabletInfo) + config.TabletView.OffsetText.Y);
            Canvas.SetLeft(textInput, Canvas.GetLeft(textInput) + config.TabletView.OffsetText.X);
            Canvas.SetTop(textInput, Canvas.GetTop(textInput) + config.TabletView.OffsetText.Y);
            Canvas.SetLeft(textOutput, Canvas.GetLeft(textOutput) + config.TabletView.OffsetText.X);
            Canvas.SetTop(textOutput, Canvas.GetTop(textOutput) + config.TabletView.OffsetText.Y);
            Canvas.SetLeft(textLatency, Canvas.GetLeft(textLatency) + config.TabletView.OffsetText.X);
            Canvas.SetTop(textLatency, Canvas.GetTop(textLatency) + config.TabletView.OffsetText.Y);

            // Background color
            Brush brush;

            try { brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(config.TabletView.BackgroundColor)); }
            catch (Exception) { brush = Brushes.White; }
            canvasTabletView.Background = brush;
            Background = brush;

            // Text colors
            try { brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(config.TabletView.InfoColor)); }
            catch (Exception) { brush = Brushes.Black; }
            textTabletInfo.Foreground = brush;
            try { brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(config.TabletView.LatencyColor)); }
            catch (Exception) { brush = Brushes.Black; }
            textLatency.Foreground = brush;
            textInput.Foreground   = tabletRenderer.brushInput;
            textOutput.Foreground  = tabletRenderer.brushOutput;

            // Text font
            try
            {
                FontFamilyConverter fontConverter = new FontFamilyConverter();
                FontFamily          fontFamily    = (FontFamily)fontConverter.ConvertFromString(config.TabletView.Font);
                textTabletInfo.FontFamily = fontFamily;
                textInput.FontFamily      = fontFamily;
                textOutput.FontFamily     = fontFamily;
                textLatency.FontFamily    = fontFamily;
            }
            catch (Exception) { }

            // Font size
            textTabletInfo.FontSize = config.TabletView.FontSize;
            textInput.FontSize      = config.TabletView.FontSize;
            textOutput.FontSize     = config.TabletView.FontSize;
            textLatency.FontSize    = config.TabletView.FontSize;

            // Info text
            textTabletInfo.Text = config.TabletName + " - " +
                                  Utils.GetNumberString(config.TabletAreas[0].Width) + " x " +
                                  Utils.GetNumberString(config.TabletAreas[0].Height) + " mm → " +
                                  Utils.GetNumberString(config.ScreenAreas[0].Width, "0") + " x " +
                                  Utils.GetNumberString(config.ScreenAreas[0].Height, "0") + " px";


            //
            // Update/draw timer
            //
            timer = new MultimediaTimer {
                Interval = 2
            };
            timer.Tick += UpdateTimer_Tick;

            // Last values
            lastPosition = new Vector(0, 0);
            lastUpdate   = DateTime.Now;
            lastPressure = 0;

            // Average values
            velocity = 0;
            latency  = 0;


            // Input loss
            hadInputLoss       = true;
            lastInputStartTime = DateTime.Now;

            // Window events
            Loaded  += WindowTabletView_Loaded;
            Closing += WindowTabletView_Closing;
            KeyDown += WindowTabletView_KeyDown;

            MouseDown += WindowTabletView_MouseDown;
            MouseUp   += WindowTabletView_MouseUp;


            // Set GC mode to low latency
            GCSettings.LatencyMode = GCLatencyMode.SustainedLowLatency;
        }