public void SetBrush(Brush brush) { _hightlightBrush = brush; _hightlightBrush.Freeze(); _textView.InvalidateLayer(Layer); }
public static ResourceDictionary SetBrush(this ResourceDictionary resource, WpfBrush brush) { brush.Freeze(); //var p = new ResourceDictionary().MergeWith(resource); resource[EditorFormatDefinition.ForegroundBrushId] = brush; return(resource); }
public PostInfoDisplay(double textRightEdge, double viewRightEdge, Geometry newTextGeometry, string body) { if (brush == null) { brush = new SolidColorBrush(Color.FromArgb(0x20, 0x48, 0x3d, 0x8b)); brush.Freeze(); Brush penBrush = new SolidColorBrush(Colors.DarkSlateBlue); penBrush.Freeze(); solidPen = new Pen(penBrush, 0.5); solidPen.Freeze(); dashPen = new Pen(penBrush, 0.5); dashPen.DashStyle = DashStyles.Dash; dashPen.Freeze(); } this.textGeometry = newTextGeometry; TextBlock tb = new TextBlock(); tb.Text = "Blog Entry: " + body; const int MarginWidth = 8; this.postGrid = new Grid(); this.postGrid.RowDefinitions.Add(new RowDefinition()); this.postGrid.RowDefinitions.Add(new RowDefinition()); ColumnDefinition cEdge = new ColumnDefinition(); cEdge.Width = new GridLength(MarginWidth); ColumnDefinition cEdge2 = new ColumnDefinition(); cEdge2.Width = new GridLength(MarginWidth); this.postGrid.ColumnDefinitions.Add(cEdge); this.postGrid.ColumnDefinitions.Add(new ColumnDefinition()); this.postGrid.ColumnDefinitions.Add(cEdge2); System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle(); rect.RadiusX = 6; rect.RadiusY = 3; rect.Fill = brush; rect.Stroke = Brushes.DarkSlateBlue; Size inf = new Size(double.PositiveInfinity, double.PositiveInfinity); tb.Measure(inf); this.postGrid.Width = tb.DesiredSize.Width + 2 * MarginWidth; Grid.SetColumn(rect, 0); Grid.SetRow(rect, 0); Grid.SetRowSpan(rect, 1); Grid.SetColumnSpan(rect, 3); Grid.SetRow(tb, 0); Grid.SetColumn(tb, 1); this.postGrid.Children.Add(rect); this.postGrid.Children.Add(tb); Canvas.SetLeft(this.postGrid, Math.Max(viewRightEdge - this.postGrid.Width - 20.0, textRightEdge + 20.0)); Canvas.SetTop(this.postGrid, textGeometry.GetRenderBounds(solidPen).Top); this.Children.Add(this.postGrid); }
public void UpdateColors(Color background, Color foreground) { _borderPen = new Pen(new SolidColorBrush(foreground), 1); _borderPen.Freeze(); _backgroundBrush = new SolidColorBrush(background); _backgroundBrush.Freeze(); }
private void setBackgroundColor() { BrushConverter bc = new BrushConverter(); System.Windows.Media.Brush brush = (System.Windows.Media.Brush)bc.ConvertFrom("#012D41"); brush.Freeze(); mainWindow.Background = brush; }
/// <summary> /// Initializes a new instance of the <see cref="NamedBrush"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="brush">The brush.</param> public NamedBrush(string name, Brush brush) { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); Name = name; Brush = brush; Brush.Freeze(); }
public static Brush FreezeBrush(Brush brush) { RenderOptions.SetBitmapScalingMode(brush, BitmapScalingMode.LowQuality); RenderOptions.SetCacheInvalidationThresholdMinimum(brush, 0.5); RenderOptions.SetCacheInvalidationThresholdMaximum(brush, 2.0); RenderOptions.SetCachingHint(brush, CachingHint.Cache); brush.Freeze(); return brush; }
static SelectAdorner() { Color color = Color.FromRgb(0x53, 0x9C, 0xD8); BorderBrush = new SolidColorBrush(color); BorderBrush.Freeze(); color.A = 100; FillBrush = new SolidColorBrush(color); FillBrush.Freeze(); }
public LogViewer() { InitializeComponent(); m_foregroundBrushTime = new SolidColorBrush(Colors.LightGray); m_foregroundBrushTime.Freeze(); m_foregroundBrushHighlight = new SolidColorBrush(Colors.Firebrick); m_foregroundBrushHighlight.Freeze(); }
public BlockToCellConverter(Brush dayOffForeground, Brush newTermForeground, Brush foreground) { dayOffForeground.Freeze(); newTermForeground.Freeze(); foreground.Freeze(); _foreground = foreground; _dayOffFroeground = dayOffForeground; _newTermForeground = newTermForeground; }
public ToxUserStatusToBrushConverter() { ToxUserStatusNONE = new SolidColorBrush(Color.FromRgb(6, 225, 1)); ToxUserStatusNONE.Freeze(); ToxUserStatusBUSY = new SolidColorBrush(Color.FromRgb(214, 43, 79)); ToxUserStatusBUSY.Freeze(); ToxUserStatusAWAY = new SolidColorBrush(Color.FromRgb(229, 222, 31)); ToxUserStatusAWAY.Freeze(); ToxUserStatusINVALID = new SolidColorBrush(Colors.Red); ToxUserStatusINVALID.Freeze(); }
public WPFCanvasAdapter() { _pen = new Pen() { Brush = new SolidColorBrush(Colors.Black), Thickness = 1, StartLineCap = PenLineCap.Round, EndLineCap = PenLineCap.Round, }; _pen.Freeze(); _brush = new SolidColorBrush(Colors.Transparent); _brush.Freeze(); }
static FormatMapWatcher() { Color highlight = SystemColors.HighlightColor; Color darkColor = Color.FromArgb(96, highlight.R, highlight.G, highlight.B); Color lightColor = Color.FromArgb(48, highlight.R, highlight.G, highlight.B); gradientBrush = new LinearGradientBrush(new GradientStopCollection() { new GradientStop(darkColor, 0.0), new GradientStop(lightColor, 0.5), new GradientStop(darkColor, 1.0) }, 90.0); gradientBorder = new Pen(SystemColors.HighlightBrush, 1) { LineJoin = PenLineJoin.Round }; gradientBrush.Freeze(); gradientBorder.Freeze(); }
/// <summary>Noformējums ar īpašām fona otām.</summary> /// <remarks> /// Lai lietotu vienu bildi visai kopējai ekrāna daļai, /// to jāpadod kā <paramref name="logoBackground"/>, bet <paramref name="guideBackground"/> jābūt <c>null</c>. /// </remarks> public Brand(Color textColor, Color statusColor, Color captionTextColor, Color windowBorderColor, Brush captionBackground, Brush logoBackground, Brush guideBackground=null) { if (textColor == null || statusColor == null || captionBackground == null) throw new ArgumentNullException("Kāda krāsa nav norādīta"); if (captionBackground == null || logoBackground == null) throw new ArgumentNullException("Kāda ota nav norādīta"); if (guideBackground == null) HasSharedBackground=true; else { guideBackground.Freeze(); HasSharedBackground=false; } textForeground=new SolidColorBrush(textColor); statusForeground=new SolidColorBrush(statusColor); captionForeground=new SolidColorBrush(captionTextColor); windowBorder=new SolidColorBrush(windowBorderColor); this.captionBackground=captionBackground; this.logoBackground=logoBackground; this.guideBackground=guideBackground; // Iesaldē otas labākai veiktspējai. To animācija pēc šī soļa nav iespējama. textForeground.Freeze(); statusForeground.Freeze(); captionForeground.Freeze(); windowBorder.Freeze(); captionBackground.Freeze(); logoBackground.Freeze(); }
public EquationBase(EquationContainer parent) { this.ParentEquation = parent; if (parent != null) { SubLevel = parent.SubLevel; fontSize = parent.fontSize; ApplySymbolGap = parent.ApplySymbolGap; r = (byte)(parent.r + 15); g = (byte)(parent.r + 15); b = (byte)(parent.r + 15); } debugBrush = new SolidColorBrush(Color.FromArgb(100, r, g, b)); debugBrush.Freeze(); boxPen.Freeze(); }
public DWindow() { InitializeComponent(); Color color = Color.FromRgb(0x00, 0x00, 0x00); _turnBrush = new SolidColorBrush(color); _turnBrush.Freeze(); DebugWindowCommand.InputGestures.Add(new KeyGesture(Key.D, ModifierKeys.Control)); var cb = new CommandBinding(DebugWindowCommand, MyCommandExecute, MyCommandCanExecute); CommandBindings.Add(cb); var kg = new KeyGesture(Key.M, ModifierKeys.Control); var ib = new InputBinding(DebugWindowCommand, kg); InputBindings.Add(ib); }
private void SetOpacity(double newOpacity) { if (mediaBrush == null) { return; } // Force opcatity to be in bounds opacity = Math.Min(100.0, Math.Max(0, newOpacity)); // Clone any Frozen brush so it can be modified if (mediaBrush.IsFrozen) { mediaBrush = mediaBrush.Clone(); } // Set Opacity and freeze brush. mediaBrush.Opacity = opacity / 100.0; mediaBrush.Freeze(); }
static CellFactory() { _padding = new Thickness(4, 0, 4, 0); _bdrError = new Thickness(4); _bdrFixed = new Thickness(0, 0, 1, 1); _bdrV = new Thickness(0, 0, 1, 0); _bdrH = new Thickness(0, 0, 0, 1); _bdrA = new Thickness(0, 0, 1, 1); _bdrN = Util.Util.ThicknessEmpty; // _brBlack = Brushes.Black; _brWhite = Brushes.White; _brError = new SolidColorBrush(Color.FromArgb(255, 220, 0, 12)); _brError.Freeze(); _brBlue = new SolidColorBrush(Color.FromArgb(255, 100, 150, 200)); _brBlue.Freeze(); // _brOpaque = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0)); // _brOpaque.Freeze(); _brTransparent = Brushes.Transparent; _imgError = null; _csSelected = new CellStyle(); }
public PassCardImagePropertyPainter(CommonDesignerCanvas designerCanvas, ElementPassCardImageProperty element, byte[] data) : base(designerCanvas, element) { if (data != null) using (var imageStream = new MemoryStream(data)) { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.CacheOption = BitmapCacheOption.OnLoad; bitmapImage.StreamSource = imageStream; bitmapImage.EndInit(); _brush = new ImageBrush(bitmapImage) { Stretch = element.Stretch.ToWindowsStretch(), }; _brush.Freeze(); } else _brush = null; }
public DynamicTactic(Maps maps, Tanks tanks, Icons icons) : base(maps, tanks, icons) { dynamicTanks = new List<DynamicTank>(); staticIcons = new List<StaticIcon>(); brush = new SolidColorBrush(Color.FromRgb(255, 0, 0)); brush.Freeze(); iconsSize = 50; ShowPlayerName = true; ShowTankName = false; TankIcon = DisplayTankIcon.tanktype; selectedStaticIcon = new List<StaticIcon>(); selectedDynamicTank = new List<DynamicTank>(); copyDynamicTank = new List<DynamicTank>(); var source = new Uri(@"pack://application:,,,/Resources/clearTactics.png", UriKind.Absolute); clearTactic = new BitmapImage(source); }
/// <summary> /// Initializes a new instance of the <see cref="Highlighter"/> class. /// </summary> /// <param name="wpfTextView">Text view to create the adornment for</param> public Highlighter(IWpfTextView wpfTextView) { if (wpfTextView == null) { throw new ArgumentNullException(nameof(wpfTextView)); } _adornmentLayer = wpfTextView.GetAdornmentLayer("Highlighter"); _wpfTextView = wpfTextView; // Listen to any event that changes the layout (text changes, scrolling, etc) _wpfTextView.LayoutChanged += OnLayoutChanged; // Create the pen and brush to color the box behind the TODO's _brush = new SolidColorBrush(Color.FromArgb(63, 221, 255, 0)); _brush.Freeze(); var penBrush = new SolidColorBrush(Color.FromArgb(255, 221, 255, 0)); penBrush.Freeze(); _pen = new Pen(penBrush, 0.5); _pen.Freeze(); }
/// <summary> /// Initializes a new instance of the <see cref="TextAdornment"/> class. /// </summary> /// <param name="view">Text view to create the adornment for</param> public TextAdornment(IWpfTextView view) { if (view == null) { throw new ArgumentNullException("view"); } _layer = view.GetAdornmentLayer("TextAdornment"); _view = view; _view.LayoutChanged += OnLayoutChanged; _view.MouseHover += OnViewMouseHover; // Create the pen and brush to color the box behind the a's _brush = new SolidColorBrush(Color.FromArgb(0x20, 0x00, 0x00, 0xff)); _brush.Freeze(); var penBrush = new SolidColorBrush(Colors.Red); penBrush.Freeze(); _pen = new Pen(penBrush, 0.5); _pen.Freeze(); }
static QuestCategoryToBrushConverter() { r_Composition = new SolidColorBrush(Color.FromRgb(0x43, 0xC7, 0x69)); r_Composition.Freeze(); r_Sortie = new SolidColorBrush(Color.FromRgb(0xEC, 0x60, 0x63)); r_Sortie.Freeze(); r_Practice = new SolidColorBrush(Color.FromRgb(0x93, 0xCE, 0x67)); r_Practice.Freeze(); r_Expedition = new SolidColorBrush(Color.FromRgb(0x4E, 0xBB, 0xD4)); r_Expedition.Freeze(); r_SupplyOrDocking = new SolidColorBrush(Color.FromRgb(0xDE, 0xC7, 0x72)); r_SupplyOrDocking.Freeze(); r_Arsenal = new SolidColorBrush(Color.FromRgb(0xBA, 0x8F, 0x79)); r_Arsenal.Freeze(); r_Modernization= new SolidColorBrush(Color.FromRgb(0xCA, 0xA6, 0xDD)); r_Modernization.Freeze(); }
static DropDownProvider() { _ddBrush = new SolidColorBrush(Color.FromArgb(255, 192, 192, 192)); _ddBrush.Freeze(); }
/// <summary> /// Initializes all general pens and brushes. /// </summary> private void InitializeResources() { textBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(120, 120, 120)); textBrush.Freeze(); Brush gridLineBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(160, 160, 160)); ; gridLineBrush.Freeze(); gridLinePen = new Pen(gridLineBrush, 1); gridLinePen.Freeze(); Brush gridBoldLineBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(20, 20, 20)); gridBoldLineBrush.Freeze(); gridBoldLinePen = new Pen(gridBoldLineBrush, 1); gridZeroLinePen = new Pen(gridBoldLineBrush, 2); gridBoldLinePen.Freeze(); gridZeroLinePen.Freeze(); backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 48, 48, 48)); backgroundBrush.Freeze(); glyphs = new Glyphs(); glyphs.FontUri = new Uri(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts) + "\\Arial.TTF"); glyphs.FontRenderingEmSize = 11; glyphs.StyleSimulations = StyleSimulations.None; // Seek Needle Brush seekNeedleBrush = Brushes.Red; Pen seekNeedlePen = new Pen(Brushes.Black, 1); seekNeedlePen.Freeze(); SeekNeedle = new GeometryDrawing(); PathGeometry path = new PathGeometry(); path.Figures.Add(new PathFigure( new System.Windows.Point(-4, 0), new[] { new PolyLineSegment(new [] { new System.Windows.Point(4, 0), new System.Windows.Point(0, -7), new System.Windows.Point(0, -20), new System.Windows.Point(0, -7)}, true) }, true)); SeekNeedle.Geometry = path; SeekNeedle.Brush = seekNeedleBrush; SeekNeedle.Pen = seekNeedlePen; }
static SpecialCharacterTextRunOptions() { BackgroundBrush = DefaultBackgroundBrush = new SolidColorBrush(Color.FromArgb(200, 128, 128, 128)); BackgroundBrush.Freeze(); ForegroundBrush = DefaultForegroundBrush; }
//Set the player's color based on their id. public void SetPlayerColor(int idx) { // Create the Player's Color Color[] baseColors = { Color.FromRgb(0x00, 0x00, 0x00), Color.FromRgb(0x00, 0x66, 0x00), Color.FromRgb(0x66, 0x00, 0x00), Color.FromRgb(0x00, 0x00, 0x66), Color.FromRgb(0x66, 0x00, 0x66), Color.FromRgb(0xFF, 0x66, 0x00), Color.FromRgb(0x00, 0x00, 0x00), Color.FromRgb(0x00, 0x99, 0x00), Color.FromRgb(0x99, 0x00, 0x00), Color.FromRgb(0x00, 0x00, 0x99), Color.FromRgb(0x99, 0x00, 0x99), Color.FromRgb(0xFF, 0x99, 0x00), Color.FromRgb(0x33, 0x33, 0x33), Color.FromRgb(0x00, 0x99, 0x00), Color.FromRgb(0x99, 0x00, 0x00), Color.FromRgb(0x00, 0x00, 0x99), Color.FromRgb(0x99, 0x00, 0x99), Color.FromRgb(0xFF, 0x99, 0x00), Color.FromRgb(0x66, 0x66, 0x66), Color.FromRgb(0xFF, 0x00, 0x00) }; if (idx == 255) idx = 0; if (idx > 18) idx = idx - 18; Color = baseColors[idx]; _solidBrush = new SolidColorBrush(Color); _solidBrush.Freeze(); _transparentBrush = new SolidColorBrush(Color) {Opacity = 0.4}; _transparentBrush.Freeze(); //Notify clients that this has changed OnPropertyChanged("Color"); OnPropertyChanged("Brush"); OnPropertyChanged("TransparentBrush"); }
static ChatTraceListener() { Color color = Color.FromRgb(0x5A, 0x9A, 0xCF); TurnBrush = new SolidColorBrush(color); TurnBrush.Freeze(); }
public BlameControl() : base(12, 1) { m_visual = new DrawingVisual(); AddVisualChild(m_visual); m_blamePreviousMenuItem = new MenuItem { Header = "Blame previous", Command = Commands.BlamePreviousCommand, CommandTarget = this }; m_viewAtGitHubMenuItem = new MenuItem { Header = "View at GitHub", Command = Commands.ViewAtGitHubCommand, CommandTarget = this }; ContextMenu = new ContextMenu { Items = { m_blamePreviousMenuItem, m_viewAtGitHubMenuItem } }; m_personBrush = new Dictionary<int, Brush>(); m_commitBrush = new Dictionary<string, SolidColorBrush>(); m_commitAlpha = new Dictionary<string, byte>(); m_newLineBrush = new SolidColorBrush(Color.FromRgb(108, 226, 108)); m_newLineBrush.Freeze(); m_changedTextBrush = new SolidColorBrush(Color.FromRgb(193, 228, 255)); m_changedTextBrush.Freeze(); m_redrawTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(100), DispatcherPriority.Background, OnRedrawTimerTick, Dispatcher); // can only show the tooltip if the mouse is over the control, and the context menu isn't open var canShowTooltip = this.WhenAny(x => x.IsMouseOver, x => x.ContextMenu.IsOpen, (mo, cm) => mo.Value && !cm.Value); canShowTooltip.Where(x => !x).ObserveOnDispatcher().Subscribe(_ => HideToolTip()); var mouseMove = Observable.FromEventPattern<MouseEventArgs>(this, "MouseMove"); var mouseOverCommits = mouseMove .Select(x => x.EventArgs.GetPosition(this)) .Select(GetCommitFromPoint) .DistinctUntilChanged(); mouseOverCommits.ObserveOnDispatcher().Subscribe(MouseOverCommit); mouseOverCommits.Throttle(TimeSpan.FromSeconds(0.5)) .CombineLatest(canShowTooltip, (l, r) => new { Commit = l, CanShowTooltip = r }) .Where(x => x.Commit != null && x.CanShowTooltip) .Select(x => x.Commit) .ObserveOnDispatcher() .Subscribe(ShowCommitTooltip); }
/// <summary> /// Creates and initializes objects required for drawing /// </summary> private void EnsureReady() { if (false == _isActivated) { _isActivated = true; EnsureVisual(); _brush = new SolidColorBrush(DotColor); _brush.Freeze(); //_linePen = new Pen(new SolidColorBrush(Colors.DarkGray), ConnectLineThickness); //_linePen.Brush.Opacity = ConnectLineOpacity; //_linePen.LineJoin = PenLineJoin.Round; _pen = new Pen(new SolidColorBrush(DotCircumferenceColor), DotCircumferenceThickness); _pen.LineJoin = PenLineJoin.Round; _pen.Freeze(); _lasso = new List<Point>(100); _boundingBox = Rect.Empty; _count = 0; } }
private static Pen GetBorderPen(Brush border) { Pen pen = null; if (border != null) { if (_commonBorderPen == null) // Common case, if non-null, avoid the lock { lock (_resourceAccess) // If non-null, lock to create the pen for thread safety { if (_commonBorderPen == null) // Check again in case _pen was created within the last line { // Assume that the first render of Button uses the most common brush for the app. // This breaks down if (a) the first Button is disabled, (b) the first Button is // customized, or (c) BulletChrome becomes more broadly used than just on Button. // // If these cons sufficiently weaken the effectiveness of this cache, then we need // to build a larger brush-to-pen mapping cache. // If the brush is not already frozen, we need to create our own // copy. Otherwise we will inadvertently freeze the user's // BorderBrush when we freeze the pen below. if (!border.IsFrozen && border.CanFreeze) { border = border.Clone(); border.Freeze(); } Pen commonPen = new Pen(border, 1); if (commonPen.CanFreeze) { // Only save frozen pens, some brushes such as VisualBrush // can not be frozen commonPen.Freeze(); _commonBorderPen = commonPen; } } } } if (_commonBorderPen != null && border == _commonBorderPen.Brush) { pen = _commonBorderPen; } else { if (!border.IsFrozen && border.CanFreeze) { border = border.Clone(); border.Freeze(); } pen = new Pen(border, 1); if (pen.CanFreeze) { pen.Freeze(); } } } return pen; }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); Debug.Assert((overwriteCaretBrush == null) == (caretBrush == null)); if (caretBrush == null) { caretBrush = classificationFormatMap.DefaultTextProperties.ForegroundBrush; Debug.Assert(!classificationFormatMap.DefaultTextProperties.ForegroundBrushEmpty); if (classificationFormatMap.DefaultTextProperties.ForegroundBrushEmpty) caretBrush = Brushes.Black; caretBrush = caretBrush.Clone(); overwriteCaretBrush = caretBrush.Clone(); overwriteCaretBrush.Opacity = 0.5; if (caretBrush.CanFreeze) caretBrush.Freeze(); if (overwriteCaretBrush.CanFreeze) overwriteCaretBrush.Freeze(); } drawingContext.DrawGeometry(caretGeometry.IsOverwriteMode ? overwriteCaretBrush : caretBrush, null, caretGeometry.Geometry); }
static HexEditorBlock() { m_InvisiBrush = new SolidColorBrush(Colors.Transparent); m_InvisiBrush.Freeze(); }