本文整理汇总了C#中System.Windows.Media.BrushConverter.ConvertFromString方法的典型用法代码示例。如果您正苦于以下问题:C# BrushConverter.ConvertFromString方法的具体用法?C# BrushConverter.ConvertFromString怎么用?C# BrushConverter.ConvertFromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.BrushConverter
的用法示例。
在下文中一共展示了BrushConverter.ConvertFromString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: ConvertBrush
public static Brush ConvertBrush(System.Drawing.Color color)
{
var b = new BrushConverter();
if (b.IsValid(color.Name)) {
return b.ConvertFromString(color.Name) as SolidColorBrush;
}
return b.ConvertFromString("Black") as SolidColorBrush;
}
示例4: Convert
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var converter = new System.Windows.Media.BrushConverter();
if(((MessageType)value) == MessageType.Incoming)
return (System.Windows.Media.Brush)converter.ConvertFromString("#FCFBF8");
else
return (System.Windows.Media.Brush)converter.ConvertFromString("#EBFECE");
}
示例5: AppendText
/// <summary>
/// Extension method for writing color to a RichTextBox.
/// </summary>
/// <param name="box">the RichTextBox to be written to.</param>
/// <param name="text">the text to be written to the RichTextBox.</param>
/// <param name="color">the color of the text, defined by the Color structure.</param>
/// <param name="sameLine">True if the text is to be written to the same line as the last text.</param>
public static void AppendText(this RichTextBox box, string text, string color, bool sameLine)
{
BrushConverter bc = new BrushConverter();
TextRange tr = new TextRange(box.Document.ContentEnd, box.Document.ContentEnd);
if (!sameLine)
tr.Text = "\r\n" + text;
else
tr.Text = text;
try { tr.ApplyPropertyValue(TextElement.ForegroundProperty, bc.ConvertFromString(color)); }
catch (FormatException) { tr.ApplyPropertyValue(TextElement.ForegroundProperty, bc.ConvertFromString("Black")); }
}
示例6: Convert
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
int? v = (int?)value;
BrushConverter conv = new BrushConverter();
if (v == null)
return conv.ConvertFromString("White");
else if (v == 0)
return conv.ConvertFromString("SpringGreen");
else
return conv.ConvertFromString("MistyRose");
}
示例7: Convert
//r:203,g:255,b:198,a:60
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool valor = (bool)value;
BrushConverter conver = new BrushConverter();
//R:# V:#
if (valor){
return conver.ConvertFromString("#CCC0FFAD") as SolidColorBrush;
}
else {
return conver.ConvertFromString("#CCFFADAD") as SolidColorBrush;
}
}
示例8: Initialize
private void Initialize(ButtonType buttonType, string iconFilePath, string buttonTitle, string buttonColour, string brushMouseEnterHexCode, string brushMouseLeaveHexCode, string brushMouseDownHexCode, string brushMouseUpHexCode)
{
BrushConverter bc = new BrushConverter();
_brushMouseEnter = (Brush)bc.ConvertFromString(brushMouseEnterHexCode);
_brushMouseLeave = (Brush)bc.ConvertFromString(brushMouseLeaveHexCode);
_brushMouseDown = (Brush)bc.ConvertFromString(brushMouseDownHexCode);
_brushMouseUp = brushMouseUpHexCode == null ? Brushes.Transparent : (Brush)bc.ConvertFromString(brushMouseUpHexCode);
TextBlockTitle.Background = (Brush)bc.ConvertFromString(buttonColour);
TextBlockTitle.Text = buttonTitle;
ImageIcon.Source = PlusPlayTools.ImageEditing.GenerateImage_FileStream(iconFilePath);
_buttonType = buttonType;
}
示例9: 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)));
}
示例10: 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");
}
示例11: BrushConverter
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
try
{
// get brush from runtime property info
if (value is PropertyInfo)
{
// create converter
BrushConverter converter = new BrushConverter();
// convert neme to brush
Brush selectedBrush = (Brush)converter.ConvertFromString(((PropertyInfo)value).Name.ToString());
// get brush
return selectedBrush;
}
else
{
// return black
return Brushes.Black;
}
}
catch (Exception e)
{
// display
Console.WriteLine("Exception caught converting property info: {0}", e.Message);
// return black
return Brushes.Black;
}
}
示例12: DiagramAssociationConnector
/// <summary>
/// Initializes a new instance of the <see cref="DiagramAssociationConnector"/> 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 DiagramAssociationConnector(DiagramConnectorNode startConnector, DiagramConnectorNode endConnector)
: base(startConnector, endConnector)
{
BrushConverter bc = new BrushConverter();
Brush brush = bc.ConvertFromString("#B0764F") as Brush;
this.ResourcePen = new Pen(brush != null ? brush : Brushes.Sienna, 1);
}
示例13: OnDrop
protected override void OnDrop(DragEventArgs e)
{
base.OnDrop(e);
if (e.Data.GetDataPresent(DataFormats.StringFormat))
{
string dataString = (string) e.Data.GetData(DataFormats.StringFormat);
BrushConverter converter = new BrushConverter();
if (converter.IsValid(dataString))
{
Brush newFill = (Brush) converter.ConvertFromString(dataString);
circleUI.Fill = newFill;
if (e.KeyStates.HasFlag(DragDropKeyStates.ControlKey))
{
e.Effects = DragDropEffects.Copy;
}
else
{
e.Effects = DragDropEffects.Move;
}
}
}
e.Handled = true;
}
示例14: click
private void click(object sender, RoutedEventArgs e)
{
Button b = sender as Button;
switch (b.Name)
{
case "activator":
if (!CManager.Properties.Settings.Default.activator)
{
this.activator.IsEnabled = false;
this.activator.BorderThickness = new Thickness(1);
BrushConverter c = new BrushConverter();
this.activator.BorderBrush = (Brush)c.ConvertFromString("#FF828282");
this.activator.ToolTip = "This options is avaible only in extended version of program";
ToolTipService.SetInitialShowDelay(this.activator, 1500);
ToolTipService.SetShowDuration(this.activator, 5000);
ToolTipService.SetShowOnDisabled(this.activator, true);
}
else
{
sel(this, new program() { page = 2 });
}
break;
case "manager":
sel(this, new program() { page = 3 });
break;
}
}
示例15: 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;
}