//--------------------------------------------------------------------------------------------------------- /// <summary> /// Изменение имени ресурса кисти. /// Метод автоматически вызывается после установки соответствующего свойства /// </summary> //--------------------------------------------------------------------------------------------------------- protected virtual void RaiseResourceNameChanged() { #if USE_WINDOWS // Копируем кисть с ресурсов System.Windows.Media.DrawingBrush resource_brush = XCadManager.GraphicsResources[mResourceName] as System.Windows.Media.DrawingBrush; mWindowsBrush = resource_brush.CloneCurrentValue(); System.Windows.Media.DrawingBrush hatch_brush = mWindowsBrush as System.Windows.Media.DrawingBrush; System.Windows.Media.DrawingGroup dg = hatch_brush.Drawing as System.Windows.Media.DrawingGroup; System.Windows.Media.GeometryDrawing gd = dg.Children[0] as System.Windows.Media.GeometryDrawing; if (mIsBackground) { gd.Brush = XWindowsColorManager.GetBrushByColor(mBackgroundColor); } else { gd.Brush = null; } gd.Pen.Brush = XWindowsColorManager.GetBrushByColor(mForegroundColor); // 2) Информируем об изменении NotifyPropertyChanged(PropertyArgsWindowsBrush); #endif #if USE_GDI if (mDrawingBrush != null) { mDrawingBrush.Dispose(); } mDrawingBrush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Cross, mForegroundColor, mBackgroundColor); #endif #if USE_SHARPDX if (mD2DBrush != null) { SharpDX.Direct2D1.SolidColorBrush d2d_solid_brush = mD2DBrush as SharpDX.Direct2D1.SolidColorBrush; d2d_solid_brush.Color = mForegroundColor; } #endif }
//--------------------------------------------------------------------------------------------------------- /// <summary> /// Обновление ресурса WPF /// </summary> //--------------------------------------------------------------------------------------------------------- public override void UpdateWindowsResource() { System.Windows.Media.DrawingBrush hatch_brush = mWindowsBrush as System.Windows.Media.DrawingBrush; if (hatch_brush.Drawing == null) { // Копируем кисть с ресурсов System.Windows.Media.DrawingBrush resource_brush = XCadManager.GraphicsResources[mResourceName] as System.Windows.Media.DrawingBrush; mWindowsBrush = resource_brush.CloneCurrentValue(); hatch_brush = mWindowsBrush as System.Windows.Media.DrawingBrush; System.Windows.Media.DrawingGroup dg = hatch_brush.Drawing as System.Windows.Media.DrawingGroup; System.Windows.Media.GeometryDrawing gd = dg.Children[0] as System.Windows.Media.GeometryDrawing; if (mIsBackground) { gd.Brush = XWindowsColorManager.GetBrushByColor(mBackgroundColor); } else { gd.Brush = null; } gd.Pen.Brush = XWindowsColorManager.GetBrushByColor(mForegroundColor); } else { System.Windows.Media.DrawingGroup dg = hatch_brush.Drawing as System.Windows.Media.DrawingGroup; System.Windows.Media.GeometryDrawing gd = dg.Children[0] as System.Windows.Media.GeometryDrawing; if (mIsBackground) { gd.Brush = XWindowsColorManager.GetBrushByColor(mBackgroundColor); } else { gd.Brush = null; } gd.Pen.Brush = XWindowsColorManager.GetBrushByColor(mForegroundColor); } }