internal static Brush GetBrush(this ResourceDictionary dictionary, string brushName, string colorName, Brush defaultBrush) { if (dictionary == null) { return defaultBrush; } var obj = dictionary[brushName]; if (obj is Brush) { return (Brush)obj; } obj = dictionary[colorName]; if (obj is Color?) { var color = (Color?)obj; if (color.HasValue) { var brush = new SolidColorBrush(color.Value); brush.Freeze(); return brush; } } return defaultBrush; }
static MouseHandler() { _brHighlight = new SolidColorBrush(Color.FromArgb(128, 255, 215, 140)); _brHighlight.Freeze(); _brInsert = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0)); _brInsert.Freeze(); }
public override object ProvideValue(IServiceProvider serviceProvider) { SolidColorBrush brush = new SolidColorBrush(GetColor()); brush.Freeze(); return brush; }
public static Brush GetBrush(string heroKey) { var color = GetColor(heroKey); var brush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B)); brush.Freeze(); return brush; }
/// <summary> /// Creates a square image and attaches an event handler to the layout changed event that /// adds the the square in the upper right-hand corner of the TextView via the adornment layer /// </summary> /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param> public TranslationAdornment(IWpfTextView view) { _view = view; Brush brush = new SolidColorBrush(Colors.BlueViolet); brush.Freeze(); Brush penBrush = new SolidColorBrush(Colors.Red); penBrush.Freeze(); Pen pen = new Pen(penBrush, 0.5); pen.Freeze(); //draw a square with the created brush and pen System.Windows.Rect r = new System.Windows.Rect(0, 0, 30, 30); Geometry g = new RectangleGeometry(r); GeometryDrawing drawing = new GeometryDrawing(brush, pen, g); drawing.Freeze(); DrawingImage drawingImage = new DrawingImage(drawing); drawingImage.Freeze(); _image = new Image(); _image.Source = drawingImage; //Grab a reference to the adornment layer that this adornment should be added to _adornmentLayer = view.GetAdornmentLayer("TranslationAdornment"); _view.ViewportHeightChanged += delegate { this.onSizeChange(); }; _view.ViewportWidthChanged += delegate { this.onSizeChange(); }; }
internal DragDropManager(FrameworkElement owner) { _owner = owner; Visibility = Visibility.Collapsed; SetValue(RowSpanProperty, 1000); SetValue(ColumnSpanProperty, 1000); Background = Brushes.Transparent; _indicatorBorderBrush = new SolidColorBrush(Color.FromArgb(192, _clr.R, _clr.G, _clr.B)); _indicatorBorderBrush.Freeze(); _indicatorBackgroundBrush = new SolidColorBrush(Color.FromArgb(64, _clr.R, _clr.G, _clr.B)); _indicatorBackgroundBrush.Freeze(); _source = CreateIndicator(); _target = CreateIndicator(); MouseMove += delegate(object s, MouseEventArgs e) { base.Cursor = ((this._target.Width > 0.0) ? Cursors.Hand : null); this.OnDragging(e); }; MouseLeftButtonUp += delegate(object s, MouseButtonEventArgs e) { this.IsOpen = false; this.OnDropped(e); }; LostMouseCapture += delegate { this.IsOpen = false; }; }
public void Draw(TextView textView, DrawingContext drawingContext) { if (textView == null) throw new ArgumentNullException("textView"); if (drawingContext == null) throw new ArgumentNullException("drawingContext"); if (currentResults == null || !textView.VisualLinesValid) return; var visualLines = textView.VisualLines; if (visualLines.Count == 0) return; int viewStart = visualLines.First().FirstDocumentLine.Offset; int viewEnd = visualLines.Last().LastDocumentLine.EndOffset; foreach (SearchResult result in currentResults.FindOverlappingSegments(viewStart, viewEnd - viewStart)) { BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder(); geoBuilder.AlignToWholePixels = true; geoBuilder.CornerRadius = 3; geoBuilder.AddSegment(textView, result); Geometry geometry = geoBuilder.CreateGeometry(); if (geometry != null) { SolidColorBrush brush = new SolidColorBrush(Colors.LightGreen); brush.Freeze(); drawingContext.DrawGeometry(brush, null, geometry); } } }
public PresentationSpace() { privacyOverlay = new SolidColorBrush { Color = Colors.Red, Opacity = 0.2 }; privacyOverlay.Freeze(); InitializeComponent(); CommandBindings.Add(new CommandBinding(ApplicationCommands.Undo, (sender, args) => Commands.Undo.Execute(null))); CommandBindings.Add(new CommandBinding(ApplicationCommands.Redo, (sender, args) => Commands.Redo.Execute(null))); Commands.InitiateDig.RegisterCommand(new DelegateCommand<object>(InitiateDig)); Commands.MoveTo.RegisterCommand(new DelegateCommand<Location>(MoveTo)); Commands.ReceiveLiveWindow.RegisterCommand(new DelegateCommand<LiveWindowSetup>(ReceiveLiveWindow)); Commands.MirrorPresentationSpace.RegisterCommand(new DelegateCommand<Window1>(MirrorPresentationSpace, CanMirrorPresentationSpace)); Commands.PreParserAvailable.RegisterCommand(new DelegateCommand<MeTLLib.Providers.Connection.PreParser>(PreParserAvailable)); Commands.UpdateConversationDetails.RegisterCommand(new DelegateCommand<ConversationDetails>(UpdateConversationDetails)); Commands.ConvertPresentationSpaceToQuiz.RegisterCommand(new DelegateCommand<int>(ConvertPresentationSpaceToQuiz)); Commands.SyncedMoveRequested.RegisterCommand(new DelegateCommand<int>(setUpSyncDisplay)); Commands.InitiateGrabZoom.RegisterCommand(new DelegateCommand<object>(InitiateGrabZoom)); Commands.Highlight.RegisterCommand(new DelegateCommand<HighlightParameters>(highlight)); Commands.RemoveHighlight.RegisterCommand(new DelegateCommand<HighlightParameters>(removeHighlight)); Commands.GenerateScreenshot.RegisterCommand(new DelegateCommand<ScreenshotDetails>(GenerateScreenshot)); Commands.BanhammerSelectedItems.RegisterCommand(new DelegateCommand<object>(BanHammerSelectedItems)); Commands.ShowConversationSearchBox.RegisterCommand(new DelegateCommand<object>(showConversationSearch)); Commands.HideConversationSearchBox.RegisterCommand(new DelegateCommand<object>(hideConversationSearch)); Commands.AllStaticCommandsAreRegistered(); inConversation = true; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var colourValue = (Color)value; var brush = new SolidColorBrush(colourValue); brush.Freeze(); return brush; }
static PainterCache() { UseTransparentImage = true; try { TransparentBrush = new SolidColorBrush(Colors.Transparent); TransparentBrush.Freeze(); BlackBrush = new SolidColorBrush(Colors.Black); BlackBrush.Freeze(); WhiteBrush = new SolidColorBrush(Colors.White); WhiteBrush.Freeze(); ZonePen = new Pen(BlackBrush, 1); GridLineBrush = new SolidColorBrush(Colors.Orange); GridLineBrush.Freeze(); GridLinePen = new Pen(GridLineBrush, 1); GridLinePen.EndLineCap = PenLineCap.Square; GridLinePen.StartLineCap = PenLineCap.Square; GridLinePen.DashStyle = DashStyles.Dash; PointGeometry = new RectangleGeometry(new Rect(-15, -15, 30, 30)); _transparentBackgroundBrush = CreateTransparentBackgroundBrush(); } catch (Exception e) { Logger.Error(e, "PainterCache.PainterCache()"); } }
/// <summary> /// Provides a ClockWidget /// </summary> public ClockWidget() { DataContext = this; using (var service = ServiceFactory.GetCallbackServiceWrapper<ISettingsService>(new SettingsServiceCallback())) { object colorString = ColorConverter.ConvertFromString(service.Instance.GetSetting(SettingKeys.Color).GetValue<string>()); if (colorString != null) { _color = new SolidColorBrush((Color)colorString); } else { _color = new SolidColorBrush(Colors.Red); } _waitTimeSetting = service.Instance.GetSetting(SettingKeys.WaitTime).GetValue<int>(); _blink = service.Instance.GetSetting(SettingKeys.Blink).GetValue<bool>(); } _black = new SolidColorBrush(Colors.Black); _transparent = new SolidColorBrush(Colors.Transparent); _black.Freeze(); _color.Freeze(); _transparent.Freeze(); InitializeComponent(); ForeColor = _black; _clockTimer = new DispatcherTimer(); _clockTimer.Interval = TimeSpan.FromSeconds(0.5); _clockTimer.Tick += ClockTimer_Tick; }
public AchievementAdornments(IWpfTextView view) { this.view = view; this.layer = view.GetAdornmentLayer("AchievementAdornments"); this.descriptionLayer = view.GetAdornmentLayer("AchievementAdornmentsDescription"); view.LayoutChanged += OnLayoutChanged; Brush brush = new SolidColorBrush(Color.FromArgb(0x20, 0x00, 0x00, 0xff)); brush.Freeze(); Brush penBrush = new SolidColorBrush(Colors.Red); penBrush.Freeze(); Pen pen = new Pen(penBrush, 0.5); pen.Freeze(); this.brush = brush; this.pen = pen; AchievementUIContext.AchievementClicked += (sender, e) => { Reset(); var filePath = GetFilePath(view); if (e.AchievementDescriptor.CodeOrigin.FileName != filePath) return; codeOrigin = e.AchievementDescriptor.CodeOrigin; achievementUiElement = (UIElement)e.UIElement; CreateAdornment(); }; }
public static Brush Convert(System.Windows.Media.Color color) { var brush = new SolidColorBrush(color); brush.Freeze(); return brush; }
static FrozenResources() { PreviewIconPinnedBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x97, 0x93, 0x8E)); PreviewIconClickedBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xA4, 0xA0, 0x9A)); PreviewIconHoverBrush = new SolidColorBrush(Color.FromArgb(0x00, 0xFF, 0xFF, 0xFF)); PreviewIconNormalBrush = new SolidColorBrush(Color.FromArgb(0x00, 0xFF, 0xFF, 0xFF)); PreviewIconPinnedBrush.Freeze(); PreviewIconClickedBrush.Freeze(); PreviewIconHoverBrush.Freeze(); PreviewIconNormalBrush.Freeze(); #region Legacy Info Bubble related data members // TODO(Ben): Remove these once Info Bubble has been completely removed. WarningFrameFill = new SolidColorBrush(Color.FromRgb(0xff, 0xef, 0xa0)); WarningFrameStrokeColor = new SolidColorBrush(Color.FromRgb(0xf2, 0xbd, 0x53)); WarningTextForeground = new SolidColorBrush(Color.FromRgb(0x33, 0x33, 0x33)); ErrorFrameFill = new SolidColorBrush(Color.FromRgb(255, 255, 255)); ErrorFrameStrokeColor = new SolidColorBrush(Color.FromRgb(190, 70, 70)); ErrorTextForeground = new SolidColorBrush(Color.FromRgb(190, 70, 70)); WarningFrameFill.Freeze(); WarningFrameStrokeColor.Freeze(); WarningTextForeground.Freeze(); ErrorFrameFill.Freeze(); ErrorFrameStrokeColor.Freeze(); ErrorTextForeground.Freeze(); #endregion }
public WpfArc(IArc arc) { _xarc = arc; _fillBrush = new SolidColorBrush(_xarc.Fill.ToNativeColor()); _fillBrush.Freeze(); _strokeBrush = new SolidColorBrush(_xarc.Stroke.ToNativeColor()); _strokeBrush.Freeze(); _path = new Path(); _path.Tag = this; _path.Fill = _fillBrush; _path.Stroke = _strokeBrush; _path.StrokeThickness = arc.StrokeThickness; _pg = new PathGeometry(); _pf = new PathFigure(); _pf.IsFilled = arc.IsFilled; _pf.IsClosed = arc.IsClosed; _start = new Point(); _as = new ArcSegment(); SetArcSegment(_as, arc, out _start); _pf.StartPoint = _start; _pf.Segments.Add(_as); _pg.Figures.Add(_pf); _path.Data = _pg; Native = _path; }
static MapViewModel() { red = new SolidColorBrush(Color.FromRgb(255, 32, 32)); red.Freeze(); green = new SolidColorBrush(Color.FromRgb(64, 200, 32)); green.Freeze(); }
private static SolidColorBrush GetNextBrush() { SolidColorBrush brush = new SolidColorBrush(GetNext()); brush.Freeze(); return brush; }
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); }
/// <summary> /// Initializes static members of the <see cref="ZigzagMarker"/> class. /// </summary> static ZigzagMarker() { var brush = new SolidColorBrush(Colors.Red); brush.Freeze(); DefaultPen = new Pen(brush, 0.75); DefaultPen.Freeze(); }
static WindowContainer() { // The default background must be transparent in order to be able to trap // all mouse events when a modal window is displayed. var defaultModalBackgroundBrush = new SolidColorBrush( Colors.Transparent ); defaultModalBackgroundBrush.Freeze(); ModalBackgroundBrushProperty = DependencyProperty.Register( "ModalBackgroundBrush", typeof( Brush ), typeof( WindowContainer ), new UIPropertyMetadata( defaultModalBackgroundBrush, OnModalBackgroundBrushChanged ) ); }
public static SolidColorBrush ToNativeBrush(this System.Drawing.Color This) { var ret = new SolidColorBrush(This.ToNative()); #if !SILVERLIGHT ret.Freeze(); #endif return ret; }
/// <summary> /// Returns a random pastel brush /// </summary> /// <returns></returns> public SolidColorBrush GetNextBrush() { SolidColorBrush brush = new SolidColorBrush(GetNext()); // freeze the brush for efficiency 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 static SolidColorBrush GetSolidColorBrush(Color color) { var brush = new SolidColorBrush {Color = color}; #if !SILVERLIGHT brush.Freeze(); #endif return brush; }
private void _UpdateGlassColor(IntPtr wParam, IntPtr lParam) { bool isOpaque = lParam != IntPtr.Zero; uint color = unchecked((uint)(int)wParam.ToInt64()); color |= isOpaque ? 0xFF000000 : 0; WindowGlassColor = Utility.ColorFromArgbDword(color); var glassBrush = new SolidColorBrush(WindowGlassColor); glassBrush.Freeze(); WindowGlassBrush = glassBrush; }
public static Brush GetBrush(Color color) { if (!_brushes.ContainsKey(color)) { var brush = new SolidColorBrush(color.ToWindowsColor()); brush.Freeze(); _brushes.Add(color, brush); } return _brushes[color]; }
/// <summary> /// Gets a solid color brush from the color specified. /// </summary> /// <param name="color">The color in RGBA format (A is the least significant byte).</param> /// <returns>A solid color brush.</returns> public System.Windows.Media.Brush GetBrushFromColor(Color color) { if (!_cachedSolidBrushes.TryGetValue(color, out var brush)) { brush = new System.Windows.Media.SolidColorBrush(color); brush.Freeze(); _cachedSolidBrushes.Add(color, brush); } return(brush); }
public ProjectEntry Initialised(Toggl.TogglAutocompleteView item, Action selectWithClick, string overideText = null) { var colorBrush = new SolidColorBrush(getProjectColor(ref item)); colorBrush.Freeze(); this.projectColor.Background = colorBrush; this.project.Text = overideText ?? item.ProjectLabel; this.task.Text = string.IsNullOrEmpty(item.TaskLabel) ? "" : "- " + item.TaskLabel; this.setClickAction(selectWithClick); return this; }
public void Draw(TextView textView, DrawingContext drawingContext) { if (markers == null || !textView.VisualLinesValid) { return; } var visualLines = textView.VisualLines; if (visualLines.Count == 0) { return; } int viewStart = visualLines.First().FirstDocumentLine.Offset; int viewEnd = visualLines.Last().LastDocumentLine.EndOffset; foreach (TextMarker marker in markers.FindOverlappingSegments(viewStart, viewEnd - viewStart)) { if (marker.BackgroundColor != null) { var geoBuilder = new BackgroundGeometryBuilder { AlignToWholePixels = true, CornerRadius = 3 }; geoBuilder.AddSegment(textView, marker); Geometry geometry = geoBuilder.CreateGeometry(); if (geometry != null) { Color color = marker.BackgroundColor.Value; var brush = new SolidColorBrush(color); brush.Freeze(); drawingContext.DrawGeometry(brush, null, geometry); } } foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, marker)) { Point startPoint = r.BottomLeft; Point endPoint = r.BottomRight; var usedPen = new Pen(new SolidColorBrush(marker.MarkerColor), 1); usedPen.Freeze(); const double offset = 2.5; int count = Math.Max((int)((endPoint.X - startPoint.X) / offset) + 1, 4); var geometry = new StreamGeometry(); using (StreamGeometryContext ctx = geometry.Open()) { ctx.BeginFigure(startPoint, false, false); ctx.PolyLineTo(CreatePoints(startPoint, endPoint, offset, count).ToArray(), true, false); } geometry.Freeze(); drawingContext.DrawGeometry(Brushes.Transparent, usedPen, geometry); break; } } }
public CoverAdorner(UIElement adornedElement) : base(adornedElement) { Color color = new Color(); color.A = 50; color.B = 0; color.R = 0; color.G = 0; brush = new SolidColorBrush(color); brush.Freeze(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is SolidColorBrush) { var idealForegroundColor = this.IdealTextColor(((SolidColorBrush)value).Color); var foreGroundBrush = new SolidColorBrush(idealForegroundColor); foreGroundBrush.Freeze(); return foreGroundBrush; } return Brushes.White; }
private WPF.Brush CreateBrush(Color color, object _ = null) { this.ViewModel.ResourcesCreated += 1; var brush = new WPF.SolidColorBrush(color.ToNative()); brush.Freeze(); if (this.ViewModel.IsFakeDelayImposed) { // fake delay to simulate the creation of an even more expensive resource Thread.Sleep(25); } return(brush); }
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "ChartCustomToolBarExample"; Calculate = Calculate.OnBarClose; IsOverlay = true; DisplayInDataBox = false; IsSuspendedWhileInactive = true; } else if (State == State.DataLoaded) { activeBackgroundDarkGray = new System.Windows.Media.SolidColorBrush(Color.FromRgb(30, 30, 30)); activeBackgroundDarkGray.Freeze(); backGroundMediumGray = new System.Windows.Media.SolidColorBrush(Color.FromRgb(45, 45, 47)); backGroundMediumGray.Freeze(); controlLightGray = new System.Windows.Media.SolidColorBrush(Color.FromRgb(64, 63, 69)); controlLightGray.Freeze(); textColor = new System.Windows.Media.SolidColorBrush(Color.FromRgb(204, 204, 204)); textColor.Freeze(); } else if (State == State.Historical) { if (ChartControl != null) { ChartControl.Dispatcher.InvokeAsync((Action)(() => { CreateWPFControls(); })); } } else if (State == State.Terminated) { if (ChartControl != null) { ChartControl.Dispatcher.InvokeAsync((Action)(() => { DisposeWPFControls(); })); } } }