示例#1
0
        ///<inheritdoc/>
        protected override void ConfigureLayout()
        {
            OptionGroup toplevelGroup   = (OptionGroup)Handler.GetGroupByName(TOP_LEVEL);
            OptionGroup generalGroup    = (OptionGroup)toplevelGroup.GetGroupByName(GENERAL);
            string      operationChoice = (string)generalGroup[OPERATION].Value;

            transformer.Operation             = operationEnum[operationChoice];
            transformer.SubgraphLayoutEnabled = (bool)generalGroup[ACT_ON_SELECTION_ONLY].Value;

            transformer.RotationAngle = (int)toplevelGroup.GetValue(ROTATE, ROTATION_ANGLE);
            if ((bool)toplevelGroup.GetValue(ROTATE, APPLY_BEST_FIT_ROTATION) &&
                ((string)toplevelGroup.GetValue(GENERAL, OPERATION)).Equals(ROTATE))
            {
                CanvasControl cv = Context.Lookup <CanvasControl>();
                if (cv != null)
                {
                    var size = cv.InnerSize;
                    applyBestFitRotation      = true;
                    transformer.RotationAngle =
                        GraphTransformer.FindBestFitRotationAngle(CurrentLayoutGraph, size.Width, size.Height);
                }
            }
            else
            {
                applyBestFitRotation = false;
            }

            transformer.ScaleFactor   = (double)toplevelGroup.GetValue(SCALE, SCALE_FACTOR);
            transformer.ScaleNodeSize = (bool)toplevelGroup.GetValue(SCALE, SCALE_NODE_SIZE);

            transformer.TranslateX = (double)toplevelGroup.GetValue(TRANSLATE, TRANSLATE_X);
            transformer.TranslateY = (double)toplevelGroup.GetValue(TRANSLATE, TRANSLATE_Y);
            LayoutAlgorithm        = transformer;
        }
示例#2
0
        /// <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 toplevelGroup = handler.AddGroup("TOP_LEVEL");

            //the toplevel group will show neither in Table view nor in dialog view explicitely
            toplevelGroup.SetAttribute(TableEditorFactory.RENDERING_HINTS_ATTRIBUTE,
                                       (int)TableEditorFactory.RenderingHints.Invisible);
            toplevelGroup.SetAttribute(DefaultEditorFactory.RENDERING_HINTS_ATTRIBUTE,
                                       (int)DefaultEditorFactory.RenderingHints.Invisible);

            OptionGroup currentGroup = toplevelGroup.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 = toplevelGroup.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)toplevelGroup.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)toplevelGroup.GetValue("Editable Items", "Edges");
                if (editEdges)
                {
                    graphEditorInputMode.LabelEditableItems |= GraphItemTypes.Edge | GraphItemTypes.EdgeLabel;
                }
                else
                {
                    graphEditorInputMode.LabelEditableItems &= ~(GraphItemTypes.Edge | GraphItemTypes.EdgeLabel);
                }
            };

            currentGroup = toplevelGroup.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);
        }