private void Canvas_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Pressed) { Play(); } }
/// <summary> /// Initial routing method /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> void Canvas_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { e.Handled = true; OutputDebug(" e.ActionType = " + e.ActionType.ToString() + " e.InContact = " + e.InContact.ToString() + " Icons: " + canvas.Icons.Count); switch (e.ActionType) { case SkiaSharp.Views.Forms.SKTouchAction.Pressed: ProcessInitialTouchEvent(e, outputVerbose: App.OutputVerbose); return; case SkiaSharp.Views.Forms.SKTouchAction.Moved: ProcessMovedTouchEvent(e, outputVerbose: App.OutputVerbose); return; case SkiaSharp.Views.Forms.SKTouchAction.Released: ProcessCompletedTouchEvent(e, outputVerbose: App.OutputVerbose); return; default: _currentIcon = null; return; } }
private void ThisDraw_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { if (_clickCommand !.CanExecute(null) == false) { return; } _clickCommand.Execute(null); }
private void Canvas_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Pressed) { Vector Dir = new Vector(sim.Objects[0].X, sim.Objects[0].Y, e.Location.X, e.Location.Y).unitVector(); Dir.scalarMultiplication(10); sim.Objects[0].MovementVector.addVector(Dir); //lblX.Text = sim.Objects[0].MovementVector.stringify(); } }
private void SideBarCanvas_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { if (GetPreviousButtonRect().Contains(e.Location)) { MovePrevious(); } if (GetNextButtonRect().Contains(e.Location)) { MoveNext(); } }
private void Canvas_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Pressed) { _currentElement = canvas.GetElementAtPoint(e.Location); if (_currentElement != null) { _startLocation = _currentElement.Location; canvas.Elements.BringToFront(_currentElement); } } }
/// <summary> /// Launch board if hit button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Canvas_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Pressed) { _currentIcon = canvasTitle.GetIconAtPoint(e.Location); if (_currentIcon != null && _currentIcon.Tag == 999) { App.BoardPage = new Xamarin.Forms.NavigationPage(new FastTalkerSkiaSharp.Pages.CommunicationBoardPage()); Xamarin.Forms.Application.Current.MainPage = App.BoardPage; } } e.Handled = true; }
private void CanvasView_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Pressed) { _lastTouchPoint = e.Location; e.Handled = true; } _lastTouchPoint = e.Location; _touchPoints.Add( new RipplingTouchPoint { TouchPointLocation = _lastTouchPoint, } ); CanvasView.InvalidateSurface(); }
private void CanvasView_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Pressed) { _animatedTouchPoint.MaxRadius = 50; _animatedTouchPoint.MinRadius = 30; _lastTouchPoint = e.Location; e.Handled = true; } if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Released) { _animatedTouchPoint.MaxRadius = 30; _animatedTouchPoint.MinRadius = 10; } _lastTouchPoint = e.Location; CanvasView.InvalidateSurface(); }
private async void CanvasView_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Pressed) { _lastTouchPoint = e.Location; e.Handled = true; } else if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Moved) { if (_lastTouchPoint.Y < e.Location.Y) { // swipe down if (ElectronsCount == 1) { return; } pageIsActive = false; ElectronsCount--; InitAtom(); InitAnimation(); } else if (_lastTouchPoint.Y > e.Location.Y) { // swipe up pageIsActive = false; await Task.Delay(TimeSpan.FromMilliseconds(33)); ElectronsCount++; InitAtom(); InitAnimation(); } _lastTouchPoint = e.Location; LabelElectronsCount.Text = $" Electrons: {ElectronsCount}"; } }
private void CanvasView_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Pressed) { _lastTouchPoint = e.Location; e.Handled = true; } else if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Moved) { if (_lastTouchPoint.Y < e.Location.Y) { // swipe down _touchMoveDirectionString = "Down"; } else if (_lastTouchPoint.Y > e.Location.Y) { // swipe up _touchMoveDirectionString = "Up"; } _lastTouchPoint = e.Location; } if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Pressed) { _touchEventString = "Pressed"; _touchMoveDirectionString = ""; } else if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Moved) { _touchEventString = "Moved"; } else if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Released) { _touchEventString = "Released"; _touchMoveDirectionString = ""; } CanvasView.InvalidateSurface(); }
private void SkiaView_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { switch (e.ActionType) { case SkiaSharp.Views.Forms.SKTouchAction.Entered: _dragX = e.Location.X; _dragY = e.Location.Y; break; case SkiaSharp.Views.Forms.SKTouchAction.Moved: _currentMatrix.TransX = _dragX + e.Location.X; _currentMatrix.TransY = _dragY + e.Location.Y; SkiaView.InvalidateSurface(); break; case SkiaSharp.Views.Forms.SKTouchAction.Released: break; default: break; } }
private void DonutChart_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { switch (clicks) { case 0: Data[0].Value = 30; break; case 1: Data.Add( new Figure(20) { Describtion = "Spices", Color = Color.FromRgb(183, 93, 174) } ); break; case 2: Data.RemoveAt(1); break; } clicks++; }
private void CanvasView_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { if (e.ActionType == SkiaSharp.Views.Forms.SKTouchAction.Pressed) { _lastTouchPoint = e.Location; e.Handled = true; } _lastTouchPoint = e.Location; Random rand = new Random(); _touchPoints.Add( new SmileyImage { Location = _lastTouchPoint, Bitmap = _smileyImagesList[rand.Next(0, _smileyImagesList.Count)], Width = 120, Alpha = 255, } ); CanvasView.InvalidateSurface(); }
private void CircularImage_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { }
async private void SvgControl_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { await DisplayAlert("Test", "Click from svg control", "OK"); }
private void hud1_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { }
private void ChartView_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { var l = e.Location; chartView.HeightRequest += 50; }
/// <summary> /// Process initial touches /// </summary> /// <param name="e"></param> /// <param name="outputVerbose"></param> void ProcessInitialTouchEvent(SkiaSharp.Views.Forms.SKTouchEventArgs e, bool outputVerbose = false) { _currentIcon = canvas.GetIconAtPoint(e.Location); // Confirmation of movement hasMoved = false; // Fail out if null if (_currentIcon == null) { return; } itemPressTime = System.DateTime.Now; // Get origin of element _startLocation = _currentIcon.Location; switch (_currentIcon.Tag) { case (int)IconRoles.Role.SentenceFrame: OutputDebug("Hit sentence frame"); return; case (int)IconRoles.Role.Emitter: // Serves as Settings button in edit mode if (canvas.Controller.InEditMode) { canvas.Icons[canvas.Icons.IndexOf(emitterReference)].IsPressed = true; canvas.InvalidateSurface(); OutputDebug("Hit settings (speech emitter)"); App.UserInputInstance.QueryUserMainSettingsAsync(); } // Serves as speech emitter as normal else { canvas.Icons[canvas.Icons.IndexOf(emitterReference)].IsPressed = true; canvas.InvalidateSurface(); OutputDebug("Hit speech emitter"); holdingEmitter = true; emitterPressTime = System.DateTime.Now; } return; case (int)IconRoles.Role.Folder: OutputDebug("Hit Folder"); ClearIconsInPlay(); canvas.Icons.BringToFront(_currentIcon); return; default: OutputDebug("In Default Hit"); ClearIconsInPlay(); canvas.Icons.BringToFront(_currentIcon); if (!canvas.Controller.InFramedMode && !canvas.Controller.IconModeAuto) { _currentIcon.IsMainIconInPlay = true; } else if (!canvas.Controller.InFramedMode && _currentIcon != null && _currentIcon.Tag == IconRoles.GetRoleInt(IconRoles.Role.Communication) && !canvas.Controller.InEditMode && canvas.Controller.IconModeAuto) { commInterface.SpeakText(_currentIcon.Text); e.Handled = true; } /* Pinned icons in sentence mode */ else if (canvas.Controller.InFramedMode && !canvas.Controller.InEditMode && _currentIcon.IsPinnedToSpot && !stripReference.Bounds.IntersectsWith(_currentIcon.Bounds)) { OutputDebug("Hit a pinned icon in sentence mode, outside of frame"); e.Handled = true; commInterface.SpeakText(text: _currentIcon.Text); _currentIcon = null; } return; } }
private async void ChartView1_Touch(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e) { await Navigation.PushModalAsync(new Sup7()); }
/// <summary> /// Process touch completed events /// </summary> /// <param name="e"></param> /// <param name="outputVerbose"></param> async void ProcessCompletedTouchEvent(SkiaSharp.Views.Forms.SKTouchEventArgs e, bool outputVerbose = false) { if (canvas.Icons[canvas.Icons.IndexOf(emitterReference)].IsPressed) { canvas.Icons[canvas.Icons.IndexOf(emitterReference)].IsPressed = false; canvas.InvalidateSurface(); } // If out of scope, return if (_currentIcon == null) { return; } switch (_currentIcon.Tag) { case (int)IconRoles.Role.Communication: if (canvas.Controller.InEditMode && !hasMoved) { if (App.UserInputInstance.AreModalsOpen()) { return; } OutputDebug("Completed icon tap"); if (App.InstanceModificationPage == null) { App.InstanceModificationPage = new ModifyPage(_currentIcon, canvas.Controller); } else { App.InstanceModificationPage.UpdateCurrentIcon(_currentIcon); } await Navigation.PushPopupAsync(App.InstanceModificationPage); } else if (canvas.Controller.InEditMode && !_currentIcon.IsInsertableIntoFolder && System.DateTime.Now.Subtract(itemPressTime).Seconds > 3) { if (App.UserInputInstance.AreModalsOpen()) { return; } OutputDebug("Completed icon held > 3s"); if (App.InstanceModificationPage == null) { App.InstanceModificationPage = new ModifyPage(_currentIcon, canvas.Controller); } else { App.InstanceModificationPage.UpdateCurrentIcon(_currentIcon); } await Navigation.PushPopupAsync(App.InstanceModificationPage); } else if (hasMoved && _currentIcon.IsInsertableIntoFolder) { OutputDebug("Icon completed, has moved"); var folderOfInterest = GetFoldersOfInterest(); App.UserInputInstance.InsertIntoFolder(_currentIcon: _currentIcon, folderOfInterest: folderOfInterest); } e.Handled = true; return; case (int)IconRoles.Role.Folder: if (canvas.Controller.InEditMode && !hasMoved) { if (App.UserInputInstance.AreModalsOpen()) { return; } OutputDebug("Completed folder tap"); if (App.InstanceModificationPage == null) { App.InstanceModificationPage = new ModifyPage(_currentIcon, canvas.Controller); } else { App.InstanceModificationPage.UpdateCurrentIcon(_currentIcon); } await Navigation.PushPopupAsync(App.InstanceModificationPage); e.Handled = true; } else if (canvas.Controller.InEditMode && System.DateTime.Now.Subtract(itemPressTime).Seconds > 3) { if (App.UserInputInstance.AreModalsOpen()) { return; } OutputDebug("Completed folder hold"); if (App.InstanceModificationPage == null) { App.InstanceModificationPage = new ModifyPage(_currentIcon, canvas.Controller); } else { App.InstanceModificationPage.UpdateCurrentIcon(_currentIcon); } await Navigation.PushPopupAsync(App.InstanceModificationPage); e.Handled = true; } if (!canvas.Controller.InEditMode && !hasMoved) { if (App.UserInputInstance.AreModalsOpen()) { return; } OutputDebug("Hit a folder, in user mode: " + _currentIcon.Text); // This is where the current item is the folder in question var itemsMatching = GetItemsMatching(); // Leave if empty if (itemsMatching == null) { e.Handled = true; return; } if (App.InstanceStoredIconsViewModel == null) { App.InstanceStoredIconsViewModel = new ViewModels.StoredIconPopupViewModel { Padding = new Xamarin.Forms.Thickness(100, 100, 100, 100), IsSystemPadding = true, FolderWithIcons = _currentIcon.Text, ItemsMatching = itemsMatching, }; App.InstanceStoredIconsViewModel.IconSelected += RestoreIcon; App.InstanceStoredIconPage = new StoredIconPopup() { BindingContext = App.InstanceStoredIconsViewModel }; } else { App.InstanceStoredIconsViewModel.FolderWithIcons = _currentIcon.Text; App.InstanceStoredIconsViewModel.ItemsMatching = itemsMatching; } await Xamarin.Forms.Application.Current.MainPage.Navigation.PushPopupAsync(App.InstanceStoredIconPage); e.Handled = true; } else if (!canvas.Controller.InEditMode && System.DateTime.Now.Subtract(itemPressTime).Seconds > 3) { if (App.UserInputInstance.AreModalsOpen()) { return; } OutputDebug("Held a folder, in user mode: " + _currentIcon.Text); // This is where the current item is the folder in question var itemsMatching = GetItemsMatching(); // Leave if empty if (itemsMatching == null) { e.Handled = true; return; } if (App.InstanceStoredIconsViewModel == null) { App.InstanceStoredIconsViewModel = new ViewModels.StoredIconPopupViewModel { Padding = new Xamarin.Forms.Thickness(100, 100, 100, 100), IsSystemPadding = true, FolderWithIcons = _currentIcon.Text, ItemsMatching = itemsMatching, }; App.InstanceStoredIconsViewModel.IconSelected += RestoreIcon; App.InstanceStoredIconPage = new StoredIconPopup() { BindingContext = App.InstanceStoredIconsViewModel }; } else { App.InstanceStoredIconsViewModel.FolderWithIcons = _currentIcon.Text; App.InstanceStoredIconsViewModel.ItemsMatching = itemsMatching; } await Xamarin.Forms.Application.Current.MainPage.Navigation.PushPopupAsync(App.InstanceStoredIconPage); e.Handled = true; } return; default: // Emitter was tapped/held if (holdingEmitter) { holdingEmitter = false; OutputDebug("Seconds held: " + (System.DateTime.Now - emitterPressTime).TotalSeconds.ToString()); OutputDebug("Bottom Oriented: " + canvas.Controller.InFramedModeBottom); // Enter into Edit Mode if ((System.DateTime.Now - emitterPressTime).Seconds >= thresholdAdmin && !canvas.Controller.InEditMode) { canvas.Controller.UpdateSettings(isEditing: !canvas.Controller.InEditMode, isInFrame: canvas.Controller.InFramedMode, isFrameBottom: canvas.Controller.InFramedModeBottom, isAutoDeselecting: canvas.Controller.RequireDeselect, isInIconModeAuto: canvas.Controller.IconModeAuto); canvas.Controller.BackgroundColor = canvas.Controller.InEditMode ? SKColors.DarkOrange : SKColors.DimGray; resource = App.BoardSettings.InEditMode ? "FastTalkerSkiaSharp.Images.Settings.png" : "FastTalkerSkiaSharp.Images.Speaker.png"; if (canvas.Controller.InFramedModeBottom && canvas.Controller.InFramedMode) { var list = canvas.Icons.Where(elem => elem.Tag == IconRoles.GetRoleInt(IconRoles.Role.Emitter)).ToList(); foreach (var icon in list) { canvas.Icons.Remove(icon); } emitterReference = App.ImageBuilderInstance.BuildStaticIconBottom(resource: resource, xPercent: 2f, yPercent: 1.5f, tag: IconRoles.GetRoleInt(IconRoles.Role.Emitter)); canvas.Icons.Add(emitterReference); } else { var list = canvas.Icons.Where(elem => elem.Tag == IconRoles.GetRoleInt(IconRoles.Role.Emitter)).ToList(); foreach (var icon in list) { canvas.Icons.Remove(icon); } emitterReference = App.ImageBuilderInstance.BuildStaticIcon(resource: resource, xPercent: 2f, yPercent: 1.5f, tag: IconRoles.GetRoleInt(IconRoles.Role.Emitter)); canvas.Icons.Add(emitterReference); } SendReferenceToBack(emitterReference); ClearIconsInPlay(); } // TODO: Fix exit program (changed since emitter fx altered) else if ((System.DateTime.Now - emitterPressTime).Seconds >= thresholdReset && canvas.Controller.InEditMode) { // TODO: Confirm message? OutputDebug("In reset hook, returning to home"); Xamarin.Forms.Application.Current.MainPage = new TitlePage(); } // Speak output else { if (canvas.Controller.InFramedMode) { var mIntersectingIcons = GetSentenceContent(); if (mIntersectingIcons != null && mIntersectingIcons.Count() > 0) { var output = System.String.Join(" ", mIntersectingIcons); OutputDebug("Verbal output (Frame): " + output); commInterface.SpeakText(text: output); } } else if (!canvas.Controller.IconModeAuto) { var selectedIcons = GetMainIconInPlay(); if (selectedIcons != null) { OutputDebug("Verbal output (Icon): " + selectedIcons); commInterface.SpeakText(text: selectedIcons); } if (canvas.Controller.RequireDeselect) { ClearIconsInPlay(); } } } e.Handled = true; } return; } }
/// <summary> /// Process moving touches /// </summary> /// <param name="e"></param> /// <param name="outputVerbose"></param> void ProcessMovedTouchEvent(SkiaSharp.Views.Forms.SKTouchEventArgs e, bool outputVerbose = false) { // If out of scope, return if (_currentIcon == null) { return; } OutputDebug("Moving Event: " + e.ToString()); switch (_currentIcon.Tag) { case (int)IconRoles.Role.Control: return; case (int)IconRoles.Role.Emitter: return; case (int)IconRoles.Role.Communication: hasMoved = true; // If pinned, prevent move if (_currentIcon.IsPinnedToSpot && !canvas.Controller.InEditMode) { return; } _currentIcon.Location = new SKPoint(e.Location.X - _currentIcon.Bounds.Width / 2f, e.Location.Y - _currentIcon.Bounds.Height / 2f); ClampCurrentIconToCanvasBounds(); if (canvas.Controller.InFramedMode) { _currentIcon.IsSpeakable = _currentIcon.Bounds.IntersectsWith(stripReference.Bounds); } else { for (int i = 0; i < canvas.Icons.Count; i++) { canvas.Icons[i].IsMainIconInPlay = false; } _currentIcon.IsMainIconInPlay = true; } _currentIcon.IsInsertableIntoFolder = canvas.Icons.Where(elem => elem.Tag == IconRoles.GetRoleInt(IconRoles.Role.Folder)) .Where(folder => folder.Bounds.IntersectsWith(_currentIcon.Bounds)) .Any(); _startLocation = _currentIcon.Location; return; case (int)IconRoles.Role.Folder: hasMoved = true; if (!canvas.Controller.InEditMode) { return; } _currentIcon.Location = new SKPoint(e.Location.X - _currentIcon.Bounds.Width / 2f, e.Location.Y - _currentIcon.Bounds.Height / 2f); ClampCurrentIconToCanvasBounds(); _startLocation = _currentIcon.Location; return; default: return; } }