Exemplo n.º 1
0
        private List <IAction> ConvertLegacyActions(List <GestureSign.Applications.Action> legacyActions)
        {
            if (legacyActions == null)
            {
                return(null);
            }
            List <IAction> newActions = new List <IAction>();

            foreach (var grouping in legacyActions.GroupBy(a => a.GestureName))
            {
                IAction newAction = new Action()
                {
                    ActivateWindow = grouping.First().ActivateWindow,
                    Condition      = grouping.First().Condition,
                    GestureName    = grouping.Key,
                    Name           = grouping.First().Name,
                };
                foreach (var legacyAction in grouping)
                {
                    newAction.AddCommand(new Command
                    {
                        CommandSettings = legacyAction.ActionSettings,
                        IsEnabled       = legacyAction.IsEnabled,
                        Name            = legacyAction.Name,
                        PluginClass     = legacyAction.PluginClass,
                        PluginFilename  = legacyAction.PluginFilename
                    });
                }
                newActions.Add(newAction);
            }
            return(newActions);
        }
Exemplo n.º 2
0
        private void NewCommandMenuItem_Click(object sender, RoutedEventArgs e)
        {
            var selectedApplication = lstAvailableApplication.SelectedItem as IApplication;

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

            var newCommand = new Command
            {
                Name = LocalizationProvider.Instance.GetTextValue("Action.NewCommand")
            };

            Dispatcher.Invoke(() =>
            {
                lstAvailableActions.SelectedItem = null;
                var newAction = new GestureSign.Common.Applications.Action();
                newAction.AddCommand(newCommand);
                selectedApplication.AddAction(newAction);
                ApplicationManager.Instance.SaveApplications();
            }, DispatcherPriority.Input);
        }
Exemplo n.º 3
0
        private void PasteToNewActionMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (_commandClipboard.Count == 0)
            {
                return;
            }

            var targetApplication = lstAvailableApplication.SelectedItem as IApplication;

            if (targetApplication == null)
            {
                return;
            }

            lstAvailableActions.SelectedItem = null;
            foreach (var actionGroup in _commandClipboard.GroupBy(ci => ci.Action))
            {
                var sourceAction = actionGroup.Key;
                var newAction    = new GestureSign.Common.Applications.Action()
                {
                    Condition         = sourceAction.Condition,
                    ContinuousGesture = sourceAction.ContinuousGesture,
                    GestureName       = sourceAction.GestureName,
                    Commands          = new List <ICommand>(),
                };
                targetApplication.AddAction(newAction);

                foreach (var info in actionGroup)
                {
                    if (_cutActionSource != null)
                    {
                        info.Action.RemoveCommand(info.Command);
                    }

                    var newCommand = ((Command)info.Command).Clone() as Command;
                    newCommand.Name = ApplicationManager.GetNextCommandName(newCommand.Name, info.Action);
                    newAction.AddCommand(newCommand);
                }
            }

            if (_cutActionSource != null)
            {
                _cutActionSource = null;
                _commandClipboard.Clear();
            }

            ApplicationManager.Instance.SaveApplications();
        }
Exemplo n.º 4
0
        private void btnAddAction_Click(object sender, RoutedEventArgs e)
        {
            var selectedApplication = lstAvailableApplication.SelectedItem as IApplication;

            if (selectedApplication == null)
            {
                lstAvailableApplication.SelectedIndex = 0;
                selectedApplication = lstAvailableApplication.SelectedItem as IApplication;
                if (selectedApplication == null)
                {
                    return;
                }
            }
            var ci = lstAvailableActions.SelectedItem as CommandInfo;

            if (ci == null)
            {
                var newCommand = new Command
                {
                    Name = LocalizationProvider.Instance.GetTextValue("Action.NewCommand")
                };
                Dispatcher.Invoke(() =>
                {
                    lstAvailableActions.SelectedItem = null;
                    var newAction = new GestureSign.Common.Applications.Action();
                    newAction.AddCommand(newCommand);
                    selectedApplication.AddAction(newAction);
                    ApplicationManager.Instance.SaveApplications();
                }, DispatcherPriority.Input);
            }
            else
            {
                var element = (FrameworkElement)sender;
                element.ContextMenu.PlacementTarget = element;
                element.ContextMenu.Placement       = System.Windows.Controls.Primitives.PlacementMode.Top;
                element.ContextMenu.IsOpen          = true;
            }
        }
Exemplo n.º 5
0
        private void btnAddAction_Click(object sender, RoutedEventArgs e)
        {
            var selectedApplication = lstAvailableApplication.SelectedItem as IApplication;

            if (selectedApplication == null)
            {
                lstAvailableApplication.SelectedIndex = 0;
                selectedApplication = lstAvailableApplication.SelectedItem as IApplication;
                if (selectedApplication == null)
                {
                    return;
                }
            }
            var ci = lstAvailableActions.SelectedItem as CommandInfo;

            var newCommand = new Command
            {
                Name = LocalizationProvider.Instance.GetTextValue("Action.NewCommand")
            };

            Dispatcher.Invoke(() =>
            {
                lstAvailableActions.SelectedItem = null;
                if (ci == null)
                {
                    var newAction = new GestureSign.Common.Applications.Action();
                    newAction.AddCommand(newCommand);
                    selectedApplication.AddAction(newAction);
                }
                else
                {
                    int commandIndex = ci.Action.Commands.ToList().IndexOf(ci.Command);
                    ci.Action.InsertCommand(commandIndex + 1, newCommand);
                }
                ApplicationManager.Instance.SaveApplications();
            }, DispatcherPriority.Input);
        }