本文整理汇总了C#中Palette.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Palette.Add方法的具体用法?C# Palette.Add怎么用?C# Palette.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Palette
的用法示例。
在下文中一共展示了Palette.Add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateImage
IndexedBitmap CreateImage()
{
var image = new IndexedBitmap (100, 100, 8);
var pal = new Palette (Palette.GetEgaPalette ());
// must have at least 256 colors for an 8-bit bitmap
while (pal.Count < 256)
pal.Add (Color.Black);
image.Palette = pal;
var bd = image.Lock ();
unsafe {
int col = 0;
byte* brow = (byte*)bd.Data;
for (int y = 0; y < image.Size.Height; y++) {
byte* b = brow;
for (int x = 0; x < image.Size.Width; x++) {
if (col >= pal.Count)
col = 0;
*b = (byte)col++;
b++;
}
brow += bd.ScanWidth;
}
}
image.Unlock (bd);
return image;
}
示例2: CreateImage
IndexedBitmap CreateImage()
{
var image = new IndexedBitmap(100, 100, 8, Generator);
var ega = Palette.GetEgaPalette();
var pal = new Palette(ega);
// must have at least 256 colors for an 8-bit bitmap
while (pal.Count < 256)
pal.Add(Colors.Black);
image.Palette = pal;
using (var bd = image.Lock())
{
unsafe
{
var brow = (byte*)bd.Data;
for (int y = 0; y < image.Size.Height; y++)
{
byte* b = brow;
var col = -y;
for (int x = 0; x < image.Size.Width; x++)
{
while (col < 0)
col = ega.Count + col;
while (col >= ega.Count)
col -= ega.Count;
*b = (byte)col++;
b++;
}
brow += bd.ScanWidth;
}
}
}
return image;
}
示例3: AddTest
public void AddTest()
{
Palette palette = new Palette();
Assert.AreEqual(0, palette.Count);
palette.Add(0, Colors.Red);
Assert.AreEqual(1, palette.Count);
Assert.AreEqual(new PaletteEntry(0, Colors.Red), palette[0]);
palette.Add(2, Colors.Blue);
Assert.AreEqual(2, palette.Count);
Assert.AreEqual(new PaletteEntry(2, Colors.Blue), palette[1]);
palette.Add(new PaletteEntry(1, Colors.Green));
Assert.AreEqual(3, palette.Count);
Assert.AreEqual(new PaletteEntry(1, Colors.Green), palette[2]);
}
示例4: GetDefaultPalette
public static Palette GetDefaultPalette()
{
var swatches = new Swatches();
var pal = new Palette();
pal.Add(swatches.FadedDarkBlue);
pal.Add(swatches.BrightOrange);
pal.Add(swatches.SimpleGreen);
pal.Add(swatches.PurpleByzantium);
pal.Add(swatches.Jonquil);
pal.Add(swatches.FireEngineRed);
pal.Add(swatches.LightGray);
pal.Add(swatches.DeepBlue);
pal.Add(swatches.DarkGray);
pal.Add(swatches.ForestGreen);
pal.Add(swatches.Carmine);
pal.Add(swatches.BrightPink);
pal.Add(swatches.Eggplant);
pal.Add(swatches.Byzantine);
pal.Add(swatches.JungleGreen);
pal.Add(swatches.Black);
pal.Add(swatches.Jonquil);
pal.Add(swatches.Chamoisee);
return pal;
}
示例5: EditValue
public override object EditValue( ITypeDescriptorContext context,
IServiceProvider provider,
object value )
{
Palette original = (Palette) value;
try
{
IWindowsFormsEditorService editorService
= (IWindowsFormsEditorService)
provider.GetService( typeof( IWindowsFormsEditorService ) );
_paletteForm = new PaletteForm();
if( value == null )
{
value = new Palette();
}
// Take a copy of the original Palette in case the user cancels
// the PaletteForm
Palette copy = new Palette();
foreach( Color c in original )
{
copy.Add( c );
}
_paletteForm.Value = original;
_paletteForm.EditorService = editorService;
DialogResult result = editorService.ShowDialog( _paletteForm );
if( result == DialogResult.OK )
{
return _paletteForm.Value;
}
else
{
return copy;
}
}
catch( Exception ex )
{
ExceptionForm ef = new ExceptionForm( ex );
ef.ShowDialog();
return original;
}
}
示例6: CreateStatisticTheme
private void CreateStatisticTheme(string LayerName)
{
//创建组
string GroupName = "统计专题_" + LayerName;
int GroupID = Program.sgworld.ProjectTree.CreateGroup(GroupName);
//根据获取的位置及表中的值建立
if (StaThemePos != null)
{
this.progressBarControl1.Properties.Minimum = 0;
this.progressBarControl1.Properties.Maximum = StaThemePos.Count;
this.progressBarControl1.Properties.Step = 1;
this.progressBarControl1.Position = 0;
for (int i = 0; i < StaThemePos.Count; i++)
{
//根据图表类型获取字段值根据设置生成图像
#region
ChartControl Chart3D = new ChartControl();
ChartTitle chartTitle1 = new ChartTitle();
Chart3D.Titles.Add(chartTitle1);
string AValue = "";
switch (this.comboBoxChartType.Text)
{
case "柱状图":
//每个字段对应一个Series,字段名以及该要素该字段的值构成一个Point
foreach (DataGridViewRow ARow in this.dataGridView3.Rows)
{
Series Aseries = new Series("Aseries", ViewType.Bar3D);
AValue = this.dataGridView4.Rows[i].Cells[ARow.Cells[1].Value.ToString()].Value.ToString();
Aseries.Points.Add(new SeriesPoint(ARow.Cells[1].Value.ToString(), Convert.ToDouble(AValue)));
Chart3D.Series.Add(Aseries);
((BarSeriesLabel)Aseries.Label).Visible = true;
Font myFont = new Font(new FontFamily("宋体"),20);
((BarSeriesLabel)Aseries.Label).Font = myFont;
((BarSeriesLabel)Aseries.Label).BackColor = Color.FromArgb(0, 0, 0, 0);
((BarSeriesLabel)Aseries.Label).Border.Visible = false;
((BarSeriesLabel)Aseries.Label).TextColor = Color.Black;
((BarSeriesLabel)Aseries.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default;
Aseries.PointOptions.PointView = PointView.ArgumentAndValues;
//是否勾选百分比
//if (this.checkPercent.Checked)
// Aseries.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
((Bar3DSeriesView)Aseries.View).Model = Bar3DModel.Cylinder;
//修改柱状体颜色
((Bar3DSeriesView)Aseries.View).Color = ARow.Cells[0].Style.BackColor;
((XYDiagram3D)Chart3D.Diagram).AxisX.GridLines.Visible = false;
((XYDiagram3D)Chart3D.Diagram).AxisX.Label.Visible = false;
((XYDiagram3D)Chart3D.Diagram).AxisY.GridLines.Visible = false;
((XYDiagram3D)Chart3D.Diagram).AxisY.Label.Visible = false;
((XYDiagram3D)Chart3D.Diagram).AxisY.Interlaced = false;
((XYDiagram3D)Chart3D.Diagram).BackColor = Color.FromArgb(0, 0, 0, 0);
}
break;
case "堆叠柱状图":
//每个字段对应一个Series,每个Series一个Point,Argument值相同,Value值对应各字段值,起码2个Series才有堆叠效果
foreach (DataGridViewRow ARow in this.dataGridView3.Rows)
{
Series Aseries = new Series("Aseries", ViewType.StackedBar3D);
AValue = this.dataGridView4.Rows[i].Cells[ARow.Cells[1].Value.ToString()].Value.ToString();
Aseries.Points.Add(new SeriesPoint(this.dataGridView4.Rows[i].Cells[0].Value.ToString(), Convert.ToDouble(AValue)));
Chart3D.Series.Add(Aseries);
((BarSeriesLabel)Aseries.Label).Visible = true;
Font myFont = new Font(new FontFamily("宋体"), 20);
((BarSeriesLabel)Aseries.Label).Font = myFont;
((BarSeriesLabel)Aseries.Label).BackColor = Color.FromArgb(0, 0, 0, 0);
((BarSeriesLabel)Aseries.Label).Border.Visible = false;
((BarSeriesLabel)Aseries.Label).TextColor = Color.Black;
((BarSeriesLabel)Aseries.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default;
Aseries.PointOptions.PointView = PointView.ArgumentAndValues;
//是否勾选百分比
//if (this.checkPercent.Checked)
// Aseries.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
((Bar3DSeriesView)Aseries.View).Model = Bar3DModel.Cylinder;
//修改柱状体颜色
((Bar3DSeriesView)Aseries.View).Color = ARow.Cells[0].Style.BackColor;
((XYDiagram3D)Chart3D.Diagram).AxisX.GridLines.Visible = false;
((XYDiagram3D)Chart3D.Diagram).AxisX.Label.Visible = false;
((XYDiagram3D)Chart3D.Diagram).AxisY.GridLines.Visible = false;
((XYDiagram3D)Chart3D.Diagram).AxisY.Label.Visible = false;
((XYDiagram3D)Chart3D.Diagram).AxisY.Interlaced = false;
((XYDiagram3D)Chart3D.Diagram).BackColor = Color.FromArgb(0, 0, 0, 0);
}
break;
case "饼图":
//每个要素仅含一个Series,每个字段对应一个Point,分别由字段名和字段值组成
Series Aseries1 = new Series("Aseries1", ViewType.Pie3D);
Palette Colorlist = new Palette("Colorlist");
foreach (DataGridViewRow ARow in this.dataGridView3.Rows)
{
AValue = this.dataGridView4.Rows[i].Cells[ARow.Cells[1].Value.ToString()].Value.ToString();
Aseries1.Points.Add(new SeriesPoint(ARow.Cells[1].Value.ToString(), Convert.ToDouble(AValue)));
//Aseries1.Points.Add(new SeriesPoint(ARow.Cells[1].Value.ToString(), 50));
Colorlist.Add(ARow.Cells[0].Style.BackColor);
//.........这里部分代码省略.........
示例7: Test
public void Test()
{
Endogine.ColorEx.Palette pal = new Palette();
ColorHsb hsb = new ColorHsb();
hsb.A = 255;
hsb.S = 0.5f;
Point p = new Point(15, 15);
for (int i = 0; i < p.X; i++)
{
hsb.B = 1f - (float)i / p.X;
for (int j = 0; j < p.Y; j++)
{
hsb.H = 359f * (float)j / p.Y;
pal.Add("Red", new ColorRgb(hsb.ColorRGBA));
}
}
this.Palette = pal;
}