Tag: 颜色

是否可以在多行文本框中使用不同颜色的线条?

是否可以在多行文本框中使用不同颜色的线条? 我正在向文本框中添加数据,我想用颜色为用户澄清不同类型的文本。 如果有可能怎么做?

Treeview绘制故障

我为每个TreeView节点实现了一个多色系统。 但每次我扩展子节点时,它都会消耗,但也会在我的rootNode上绘制节点(图像2和3)。 代码来自我之前的问题 ,这就是bug的样子 如果我决定关闭每个节点并重新扩展毛刺消失了。(图4) 问题似乎与Bounds ,这就是抽签不在正确位置的原因。 知道为什么吗? private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e) { string[] texts = e.Node.Text.Split(); using (Font font = new Font(this.Font, FontStyle.Regular)) { using (Brush brush = new SolidBrush(Color.Red)) { e.Graphics.DrawString(texts[0], font, brush, e.Bounds.Left, e.Bounds.Top); } using (Brush brush = new SolidBrush(Color.Blue)) { SizeF s = e.Graphics.MeasureString(texts[0], font); e.Graphics.DrawString(texts[1], font, brush, […]

数据网格视图的单个单元格中的C#多色文本

是否可以更改datagridview单元格中存在的子字符串的颜色?

将HSV循环代码从Delphi转换为C#

我正在尝试将函数转换为从Delphi到C#创建HSV Circle,但结果不是正确的。 我的目标是为Windows Phone 7做一个应用程序,我只使用WP7.1 SDK和WriteableBitmapEx库。 delphi代码: FUNCTION CreateHueSaturationCircle(CONST size: INTEGER; CONST ValueLevel: INTEGER; CONST BackgroundColor: TColor): TBitmap; VAR dSquared: INTEGER; H,S,V: INTEGER; i: INTEGER; j: INTEGER; Radius: INTEGER; RadiusSquared: INTEGER; row: pRGBTripleArray; X: INTEGER; Y: INTEGER; BEGIN RESULT := TBitmap.Create; RESULT.PixelFormat := pf24bit; RESULT.Width := size; RESULT.Height := size; // Fill with background color […]

设置只读文本框默认Backcolor

我有一个TextBox ,它被设置为ReadOnly。 在某些时候,TextBox可用于编辑,并且它的BackColor发生了变化(它指示值是否有效)。 如果我想将Texbox设置回ReadOnly,则TextBox不会返回ReadOnly TextBox获得的原始BackColor。 我该怎么办才能再次获得原始颜色? 我意识到我可以手动将颜色设置为SystemColors.Control ,但这是“正确的方法”吗? 代码示例 这是一个简单的演示代码。 如果SystemColors.Control是要走的路,我将在ReadOnlyChanged事件中更改它… private void button1_Click(object sender, EventArgs e) { //At this point this.textBox1 is ReadOnly this.textBox1.ReadOnly = false; this.textBox1.BackColor = Color.Orange; /*this.textBox1.BackColor = SystemColors.Control;*/ //Is this the right way? this.textBox1.ReadOnly = true; //Textbox remains orange… }

将System.Windows.Media.Color转换为System.Drawing.Color

private void DialogFont_Load(object sender, EventArgs e) { LoadInstalledFonts(); SetupInitialDialogSelections(); lblPreview.ForeColor = colorPicker1.colorPickerControlView1.CurrentColor.Color; } 我想将值转换为System.Drawing.Color。 有任何想法吗?

关于“添加剂混合”和“色调替换”的问题

由于绘制字体在CPU方面非常昂贵,许多开发人员使用栅格化字体在video游戏上绘制文本; 那也是我做的。 在绘制文本时使用叠加混合可以很好地处理字形边缘,这些与背景颜色很好地融合。 但它带来了另一个问题, 我决定实现一个’color’参数来绘制字体,而不是为每种颜色生成字形位图,否则很快就会出现内存使用问题; 取决于需要多少字形和颜色以及字体大小,因为它支持Unicode,根据语言可能需要数千个字形。 现在当我混合时,在’红色’背景上说一个’绿色’字体,它就变成了’橙色’! 添加剂混合的目的是什么,但试图绕过这一点比预期的要复杂一些。 显然当背景为“黑色”时不会发生,但最终可能不是那种颜色。 如何将“白色”字体重新着色为“任意”颜色,同时仍保留“任何”颜色的添加剂混合? 非常感谢:D

使用C#确定当前的打印作业颜色

在来到SO寻找答案之前,我花了最后2或3天在Google上尝试不同的问题表单来尝试让它发挥作用。 我需要获取当前打印作业的颜色设置,以确定用户执行了多少彩色或灰度打印。 但是我试图访问的每个颜色属性(通过ManagementObjectSearcher,“Watcher和C#的内置打印机类”)总是返回颜色,而不是灰度。 任何帮助将不胜感激,因为我已经停止在解决方案上取得进展。 谢谢。 下面是我的代码(请记住它是我的原型代码,所以除了我要问的问题之外可能还有很多问题。请仅提供您对我的问题的答案的建议)。 using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Printing; using System.Management; using System.Management.Instrumentation; using System.Threading; using System.Windows.Threading; using System.Diagnostics; namespace PrintPlus { public partial class PrintPlus : Form { #region Objects // Mgmt ManagementEventWatcher watcher; ManagementObjectSearcher searcher; // […]

WPF矩形颜色绑定

我正在尝试编写矩形网格,它确实会改变其对象的颜色。 private void Window_Loaded(object sender, RoutedEventArgs e) { for (int i = 0; i < size; i++) { main_grid.ColumnDefinitions.Add(new ColumnDefinition()); main_grid.RowDefinitions.Add(new RowDefinition()); } for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { cells[i, j] = new Cell { state = false, col = false […]

更改RichTextBox中的链接颜色

我有一个RichTextBox,其中包含用户发布的链接。 问题是我的RTB使链接的颜色变黑,背景颜色也变黑。 这导致链接不可见。 如何更改RTB中链接的颜色?