예제 #1
0
        // public static event EventHandler StartCapture;
        public AvailableActions()
        {
            InitializeComponent();

            var actionsSourceView = new ListCollectionView(ActionInfos);                          //创建数据源的视图

            actionsSourceView.GroupDescriptions.Add(new PropertyGroupDescription("GestureName")); //在图中添加分组
            actionsSourceView.SortDescriptions.Add(new SortDescription("GestureName", ListSortDirection.Ascending));
            lstAvailableActions.ItemsSource = actionsSourceView;                                  //绑定数据源

            var applicationSourceView       = new ListCollectionView(_applications);
            var applicationGroupDesctrption = new PropertyGroupDescription("Group");  //设置分组列

            applicationSourceView.GroupDescriptions.Add(applicationGroupDesctrption); //在图中添加分组
            lstAvailableApplication.ItemsSource = applicationSourceView;

            ActionDialog.ActionsChanged += (o, e) =>
            {
                if (lstAvailableApplication.SelectedItem == e.Application)
                {
                    var oldActionInfo =
                        ActionInfos.FirstOrDefault(ai => ai.ActionName.Equals(e.Action.Name, StringComparison.Ordinal));
                    if (oldActionInfo != null)
                    {
                        int index         = ActionInfos.IndexOf(oldActionInfo);
                        var newActionInfo = Action2ActionInfo(e.Action);
                        ActionInfos[index] = newActionInfo;
                        RefreshGroup(e.Action.GestureName);
                        SelectAction(newActionInfo);
                    }
                    else
                    {
                        RefreshActions(false);
                    }
                }
                else
                {
                    BindApplications();
                    _selecteNewestItem = true;
                    lstAvailableApplication.SelectedItem = e.Application;
                    lstAvailableApplication.ScrollIntoView(e.Application);
                }
            };
            AvailableGestures.GestureChanged         += (o, e) => { RefreshActions(true); };
            GestureDefinition.GesturesChanged        += (o, e) => { RefreshActions(true); };
            ApplicationDialog.UserApplicationChanged += (o, e) =>
            {
                BindApplications();
                lstAvailableApplication.SelectedItem = e.Application;
                lstAvailableApplication.ScrollIntoView(e.Application);
            };

            ApplicationManager.OnLoadApplicationsCompleted += (o, e) => { this.Dispatcher.InvokeAsync(BindApplications); };

            if (ApplicationManager.FinishedLoading)
            {
                BindApplications();
            }
        }
예제 #2
0
        private void UserControl_Initialized(object sender, EventArgs eArgs)
        {
            ActionDialog.ActionsChanged += (o, e) =>
            {
                if (lstAvailableApplication.SelectedItem == e.Application)
                {
                    var oldActionInfo =
                        ActionInfos.FirstOrDefault(ai => ai.ActionName.Equals(e.Action.Name, StringComparison.Ordinal));
                    if (oldActionInfo != null)
                    {
                        int index         = ActionInfos.IndexOf(oldActionInfo);
                        var newActionInfo = Action2ActionInfo(e.Action);
                        ActionInfos[index] = newActionInfo;
                        RefreshGroup(e.Action.GestureName);
                        SelectAction(newActionInfo);
                    }
                    else
                    {
                        RefreshActions(false);
                    }
                }
                else
                {
                    BindApplications();
                    _selecteNewestItem = true;
                    lstAvailableApplication.SelectedItem = e.Application;
                    lstAvailableApplication.ScrollIntoView(e.Application);
                }
            };
            AvailableGestures.GestureChanged         += (o, e) => { RefreshActions(true); };
            GestureDefinition.GesturesChanged        += (o, e) => { RefreshActions(true); };
            ApplicationDialog.UserApplicationChanged += (o, e) =>
            {
                BindApplications();
                lstAvailableApplication.SelectedItem = e.Application;
                lstAvailableApplication.ScrollIntoView(e.Application);
            };

            ApplicationManager.OnLoadApplicationsCompleted += (o, e) => { this.Dispatcher.InvokeAsync(BindApplications); };

            if (ApplicationManager.FinishedLoading)
            {
                BindApplications();
            }
        }