本文整理汇总了C#中System.Windows.Media.Brush.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Brush.ToString方法的具体用法?C# Brush.ToString怎么用?C# Brush.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Brush
的用法示例。
在下文中一共展示了Brush.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSaveBrushText
public static string GetSaveBrushText(Brush brush)
{
if (brush == null)
return string.Empty;
string knownName = GetKnownBrushName(brush);
if (!string.IsNullOrEmpty(knownName))
return knownName;
else
return brush.ToString();
}
示例2: Settings
/// <summary>
/// Window constructor.
/// </summary>
public Settings(IMainViewModel host, double currentOpacity, Brush currentTextColor, int workTime, int breakTime, int breakLongTime, bool soundEfects, double shadowOpacity, bool countBackwards)
{
InitializeComponent();
this.DataContext = this;
_host = host;
_useWhiteText = true;
_soundEfects = soundEfects;
_clockOpacity = currentOpacity;
_saveSettings = new SaveSettings(this);
_useWhiteText = (currentTextColor.ToString() == Brushes.White.ToString());
_breakTime = breakTime;
_breakLongTime = breakLongTime;
_workTime = workTime;
_shadowOpacity = shadowOpacity;
_countBackwards = countBackwards;
MouseLeftButtonDown += Settings_MouseLeftButtonDown;
_itemRepository = new ItemRepository();
Loaded += Settings_Loaded;
}
示例3: IsANeighboringColor
private bool IsANeighboringColor(Brush selectedStoneFill, Brush currentStoneFill)
{
bool isNeighboring = false;
int indexDifference = ColorSequence[selectedStoneFill.ToString()] - ColorSequence[currentStoneFill.ToString()];
if ((indexDifference == 1) || (indexDifference == -1))
{
isNeighboring = true;
}
return isNeighboring;
}
示例4: ConvertDataTableToPDF
//导出PDF文件方法
/// <summary>
/// DataTable导出到PDF
/// </summary>
/// <param name="datatable">DataTable</param>
/// <param name="PDFFilePath">导出的PDF存储路径</param>
/// <param name="PdfSaveTitle">导出的文件名</param>
/// <param name="FontPath">字体路径</param>
/// <param name="FontSize">字体大小</param>
/// <param name="widthmz">每一列宽度</param>
/// <returns>布尔值</returns>
public static bool ConvertDataTableToPDF(DataTable datatable, string PDFFilePath, string PdfSaveTitle, Brush brush, float FontSize, float[] widthmz)
{
if (widthmz == null || widthmz.Length == 0)//如果每一列宽度未指定
{
widthmz = new float[datatable.Columns.Count];
for (int i = 0; i < datatable.Columns.Count; i++)
{
widthmz[i] = 30f;
}
}
//初始化一个目标文档类
Document document = new Document(PageSize.A4, 10, 10, 25, 25);
//调用PDF的写入方法流
//注意FileMode-Create表示如果目标文件不存在,则创建,如果已存在,则覆盖。
PdfWriter writer = PdfWriter.getInstance(document, new FileStream(PDFFilePath, FileMode.Create));
try
{
System.Windows.Media.Color color = (System.Windows.Media.Color)ColorConverter.ConvertFromString(brush.ToString());
//打开目标文档对象
document.Open();
// 添加页眉
HeaderFooter header = new HeaderFooter(new Phrase(PdfSaveTitle), false);
document.Header = header;
// 添加页脚
HeaderFooter footer = new HeaderFooter(new Phrase(PdfSaveTitle), true);
footer.Border = Rectangle.NO_BORDER;
document.Footer = footer;
//创建PDF文档中的字体
BaseFont baseFont = BaseFont.createFont(@"C:\WINDOWS\Fonts\SIMFANG.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
//根据字体路径和字体大小属性创建字体
Font font = new Font(baseFont, FontSize);
font.setColor(color.R, color.G, color.B);
Paragraph pTitle = new Paragraph(new Chunk(PdfSaveTitle, FontFactory.getFont(FontFactory.HELVETICA, 12)));
document.Add(pTitle);
//根据数据表内容创建一个PDF格式的表
PdfPTable table = null;
table = new PdfPTable(widthmz);
//打印列名
for (int j = 0; j < datatable.Columns.Count; j++)
{
string ColumnName =datatable.Columns[j].ColumnName.ToString();
table.addCell(new Phrase(ColumnName, font));
}
//遍历原table的内容
for (int i = 0; i < datatable.Rows.Count; i++)
{
for (int j = 0; j < datatable.Columns.Count; j++)
{
table.addCell(new Phrase(datatable.Rows[i][j].ToString(), font));
}
}
//在目标文档中添加转化后的表数据
document.Add(table);
}
catch (Exception ec)
{
ec.GetBaseException();
return false;
}
finally
{
//关闭目标文件
document.Close();
//关闭写入流
writer.Close();
}
return true;
}
示例5: MakeHtml
//HTML文件导出
public static bool MakeHtml(string fileName, DataSet ds, string title, Brush fontColor, int fontSize)
{
FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
BufferedStream bs = new BufferedStream(fs);
StreamWriter sw = new StreamWriter(bs);
try
{
sw.WriteLine("<html>");
sw.WriteLine("<head>");
sw.WriteLine("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'><title>" + title + "</title>" +
"<style type='text/css' <!--" +
".normal { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #000000}" +
".medium { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 15px; font-weight: bold; color: #000000; text-decoration: none}" +
"--></style>"
);
sw.WriteLine("<title>");
sw.WriteLine(title);
sw.WriteLine("</title>");
sw.WriteLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
sw.WriteLine("</head>");
sw.WriteLine("<body>");
sw.WriteLine("<center><font=宋体 size=6><b>" + title + "</b></font></center><br>");
sw.WriteLine("<table border='1' font-size='" + fontSize + "' align='center' >");
sw.WriteLine("<tr>");
System.Windows.Media.Color color = (System.Windows.Media.Color)ColorConverter.ConvertFromString(fontColor.ToString());
for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
{
sw.WriteLine("<td bgcolor=silver class='medium'>");
string ColumnName = ds.Tables[0].Columns[j].ColumnName.ToString();
sw.WriteLine(ColumnName);
sw.WriteLine("</td>");
}
sw.WriteLine("</tr>");
//遍历原table的内容
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
sw.WriteLine("<tr>");
for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
{
sw.WriteLine("<td class='normal' valign='top' color=" + color + ">");
sw.WriteLine(ds.Tables[0].Rows[i][j].ToString());
sw.WriteLine("</td>");
}
sw.WriteLine("</tr>");
}
sw.WriteLine("</table>");
sw.WriteLine("<br>");
sw.WriteLine("<div align='center'><font=宋体 size=4> <b>");
sw.WriteLine("制表用户:" + Session.UserAccount + " " + "日期:" + DateTime.Now.ToLongDateString());
sw.WriteLine("</b></font></div");
sw.WriteLine("</body>");
sw.WriteLine("</html>");
}
catch (Exception e)
{
e.GetBaseException();
return false;
}
finally
{
sw.Close();
}
return true;
}
示例6: BrushToString
/// <summary>
/// Brushes to string.
/// </summary>
/// <param name="brush">
/// The brush.
/// </param>
/// <returns>
/// brush type
/// </returns>
private static string BrushToString(Brush brush)
{
if (brush == null)
{
return string.Empty;
}
var solidColorBrush = brush as SolidColorBrush;
if (solidColorBrush != null)
{
return string.Format("SolidColorBrush: {0}", solidColorBrush.Color);
}
var imageBrush = brush as ImageBrush;
if (imageBrush != null)
{
var bi = imageBrush.ImageSource as BitmapImage;
if (bi != null)
{
return string.Format(
"ImageBrush: {0}, UriSource: {1}",
bi,
bi.UriSource);
}
return string.Format("ImageBrush: {0}", imageBrush.ImageSource);
}
return brush.ToString();
}
示例7: ConvertBrushToHex
public static string ConvertBrushToHex(Brush color)
{
return color.ToString();
}
示例8: stuname_MouseEnter
private void stuname_MouseEnter(object sender, MouseEventArgs e)
{
Button b = (Button)sender;
if (b != null)
{
brush = b.Foreground;
Debug.WriteLine(brush.ToString());
b.Foreground = b.Background;
Debug.WriteLine(b.Foreground);
}
}