本文整理汇总了C#中System.Windows.Media.BrushConverter类的典型用法代码示例。如果您正苦于以下问题:C# BrushConverter类的具体用法?C# BrushConverter怎么用?C# BrushConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BrushConverter类属于System.Windows.Media命名空间,在下文中一共展示了BrushConverter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:romeo08437,项目名称:Dynamo,代码行数:27,代码来源:WatchViewFullscreen.xaml.cs
示例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;
}
开发者ID:undecimus,项目名称:komunikator,代码行数:7,代码来源:ChangeBackgroundWindow.xaml.cs
示例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;
}
开发者ID:GodLesZ,项目名称:LegendaryClient,代码行数:12,代码来源:PatcherPage.xaml.cs
示例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);
}
开发者ID:ux-hs-mannheim,项目名称:lgRuntime,代码行数:25,代码来源:SelfmadeSVI.xaml.cs
示例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;
}
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:7,代码来源:MainWindow.cs
示例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);
}
}
开发者ID:Drumofrain,项目名称:netservices,代码行数:28,代码来源:MainWindow.xaml.cs
示例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)));
}
开发者ID:sonicrang,项目名称:RangPaint,代码行数:27,代码来源:RectangleStroke.cs
示例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");
}
开发者ID:jelee9,项目名称:wsr_pos_vs,代码行数:30,代码来源:MetrialColor.cs
示例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;
}
开发者ID:OxyProgrammer,项目名称:XPence,代码行数:37,代码来源:StringToColorConverter.cs
示例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);
}
开发者ID:01org,项目名称:ezIOmeter,代码行数:31,代码来源:RangeConverter.cs
示例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;
}
开发者ID:bobytools,项目名称:boby_add_files,代码行数:27,代码来源:WinColor.xaml.cs
示例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;
}
开发者ID:Newtopian,项目名称:nuget,代码行数:30,代码来源:ColorToBrushConverter.cs
示例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);
}
开发者ID:GREYFOXRGR,项目名称:AssemblyVisualizer,代码行数:7,代码来源:BrushProvider.cs
示例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);
}
开发者ID:WrongDog,项目名称:Sequence,代码行数:15,代码来源:DiagramInheritanceConnector.cs
示例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 { }
}
开发者ID:BillerFaktura,项目名称:Biller.OrderTypes,代码行数:33,代码来源:Content.xaml.cs
示例16: TextBox_TextChanged
/// <summary>
/// Checks if the entered <see cref="ArticleID"/> already exists or not.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
if ((sender as TextBox).IsFocused == true)
{
bool result = true;
try { result = await (DataContext as ArticleEditViewModel).ParentViewModel.ParentViewModel.Database.ArticleExists((sender as TextBox).Text); }
catch { }
if (result && (DataContext as ArticleEditViewModel).EditMode == false)
{
(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 ArticleEditViewModel).ParentViewModel.ParentViewModel.Database.UpdateTemporaryUsedArticleID(previousID, (sender as TextBox).Text);
previousID = (sender as TextBox).Text;
}
}
catch { }
}
开发者ID:BillerFaktura,项目名称:Biller.App,代码行数:32,代码来源:ArticleEditControl.xaml.cs
示例17: LoginWindow
public LoginWindow()
{
Logger.MonitoringLogger.Debug("Initializing LoginWindow");
InitializeComponent();
//Title Bar color change
var converter = new System.Windows.Media.BrushConverter();
var brush = (Brush)converter.ConvertFromString("#404040");
this.TitleBarBackground = brush;
this.DataContext = loginDataView;
//Event handler
this.Loaded += new RoutedEventHandler(LoadedEventHandler);
this.Closing += new CancelEventHandler(ClosedEventHandler);
loginDataView.ServersProfiles.CollectionChanged += new NotifyCollectionChangedEventHandler(CollectionChangedEventHandler);
ResourceDictionary resourceDictionary = new ResourceDictionary()
{
Source = new Uri("/Framework.UI;component/Themes/ElysiumExtra/GeometryIcon.xaml", UriKind.RelativeOrAbsolute)
};
//BattlEyeLoginCredentials loginCredentials = new BattlEyeLoginCredentials();
Logger.MonitoringLogger.Debug("Login Window Initialized");
}
开发者ID:Krisscut,项目名称:InvolvedRCON,代码行数:25,代码来源:LoginWindow.xaml.cs
示例18: setUpMap
private void setUpMap()
{
for (int i = 0; i < 20; i++)
{
RowDefinition rowDef = new RowDefinition();
rowDef.Height = new GridLength(1, GridUnitType.Star);
mapGrid.RowDefinitions.Add(rowDef);
}
for (int i = 0; i < 15; i++)
{
ColumnDefinition colDef = new ColumnDefinition();
colDef.Width = new GridLength(1, GridUnitType.Star);
mapGrid.ColumnDefinitions.Add(colDef);
}
var bc = new BrushConverter();
mapGrid.ShowGridLines = true;
for (int i = 0; i < 9; i++)
{
Label label = new Label();
label.Background = (Brush)bc.ConvertFrom("#FF28701C");
Grid.SetRow(label, 19 - i / 3);
Grid.SetColumn(label, i % 3);
mapGrid.Children.Add(label);
}
for (int i = 0; i < 9; i++)
{
Label label = new Label();
label.Background = (Brush)bc.ConvertFrom("#FF28701C");
Grid.SetRow(label, i / 3);
Grid.SetColumn(label, 14 - i % 3);
mapGrid.Children.Add(label);
}
}
开发者ID:yikolyk,项目名称:MDP-Jan-2015,代码行数:35,代码来源:MainPage.xaml.cs
示例19: 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());
GeometryConverter gc = new GeometryConverter();
Geometry geometry = (Geometry)gc.ConvertFromString(string.Format("M {0},{1} {2},{3} {4},{5} Z", StylusPoints[0].X, StylusPoints[1].Y, (Math.Abs(StylusPoints[1].X - StylusPoints[0].X))/2 + StylusPoints[0].X, StylusPoints[0].Y, StylusPoints[1].X, StylusPoints[1].Y));
GeometryDrawing gd = new GeometryDrawing(BackGround, pen, geometry);
drawingContext.DrawDrawing(gd);
}
开发者ID:sonicrang,项目名称:RangPaint,代码行数:25,代码来源:TriangleStroke.cs
示例20: startClient
private async void startClient()
{
try
{
BrushConverter bc = new BrushConverter();
Brush brush = (Brush)bc.ConvertFrom(strColor);
udpClient.Client.Bind(new IPEndPoint(IPAddress.Any, 0));
udpClient.BeginReceive(dataReceived, udpClient);
gridHeader.Background = brush;
border.BorderBrush = brush;
sendInformation(1, strName, string.Empty);
while (true)
{
sendInformation(3, strName, string.Empty);
await Task.Delay(100);
}
}
catch (Exception)
{
MessageBox.Show("Failed to connect to master server!");
Environment.Exit(0);
}
}
开发者ID:vldr,项目名称:TLDRChat,代码行数:26,代码来源:MainWindow.xaml.cs
注:本文中的System.Windows.Media.BrushConverter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论