/// <summary> /// Initializes the option handler for the export /// </summary> private void SetupHandler() { handler = new OptionHandler(PRINTING); OptionGroup currentGroup = handler.AddGroup(OUTPUT); currentGroup.AddBool(HIDE_DECORATIONS, true); currentGroup.AddBool(EXPORT_RECTANGLE, true); currentGroup = handler.AddGroup(DOCUMENT_SETTINGS); var item = currentGroup.AddDouble(SCALE, 1.0); currentGroup.AddBool(CENTER_CONTENT, false); currentGroup.AddBool(PAGE_MARK_PRINTING, false); currentGroup.AddBool(SCALE_DOWN_TO_FIT_PAGE, false); currentGroup.AddBool(SCALE_UP_TO_FIT_PAGE, false); // localization var rm = new ResourceManager("Demo.yFiles.Printing.Printing", Assembly.GetExecutingAssembly()); var rmf = new ResourceManagerI18NFactory(); rmf.AddResourceManager(Handler.Name, rm); Handler.I18nFactory = rmf; }
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); }
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; }
/// <summary> /// Initializes the option handler for the export /// </summary> private void SetupHandler() { handler = new OptionHandler(IMAGE_EXPORT); handler.PropertyChanged += handler_PropertyChanged; OptionGroup currentGroup = handler.AddGroup(OUTPUT); OptionItem formatItem = currentGroup.AddList(FORMAT, Formats.Keys, FORMAT_JPG); currentGroup.AddBool(HIDE_DECORATIONS, true); currentGroup.AddBool(EXPORT_RECTANGLE, true); currentGroup = handler.AddGroup(BOUNDS); OptionItem sizeItem = currentGroup.AddList(SIZE, SizeModes, USE_ORIGINAL_SIZE); IOptionItem widthItem = currentGroup.AddInt(WIDTH, DefaultWidth, 1, int.MaxValue); IOptionItem heightItem = currentGroup.AddInt(HEIGHT, DefaultHeight, 1, Int32.MaxValue); currentGroup.AddDouble(SCALE, DefaultScale); currentGroup = handler.AddGroup(MARGINS); currentGroup.AddInt(LEFT_MARGIN, DefaultMargins); currentGroup.AddInt(RIGHT_MARGIN, DefaultMargins); currentGroup.AddInt(TOP_MARGIN, DefaultMargins); currentGroup.AddInt(BOTTOM_MARGIN, DefaultMargins); currentGroup = handler.AddGroup(JPG); IOptionItem qualityItem = currentGroup.AddDouble(QUALITY, DefaultQuality); currentGroup = handler.AddGroup(TIFF); OptionItem compressionItem = currentGroup.AddList(COMPRESSION, Compressions.Keys, DefaultCompression); currentGroup = handler.AddGroup(PNG); var transparentItem = currentGroup.AddBool(TRANSPARENT, false); var cm = new ConstraintManager(Handler); cm.SetEnabledOnValueEquals(sizeItem, SPECIFY_WIDTH, widthItem); cm.SetEnabledOnValueEquals(sizeItem, SPECIFY_HEIGHT, heightItem); cm.SetEnabledOnValueEquals(formatItem, FORMAT_PNG, transparentItem); cm.SetEnabledOnValueEquals(formatItem, FORMAT_JPG, qualityItem); cm.SetEnabledOnValueEquals(formatItem, FORMAT_TIFF, compressionItem); // localization var rm = new ResourceManager("Demo.yFiles.ImageExport.ImageExport", Assembly.GetExecutingAssembly()); var rmf = new ResourceManagerI18NFactory(); rmf.AddResourceManager(Handler.Name, rm); Handler.I18nFactory = rmf; }
/// <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); }
/// <summary> /// Initializes the option handler for the export /// </summary> private void SetupHandler() { handler = new OptionHandler(IMAGE_EXPORT); handler.PropertyChanged += handler_PropertyChanged; OptionGroup currentGroup = handler.AddGroup(OUTPUT); OptionItem formatItem = currentGroup.AddList(FORMAT, Formats.Keys, FORMAT_JPG); currentGroup.AddBool(HIDE_DECORATIONS, true); currentGroup.AddBool(EXPORT_RECTANGLE, true); currentGroup = handler.AddGroup(BOUNDS); OptionItem sizeItem = currentGroup.AddList(SIZE, SizeModes, USE_ORIGINAL_SIZE); IOptionItem widthItem = currentGroup.AddInt(WIDTH, DefaultWidth, 1, int.MaxValue); IOptionItem heightItem = currentGroup.AddInt(HEIGHT, DefaultHeight, 1, Int32.MaxValue); currentGroup.AddDouble(SCALE, DefaultScale); currentGroup.AddDouble(ZOOM, DefaultZoom); currentGroup = handler.AddGroup(GRAPHICS); currentGroup.AddGeneric(SMOOTHING, SimpleSmoothingMode.HighSpeed).SetAttribute( OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false); currentGroup.AddGeneric(TEXTRENDERING, TextRenderingHint.SystemDefault).SetAttribute( OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false); currentGroup.AddGeneric(INTERPOLATION, InterpolationMode.Invalid).SetAttribute( OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false); currentGroup.AddGeneric(PIXELOFFSET, PixelOffsetMode.Invalid).SetAttribute( OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false); currentGroup = handler.AddGroup(MARGINS); currentGroup.AddInt(LEFT_MARGIN, DefaultMargins); currentGroup.AddInt(RIGHT_MARGIN, DefaultMargins); currentGroup.AddInt(TOP_MARGIN, DefaultMargins); currentGroup.AddInt(BOTTOM_MARGIN, DefaultMargins); currentGroup = handler.AddGroup(JPG); DoubleOptionItem qualityItem = currentGroup.AddDouble(QUALITY, DefaultQuality); currentGroup = handler.AddGroup(TIFF); OptionItem colorDepthItem = currentGroup.AddList(COLOR_DEPTH, ColorDepthList.Keys, DefaultDepth); OptionItem compressionItem = currentGroup.AddList(COMPRESSION, Compressions.Keys, DefaultCompression); currentGroup = handler.AddGroup(PNG); BoolOptionItem transparentPNGItem = currentGroup.AddBool(TRANSPARENT, false); currentGroup = handler.AddGroup(EMF); BoolOptionItem transparentEMFItem = currentGroup.AddBool(TRANSPARENT, false); var cm = new ConstraintManager(Handler); cm.SetEnabledOnValueEquals(sizeItem, SPECIFY_WIDTH, widthItem); cm.SetEnabledOnValueEquals(sizeItem, SPECIFY_HEIGHT, heightItem); cm.SetEnabledOnValueEquals(formatItem, FORMAT_EMF, transparentEMFItem); cm.SetEnabledOnValueEquals(formatItem, FORMAT_PNG, transparentPNGItem); cm.SetEnabledOnValueEquals(formatItem, FORMAT_JPG, qualityItem); cm.SetEnabledOnValueEquals(formatItem, FORMAT_TIFF, colorDepthItem); cm.SetEnabledOnValueEquals(formatItem, FORMAT_TIFF, compressionItem); // localization var rm = new ResourceManager("Demo.yFiles.ImageExport.ImageExport", Assembly.GetExecutingAssembly()); var rmf = new ResourceManagerI18NFactory(); rmf.AddResourceManager(Handler.Name, rm); Handler.I18nFactory = rmf; }