private bool SaveGesture(IGesture gesture) { if (string.IsNullOrEmpty(gesture.Name)) { gesture.Name = GestureManager.GetNewGestureName(); } if (GestureManager.Instance.GestureExists(gesture.Name)) { GestureManager.Instance.DeleteGesture(gesture.Name); } GestureManager.Instance.AddGesture(gesture); GestureManager.Instance.SaveGestures(); return(true); }
public static int ImportGestures(this GestureManager gestureManager, IEnumerable <IGesture> gestures, IEnumerable <IApplication> relatedApplications) { int count = 0; if (gestures == null) { return(count); } foreach (IGesture newGesture in gestures) { string matchName = gestureManager.GetMostSimilarGestureName(newGesture); if (!string.IsNullOrEmpty(matchName)) { if (relatedApplications != null && newGesture.Name != matchName) { relatedApplications.RenameGestures(newGesture.Name, matchName); } } else { if (gestureManager.GestureExists(newGesture.Name)) { string newName = gestureManager.GetNewGestureName(); if (relatedApplications != null) { relatedApplications.RenameGestures(newGesture.Name, newName); } newGesture.Name = newName; } gestureManager.AddGesture(newGesture); count++; } } if (count != 0) { gestureManager.SaveGestures(); } return(count); }
private void ImportGesture(List <IGesture> gestureList) { if (gestureList == null || gestureList.Count == 0) { return; } int addcount = 0; int ignoredCount = 0; foreach (IGesture newGesture in gestureList) { string matchName = GestureManager.Instance.GetMostSimilarGestureName(newGesture); if (matchName != null) { ignoredCount++; continue; } if (GestureManager.Instance.GestureExists(newGesture.Name)) { newGesture.Name = GestureManager.GetNewGestureName(); } GestureManager.Instance.AddGesture(newGesture); addcount++; } if (addcount != 0) { GestureManager.Instance.SaveGestures(); } UIHelper.GetParentWindow(this).ShowModalMessageExternal( LocalizationProvider.Instance.GetTextValue("Gesture.Messages.ImportCompleteTitle"), String.Format(LocalizationProvider.Instance.GetTextValue("Gesture.Messages.ImportComplete"), ignoredCount, addcount), settings: new MetroDialogSettings() { AffirmativeButtonText = LocalizationProvider.Instance.GetTextValue("Common.OK"), ColorScheme = MetroDialogColorScheme.Accented, }); }
/// <summary> /// /// </summary> /// <param name="action">Related action</param> /// <returns>Indicates whether the new gesture was added</returns> private bool UpdateGesture(IAction action) { PointPattern[] gesture; if (ApplicationSelector.PatternMap.TryGetValue(action.GestureName, out gesture)) { var existingGesture = GestureManager.Instance.GetMostSimilarGestureName(gesture); if (existingGesture != null) { action.GestureName = existingGesture; } else { if (GestureManager.Instance.GestureExists(action.GestureName)) { action.GestureName = GestureManager.GetNewGestureName(); } GestureManager.Instance.AddGesture(new Gesture(action.GestureName, gesture)); return(true); } } return(false); }