示例#1
0
        private OptionHandler CreateOptionHandler()
        {
            var handler = new OptionHandler(PreferredPlacement);

            IOptionItem item;

            handler.AddString(LabelText, "Label").PropertyChanged     += OptionHandlerPropertyChanged;
            handler.AddDouble(PlacementDistance, 5.0).PropertyChanged += OptionHandlerPropertyChanged;
            item = handler.AddList(PlacementAlongEdge, PlacementsAlongEdge, PlacementsAlongEdge[0]);
            item.PropertyChanged += OptionHandlerPropertyChanged;
            item = handler.AddList(PlacementSideOfEdge, PlacementsSideOfEdge, PlacementsSideOfEdge[0]);
            item.PropertyChanged += OptionHandlerPropertyChanged;
            item = handler.AddList(PlacementSideReference, SideReferences, SideReferences[0]);
            item.PropertyChanged += OptionHandlerPropertyChanged;
            handler.AddDouble(Angle, 0.0).PropertyChanged += OptionHandlerPropertyChanged;
            item = handler.AddList(AngleReference, AngleReferences, AngleReferences[0]);
            item.PropertyChanged += OptionHandlerPropertyChanged;
            item = handler.AddList(AngleRotation, AngleRotations, AngleRotations[0]);
            item.PropertyChanged += OptionHandlerPropertyChanged;
            handler.AddBool(AngleAdd180Degree, false).PropertyChanged += OptionHandlerPropertyChanged;

            var rm = new ResourceManager("Demo.yFiles.Layout.PreferredLabelPlacement.PreferredLabelPlacement",
                                         Assembly.GetExecutingAssembly());
            var rmf = new ResourceManagerI18NFactory();

            rmf.AddResourceManager(handler.Name, rm);
            handler.I18nFactory = rmf;

            return(handler);
        }
        /// <summary>
        /// Initializes the option handler for the export
        /// </summary>
        private void SetupHandler()
        {
            handler = new OptionHandler(LayoutOptions);
            OptionItem componentItem = handler.AddList(ComponentAssignment,
                                                       new[]
            {
                ComponentAssignmentStrategy.Single,
                ComponentAssignmentStrategy.Connected
            },
                                                       ComponentAssignmentStrategy.Single);
            OptionItem subgraphItem = handler.AddList(SubgraphLayout, SubGraphLayouts.Keys, LayoutIncremental);

            handler.AddGeneric(SubgraphPositioning, SubgraphPlacement.Barycenter).SetAttribute(
                OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false);
            handler.AddGeneric(EdgeRouting, EdgeRoutingStrategy.Automatic).SetAttribute(
                OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false);
            handler.AddGeneric(LayoutOrientationStrategy, LayoutOrientation.TopToBottom).SetAttribute(
                OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false);
            handler.AddInt(MinimumNodeDistance, 5, 0, int.MaxValue);
            handler.AddBool(AllowMirroring, true);
            handler.AddBool(NodeSnapping, true);
            var cm = new ConstraintManager(Handler);

            cm.SetEnabledOnValueEquals(componentItem, ComponentAssignmentStrategy.Connected, subgraphItem);
        }