Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
 public StoryTextPainter(StoryTextEditorControl control)
 {
     m_control = control;
     D2dFactory.EnableResourceSharing(m_control.Handle);
     m_d2dGraphics = D2dFactory.CreateD2dHwndGraphics(m_control.Handle);
     CreateSharedResources();
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        private void CreateSharedResources()
        {
            // create text format object for various test modes
            m_generalTextFormat = D2dFactory.CreateTextFormat("Calibri"
                                                              , D2dFontWeight.Bold, D2dFontStyle.Normal, D2dFactory.FontSizeToPixel(16));

            m_generalTextFormat.WordWrapping = D2dWordWrapping.Wrap;
        }
Exemplo n.º 5
0
        public FormTest()
        {
            D2dFactory.EnableResourceSharing(this.Handle);
            m_canvas      = new Canvas2d();
            m_canvas.Dock = DockStyle.Fill;
            Controls.Add(m_canvas);

            this.ClientSize = new Size(1280, 900);
        }
Exemplo n.º 6
0
        /// <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;
        }
Exemplo n.º 7
0
        public Canvas2d()
        {
            this.SetStyle(ControlStyles.AllPaintingInWmPaint
                          | ControlStyles.Opaque | ControlStyles.UserPaint, true);
            this.ResizeRedraw = true;

            m_d2dGraphics = D2dFactory.CreateD2dHwndGraphics(this.Handle);

            CreateSharedResources();
        }
Exemplo n.º 8
0
        /// <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);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Constructor</summary>
        public D2dAdaptableControl()
        {
            DoubleBuffered = false;
            SetStyle(
                ControlStyles.ResizeRedraw |
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.Opaque |
                ControlStyles.UserPaint, true);

            // D2dHwndGraphics needs to be resized on size changed. Look at OnResize.
            m_d2dGraphics = D2dFactory.CreateD2dHwndGraphics(Handle);
        }
Exemplo n.º 10
0
        private void RecreateLayout(string text)
        {
            var textLayout = D2dFactory.CreateTextLayout(text, TextFormat, TextLayout.LayoutWidth, TextLayout.LayoutHeight);

            if (TextFormat.Underlined)
            {
                textLayout.SetUnderline(true, 0, text.Length);
            }
            if (TextFormat.Strikeout)
            {
                textLayout.SetStrikethrough(true, 0, text.Length);
            }
            TextLayout.Dispose();
            TextLayout = textLayout;
        }
Exemplo n.º 11
0
        /// <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));
        }
Exemplo n.º 12
0
        /// <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);
        }
Exemplo n.º 13
0
        private void UpdateToTheme()
        {
            D2dTextFormat textFormat = m_theme.TextFormat;

            if (m_centerText == null ||
                textFormat.FontFamilyName != m_centerText.FontFamilyName ||
                textFormat.FontSize != m_centerText.FontSize)
            {
                if (m_centerText != null)
                {
                    m_centerText.Dispose();
                }

                m_centerText = D2dFactory.CreateTextFormat(textFormat.FontFamilyName,
                                                           D2dFontWeight.Bold, D2dFontStyle.Normal, m_theme.TextFormat.FontHeight);
                m_centerText.TextAlignment      = D2dTextAlignment.Center;
                m_centerText.ParagraphAlignment = D2dParagraphAlignment.Center;
                m_fontHeight = m_theme.TextFormat.FontHeight;
            }
        }
Exemplo n.º 14
0
        /// <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;
        }
Exemplo n.º 15
0
        /// <summary>
        /// Registers a bitmap with a unique key</summary>
        /// <param name="key">Key to access bitmap</param>
        /// <param name="image">Custom bitmap</param>
        public void RegisterBitmap(object key, Image image)
        {
            var bitmap = D2dFactory.CreateBitmap(image);

            m_bitmaps[key] = bitmap;
        }