Exemple #1
0
        public void Accept()
        {
            if (this.HasValidationErrors)
            {
                this.ShowValidation(true);
                return;
            }

            try
            {
                foreach (ActionModelConfigurationComponent component in _tabComponent.ContainedComponents)
                {
                    component.Save();
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.Report(ex, SR.MessageActionModelUpdateFailure, Host.DesktopWindow);
            }

            MouseToolSettingsProfile toolProfile = MouseToolSettingsProfile.Current.Clone();

            foreach (KeyValuePair <XMouseButtons, IEnumerable <string> > pair in _mouseButtonMap)
            {
                foreach (string actionId in pair.Value)
                {
                    if (toolProfile.HasEntryByActivationActionId(actionId))
                    {
                        var setting            = toolProfile.GetEntryByActivationActionId(actionId);
                        var defaultMouseButton = _defaultMouseToolsMap.FindAssignment(actionId, XMouseButtonCombo.None);
                        setting.MouseButton                 = pair.Key;
                        setting.InitiallyActive             = _initialMouseToolsMap.IsAssignedToMe(pair.Key, actionId);
                        setting.DefaultMouseButton          = defaultMouseButton.MouseButtons;
                        setting.DefaultMouseButtonModifiers = defaultMouseButton.Modifiers;
                    }
                }
            }
            MouseToolSettingsProfile.Current = toolProfile;
            //TODO (CR Sept 2010): is this method necessary?
            MouseToolSettingsProfile.SaveCurrentAsDefault();

            base.Exit(ApplicationComponentExitCode.Accepted);
        }
Exemple #2
0
            public ImageViewerActionModelConfigurationComponent(string @namespace, string site, CustomizeViewerActionModelsComponent owner)
                : base(@namespace, site, owner._imageViewer.ExportedActions, owner._imageViewer.DesktopWindow, site == _globalToolbarActionSite)
            {
                _owner = owner;

                // just keep a single copy of it for a consistent startup state - we don't store the unsaved changes in here
                _toolProfile = MouseToolSettingsProfile.Current.Clone();

                this.ValidationPolicy = _owner._validationPolicy;

                // update the keystroke and action maps
                foreach (AbstractActionModelTreeLeafAction node in base.ActionNodeMap.ActionNodes)
                {
                    if (node is AbstractActionModelTreeLeafClickAction)
                    {
                        AbstractActionModelTreeLeafClickAction clickActionNode = (AbstractActionModelTreeLeafClickAction)node;
                        if (clickActionNode.KeyStroke != XKeys.None)
                        {
                            if (_owner._keyStrokeMap.IsAssignedToOther(clickActionNode.KeyStroke, clickActionNode.ActionId))
                            {
                                clickActionNode.KeyStroke = XKeys.None;
                            }
                            else
                            {
                                _owner._keyStrokeMap[clickActionNode.KeyStroke] = clickActionNode.ActionId;
                            }
                        }
                    }

                    if (_toolProfile.HasEntryByActivationActionId(node.ActionId))
                    {
                        var mouseToolSetting = _toolProfile.GetEntryByActivationActionId(node.ActionId);
                        var mouseButtonValue = mouseToolSetting.MouseButton.GetValueOrDefault(XMouseButtons.Left);
                        if (mouseButtonValue != XMouseButtons.None)
                        {
                            if (mouseToolSetting.InitiallyActive.GetValueOrDefault(false))
                            {
                                if (!_owner._initialMouseToolsMap.IsAssignedToOther(mouseButtonValue, node.ActionId))
                                {
                                    _owner._initialMouseToolsMap[mouseButtonValue] = node.ActionId;
                                }
                            }
                            if (!_owner._mouseButtonMap[mouseButtonValue].Contains(node.ActionId))
                            {
                                _owner._mouseButtonMap.Add(mouseButtonValue, node.ActionId);
                            }
                        }
                        var defaultMouseButtonValue     = mouseToolSetting.DefaultMouseButton.GetValueOrDefault(XMouseButtons.None);
                        var defaultMouseButtonModifiers = mouseToolSetting.DefaultMouseButtonModifiers.GetValueOrDefault(ModifierFlags.None);
                        if (defaultMouseButtonValue != XMouseButtons.None)
                        {
                            var defaultMouseButton = new XMouseButtonCombo(defaultMouseButtonValue, defaultMouseButtonModifiers);
                            if (!_owner._defaultMouseToolsMap.IsAssignedToOther(defaultMouseButton, node.ActionId))
                            {
                                _owner._defaultMouseToolsMap[defaultMouseButton] = node.ActionId;
                            }
                        }
                    }
                }

                foreach (string actionId in base.ActionNodeMap.ActionIds)
                {
                    _owner._actionMap.AddRange(actionId, base.ActionNodeMap[actionId]);
                }
            }