Esempio n. 1
0
        protected override void SetupHandler()
        {
            OptionGroup toplevelGroup = Handler.AddGroup(TOP_LEVEL);

            //the toplevel group will show neither in Table view nor in dialog view explicitely
            //it's children will be shown one level above
            toplevelGroup.SetAttribute(TableEditorFactory.RENDERING_HINTS_ATTRIBUTE, (int)TableEditorFactory.RenderingHints.Invisible);
            toplevelGroup.SetAttribute(DefaultEditorFactory.RENDERING_HINTS_ATTRIBUTE, (int)DefaultEditorFactory.RenderingHints.Invisible);

            var sourceIdItem = toplevelGroup.AddString(SourceID, "");
            var targetIdItem = toplevelGroup.AddString(TargetID, "");

            CollectionOptionItem <string> scopeItem = toplevelGroup.AddList(Scope, scopes, ScopeAllEdges);
            var clearItem        = toplevelGroup.AddBool(ClearAllConstraints, false);
            ConstraintManager cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(clearItem, false, sourceIdItem);
            cm.SetEnabledOnValueEquals(clearItem, false, scopeItem);
            cm.SetEnabledOnValueEquals(clearItem, false, targetIdItem);
        }
        /// <summary>
        /// Creates the option handler for the label editing properties.
        /// </summary>
        /// <remarks>
        /// These options either delegate directly to properties of <see cref="GraphEditorInputMode" /> or set some global flag
        /// that is evaluated elsewhere.
        /// </remarks>
        private OptionHandler CreateOptionHandler()
        {
            var graphEditorInputMode = ((GraphEditorInputMode)GraphControl.InputMode);

            var handler = new OptionHandler("Labeling Options");

            OptionGroup currentGroup = handler.AddGroup("General");
            var         labelAddItem = currentGroup.AddBool("Label Creation", true);

            labelAddItem.PropertyChanged += delegate { graphEditorInputMode.AllowAddLabel = (bool)labelAddItem.Value; };

            var labelEditItem = currentGroup.AddBool("Label Editing", true);

            labelEditItem.PropertyChanged +=
                delegate { graphEditorInputMode.AllowEditLabel = (bool)labelEditItem.Value; };

            var hideItem = currentGroup.AddBool("Hide Label during Editing", true);

            hideItem.PropertyChanged += delegate {
                graphEditorInputMode.HideLabelDuringEditing = (bool)hideItem.Value;
            };

            var instantTypingItem = currentGroup.AddBool("Instant Typing", false);

            instantTypingItem.PropertyChanged += delegate { instantTypingEnabled = (bool)instantTypingItem.Value; };

            var useCustomHelperItem = currentGroup.AddBool("Custom Label Helper", false);

            useCustomHelperItem.PropertyChanged += delegate { customHelperEnabled = (bool)useCustomHelperItem.Value; };

            currentGroup = handler.AddGroup("Editable Items");

            // Disable the whole editable items group if neither label editing or adding allowed
            ConstraintManager cm = new ConstraintManager(handler);

            cm.SetEnabledOnCondition(
                ConstraintManager.LogicalCondition.Or(cm.CreateValueEqualsCondition(labelEditItem, true),
                                                      cm.CreateValueEqualsCondition(labelAddItem, true)), currentGroup);

            currentGroup.AddBool("Nodes", true).PropertyChanged += delegate {
                var editNodes = (bool)handler.GetValue("Editable Items", "Nodes");
                if (editNodes)
                {
                    graphEditorInputMode.LabelEditableItems |= GraphItemTypes.Node | GraphItemTypes.NodeLabel;
                }
                else
                {
                    graphEditorInputMode.LabelEditableItems &= ~(GraphItemTypes.Node | GraphItemTypes.NodeLabel);
                }
            };

            currentGroup.AddBool("Edges", true).PropertyChanged += delegate {
                var editEdges = (bool)handler.GetValue("Editable Items", "Edges");
                if (editEdges)
                {
                    graphEditorInputMode.LabelEditableItems |= GraphItemTypes.Edge | GraphItemTypes.EdgeLabel;
                }
                else
                {
                    graphEditorInputMode.LabelEditableItems &= ~(GraphItemTypes.Edge | GraphItemTypes.EdgeLabel);
                }
            };

            currentGroup = handler.AddGroup("Validation");
            var validationItem = currentGroup.AddBool("Enable Validation", false);

            validationItem.PropertyChanged += delegate { validationEnabled = (bool)validationItem.Value; };
            var patternItem = currentGroup.AddString("Pattern", DefaultValidationPattern);

            patternItem.PropertyChanged += delegate { validationPattern = new Regex((string)patternItem.Value, RegexOptions.Compiled); };

            // Editing the pattern doesn't make sense if validation is disabled
            cm.SetEnabledOnValueEquals(validationItem, true, patternItem);

            return(handler);
        }