コード例 #1
0
ファイル: AvailableActions.cs プロジェクト: Sin96/GestureSign
        private void MoveDownButton_Click(object sender, RoutedEventArgs e)
        {
            var selected        = (lstAvailableActions.SelectedItem as ActionInfo);
            var actionInfoGroup =
                ActionInfos.Where(ai => ai.GestureName.Equals(selected.GestureName, StringComparison.Ordinal)).ToList();
            int index = actionInfoGroup.IndexOf(selected);

            if (index + 1 < actionInfoGroup.Count)
            {
                ActionInfos.Move(ActionInfos.IndexOf(selected), ActionInfos.IndexOf(actionInfoGroup[index + 1]));
                RefreshGroup(selected.GestureName);
                lstAvailableActions.SelectedItem = selected;


                IApplication selectedApplication = lstAvailableApplication.SelectedItem as IApplication;
                if (selectedApplication == null)
                {
                    return;
                }

                int selectedIndex = selectedApplication.Actions.FindIndex(a => a.Name.Equals(selected.ActionName, StringComparison.Ordinal));
                int nextIndex     = selectedApplication.Actions.FindIndex(selectedIndex + 1,
                                                                          a => a.GestureName.Equals(selected.GestureName, StringComparison.Ordinal));

                var temp = selectedApplication.Actions[nextIndex];
                selectedApplication.Actions[nextIndex]     = selectedApplication.Actions[selectedIndex];
                selectedApplication.Actions[selectedIndex] = temp;

                ApplicationManager.Instance.SaveApplications();
            }
        }
コード例 #2
0
ファイル: AvailableActions.cs プロジェクト: Sin96/GestureSign
        void RefreshGroup(string gestureName)
        {
            lstAvailableActions.SelectedItem = null;
            var temp = ActionInfos.Where(ai => ai.GestureName.Equals(gestureName, StringComparison.Ordinal)).ToList();

            foreach (ActionInfo ai in temp)
            {
                int i = ActionInfos.IndexOf(ai);
                ActionInfos.Remove(ai);
                ActionInfos.Insert(i, ai);
            }
        }
コード例 #3
0
ファイル: AvailableActions.cs プロジェクト: Sin96/GestureSign
        private void RefreshActions(bool refreshAll)
        {
            var selectedApplication = lstAvailableApplication.SelectedItem as IApplication;

            if (selectedApplication == null)
            {
                return;
            }
            if (refreshAll)
            {
                Action <object> refreshAction = (o) =>
                {
                    Dispatcher.Invoke(() => { ActionInfos.Clear(); }, DispatcherPriority.Loaded);
                    AddActionsToGroup(selectedApplication.Actions);
                };

                if (_addActionTask == null)
                {
                    _addActionTask = Task.Factory.StartNew(refreshAction, null);
                }
                else
                {
                    _addActionTask = _addActionTask.ContinueWith(refreshAction);
                }
            }
            else
            {
                _selecteNewestItem = true;
                var newApp     = selectedApplication.Actions.Where(a => !ActionInfos.Any(ai => ai.Equals(a))).ToList();
                var deletedApp = ActionInfos.Where(ai => !selectedApplication.Actions.Any(ai.Equals)).ToList();

                if (newApp.Count == 1 && deletedApp.Count == 1)
                {
                    var newActionInfo = Action2ActionInfo(newApp[0]);
                    ActionInfos[ActionInfos.IndexOf(deletedApp[0])] = newActionInfo;
                    RefreshGroup(newApp[0].GestureName);
                    SelectAction(newActionInfo);
                }
                else
                {
                    foreach (ActionInfo ai in deletedApp)
                    {
                        ActionInfos.Remove(ai);
                    }
                    AddActionsToGroup(newApp);
                }
            }
        }
コード例 #4
0
ファイル: AvailableActions.cs プロジェクト: Sin96/GestureSign
        private void EnableRelevantButtons()
        {
            cmdDelete.IsEnabled = cmdEdit.IsEnabled = lstAvailableActions.SelectedItems.Count == 1;

            var selectedActionInfo = (lstAvailableActions.SelectedItem as ActionInfo);

            if (selectedActionInfo == null)
            {
                MoveUpButton.IsEnabled = MoveDownButton.IsEnabled = false;
            }
            else
            {
                var actionInfoGroup = ActionInfos.Where(ai => ai.GestureName.Equals(selectedActionInfo.GestureName, StringComparison.Ordinal)).ToList();
                int index           = actionInfoGroup.IndexOf(selectedActionInfo);

                MoveUpButton.IsEnabled   = index != 0;
                MoveDownButton.IsEnabled = index != actionInfoGroup.Count - 1;
            }
        }