private void OnPaintCanvas(object sender, SKPaintSurfaceEventArgs e) { SKDevicePainter painter = new SKDevicePainter(e.Surface.Canvas); KDeviceHandler.Draw(painter, 0, 0, e.Info.Width, e.Info.Height); data.DisplayTouchLocation(painter); }
public static void Executing(bool executing) { if (executing) { theOutputPageNavigation.IconImageSource = "icons8refresh96.png"; // this is actually a size 40 icon in iOS resources: otherwise it does not scale theChartPageNavigation.IconImageSource = "icons8refresh96.png"; // this is actually a size 40 icon in iOS resources: otherwise it does not scale // we need to use size 40x40 icons or they get stuck at wrong size after changing icon: theModelEntryPage.deviceButton.Source = "icons8device40disabled.png"; theChartPage.deviceButton.Source = "icons8device40disabled.png"; theModelEntryPage.startButton.Source = "icons8play40disabled.png"; theChartPage.startButton.Source = "icons8play40disabled.png"; theChartPage.stopButton.Source = "icons8stop40.png"; } else { theOutputPageNavigation.IconImageSource = "icons8truefalse100.png"; theChartPageNavigation.IconImageSource = "icons8combochart48.png"; // DO NOT use icons8combochart96, it will not scale // we need to use size 40x40 icons or they get stuck at wrong size after changing icon: theModelEntryPage.deviceButton.Source = KDeviceHandler.Exists() ? "icons8device40on.png" : "icons8device40off.png"; theChartPage.deviceButton.Source = KDeviceHandler.Exists() ? "icons8device40on.png" : "icons8device40off.png"; theModelEntryPage.startButton.Source = "icons8play40.png"; theChartPage.startButton.Source = "icons8play40.png"; theChartPage.stopButton.Source = "icons8stop40disabled.png"; } }
// Implement this to draw on the canvas. public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); var context = NSGraphicsContext.CurrentContext.CGContext; CG.FlipCoordinateSystem(context); KDeviceHandler.Draw(new CGDevicePainter(context), 0, 0, (int)dirtyRect.Width, (int)dirtyRect.Height); }
public DeviceView() { // register this as KTouchable so that touch callbacks can be attached through interface KTouchable: // (If we want to add special actions for Tap, etc. beyond built-in two-finger swiping and zooming) // KDeviceHandler.Register(this); this.BackgroundColor = Color.Transparent; this.PaintSurface += OnPaintCanvas; /* Attact Touch effect from KTouch.OnTouchEffectAction */ TouchEffect touchEffect = new TouchEffect(); touchEffect.TouchAction += KTouchServer.OnTouchEffectAction; touchEffect.Capture = true; // "This has the effect of delivering all subsequent events to the same event handler" this.Effects.Add(touchEffect); /* Initialize Interface KTouchClient with a locally-sourced KTouchClientData closure */ this.data = new KTouchClientData( invalidateSurface: () => { this.InvalidateSurface(); }, setManualPinchPan: (Swipe pinchPan) => { KDeviceHandler.SetPinchPan(pinchPan); } ); }
public ImageButton DeviceButton() { ImageButton button = new ImageButton() { Source = "icons8device40off.png", HeightRequest = MainTabbedPage.buttonHeightRequest, WidthRequest = MainTabbedPage.buttonHeightRequest, HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = MainTabbedPage.secondBarColor, }; button.Clicked += async(object sender, EventArgs e) => { if (!modelInfo.executable) { return; } if (Exec.IsExecuting()) { return; // pretend button is in disabled state } if (KDeviceHandler.Exists()) { deviceButton.Source = "icons8device40off.png"; MainTabbedPage.theChartPage.deviceButton.Source = "icons8device40off.png"; MainTabbedPage.theChartPage.SwitchToPlotView(); KDeviceHandler.Stop(); } else { KDeviceHandler.Start(35, 200); MainTabbedPage.theChartPage.SwitchToDeviceView(); deviceButton.Source = "icons8device40on.png"; MainTabbedPage.theChartPage.deviceButton.Source = "icons8device40on.png"; } }; return(button); }
// Implement this to draw on the canvas. protected override void OnPaintSurface(SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { base.OnPaintSurface(e); KDeviceHandler.Draw(new SKDevicePainter(e.Surface.Canvas), Location.X, Location.Y, e.Info.Width, e.Info.Height); }