コード例 #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
            ((IOptionItem)toplevelGroup).Attributes[TableEditorFactory.RenderingHintsAttribute]   = TableEditorFactory.RenderingHints.Invisible;
            ((IOptionItem)toplevelGroup).Attributes[DefaultEditorFactory.RenderingHintsAttribute] = DefaultEditorFactory.RenderingHints.Invisible;

            OptionGroup spcg = toplevelGroup.AddGroup(SourcePortConstraints);

            spcg.Add(PortConstraintStr, PortConstraintType.Any).Attributes[OptionItem.SupportNullValueAttribute] = false;
            spcg.AddBool(StrongPortConstraint, false);
            OptionGroup tpcg = toplevelGroup.AddGroup(TargetPortConstraints);

            tpcg.Add(PortConstraintStr, PortConstraintType.Any).Attributes[OptionItem.SupportNullValueAttribute] = false;
            tpcg.AddBool(StrongPortConstraint, false);
            CollectionOptionItem <string> scopeItem = toplevelGroup.AddList(Scope, scopes, ScopeAllEdges);
            var clearItem        = toplevelGroup.AddBool(ClearAllConstraints, false);
            ConstraintManager cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(clearItem, false, spcg);
            cm.SetEnabledOnValueEquals(clearItem, false, scopeItem);
            cm.SetEnabledOnValueEquals(clearItem, false, tpcg);
        }
        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);

            OptionGroup spcg = toplevelGroup.AddGroup(SourcePortConstraints);

            spcg.AddGeneric(PortConstraintStr, PortConstraintType.Any).SetAttribute(OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE,
                                                                                    false);
            spcg.AddBool(StrongPortConstraint, false);
            OptionGroup tpcg = toplevelGroup.AddGroup(TargetPortConstraints);

            tpcg.AddGeneric(PortConstraintStr, PortConstraintType.Any).SetAttribute(OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE,
                                                                                    false);
            tpcg.AddBool(StrongPortConstraint, false);
            CollectionOptionItem <string> scopeItem = toplevelGroup.AddList(Scope, scopes, ScopeAllEdges);
            BoolOptionItem    clearItem             = toplevelGroup.AddBool(ClearAllConstraints, false);
            ConstraintManager cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(clearItem, false, spcg);
            cm.SetEnabledOnValueEquals(clearItem, false, scopeItem);
            cm.SetEnabledOnValueEquals(clearItem, false, tpcg);
        }
コード例 #3
0
        ///<inheritdoc/>
        protected override void SetupHandler()
        {
            ConstraintManager cm            = new ConstraintManager(Handler);
            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);

            OptionGroup generalGroup  = toplevelGroup.AddGroup(GENERAL);
            OptionItem  operationItem = generalGroup.AddList(OPERATION, operationEnum.Keys, SCALE);

            generalGroup.AddBool(ACT_ON_SELECTION_ONLY, false);

            OptionGroup rotateGroup = toplevelGroup.AddGroup(ROTATE);

            cm.SetEnabledOnValueEquals(operationItem, ROTATE, rotateGroup);
            rotateGroup.AddInt(ROTATION_ANGLE, (int)transformer.RotationAngle, -360, 360);
            rotateGroup.AddBool(APPLY_BEST_FIT_ROTATION, applyBestFitRotation);

            OptionGroup scaleGroup = toplevelGroup.AddGroup(SCALE);

            cm.SetEnabledOnValueEquals(operationItem, SCALE, scaleGroup);
            scaleGroup.AddDouble(SCALE_FACTOR, transformer.ScaleFactorX, 0.1, 10.0);
            scaleGroup.AddBool(SCALE_NODE_SIZE, transformer.ScaleNodeSize);

            OptionGroup translateGroup = toplevelGroup.AddGroup(TRANSLATE);

            cm.SetEnabledOnValueEquals(operationItem, TRANSLATE, translateGroup);
            translateGroup.AddDouble(TRANSLATE_X, transformer.TranslateX);
            translateGroup.AddDouble(TRANSLATE_Y, transformer.TranslateY);
        }
コード例 #4
0
        ///<inheritdoc/>
        protected override void SetupHandler()
        {
            createRouter();
            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 layoutGroup = toplevelGroup.AddGroup(LAYOUT_OPTIONS);
            OptionGroup costGroup   = toplevelGroup.AddGroup(COST);

            if (router.PathFinderStrategy is OrthogonalPatternEdgeRouter)
            {
                OrthogonalPatternEdgeRouter oper = (OrthogonalPatternEdgeRouter)router.PathFinderStrategy;
                layoutGroup.AddList(PATHFINDER, pathFinderList, ORTHOGONAL_PATTERN_PATH_FINDER);
                layoutGroup.AddList(SCOPE, scopes, SCOPE_ALL_EDGES);
                layoutGroup.AddDouble(MINIMUM_DISTANCE, oper.MinimumDistance);
                layoutGroup.AddBool(ACTIVATE_GRID_ROUTING, oper.GridRouting);
                layoutGroup.AddDouble(GRID_SPACING, oper.GridSpacing, 2.0, Double.MaxValue);

                ConstraintManager cm = new ConstraintManager(Handler);
                cm.SetEnabledOnValueEquals(layoutGroup[ACTIVATE_GRID_ROUTING], true, layoutGroup[GRID_SPACING]);

                costGroup.AddDouble(BEND_COST, oper.BendCost);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[BEND_COST]);
                costGroup.AddDouble(EDGE_CROSSING_COST, oper.EdgeCrossingCost);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[EDGE_CROSSING_COST]);
                costGroup.AddDouble(NODE_CROSSING_COST, oper.NodeCrossingCost);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[NODE_CROSSING_COST]);
            }
            else
            {
                layoutGroup.AddList(PATHFINDER, pathFinderList, ORTHOGONAL_PATTERN_PATH_FINDER);
                layoutGroup.AddList(SCOPE, scopes, SCOPE_ALL_EDGES);
                layoutGroup.AddDouble(MINIMUM_DISTANCE, 10);
                layoutGroup.AddBool(ACTIVATE_GRID_ROUTING, true);
                layoutGroup.AddDouble(GRID_SPACING, 20);

                ConstraintManager cm = new ConstraintManager(Handler);
                cm.SetEnabledOnValueEquals(layoutGroup[ACTIVATE_GRID_ROUTING], true, layoutGroup[GRID_SPACING]);

                costGroup.AddDouble(BEND_COST, 1);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[BEND_COST]);
                costGroup.AddDouble(EDGE_CROSSING_COST, 5);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[EDGE_CROSSING_COST]);
                costGroup.AddDouble(NODE_CROSSING_COST, 50);
                cm.SetEnabledOnValueEquals(layoutGroup[PATHFINDER], ORTHOGONAL_PATTERN_PATH_FINDER, costGroup[NODE_CROSSING_COST]);
            }
        }
コード例 #5
0
        static OptionHandler CreateHandler(GraphEditorForm form)
        {
            GraphControl         gc   = form.GraphControl;
            IGraph               g    = form.Graph;
            GraphEditorInputMode geim = form.GraphEditorInputMode;


            OptionHandler handler      = new OptionHandler(NAME);
            OptionGroup   controlGroup = handler.AddGroup(UI_DEFAULTS);

            controlGroup.AddDouble(HitTestRadius, gc.HitTestRadius);
            controlGroup.AddBool(AutoRemoveEmptyLabels, geim.AutoRemoveEmptyLabels);

//      var gridEnabledItem = controlGroup.AddBool(GridEnabled, form.Grid.Enabled);
            var gridVisibleItem  = controlGroup.AddBool(GridVisible, form.GridVisible);
            var gridWidthItem    = controlGroup.AddInt(GridWidth, form.GridWidth);
            var gridSnapTypeItem = controlGroup.AddList <GridSnapTypes>(GridSnapeType, new List <GridSnapTypes>
            {
                GridSnapTypes.All, GridSnapTypes.GridPoints, GridSnapTypes.HorizontalLines, GridSnapTypes.Lines, GridSnapTypes.None, GridSnapTypes.VerticalLines
            }, form.GridSnapType);

            ConstraintManager cm = new ConstraintManager(handler);

            cm.SetEnabledOnCondition(
                ConstraintManager.LogicalCondition.Or(cm.CreateValueEqualsCondition(gridVisibleItem, true),
                                                      cm.CreateValueEqualsCondition(gridVisibleItem, true)),
                gridWidthItem);
            cm.SetEnabledOnValueEquals(gridVisibleItem, true, gridSnapTypeItem);

            if (g != null)
            {
                OptionGroup graphGroup = handler.AddGroup(GRAPH_SETTINGS);
                graphGroup.AddBool(AutoAdjustPreferredLabelSize, g.NodeDefaults.Labels.AutoAdjustPreferredSize);
                graphGroup.AddBool(AutoCleanupPorts, g.NodeDefaults.Ports.AutoCleanUp);
                OptionGroup sharingGroup = graphGroup.AddGroup(SHARING_SETTINGS);

                sharingGroup.AddBool(ShareDefaultNodeStyleInstance, g.NodeDefaults.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultEdgeStyleInstance, g.EdgeDefaults.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultNodeLabelStyleInstance, g.NodeDefaults.Labels.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultEdgeLabelStyleInstance, g.EdgeDefaults.Labels.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultPortStyleInstance, g.NodeDefaults.Ports.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultNodeLabelModelParameter, g.NodeDefaults.Labels.ShareLayoutParameterInstance);
                sharingGroup.AddBool(ShareDefaultEdgeLabelModelParameter, g.EdgeDefaults.Labels.ShareLayoutParameterInstance);
            }
            OptionGroup miscGroup  = handler.AddGroup(MISC_SETTINGS);
            UndoEngine  undoEngine = form.Graph.GetUndoEngine();

            if (undoEngine != null)
            {
                miscGroup.AddInt(UndoEngine_Size, undoEngine.Size);
            }
            return(handler);
        }
コード例 #6
0
        private void SetupHandler()
        {
            handler = new OptionHandler(SnappingConfiguration);
            OptionGroup currentGroup = handler.AddGroup(CollectSnapLinesGroup);

            currentGroup.AddBool(CollectNodePairSnapLines, true).PropertyChanged       += OnSnappingChanged;
            currentGroup.AddBool(CollectNodePairCenterSnapLines, true).PropertyChanged += OnSnappingChanged;
            currentGroup.AddBool(CollectSameSizeSnapLines, true).PropertyChanged       += OnSnappingChanged;
            currentGroup.AddBool(CollectNodeSnapLines, true).PropertyChanged           += OnSnappingChanged;
            currentGroup.AddBool(CollectEdgeSnapLines, true).PropertyChanged           += OnSnappingChanged;
            currentGroup.AddBool(CollectPortSnapLines, true).PropertyChanged           += OnSnappingChanged;
            currentGroup.AddBool(OrthogonalMovement, false).PropertyChanged            += OnSnappingChanged;

            OptionGroup innerGroup = currentGroup.AddGroup(SnappingDistancesGroup);

            innerGroup.AddDouble(NodeToNode, 50).PropertyChanged += OnSnappingChanged;
            innerGroup.AddDouble(NodeToEdge, 30).PropertyChanged += OnSnappingChanged;
            innerGroup.AddDouble(EdgeToEdge, 40).PropertyChanged += OnSnappingChanged;

            currentGroup = handler.AddGroup(OrthogonalSnappingGroup);
            currentGroup.AddBool(OrthogonalPorts, true).PropertyChanged        += OnSnappingChanged;
            currentGroup.AddBool(OrthogonalBends, true).PropertyChanged        += OnSnappingChanged;
            currentGroup.AddBool(OrthogonalEdgeCreation, true).PropertyChanged += OnSnappingChanged;
            currentGroup.AddBool(OrthogonalEdgeEditing, false).PropertyChanged += OnSnappingChanged;

            currentGroup = handler.AddGroup(SnappingElementsGroup);
            currentGroup.AddBool(SnapNodes, true).PropertyChanged         += OnSnappingChanged;
            currentGroup.AddBool(SnapBends, true).PropertyChanged         += OnSnappingChanged;
            currentGroup.AddBool(SnapAdjacentBends, true).PropertyChanged += OnSnappingChanged;
            currentGroup.AddBool(SnapSegments, true).PropertyChanged      += OnSnappingChanged;

            currentGroup = handler.AddGroup(GridGroup);
            currentGroup.AddOptionItem(
                new CollectionOptionItem <GridSnapTypes>(GridSnapping,
                                                         new List <GridSnapTypes> {
                GridSnapTypes.All, GridSnapTypes.GridPoints, GridSnapTypes.Lines, GridSnapTypes.VerticalLines, GridSnapTypes.HorizontalLines, GridSnapTypes.None
            },
                                                         GridSnapTypes.None
                                                         )).PropertyChanged += OnSnappingChanged;
            currentGroup.AddInt(GridHorizontalWidth, 50).PropertyChanged    += OnGridHorizontalWidthChanged;
            currentGroup.AddInt(GridVerticalWidth, 50).PropertyChanged      += OnGridVerticalWidthChanged;
            currentGroup.AddInt(GridSnapDistance, 10).PropertyChanged       += OnGridSnapDistanceChanged;
        }
コード例 #7
0
        ///<inheritdoc/>
        protected override void SetupHandler()
        {
            CreateOrganic();

            ConstraintManager cm          = new ConstraintManager(Handler);
            OptionGroup       visualGroup = Handler.AddGroup(VISUAL);

            visualGroup.AddList(SCOPE, scopes.Keys, SCOPE_ALL);
            visualGroup.AddInt(PREFERRED_EDGE_LENGTH, (int)organic.PreferredEdgeLength, 5, int.MaxValue);
            IOptionItem considerNodeLabelsItem = visualGroup.AddBool(CONSIDER_NODE_LABELS, organic.ConsiderNodeLabels);
            IOptionItem allowNodeOverlapsItem  = visualGroup.AddBool(ALLOW_NODE_OVERLAPS, organic.NodeOverlapsAllowed);

            IOptionItem minDistItem = visualGroup.AddDouble(MINIMAL_NODE_DISTANCE, 10, 0, double.MaxValue);
            ICondition  condition   = ConstraintManager.LogicalCondition.Or(cm.CreateValueEqualsCondition(allowNodeOverlapsItem, false),
                                                                            cm.CreateValueEqualsCondition(considerNodeLabelsItem, true));

            cm.SetEnabledOnCondition(condition, minDistItem);

            visualGroup.AddBool(AVOID_NODE_EDGE_OVERLAPS, organic.NodeEdgeOverlapAvoided);
            cm.SetEnabledOnValueEquals(considerNodeLabelsItem, false, allowNodeOverlapsItem);

            visualGroup.AddDouble(COMPACTNESS, organic.CompactnessFactor, 0, 1);
            visualGroup.AddBool(USE_AUTO_CLUSTERING, organic.ClusterNodes);
            visualGroup.AddDouble(AUTO_CLUSTERING_QUALITY, organic.ClusteringQuality, 0, 1);
            cm.SetEnabledOnValueEquals(visualGroup[USE_AUTO_CLUSTERING], true, visualGroup[AUTO_CLUSTERING_QUALITY]);

            OptionGroup outputRestrictionsGroup = Handler.AddGroup(RESTRICTIONS);

            OptionItem outputRestrictionsItem =
                outputRestrictionsGroup.AddList(RESTRICT_OUTPUT, outputRestrictions, NONE);

            OptionGroup outputCageGroup = outputRestrictionsGroup.AddGroup(BOUNDS);

            ICondition cond = cm.CreateValueIsOneOfCondition(outputRestrictionsItem, OUTPUT_CAGE, OUTPUT_ELLIPTICAL_CAGE);

            cm.SetEnabledOnCondition(cond, outputCageGroup);

            //IOptionItem rectCageUseViewItem = new BoolOptionItem(RECT_CAGE_USE_VIEW, true);
            IOptionItem rectCageUseViewItem = outputCageGroup.AddBool(RECT_CAGE_USE_VIEW, true);
            IOptionItem cageXItem           = outputCageGroup.AddDouble(CAGE_X, 0.0d);
            IOptionItem cageYItem           = outputCageGroup.AddDouble(CAGE_Y, 0.0d);
            IOptionItem cageWidthItem       = outputCageGroup.AddDouble(CAGE_WIDTH, 1000.0d, 1, double.MaxValue);
            IOptionItem cageHeightItem      = outputCageGroup.AddDouble(CAGE_HEIGHT, 1000.0d, 1, double.MaxValue);

            cm.SetEnabledOnValueEquals(rectCageUseViewItem, false, cageXItem);
            cm.SetEnabledOnValueEquals(rectCageUseViewItem, false, cageYItem);
            cm.SetEnabledOnValueEquals(rectCageUseViewItem, false, cageWidthItem);
            cm.SetEnabledOnValueEquals(rectCageUseViewItem, false, cageHeightItem);

            OptionGroup outputARGroup = outputRestrictionsGroup.AddGroup(OUTPUT_AR);

            cm.SetEnabledOnValueEquals(outputRestrictionsItem, OUTPUT_AR, outputARGroup);
            IOptionItem arCageUseViewItem = outputARGroup.AddBool(AR_CAGE_USE_VIEW, true);
            IOptionItem cageRatioItem     = outputARGroup.AddDouble(CAGE_RATIO, 1.0d);

            cm.SetEnabledOnValueEquals(arCageUseViewItem, false, cageRatioItem);

            OptionGroup groupingGroup = Handler.AddGroup(GROUPING);

            groupingGroup.AddList(GROUP_LAYOUT_POLICY, groupModes, LAYOUT_GROUPS);

            OptionGroup algorithmGroup = Handler.AddGroup(ALGORITHM);

            algorithmGroup.AddDouble(QUALITY_TIME_RATIO, organic.QualityTimeRatio, 0, 1);
            algorithmGroup.AddInt(MAXIMAL_DURATION, (int)(organic.MaximumDuration / 1000), 0, int.MaxValue);
            algorithmGroup.AddBool(ACTIVATE_DETERMINISTIC_MODE, organic.Deterministic);
            algorithmGroup.AddBool(ALLOW_MULTI_THREADING, true);
        }
コード例 #8
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);
        }
コード例 #9
0
        ///<inheritdoc/>
        protected override void SetupHandler()
        {
            OptionGroup generalGroup     = Handler.AddGroup(GENERAL);
            OptionGroup interactionGroup = generalGroup.AddGroup(INTERACTION);

            interactionGroup.AddBool(SELECTED_ELEMENTS_INCREMENTALLY, false);
            IOptionItem useDrawingItem = interactionGroup.AddBool(USE_DRAWING_AS_SKETCH, false);

            interactionGroup.SetAttribute(TableEditorFactory.RENDERING_HINTS_ATTRIBUTE, TableEditorFactory.RenderingHints.Invisible);

            generalGroup.AddList(ORIENTATION, orientEnum.Keys, TOP_TO_BOTTOM);
            generalGroup.AddBool(LAYOUT_COMPONENTS_SEPARATELY, false);
            IOptionItem symmetricPlacement = generalGroup.AddBool(SYMMETRIC_PLACEMENT, true);

            generalGroup.AddInt(MAXIMUM_DURATION, 5);

            OptionGroup distanceGroup = generalGroup.AddGroup(MINIMUM_DISTANCES);

            distanceGroup.AddDouble(NODE_TO_NODE_DISTANCE, 30.0d);
            distanceGroup.AddDouble(NODE_TO_EDGE_DISTANCE, 15.0d);
            distanceGroup.AddDouble(EDGE_TO_EDGE_DISTANCE, 15.0d);
            distanceGroup.AddDouble(MINIMUM_LAYER_DISTANCE, 10.0d);

            OptionGroup edgeSettingsGroup = Handler.AddGroup(EDGE_SETTINGS);
            OptionItem  eoi = edgeSettingsGroup.AddList(EDGE_ROUTING, edgeRoutingEnum.Keys, EDGE_ROUTING_ORTHOGONAL);

            edgeSettingsGroup.AddBool(BACKLOOP_ROUTING, false);
            edgeSettingsGroup.AddBool(AUTOMATIC_EDGE_GROUPING_ENABLED, false);
            IOptionItem edgeStraightening = edgeSettingsGroup.AddBool(EDGE_STRAIGHTENING_OPTIMIZATION_ENABLED, false);

            edgeSettingsGroup.AddBool(CONSIDER_EDGE_THICKNESS, false);
            edgeSettingsGroup.AddBool(CONSIDER_EDGE_DIRECTION, false);
            edgeSettingsGroup.AddDouble(MINIMUM_FIRST_SEGMENT_LENGTH, 10.0d);
            edgeSettingsGroup.AddDouble(MINIMUM_LAST_SEGMENT_LENGTH, 15.0d);
            edgeSettingsGroup.AddDouble(MINIMUM_EDGE_LENGTH, 20.0d);
            edgeSettingsGroup.AddDouble(MINIMUM_EDGE_DISTANCE, 15.0d);

            ConstraintManager cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(eoi, EDGE_ROUTING_POLYLINE,
                                       edgeSettingsGroup.AddDouble(MINIMUM_SLOPE, 0.25d, 0.0d, 5.0d));
            cm.SetEnabledOnValueEquals(symmetricPlacement, false, edgeStraightening);

            edgeSettingsGroup.AddBool(PC_OPTIMIZATION_ENABLED, false);
            edgeSettingsGroup.AddList(RECURSIVE_EDGE_ROUTING, new[] { RECURSIVE_EDGE_ROUTING_OFF, RECURSIVE_EDGE_ROUTING_DIRECTED, RECURSIVE_EDGE_ROUTING_UNDIRECTED }, RECURSIVE_EDGE_ROUTING_OFF);

            OptionGroup rankGroup = Handler.AddGroup(RANKS);

            rankGroup.AddList(RANKING_POLICY, rankingPolicies.Keys, HIERARCHICAL_OPTIMAL);
            rankGroup.AddList(LAYER_ALIGNMENT, alignmentEnum.Keys, BOTTOM);
            rankGroup.AddList(COMPONENT_ARRANGEMENT_POLICY, componentAlignmentEnum.Keys, POLICY_TOPMOST);

            OptionGroup sketchGroup = rankGroup.AddGroup(FROM_SKETCH_PROPERTIES);

            sketchGroup.AddDouble(SCALE, 1.0d, 0.0d, 5.0d);
            sketchGroup.AddDouble(HALO, 0.0d);
            sketchGroup.AddDouble(MINIMUM_SIZE, 0.0d, 0, Double.MaxValue);
            sketchGroup.AddDouble(MAXIMUM_SIZE, 1000.0d, 0, Double.MaxValue);
            cm.SetEnabledOnValueEquals(Handler.GetItemByName(RANKS + "." + RANKING_POLICY), FROM_SKETCH,
                                       Handler.GetItemByName(RANKS + "." + FROM_SKETCH_PROPERTIES));

            OptionGroup labelingGroup = Handler.AddGroup(LABELING);
            OptionGroup npGroup       = labelingGroup.AddGroup(NODE_PROPERTIES);

            npGroup.AddBool(CONSIDER_NODE_LABELS, true);
            npGroup.SetAttribute(TableEditorFactory.RENDERING_HINTS_ATTRIBUTE, TableEditorFactory.RenderingHints.Invisible);
            //npGroup.SetAttribute(DefaultEditorFactory.RenderingHintsAttribute,
            //  DefaultEditorFactory.RenderingHints.Invisible);
            OptionGroup epGroup = labelingGroup.AddGroup(LABELING_EDGE_PROPERTIES);
            CollectionOptionItem <string> edgeLabelingEnumItem = epGroup.AddList(EDGE_LABELING, edgeLabeling, EDGE_LABELING_NONE);
            CollectionOptionItem <string> labelModelItem       = epGroup.AddList(EDGE_LABEL_MODEL, edgeLabelModel, EDGE_LABEL_MODEL_BEST);

            epGroup.SetAttribute(TableEditorFactory.RENDERING_HINTS_ATTRIBUTE, TableEditorFactory.RenderingHints.Invisible);
            ICondition cond = ConstraintManager.LogicalCondition.Not(cm.CreateValueEqualsCondition(edgeLabelingEnumItem, EDGE_LABELING_NONE));

            cm.SetEnabledOnCondition(cond, labelModelItem);
            IOptionItem compactEdgeLabel = epGroup.AddBool(COMPACT_EDGE_LABEL_PLACEMENT, true);

            cm.SetEnabledOnValueEquals(edgeLabelingEnumItem, EDGE_LABELING_HIERARCHIC, compactEdgeLabel);
            OptionGroup groupingGroup = Handler.AddGroup(GROUPING);
            CollectionOptionItem <string> groupStrategyItem = groupingGroup.AddList(GROUP_LAYERING_STRATEGY, groupStrategyEnum.Keys, RECURSIVE_LAYERING);
            CollectionOptionItem <string> groupAlignItem    = groupingGroup.AddList(GROUP_ALIGNMENT, groupAlignmentEnum.Keys, GROUP_ALIGN_TOP);
            IOptionItem groupCompactionItem = groupingGroup.AddBool(GROUP_ENABLE_COMPACTION, false);

            groupingGroup.AddList(GROUP_HORIZONTAL_COMPACTION, groupHorizCompactionEnum.Keys, GROUP_HORIZONTAL_COMPACTION_NONE);
            cm.SetEnabledOnValueEquals(groupStrategyItem, RECURSIVE_LAYERING, groupCompactionItem);
            cm.SetEnabledOnValueEquals(groupStrategyItem, RECURSIVE_LAYERING, groupAlignItem);

            cm.SetEnabledOnValueEquals(useDrawingItem, false, groupStrategyItem);
            cm.SetEnabledOnCondition(ConstraintManager.LogicalCondition.And(cm.CreateValueEqualsCondition(groupStrategyItem, RECURSIVE_LAYERING),
                                                                            cm.CreateValueEqualsCondition(groupCompactionItem, false)), groupAlignItem);

            cm.SetEnabledOnCondition(ConstraintManager.LogicalCondition.And(cm.CreateValueEqualsCondition(groupStrategyItem, RECURSIVE_LAYERING),
                                                                            cm.CreateValueEqualsCondition(useDrawingItem, false)), groupCompactionItem);

            OptionGroup swimGroup        = Handler.AddGroup(SWIMLANES);
            IOptionItem swimlaneOption   = swimGroup.AddBool(TREAT_ROOT_GROUPS_AS_SWIMLANES, false);
            IOptionItem fromSketchOption = swimGroup.AddBool(USE_ORDER_FROM_SKETCH, false);
            IOptionItem spacingOption    = swimGroup.AddDouble(SWIMLANE_SPACING, 0.0d, 0, Double.MaxValue);

            cm.SetEnabledOnValueEquals(swimlaneOption, true, fromSketchOption);
            cm.SetEnabledOnValueEquals(swimlaneOption, true, spacingOption);

            OptionGroup gridGroup          = Handler.AddGroup(GRID);
            IOptionItem gridEnabled        = gridGroup.AddBool(GRID_ENABLED, false);
            IOptionItem gridSpacing        = gridGroup.AddDouble(GRID_SPACING, 10);
            IOptionItem gridPortAssignment = gridGroup.AddList(GRID_PORT_ASSIGNMENT, new[] { GRID_PORT_ASSIGNMENT_DEFAULT, GRID_PORT_ASSIGNMENT_ON_GRID, GRID_PORT_ASSIGNMENT_ON_SUBGRID }, GRID_PORT_ASSIGNMENT_DEFAULT);

            cm.SetEnabledOnValueEquals(gridEnabled, true, gridSpacing);
            cm.SetEnabledOnValueEquals(gridEnabled, true, gridPortAssignment);
        }