public void Initialize(IEnumerable <IApplication> apps, IEnumerable <IGesture> gestures, bool showIgnore = false, bool selecteAll = false)
        {
            if (showIgnore)
            {
                AppTabControl.SelectedIndex = 1;
            }

            var newUserAppList = new List <AppListItem>();
            var newIgnoredApp  = new List <AppListItem>();

            foreach (var app in apps)
            {
                IgnoredApp ignoredApp = app as IgnoredApp;
                if (ignoredApp != null)
                {
                    newIgnoredApp.Add(new AppListItem(ignoredApp, null, selecteAll));
                }
                else
                {
                    var ali = new AppListItem(app, null, selecteAll);
                    ali.ActionItemList.ForEach(a => a.IsSelected = selecteAll);
                    newUserAppList.Add(ali);
                }
            }
            var color = (Color)Application.Current.Resources["HighlightColor"];

            GestureMap = gestures.ToDictionary(g => g.Name, g => new GestureItem()
            {
                Gesture      = g,
                GestureImage = GestureImage.CreateImage(g.PointPatterns, new Size(56, 56), color),
            });
            UserAppList    = newUserAppList;
            IgnoredAppList = newIgnoredApp;
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _color = (Color)Application.Current.Resources["HighlightColor"];

            if (_currentPointPatterns != null)
            {
                imgGestureThumbnail.Source = GestureImage.CreateImage(_currentPointPatterns, new Size(65, 65), _color);
            }

            if (_oldGestureName == null)
            {
                NamedPipe.SendMessageAsync("StartTeaching", "GestureSignDaemon");
                Title = LocalizationProvider.Instance.GetTextValue("GestureDefinition.Title");
            }
            else
            {
                Title = LocalizationProvider.Instance.GetTextValue("GestureDefinition.Rename");
                txtGestureName.Text = _oldGestureName; //this.txtGestureName.Text

                DrawGestureTextBlock.Visibility = ResetButton.Visibility = StackUpGestureButton.Visibility = Visibility.Collapsed;

                txtGestureName.Focus();
                txtGestureName.SelectAll();
            }
        }
Ejemplo n.º 4
0
        private async void MessageProcessor_GotNewGesture(object sender, Gesture e)
        {
            SimilarGestureName         = e.Name;
            _currentPointPatterns      = e.PointPatterns;
            imgGestureThumbnail.Source = GestureImage.CreateImage(_currentPointPatterns, new Size(65, 65), _color);

            await SetTrainingState(false);

            StackUpGestureButton.IsEnabled = _currentPointPatterns.Length < 3;
        }
Ejemplo n.º 5
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var pattern = value as PointPattern[];
            int height;

            if (int.TryParse(parameter as string, out height))
            {
                var color = (Color)Application.Current.Resources["HighlightColor"];
                return(GestureImage.CreateImage(pattern, new Size(height, height), color));
            }
            ;
            return(null);
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var color = (Color)Application.Current.Resources["HighlightColor"];

            this.imgGestureThumbnail.Source = GestureImage.CreateImage(_capturedPointPatterns, new Size(65, 65), color);

            if (String.IsNullOrEmpty(GestureManager.Instance.GestureName))
            {
                this.ExistingTextBlock.Visibility = this.ExistingGestureImage.Visibility = Visibility.Collapsed;
                this.txtGestureName.Focus();
            }
            else
            {
                this.txtGestureName.Text = GestureManager.Instance.GestureName;//this.txtGestureName.Text
                if (!reName)
                {
                    cmdDone.Content          = LocalizationProvider.Instance.GetTextValue("Common.Overwrite");
                    txtGestureName.IsEnabled = false;

                    var gesture = GestureManager.Instance.GetNewestGestureSample();
                    if (gesture != null)
                    {
                        this.ExistingGestureImage.Source = GestureImage.CreateImage(gesture.PointPatterns, new Size(65, 65), color);
                    }
                    return;
                }

                OverlayGestureButton.Visibility = cmdNext.Visibility = ExistingTextBlock.Visibility = ExistingGestureImage.Visibility = Visibility.Collapsed;

                this.txtGestureName.Focus();
                this.txtGestureName.SelectAll();
            }
            cmdDone.Content = LocalizationProvider.Instance.GetTextValue("Common.Save");

            OverlayGestureButton.IsEnabled = _capturedPointPatterns.Length < 3;
        }