本文整理汇总了C#中System.Windows.Media.BrushConverter类的典型用法代码示例。如果您正苦于以下问题:C# BrushConverter类的具体用法?C# BrushConverter怎么用?C# BrushConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BrushConverter类属于System.Windows.Media命名空间,在下文中一共展示了BrushConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WatchViewFullscreen
public WatchViewFullscreen()
{
InitializeComponent();
MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(view_MouseButtonIgnore);
MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(view_MouseButtonIgnore);
MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(view_MouseRightButtonUp);
PreviewMouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(view_PreviewMouseRightButtonDown);
MenuItem mi = new MenuItem();
mi.Header = "Zoom to Fit";
mi.Click += new RoutedEventHandler(mi_Click);
MainContextMenu.Items.Add(mi);
System.Windows.Shapes.Rectangle backgroundRect = new System.Windows.Shapes.Rectangle();
Canvas.SetZIndex(backgroundRect, -10);
backgroundRect.IsHitTestVisible = false;
BrushConverter bc = new BrushConverter();
Brush strokeBrush = (Brush)bc.ConvertFrom("#313131");
backgroundRect.Stroke = strokeBrush;
backgroundRect.StrokeThickness = 1;
SolidColorBrush backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromRgb(250, 250, 216));
backgroundRect.Fill = backgroundBrush;
inputGrid.Children.Add(backgroundRect);
}
示例2: cpColor_SelectedColorChanged
private void cpColor_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs<Color> e)
{
Color selected = cpColor.SelectedColor;
var bc = new BrushConverter();
TheBackground = bc.ConvertFromString(selected.ToString()) as Brush;
colorDisplay.Background = TheBackground;
}
示例3: OverButtonLeft_MouseEnter
/// <summary>
/// Highlights UnderButtons
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OverButtonLeft_MouseEnter(object sender, MouseEventArgs e)
{
BrushConverter bc = new BrushConverter();
Brush brush = (Brush)bc.ConvertFrom("#41B1E1");
UnderButtonLeft.Foreground = brush;
UnderButtonLeft.Background = brush;
}
示例4: SelfmadeSVI
public SelfmadeSVI(ProtoDefinition protoDefinition = null)
{
InitializeComponent();
if (protoDefinition != null)
{
this.ProtoDefinition = protoDefinition;
}
//apply width and height
this.MainCanvas.Width = this.ProtoDefinition.Width;
this.MainCanvas.Height = this.ProtoDefinition.Height;
// applying the color
BrushConverter cConverter = new BrushConverter();
this.OwnColoredRectangle.Fill = cConverter.ConvertFromString(this.ProtoDefinition.Color) as SolidColorBrush;
//TODO: apply the given image
// initial position
MatrixTransform matrixTransform = this.RenderTransform as MatrixTransform;
Matrix rectsMatrix = matrixTransform.Matrix;
rectsMatrix.Translate(this.ProtoDefinition.X, this.ProtoDefinition.Y);
this.RenderTransform = new MatrixTransform(rectsMatrix);
}
示例5: ChangeColor
private void ChangeColor(object sender, SelectionChangedEventArgs args)
{
var li2 = ((sender as ListBox).SelectedItem as ListBoxItem);
var myBrushConverter = new BrushConverter();
border1.BorderBrush = (Brush) myBrushConverter.ConvertFromString((string) li2.Content);
bColor.Text = "Border.Borderbrush =" + li2.Content;
}
示例6: CreateField
//Создание пустого поля для игры
private void CreateField(int[] matr)
{
int side = (int)(237 / Math.Sqrt(matr.Length));
for (int i = 0; i < matr.Length; i++)
{
int leftPlace = (((int)(i % Math.Sqrt(matr.Length)))*side);
int topPlace = ((i / (int)(Math.Sqrt(matr.Length)))*side);
TextBox textBox = new TextBox();
textBox.FontSize = 50;
textBox.TextAlignment = TextAlignment.Center;
var bc = new BrushConverter();
textBox.Background = (Brush)bc.ConvertFrom("#FFD6D6D6");
if (matr[i] != 0)
textBox.Text = Convert.ToString(matr[i]);
textBox.Width = side - 1;
textBox.Height = side - 1;
Canvas.SetLeft(textBox, leftPlace);
Canvas.SetTop(textBox, topPlace);
Field.Children.Add(textBox);
}
}
示例7: DrawCore
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
{
if (drawingContext == null)
{
throw new ArgumentNullException("drawingContext");
}
if (null == drawingAttributes)
{
throw new ArgumentNullException("drawingAttributes");
}
Pen pen = new Pen
{
StartLineCap = PenLineCap.Round,
EndLineCap = PenLineCap.Round,
Brush = new SolidColorBrush(drawingAttributes.Color),
Thickness = drawingAttributes.Width
};
BrushConverter bc = new BrushConverter();
Brush BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString());
drawingContext.DrawRectangle(
BackGround,
pen,
new Rect(new Point(StylusPoints[0].X, StylusPoints[0].Y),
new Point(StylusPoints[1].X, StylusPoints[1].Y)));
}
示例8: getBrush
public static Brush getBrush(Name name, int num = 4)
{
var converter = new System.Windows.Media.BrushConverter();
switch(name)
{
case Name.Red: return (Brush)converter.ConvertFromString(RED[num]);
case Name.Pink: return (Brush)converter.ConvertFromString(PINK[num]);
case Name.Purple: return (Brush)converter.ConvertFromString(PURPLE[num]);
case Name.DeepPurple: return (Brush)converter.ConvertFromString(DEEP_PURPLE[num]);
case Name.Indigo: return (Brush)converter.ConvertFromString(INDIGO[num]);
case Name.Blue: return (Brush)converter.ConvertFromString(BLUE[num]);
case Name.LightBlue: return (Brush)converter.ConvertFromString(LIGHT_BLUE[num]);
case Name.Cyan: return (Brush)converter.ConvertFromString(CYAN[num]);
case Name.Teal: return (Brush)converter.ConvertFromString(TEAL[num]);
case Name.Green: return (Brush)converter.ConvertFromString(GREEN[num]);
case Name.LightGreen: return (Brush)converter.ConvertFromString(LIGHT_GREEN[num]);
case Name.Lime: return (Brush)converter.ConvertFromString(LIME[num]);
case Name.Yellow: return (Brush)converter.ConvertFromString(YELLOW[num]);
case Name.Amber: return (Brush)converter.ConvertFromString(AMBER[num]);
case Name.Orange: return (Brush)converter.ConvertFromString(ORANGE[num]);
case Name.DeepOrange: return (Brush)converter.ConvertFromString(DEEP_ORANGE[num]);
case Name.Brown: return (Brush)converter.ConvertFromString(BROWN[num]);
case Name.Grey: return (Brush)converter.ConvertFromString(GREY[num]);
case Name.BlueGrey: return (Brush)converter.ConvertFromString(BLUE_GREY[num]);
case Name.Black: return (Brush)converter.ConvertFromString("#FF000000");
}
return (Brush)converter.ConvertFromString("#FFFFFFFF");
}
示例9: Convert
/// <summary>
/// Converts the name of a color to a <see cref="System.Windows.Media.Brush"/> object.
/// </summary>
/// <param name="value"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var purpose = System.Convert.ToString(parameter);
switch (purpose)
{
case AppConstants.CONVERT_ACCENT:
var aceentColorName = System.Convert.ToString(value);
var accent = ThemeManager.DefaultAccents.FirstOrDefault(a => string.CompareOrdinal(a.Name, aceentColorName) == 0);
if (null != accent)
return accent.Resources["AccentColorBrush"] as Brush;
break;
case AppConstants.CONVERT_BASE:
var baseColorName = System.Convert.ToString(value);
var converter = new BrushConverter();
if (string.CompareOrdinal(baseColorName, AppConstants.LIGHT_BASE) == 0)
{
var brush = (Brush)converter.ConvertFromString("#FFFFFFFF");
return brush;
}
if (string.CompareOrdinal(baseColorName, AppConstants.DARK_BASE) == 0)
{
var brush = (Brush)converter.ConvertFromString("#FF000000");
return brush;
}
break;
}
return null;
}
示例10: Convert
public object Convert(object value_to_test, Type type, object paramater, CultureInfo cultureInfo)
{
double tempvalue = (double)value_to_test;
object tempBrushConverter = null;
if (!ReverseOrder)
{
// Default Order
if (tempvalue <= Bucket0)
tempBrushConverter = new BrushConverter().ConvertFromString("#7FFF0000");
else if (tempvalue > Bucket0 && tempvalue <= Bucket1)
tempBrushConverter = new BrushConverter().ConvertFromString("#7FF9E719");
else if (tempvalue > Bucket1)
tempBrushConverter = new BrushConverter().ConvertFromString("#7F00F500");
else
tempBrushConverter = Brushes.White;
}
else
{
if (tempvalue <= Bucket0)
tempBrushConverter = new BrushConverter().ConvertFromString("#7F00F500");
else if (tempvalue > Bucket0 && tempvalue <= Bucket1)
tempBrushConverter = new BrushConverter().ConvertFromString("#7FF9E719");
else if (tempvalue > Bucket1)
tempBrushConverter = new BrushConverter().ConvertFromString("#7FFF0000");
else
tempBrushConverter = Brushes.White;
}
return (tempBrushConverter as SolidColorBrush);
}
示例11: WinColor
public WinColor(MainWindow in_main)
{
InitializeComponent();
Config = new IniFile("./boby_add_file.ini");
tb_red.Text = Config.IniReadValue("boby", "red");
tb_green.Text = Config.IniReadValue("boby", "green");
tb_blue.Text = Config.IniReadValue("boby", "blue");
if (tb_red.Text == "")
tb_red.Text = "255";
if (tb_green.Text == "")
tb_green.Text = "0";
if (tb_blue.Text == "")
tb_blue.Text = "0";
if (Convert.ToInt32(tb_red.Text.Trim()) > 255)
tb_red.Text = "255";
if (Convert.ToInt32(tb_green.Text.Trim()) > 255)
tb_green.Text = "255";
if (Convert.ToInt32(tb_blue.Text.Trim()) > 255)
tb_blue.Text = "255";
var bc = new BrushConverter();
rt_color.Fill = (Brush)bc.ConvertFrom("#FF" + Convert.ToInt32(tb_red.Text.Trim()).ToString("X2") + Convert.ToInt32(tb_green.Text.Trim()).ToString("X2") + Convert.ToInt32(tb_blue.Text.Trim()).ToString("X2"));
in_main_win = in_main;
}
示例12: Convert
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Debug.Assert(value != null, "Value must not be null");
Brush brush = null;
if (value is Color)
{
brush = new SolidColorBrush((Color)value);
}
else if (value is string)
{
try
{
BrushConverter converter = new BrushConverter();
brush = converter.ConvertFromString((string)value) as SolidColorBrush;
}
catch
{
// We want to eat the exception
}
}
if (brush == null)
{
Debug.Fail(string.Format("Unable to convert {0} to a Brush. Using a Colors.Black as a default.", value ?? "NULL"));
brush = new SolidColorBrush(Colors.Black);
}
return brush;
}
示例13: BrushProvider
static BrushProvider()
{
var brushConverter = new BrushConverter();
_brushes.Insert(0, brushConverter.ConvertFromString("#88FFB7A5") as SolidColorBrush);
_brushes.Insert(0, brushConverter.ConvertFromString("#88BFE0FF") as SolidColorBrush);
_brushes.Insert(0, brushConverter.ConvertFromString("#88D2FFB5") as SolidColorBrush);
}
示例14: DiagramInheritanceConnector
/// <summary>
/// Initializes a new instance of the <see cref="DiagramInheritanceConnector"/> class.
/// </summary>
/// <param name="startConnector">The start connector.</param>
/// <param name="endConnector">The end connector.</param>
/// <remarks>
/// Consturctor that specifies the two nodes that are connected.
/// </remarks>
internal DiagramInheritanceConnector(DiagramConnectorNode startConnector, DiagramConnectorNode endConnector)
: base(startConnector, endConnector)
{
BrushConverter bc = new BrushConverter();
Brush brush = bc.ConvertFromString("#716F64") as Brush;
this.ResourcePen = new Pen(brush != null ? brush : Brushes.DimGray, 1);
}
示例15: WatermarkTextBox_TextChanged
private async void WatermarkTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (string.IsNullOrEmpty(previousID))
previousID = (sender as TextBox).Text;
try
{
if ((sender as TextBox).IsFocused == true)
{
bool result = true;
var doc = (DataContext as DocumentEditViewModel).Document;
doc.DocumentID = (sender as TextBox).Text;
try { result = await (DataContext as DocumentEditViewModel).ParentViewModel.ParentViewModel.Database.DocumentExists(doc); }
catch { }
if (result && (DataContext as DocumentEditViewModel).EditMode == true)
{
(sender as TextBox).BorderBrush = Brushes.Red;
(sender as TextBox).BorderThickness = new System.Windows.Thickness(2);
}
else
{
var converter = new System.Windows.Media.BrushConverter();
var brush = (Brush)converter.ConvertFromString("#FFABADB3");
(sender as TextBox).BorderBrush = brush;
(sender as TextBox).BorderThickness = new System.Windows.Thickness(1);
}
result = await (DataContext as DocumentEditViewModel).ParentViewModel.ParentViewModel.Database.UpdateTemporaryUsedDocumentID(previousID, (sender as TextBox).Text, doc.DocumentType);
previousID = (sender as TextBox).Text;
}
}
catch { }
}