Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
                }
            }
        }