public override void ReadExternal(IMemento memento, ExternalizeContext context) { base.ReadExternal(memento, context); _font = (FontDescription)memento.ReadSerializable("Font"); _fontColor = (Color)memento.ReadSerializable("FontColor"); _foreground = (Color)memento.ReadSerializable("Foreground"); _background = (IBrushDescription)memento.ReadSerializable("Background"); _isForegroundEnabled = memento.ReadBool("IsForegroundEnabled"); _isBackgroundEnabled = memento.ReadBool("IsBackgroundEnabled"); _borderWidth = memento.ReadInt("BorderWidth"); _borderDashStyle = (DashStyle)memento.ReadSerializable("BorderDashStyle"); _minSize = (Size)memento.ReadSerializable("MinSize"); _maxSize = (Size)memento.ReadSerializable("MaxSize"); _autoSize = (AutoSizeKinds)memento.ReadSerializable("AutoSize"); _padding = (Insets)memento.ReadSerializable("Padding"); _selectionBorderColor = (Color)memento.ReadSerializable("SelectionBorderColor"); _selectionBrush = (IBrushDescription)memento.ReadSerializable("SelectionBrush"); StyledText = (StyledText)memento.ReadSerializable("StyledText"); _text = memento.ReadString("Text"); _textHorizontalAlignment = (DataType::HorizontalAlignment)memento.ReadSerializable("TextHorizontalAlignment"); _textVerticalAlignment = (VerticalAlignment)memento.ReadSerializable("TextVerticalAlignment"); }
private bool _showBlockBreak = false; /// transient // ======================================== // constructor // ======================================== public AbstractNode() : base() { _font = SystemFontDescriptions.DefaultFont; _fontColor = FigureConsts.WindowTextColor; _foreground = FigureConsts.WindowTextColor; _background = FigureConsts.WindowBrush; _isForegroundEnabled = true; _isBackgroundEnabled = true; _borderWidth = 1; _borderDashStyle = DashStyle.Solid; _minSize = new Size(4, 4); _maxSize = new Size(int.MaxValue, int.MaxValue); _autoSize = AutoSizeKinds.None; _padding = new Insets(2); _text = string.Empty; _textSizeCache = Size.Empty; _textHorizontalAlignment = DataType::HorizontalAlignment.Left; _textVerticalAlignment = VerticalAlignment.Top; _styledText = null; _selectionBorderColor = FigureConsts.HighlightColor; _selectionBrush = FigureConsts.HighlightBrush; _fontCache = new FontCache(); _updateStyledTextDepth = 0; _ResourceCache.RegisterResourceCreator( FontResourceKey, () => _font.CreateFont(), ResourceDisposingPolicy.Explicit ); _ResourceCache.RegisterResourceCreator( PenResourceKey, () => { var ret = new Pen(_foreground, _borderWidth); ret.DashStyle = _borderDashStyle; return(ret); }, ResourceDisposingPolicy.Immediate ); _ResourceCache.RegisterResourceCreator( BrushResourceKey, () => _background == null? null: _background.CreateBrush(Bounds), ResourceDisposingPolicy.Immediate ); _ResourceCache.RegisterResourceCreator( SelectionPenResourceKey, () => new Pen(_selectionBorderColor), ResourceDisposingPolicy.Immediate ); _ResourceCache.RegisterResourceCreator( SelectionBrushResourceKey, () => _selectionBrush.CreateBrush(Bounds), ResourceDisposingPolicy.Immediate ); }
// ======================================== // constructor // ======================================== public FrameMoveHandle(int height, int frameWidth, Color foreground, IBrushDescription background) { //_figure = new SimpleRect(); _figure = new MoveHandleFigure(); _figure.Foreground = foreground; _figure.Background = background; _height = height; _frameWidth = frameWidth; Cursor = Cursors.SizeAll; }
private void SetStyle( Color fontColor, IBrushDescription newBackground, bool newIsBorderEnabled, Color newBorderColor, int newBorderWidth, DashStyle newBorderDashStyle ) { var canvas = _form.EditorCanvas; if (canvas == null) { return; } var cmd = new CompositeCommand(); var selecteds = canvas.SelectionManager.SelectedEditors.ToArray(); foreach (var target in selecteds) { var shape = target.Model as MemoStyledText; if (shape != null) { cmd.Chain( new SetStyledTextColorCommand( target, () => shape.StyledText, flow => fontColor ) ); cmd.Chain( new SetNodeBackgroundCommand(target, newBackground) ); cmd.Chain( new SetNodeBorderCommand( target, newIsBorderEnabled, newBorderColor, newBorderWidth, newBorderDashStyle ) ); } } using (canvas.RootFigure.DirtManager.BeginDirty()) { canvas.CommandExecutor.Execute(cmd); } }
// ======================================== // method // ======================================== public override void Execute() { var node = _target.Figure as INode; if (node != null) { _oldBackground = node.Background; _oldIsBackgroundEnabled = node.IsBackgroundEnabled; node.Background = _newBackground; node.IsBackgroundEnabled = _newBackground != null; } }
// ======================================== // static method // ======================================== public static IBrushDescription CreateFrom(IBrushDescription prototype, float opacity) { if (prototype == null) { return(null); } switch (prototype.Kind) { case BrushKind.Solid: { var solid = prototype as SolidBrushDescription; return(new SolidBrushDescription(solid.Color, opacity)); } case BrushKind.Gradient: { var gradient = prototype as GradientBrushDescription; if (gradient.ColorBlend != null) { return(new GradientBrushDescription( gradient.ColorBlend, gradient.Angle, opacity )); } else { return(new GradientBrushDescription( gradient.Color1, gradient.Color2, gradient.Blend, gradient.Angle, opacity )); } } } throw new ArgumentException("prototype is unknown kind of IBrushDescriptor"); }
// ======================================== // constructor // ======================================== public MemoTextFrameMoveAndCombineHandle(int height, int frameWidth, Color foreground, IBrushDescription background) : base(height, frameWidth, foreground, background) { }
// ======================================== // constructor // ======================================== public SetNodeBackgroundCommand(IEditor target, IBrushDescription newBackground) { _target = target; _newBackground = newBackground; }
// ======================================== // constructor // ======================================== public MemoTextFrameHandle( int hitMargin, int frameWidth, Size cornerSize, Color color, Color moveFore, IBrushDescription moveBack ) : base(false) { Children.Add(new FrameResizeHandle(hitMargin, frameWidth, cornerSize, color)); Children.Add(new MemoTextFrameMoveAndCombineHandle(cornerSize.Height, frameWidth, moveFore, moveBack)); Children.Add(new MemoTextWidthHandle()); }
// ======================================== // constructor // ======================================== public FrameHandle( int hitMargin, int frameWidth, Size cornerSize, Color color, Color moveFore, IBrushDescription moveBack ) { Children.Add(new FrameResizeHandle(hitMargin, frameWidth, cornerSize, color)); Children.Add(new FrameMoveHandle(cornerSize.Height, frameWidth, moveFore, moveBack)); }