예제 #1
0
        private static void Update()
        {
            if (_gestureItems == null)
            {
                _gestureItems = new ObservableCollection <GestureItem>();
            }
            else
            {
                _gestureItems.Clear();
            }

            // Get all available gestures from gesture manager
            IEnumerable <IGesture> results = GestureManager.Instance.Gestures.OrderBy(g => g.Name);

            var color = (Color)Application.Current.Resources["HighlightColor"];

            foreach (IGesture gesture in results)
            {
                GestureItem newItem = new GestureItem()
                {
                    Image = GestureImage.CreateImage(gesture.PointPatterns, new Size(65, 65), color),
                    Name  = gesture.Name
                };
                GestureItems.Add(newItem);
            }
        }
예제 #2
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var    gestureMap  = values[0] as Dictionary <string, GestureItem>;
            string gestureName = values[1] as string;

            if (gestureName == null || gestureMap == null)
            {
                return(null);
            }

            GestureItem gi = null;

            if (gestureMap.TryGetValue(gestureName, out gi))
            {
                return(gi?.GestureImage);
            }
            return(null);
        }
예제 #3
0
        private static void Update()
        {
            if (_gestureItems == null)
            {
                _gestureItems = new ObservableCollection <GestureItem>();
            }
            else
            {
                _gestureItems.Clear();
            }

            // Get all available gestures from gesture manager
            var apps = ApplicationManager.Instance.Applications.Where(app => !(app is IgnoredApp)).ToList();

            var color = (Color)Application.Current.Resources["HighlightColor"];

            foreach (var g in GestureManager.Instance.Gestures)
            {
                var    gesture = (Gesture)g;
                string result  = string.Empty;
                foreach (IApplication application in apps)
                {
                    if (application.Actions.Any(a => a.GestureName == gesture.Name))
                    {
                        result += $" {application.Name},";
                    }
                }
                result = result.TrimEnd(',');

                GestureItem newItem = new GestureItem()
                {
                    GestureImage = GestureImage.CreateImage(gesture.PointPatterns, new Size(60, 60), color),
                    Features     = GestureManager.Instance.GetNewGestureId(gesture.PointPatterns),
                    PatternCount = gesture?.PointPatterns.Max(p => p.Points.Count) ?? 0,
                    Applications = result,
                    Gesture      = gesture
                };
                GestureItems.Add(newItem);
            }
            GestureMap = GestureItems.ToDictionary(gi => gi.Gesture.Name);
            GlobalPropertyChanged?.Invoke(typeof(GestureItemProvider), nameof(InstanceGestureMap));
        }
예제 #4
0
        private void AddCommandInfo(CommandInfo commandInfo)
        {
            string      features;
            int         patternCount;
            GestureItem gi = null;

            if (commandInfo.Action?.GestureName != null && GestureItemProvider.GestureMap.TryGetValue(commandInfo.Action.GestureName, out gi))
            {
                features     = gi.Features;
                patternCount = gi.PatternCount;
            }
            else
            {
                features     = string.Empty;
                patternCount = 0;
            }
            commandInfo.GestureFeatures = features;
            commandInfo.PatternCount    = patternCount;
            CommandInfos.Add(commandInfo);
        }
예제 #5
0
        private static void Update()
        {
            if (_gestureItems == null)
            {
                _gestureItems = new ObservableCollection <GestureItem>();
            }
            else
            {
                _gestureItems.Clear();
            }

            // Get all available gestures from gesture manager
            IEnumerable <IGesture> results = GestureManager.Instance.Gestures.OrderBy(g => g.PointPatterns?.Max(p => p.Points.Count));
            var apps = ApplicationManager.Instance.Applications.Where(app => !(app is IgnoredApp)).ToList();

            foreach (var g in results)
            {
                var    gesture = (Gesture)g;
                string result  = string.Empty;
                foreach (IApplication application in apps)
                {
                    if (application.Actions.Any(a => a.GestureName == gesture.Name))
                    {
                        result += $" {application.Name},";
                    }
                }
                result = result.TrimEnd(',');

                GestureItem newItem = new GestureItem()
                {
                    Applications = result,
                    PointPattern = gesture.PointPatterns,
                    Name         = gesture.Name,
                };
                GestureItems.Add(newItem);
            }
            GlobalPropertyChanged?.Invoke(typeof(GestureItemProvider), nameof(PatternMap));
        }
예제 #6
0
 public void Remove(GestureItem item)
 {
     Gestures.Remove(item);
     Provider.RemoveGesture(item.Gesture);
 }
예제 #7
0
 public void Record(GestureItem item)
 {
     timer_ = new Timer(1000);
     timer_.Elapsed += UpdateRecordTimer;
     recordDelay_ = 3;
     recordGesture_ = item;
     captureMode_ = true;
     UpdateRecordTimer(this, null);
     timer_.Start();
 }
예제 #8
0
 public void NewGesture()
 {
     var newGest = new GestureItem(this, new Gesture());
     Gestures.Add(newGest);
     SelectedGesture = newGest;
     newGest.IsEditing = true;
 }