/// <summary> /// Constructor with parameters</summary> /// <param name="fontFamilyName">Font family name for theme</param> /// <param name="fontSize">Font size</param> public D2dDiagramTheme(string fontFamilyName, float fontSize) { m_d2dTextFormat = D2dFactory.CreateTextFormat(fontFamilyName, fontSize); m_fillBrush = D2dFactory.CreateSolidBrush(SystemColors.Window); m_fillTitleBrush = D2dFactory.CreateSolidBrush(Color.YellowGreen); m_textBrush = D2dFactory.CreateSolidBrush(SystemColors.WindowText); m_outlineBrush = D2dFactory.CreateSolidBrush(SystemColors.ControlDark); m_highlightBrush = D2dFactory.CreateSolidBrush(SystemColors.Highlight); m_lastHighlightBrush = D2dFactory.CreateSolidBrush(SystemColors.Highlight); m_textHighlightBrush = D2dFactory.CreateSolidBrush(SystemColors.Highlight); m_hotBrush = D2dFactory.CreateSolidBrush(SystemColors.HotTrack); m_dragSourceBrush = D2dFactory.CreateSolidBrush(Color.SlateBlue); m_dropTargetBrush = D2dFactory.CreateSolidBrush(Color.Chartreuse); m_ghostBrush = D2dFactory.CreateSolidBrush(Color.White); m_hiddenBrush = D2dFactory.CreateSolidBrush(Color.LightGray); m_templatedInstance = D2dFactory.CreateSolidBrush(Color.Yellow); m_copyInstance = D2dFactory.CreateSolidBrush(Color.Green); m_errorBrush = D2dFactory.CreateSolidBrush(Color.Tomato); m_infoBrush = D2dFactory.CreateSolidBrush(SystemColors.Info); m_hoverBorderBrush = D2dFactory.CreateSolidBrush(SystemColors.ControlDarkDark); int fontHeight = (int)TextFormat.FontHeight; m_rowSpacing = fontHeight + PinMargin; m_pinOffset = (fontHeight - m_pinSize) / 2; D2dGradientStop[] gradstops = { new D2dGradientStop(Color.White, 0), new D2dGradientStop(Color.LightSteelBlue, 1.0f), }; m_fillLinearGradientBrush = D2dFactory.CreateLinearGradientBrush(gradstops); StrokeWidth = 2; }
public Editor( IControlHostService controlHostService, ICommandService commandService, IContextRegistry contextRegistry, IDocumentRegistry documentRegistry, IDocumentService documentService, SchemaLoader schemaLoader, PrototypeLister prototypeLister) { m_controlHostService = controlHostService; m_commandService = commandService; m_contextRegistry = contextRegistry; m_documentRegistry = documentRegistry; m_documentService = documentService; m_schemaLoader = schemaLoader; m_diagramTheme = new D2dDiagramTheme(); D2dGradientStop[] gradStops = { new D2dGradientStop(Color.WhiteSmoke, 0), new D2dGradientStop(Color.LightGray, 1) }; m_diagramTheme.FillGradientBrush = D2dFactory.CreateLinearGradientBrush(gradStops); m_diagramTheme.FillBrush = D2dFactory.CreateSolidBrush(Color.WhiteSmoke); m_statechartRenderer = new D2dStatechartRenderer <StateBase, Transition>(m_diagramTheme); string initialDirectory = Path.Combine(Directory.GetCurrentDirectory(), "..\\..\\..\\..\\components\\wws_atf\\Samples\\StatechartEditor\\data"); EditorInfo.InitialDirectory = initialDirectory; }
/// <summary> /// Finishes initializing component by setting up scripting service and setting service</summary> void IInitializable.Initialize() { if (m_scriptingService != null) { // load this assembly into script domain. m_scriptingService.LoadAssembly(GetType().Assembly); m_scriptingService.ImportAllTypes("CircuitEditorSample"); m_scriptingService.ImportAllTypes("Sce.Atf.Controls.Adaptable.Graphs"); m_scriptingService.SetVariable("editor", this); m_scriptingService.SetVariable("schemaLoader", m_schemaLoader); m_scriptingService.SetVariable("layerLister", m_layerLister); m_contextRegistry.ActiveContextChanged += delegate { var editingContext = m_contextRegistry.GetActiveContext <CircuitEditingContext>(); ViewingContext viewContext = m_contextRegistry.GetActiveContext <ViewingContext>(); IHistoryContext hist = m_contextRegistry.GetActiveContext <IHistoryContext>(); m_scriptingService.SetVariable("editingContext", editingContext); m_scriptingService.SetVariable("circuitContainer", editingContext != null ? editingContext.CircuitContainer : null); m_scriptingService.SetVariable("view", viewContext); m_scriptingService.SetVariable("hist", hist); }; } if (m_settingsService != null) { var settings = new[] { new BoundPropertyDescriptor(typeof(CircuitDefaultStyle), () => CircuitDefaultStyle.EdgeStyle, "Wire Style".Localize(), "Circuit Editor".Localize(), "Default Edge Style".Localize()), new BoundPropertyDescriptor(typeof(CircuitDefaultStyle), () => CircuitDefaultStyle.ShowExpandedGroupPins, "Show Expanded Group Pins".Localize(), "Circuit Editor".Localize(), "Show group pins when a group is expanded".Localize()), new BoundPropertyDescriptor(typeof(CircuitDefaultStyle), () => CircuitDefaultStyle.ShowVirtualLinks, "Show Virtual links".Localize(), "Circuit Editor".Localize(), "Show virtual links between group pin and its associated subnodes when a group is expanded".Localize()), }; m_settingsService.RegisterUserSettings("Circuit Editor", settings); m_settingsService.RegisterSettings(this, settings); } if (m_modulePlugin != null) { var pen = D2dFactory.CreateSolidBrush(Color.LightSeaGreen); m_theme.RegisterCustomBrush(m_modulePlugin.BooleanPinTypeName, pen); pen = D2dFactory.CreateSolidBrush(Color.LightSeaGreen); m_theme.RegisterCustomBrush(m_modulePlugin.FloatPinTypeName, pen); } CircuitEditingContext.CircuitFormat = CircuitFormat; }
/// <summary> /// Binds the adapter to the adaptable control; called in the order that the adapters /// were defined on the control</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { base.Bind(control); var d2dControl = control as D2dAdaptableControl; m_d2dGraphics = d2dControl.D2dGraphics; d2dControl.ContextChanged += control_ContextChanged; m_scaleBrush = D2dFactory.CreateSolidBrush(control.ForeColor); m_textFormat = D2dFactory.CreateTextFormat(d2dControl.Font); }
/// <summary> /// Initializes a new instance of this class</summary> /// <param name="theme">Diagram theme for rendering graph</param> /// <param name="documentRegistry">An optional document registry, used to clear the internal /// element type cache when a document is removed</param> public ScriptRenderer(D2dDiagramTheme theme, IDocumentRegistry documentRegistry) : base(theme, documentRegistry) { m_disabledTheme = new D2dDiagramTheme(); m_disabledTheme.FillBrush = D2dFactory.CreateSolidBrush(SystemColors.ControlDark); m_disabledTheme.TextBrush = D2dFactory.CreateSolidBrush(SystemColors.InactiveCaption); D2dGradientStop[] gradstops = { new D2dGradientStop(Color.DarkGray, 0), new D2dGradientStop(Color.DimGray, 1.0f), }; m_disabledTheme.FillGradientBrush = D2dFactory.CreateLinearGradientBrush(gradstops); // Set the pin colors m_disabledTheme.RegisterCustomBrush("boolean", D2dFactory.CreateSolidBrush(Color.LightGray)); }
/// <summary> /// Constructor</summary> /// <param name="defaultTheme">Diagram theme for rendering graph</param> /// <param name="documentRegistry">An optional document registry, used to clear the internal /// element type cache when a document is removed</param> public D2dSubCircuitRenderer(D2dDiagramTheme defaultTheme, IDocumentRegistry documentRegistry = null) : base(defaultTheme, documentRegistry) { m_fakeInputLinkPen = D2dFactory.CreateSolidBrush(Color.DarkOrchid); m_fakeOutputLinkPen = D2dFactory.CreateSolidBrush(Color.SlateGray); m_subGraphPinNodePen = D2dFactory.CreateSolidBrush(Color.SandyBrown); m_subGraphPinPen = D2dFactory.CreateSolidBrush(Color.DeepSkyBlue); m_pinBrush = D2dFactory.CreateSolidBrush(SystemColors.ControlDarkDark); m_visiblePinBrush = D2dFactory.CreateSolidBrush(Color.Black); m_hiddrenPinBrush = D2dFactory.CreateSolidBrush(Color.Gray); var props = new D2dStrokeStyleProperties(); props.EndCap = D2dCapStyle.Round; props.StartCap = D2dCapStyle.Round; props.DashStyle = D2dDashStyle.DashDot; m_VirtualLinkStrokeStyle = D2dFactory.CreateD2dStrokeStyle(props); }
/// <summary> /// Finishes initializing component by setting up scripting service and setting service</summary> void IInitializable.Initialize() { if (m_scriptingService != null) { // load this assembly into script domain. m_scriptingService.LoadAssembly(GetType().Assembly); m_scriptingService.ImportAllTypes("CircuitEditorSample"); m_scriptingService.ImportAllTypes("Sce.Atf.Controls.Adaptable.Graphs"); m_scriptingService.SetVariable("editor", this); m_scriptingService.SetVariable("schemaLoader", m_schemaLoader); m_scriptingService.SetVariable("layerLister", m_layerLister); m_contextRegistry.ActiveContextChanged += delegate { var editingContext = m_contextRegistry.GetActiveContext <CircuitEditingContext>(); ViewingContext viewContext = m_contextRegistry.GetActiveContext <ViewingContext>(); IHistoryContext hist = m_contextRegistry.GetActiveContext <IHistoryContext>(); m_scriptingService.SetVariable("editingContext", editingContext); m_scriptingService.SetVariable("circuitContainer", editingContext != null ? editingContext.CircuitContainer : null); m_scriptingService.SetVariable("view", viewContext); m_scriptingService.SetVariable("hist", hist); }; } if (m_settingsService != null) { var settings = new[] { new BoundPropertyDescriptor(this, () => SnapToGridEnabled, "Snap to grid".Localize(), "Circuit Editor".Localize(), "Snaps circuit element to grid when dragging".Localize(), new BoolEditor(), null), new BoundPropertyDescriptor(typeof(CircuitDefaultStyle), () => CircuitDefaultStyle.EdgeStyle, "Wire Style".Localize(), "Circuit Editor".Localize(), "Default Edge Style".Localize()), new BoundPropertyDescriptor(typeof(CircuitDefaultStyle), () => CircuitDefaultStyle.ShowExpandedGroupPins, "Show Expanded Group Pins".Localize(), "Circuit Editor".Localize(), "Show group pins when a group is expanded".Localize()), new BoundPropertyDescriptor(typeof(CircuitDefaultStyle), () => CircuitDefaultStyle.ShowVirtualLinks, "Show Virtual links".Localize(), "Circuit Editor".Localize(), "Show virtual links between group pin and its associated subnodes when a group is expanded".Localize()), new BoundPropertyDescriptor(this, () => InitialDirectory, "Initial Directory".Localize(), "Circuit Editor".Localize(), "The initial directory for documents".Localize(), new System.Windows.Forms.Design.FolderNameEditor(), null), }; m_settingsService.RegisterUserSettings("Circuit Editor", settings); m_settingsService.RegisterSettings(this, settings); } if (m_modulePlugin != null) { // define pin/connection pens var pen = D2dFactory.CreateSolidBrush(Color.LightSeaGreen); Theme.RegisterCustomBrush(m_modulePlugin.BooleanPinTypeName, pen); pen = D2dFactory.CreateSolidBrush(Color.LightSeaGreen); Theme.RegisterCustomBrush(m_modulePlugin.FloatPinTypeName, pen); } D2dGradientStop[] gradstops = { new D2dGradientStop(Color.White, 0), new D2dGradientStop(Color.MediumVioletRed, 1.0f), }; Theme.RegisterCustomBrush(MissingModule.MissingTypeName, D2dFactory.CreateLinearGradientBrush(gradstops)); CircuitEditingContext.CircuitFormat = CircuitFormat; }