/// <override></override> public override void PaintValue(PaintValueEventArgs e) { base.PaintValue(e); if (e != null && e.Value is NamedImage) { NamedImage img = (NamedImage)e.Value; if (img.Image != null) { Rectangle srcRect = Rectangle.Empty; srcRect.X = 0; srcRect.Y = 0; srcRect.Width = img.Width; srcRect.Height = img.Height; float lowestRatio = (float)Math.Round(Math.Min((double)(e.Bounds.Width - (e.Bounds.X + e.Bounds.X)) / (double)img.Width, (double)(e.Bounds.Height - (e.Bounds.Y + e.Bounds.Y)) / (double)img.Height), 6); Rectangle dstRect = Rectangle.Empty; dstRect.Width = (int)Math.Round(srcRect.Width * lowestRatio); dstRect.Height = (int)Math.Round(srcRect.Height * lowestRatio); dstRect.X = e.Bounds.X + (int)Math.Round((float)(e.Bounds.Width - dstRect.Width) / 2); dstRect.Y = e.Bounds.Y + (int)Math.Round((float)(e.Bounds.Height - dstRect.Height) / 2); // Apply HighQuality rendering settings to avoid false-color images when using // certain image formats (e.g. JPG with 24 bits color depth) on x64 OSes // Revert to default settings afterwards in order to avoid other graphical glitches GdiHelpers.ApplyGraphicsSettings(e.Graphics, RenderingQuality.HighQuality); e.Graphics.DrawImage(img.Image, dstRect, srcRect, GraphicsUnit.Pixel); GdiHelpers.ApplyGraphicsSettings(e.Graphics, RenderingQuality.DefaultQuality); } } }
/// <summary> /// Initializes a new instance of <see cref="T:Dataweb.NShape.WinFormsUI.ImageEditor" />. /// </summary> public ImageEditor(NamedImage namedImage) { InitializeComponent(); if (namedImage == null) throw new ArgumentNullException("namedImage"); if (namedImage.Image != null) resultImage.Image = (Image)namedImage.Image.Clone(); resultImage.Name = namedImage.Name; }
private void finishSelection() { if (SelectedIndex >= 0) { MadeSelection = true; NamedImage kv = (NamedImage)Items[SelectedIndex]; Selection = kv.Type; } _service.CloseDropDown(); }
public NamedImage Add(string name, Image image) { NamedImage namedImage = new NamedImage(name, image); if (UniqueName(name)) { namedImage.Name = name; array.Add(namedImage); return(namedImage); } throw new ArgumentException(SR.ExceptionNamedImageAddedIsNotUnique(name)); }
private void setChartImages() { NamedImage img1 = new NamedImage("00", Properties.Resources.alloff); NamedImage img2 = new NamedImage("11", Properties.Resources.allon); NamedImage img3 = new NamedImage("01", Properties.Resources._1on); NamedImage img4 = new NamedImage("10", Properties.Resources._2on); chart1.Images.Add(img1); chart1.Images.Add(img2); chart1.Images.Add(img3); chart1.Images.Add(img4); }
/// <summary> /// Initializes a new instance of <see cref="T:Dataweb.NShape.WinFormsUI.ImageEditor" />. /// </summary> public ImageEditor(NamedImage namedImage) { InitializeComponent(); if (namedImage == null) { throw new ArgumentNullException("namedImage"); } if (namedImage.Image != null) { resultImage.Image = (Image)namedImage.Image.Clone(); } resultImage.Name = namedImage.Name; }
/// <override></override> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (value != null && value is NamedImage) { NamedImage val = (NamedImage)value; if (destinationType == typeof(string)) return val.Name; else if (destinationType == typeof(Bitmap)) return (Bitmap)val.Image; else if (destinationType == typeof(Metafile)) return (Metafile)val.Image; else if (destinationType == typeof(Image)) return val.Image; } return base.ConvertTo(context, culture, value, destinationType); }
void Update() { if (canUpdate) { allCars = new List <NamedImage>(); foreach (var kvp in carsInPaths) { var x = new NamedImage() { number = kvp.Key, cars = kvp.Value }; allCars.Add(x); } } }
private void SetupMainField() { baseFieldImage = buildField(); Image b = new Bitmap(baseFieldImage, 1000, 1000); b.RotateFlip(RotateFlipType.Rotate180FlipNone); NamedImage backImage = new NamedImage("Background", b); mainField.Series.Add("test"); mainField.Series["test"].ChartType = SeriesChartType.Point; mainField.Series["test"].Points.AddXY(0, 0); mainField.Series["test"].Points.AddXY(fieldWidth, fieldWidth); mainField.Series.Add("path"); mainField.Series.Add("left"); mainField.Series.Add("right"); mainField.Series.Add("cp"); mainField.Series["cp"].MarkerSize = 8; mainField.Series["path"].MarkerSize = 2; mainField.Series["left"].MarkerSize = 2; mainField.Series["right"].MarkerSize = 2; mainField.Series["cp"].MarkerStyle = MarkerStyle.Circle; mainField.Series["cp"].ChartType = SeriesChartType.Point; mainField.Series["path"].ChartType = SeriesChartType.Point; mainField.Series["left"].ChartType = SeriesChartType.Point; mainField.Series["right"].ChartType = SeriesChartType.Point; mainField.Series["cp"].Color = Color.ForestGreen; mainField.Series["path"].Color = Color.Gray; mainField.Series["left"].Color = Color.Blue; mainField.Series["right"].Color = Color.Red; mainField.ChartAreas[0].Axes[0].Maximum = fieldWidth; mainField.ChartAreas[0].Axes[0].Interval = 1000; mainField.ChartAreas[0].Axes[0].Minimum = 0; mainField.ChartAreas[0].Axes[1].Maximum = fieldWidth; mainField.ChartAreas[0].Axes[1].Interval = 1000; mainField.ChartAreas[0].Axes[1].Minimum = 0; mainField.Images.Add(backImage); mainField.ChartAreas[0].BackImageWrapMode = ChartImageWrapMode.Scaled; mainField.ChartAreas[0].BackImage = "Background"; }
private static void CompareNamedImage(NamedImage imageA, NamedImage imageB, int version) { if (imageA == null && imageB == null) { return; } CompareString(imageA.Name, imageB.Name, true); if (imageA.Image == null && imageB.Image == null) { return; } Assert.AreEqual <Size>(imageA.Image.Size, imageB.Image.Size); CompareFloat(imageA.Image.HorizontalResolution, imageB.Image.HorizontalResolution); CompareFloat(imageA.Image.VerticalResolution, imageB.Image.VerticalResolution); Assert.AreEqual <System.Drawing.Imaging.PixelFormat>(imageA.Image.PixelFormat, imageB.Image.PixelFormat); Assert.AreEqual <System.Drawing.Imaging.ImageFormat>(imageA.Image.RawFormat, imageB.Image.RawFormat); }
private static void CompareNamedImage(NamedImage savedImage, NamedImage loadedImage, int version) { if (savedImage == null && loadedImage == null) { return; } CompareString(savedImage.Name, loadedImage.Name, true); if (savedImage.Image == null && loadedImage.Image == null) { return; } Assert.AreEqual <Size>(savedImage.Image.Size, loadedImage.Image.Size); CompareFloat(savedImage.Image.HorizontalResolution, loadedImage.Image.HorizontalResolution); CompareFloat(savedImage.Image.VerticalResolution, loadedImage.Image.VerticalResolution); Assert.AreEqual <System.Drawing.Imaging.PixelFormat>(savedImage.Image.PixelFormat, loadedImage.Image.PixelFormat); Assert.AreEqual <System.Drawing.Imaging.ImageFormat>(savedImage.Image.RawFormat, loadedImage.Image.RawFormat); }
/// <override></override> public override void PaintValue(PaintValueEventArgs e) { base.PaintValue(e); if (e != null && e.Value is NamedImage) { try { NamedImage imageValue = (NamedImage)e.Value; if (imageValue.Image != null) { // Create a thumbnail image GraphicsUnit gfxUnit = GraphicsUnit.Pixel; Rectangle imgBounds = Rectangle.Round(imageValue.Image.GetBounds(ref gfxUnit)); Rectangle bounds = CalcDestinationBounds(imageValue.Image, imgBounds, Rectangle.FromLTRB(0, 0, 100, 100)); using (Image img = imageValue.Image.GetThumbnailImage(bounds.Width, bounds.Height, null, IntPtr.Zero)) { Rectangle srcRect = Rectangle.Empty; srcRect.X = 0; srcRect.Y = 0; srcRect.Width = img.Width; srcRect.Height = img.Height; float highestRatio = (float)Math.Round( Math.Max((double)(e.Bounds.Width - (e.Bounds.X + e.Bounds.X)) / (double)img.Width, (double)(e.Bounds.Height - (e.Bounds.Y + e.Bounds.Y)) / (double)img.Height) , 6); Rectangle dstRect = Rectangle.Empty; dstRect.Width = (int)Math.Round(srcRect.Width * highestRatio); dstRect.Height = (int)Math.Round(srcRect.Height * highestRatio); dstRect.X = e.Bounds.X + (int)Math.Round((float)(e.Bounds.Width - dstRect.Width) / 2); dstRect.Y = e.Bounds.Y + (int)Math.Round((float)(e.Bounds.Height - dstRect.Height) / 2); // Apply HighQuality rendering settings to avoid false-color images when using // certain image formats (e.g. JPG with 24 bits color depth) on x64 OSes // Revert to default settings afterwards in order to avoid other graphical glitches GdiHelpers.ApplyGraphicsSettings(e.Graphics, RenderingQuality.HighQuality); e.Graphics.DrawImage(img, dstRect, srcRect, GraphicsUnit.Pixel); GdiHelpers.ApplyGraphicsSettings(e.Graphics, RenderingQuality.DefaultQuality); } } } catch (Exception exc) { // Ignore errors while drawing Debug.Print(string.Format("Error in {0}.PaintValue: {1}", GetType().Name, exc.Message)); } } }
private void InsertInTopView(double x, double y, Bitmap img) { var id = chartTopView.Series["Signs"].Points.Count; var dataPoint = new DataPoint(x, y); chartTopView.Series["Signs"].Points.Add(dataPoint); var namedImg = new NamedImage($"sign_{id}", img); chartTopView.Images.Add(namedImg); ImageAnnotation ia = new ImageAnnotation() { AnchorDataPoint = dataPoint, }; ia.Image = namedImg.Name; ia.AllowMoving = false; chartTopView.Annotations.Add(ia); }
public Chart(mainForm mainForm, bool hideCursor = false, bool useCurves = false, bool isM2Enabled = true) { this.mainForm = mainForm; InitializeComponent(); SetTextScale(); NamedImage namedImage = new NamedImage("inonde_logo_noir_700px", global::Remous.Resources.inonde_logo_noir_700px); chart1.Images.Add(namedImage); ((ImageAnnotation)chart1.Annotations["logo"]).Image = "inonde_logo_noir_700px"; maxPoints = Program.settings.GraphicDuration / Program.settings.GraphicIntervalWithMargin; chart1.ChartAreas[0].AxisX.ScaleView.Size = maxPoints; s1 = chart1.Series["Series1"]; s2 = chart1.Series["Series2"]; s1Points = s1.Points; s2Points = s2.Points; if (!useCurves) { chart1.Series["Series1"].ChartType = SeriesChartType.Column; chart1.Series["Series2"].ChartType = SeriesChartType.Column; } if (!isM2Enabled) { chart1.Series["Series2"].Enabled = false; } if (hideCursor) { System.Windows.Forms.Cursor.Hide(); } Program.OnTimerTick += AddPoints; }
protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index >= 0 && e.Index < this.Items.Count) { bool selected = ((e.State & DrawItemState.Selected) != 0); NamedImage item = (NamedImage)this.Items[e.Index]; Rectangle rcBK = new Rectangle(e.Bounds.Left, e.Bounds.Top, 1, this.ItemHeight); if (e.Bounds.Width > this.ItemHeight) { rcBK.Width = e.Bounds.Width - this.ItemHeight; rcBK.X = this.ItemHeight; if (selected) { e.Graphics.FillRectangle(Brushes.LightBlue, rcBK); } else { e.Graphics.FillRectangle(Brushes.White, rcBK); } } Rectangle rc = new Rectangle(e.Bounds.Left, e.Bounds.Top, this.ItemHeight, this.ItemHeight); float w = (float)(e.Bounds.Width - this.ItemHeight); if (w > 0) { RectangleF rcf = new RectangleF((float)(rc.Left + this.ItemHeight + 2), (float)(rc.Top), w, (float)this.ItemHeight); if (selected) { e.Graphics.DrawString(item.Name, this.Font, Brushes.White, rcf); } else { e.Graphics.DrawString(item.Name, this.Font, Brushes.Black, rcf); } } e.Graphics.DrawImage(item.Image, rc); } }
static public void Repaint(InitialStatisticalAnalys gr, InitialStatisticalAnalys gr2, Correlation_RegressionAnalysis CRA, Chart chart1, Chart chart2) { chart1.ChartAreas[0].AxisX.LabelStyle.Format = "###,##0.000"; chart1.ChartAreas[0].AxisY.LabelStyle.Format = "###,##0.000"; chart2.ChartAreas[0].AxisX.LabelStyle.Format = "###,##0.000"; chart2.ChartAreas[0].AxisY.LabelStyle.Format = "###,##0.000"; ///++++++++++++++++++++++++++++++++++++++++++++++ ///GISTOGAMA_PAINT ///++++++++++++++++++++++++++++++++++++++++++++++ chart1.Series.Clear(); chart2.Series.Clear(); if (CRA.f == null) { return; } chart1.Series.Add(CorelPaint(gr.unsortl, gr2.unsortl, Color.DarkBlue, "f")); chart1.ChartAreas[0].AxisX.Minimum = gr.Min.Q - gr.Len.Q * 0.05; chart1.ChartAreas[0].AxisX.Maximum = gr.Max.Q + gr.Len.Q * 0.05; chart1.ChartAreas[0].AxisX.Interval = Math.Round(gr.Len.Q * 0.1, 3); chart1.ChartAreas[0].AxisY.Interval = Math.Round(gr2.Len.Q * 0.1, 3); chart1.ChartAreas[0].AxisY.Minimum = gr2.Min.Q - gr2.Len.Q * 0.05; chart1.ChartAreas[0].AxisY.Maximum = gr2.Max.Q + gr2.Len.Q * 0.05; chart2.ChartAreas[0].AxisX.Minimum = chart2.ChartAreas[0].AxisY.Minimum = 0; chart2.ChartAreas[0].AxisX.Maximum = CRA.f.GetLength(0); chart2.ChartAreas[0].AxisY.Maximum = CRA.f.GetLength(1); chart2.ChartAreas[0].AxisX.Interval = chart2.ChartAreas[0].AxisY.Interval = 100; chart1.Titles[0].Text = "y"; chart1.Titles[1].Text = "x"; chart2.Titles[0].Text = "x"; chart2.Titles[1].Text = "y"; chart2.ChartAreas[0].AxisY.CustomLabels.Clear(); /*for (int j = 0; j < CRA.f.GetLength(0); j++) * { * string str2 = ""; * for (int k = 0; k < CRA.f.GetLength(1); k++) * { * str2 = "f" + j.ToString() + "_" + k.ToString(); * chart2.Series.Add(str2); * chart2.Series[str2].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point; * chart2.Series[str2].MarkerStyle = MarkerStyle.Square; * chart2.Series[str2].IsVisibleInLegend = false; * chart2.Series[str2].MarkerSize = (chart2.Size.Width - 20 + k * 10) / CRA.f.GetLength(0); * //chart2.Series[str2]["PixelPointWidth"] = "200";//PointWidth * double z = CRA.f[j, k]; * if (z > 0.07) * chart2.Series[str2].Color = Color.Black; * else * { * int r = 255 - (int)(255 * CRA.f[j, k] / 0.07); * chart2.Series[str2].Color = Color.FromArgb(r, r, r); * } * //chart2.Series[str2].Color = Color.FromArgb(r, r, r); * //chart2.Series[str2]["StackedGroupName"] = "Group" + j.ToString(); * chart2.Series[str2].Points.AddXY(j + 0.5, * k + 0.5); * } * }*/ Image d = PaintData.Paintf(CRA, 1000, 1000); NamedImage ni = new NamedImage("backimage", d); chart2.Images.Add(ni); chart2.ChartAreas[0].BackImageAlignment = ChartImageAlignmentStyle.Center; chart2.ChartAreas[0].BackImageWrapMode = ChartImageWrapMode.Scaled; chart2.ChartAreas[0].BackImage = "backimage"; if (CRA.Doubl == true && CRA.Nezal == true) { chart1.Series.Add("Лін Рег" + ":" + CRA.RegresTypeVib); chart1.Series["Лін Рег" + ":" + CRA.RegresTypeVib].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; chart1.Series["Лін Рег" + ":" + CRA.RegresTypeVib].Color = Color.Yellow; chart1.Series["Лін Рег" + ":" + CRA.RegresTypeVib].BorderWidth = 3; if (CRA.RegresTypeVib == RegresTypeName.LineRegresion) { //CRA.ABTeil ///teilor chart1.Series.Add("Лін Рег Тейл"); chart1.Series["Лін Рег Тейл"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; chart1.Series["Лін Рег Тейл"].Color = Color.Green; chart1.Series["Лін Рег Тейл"].Points.AddXY(gr.Min.Q, CRA.ABTeil[0] + gr.Min.Q * CRA.ABTeil[1]); chart1.Series["Лін Рег Тейл"].BorderWidth = 3; chart1.Series["Лін Рег Тейл"].Points.AddXY(gr.Max.Q, CRA.ABTeil[0] + gr.Max.Q * CRA.ABTeil[1]); } chart1.Series.Add("Тол меж"); chart1.Series["Тол меж"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; chart1.Series["Тол меж"].Color = Color.DarkRed; chart1.Series["Тол меж"].BorderWidth = 2; chart1.Series.Add("Тол меж2"); chart1.Series["Тол меж2"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; chart1.Series["Тол меж2"].Color = chart1.Series["Тол меж"].Color; chart1.Series["Тол меж2"].IsVisibleInLegend = false; chart1.Series["Тол меж2"].BorderWidth = 2; chart1.Series.Add("Дов інтр"); chart1.Series["Дов інтр"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; chart1.Series["Дов інтр"].Color = Color.DarkMagenta; chart1.Series["Дов інтр"].BorderWidth = 2; chart1.Series.Add("Дов інтр2"); chart1.Series["Дов інтр2"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; chart1.Series["Дов інтр2"].Color = chart1.Series["Дов інтр"].Color; chart1.Series["Дов інтр2"].IsVisibleInLegend = false; chart1.Series["Дов інтр2"].BorderWidth = 2; if (CRA.RegresTypeVib != RegresTypeName.ParabRegresion) { for (double x0 = gr.Min.Q; x0 <= gr.Max.Q; x0 += gr.Len.Q * 0.005) { double Sx0 = Math.Sqrt(CRA.Szal * (1 + 1.0 / gr.l.Count) + CRA.Q[1].QSigma * Math.Pow(x0 - gr.Mx.Q, 2)); if (CRA.RegresTypeVib == RegresTypeName.LineRegresion) { chart1.Series["Дов інтр"].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib) - CRA.T * Sx0); chart1.Series["Дов інтр2"].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib) + CRA.T * Sx0); } chart1.Series["Тол меж"].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib) - CRA.T * CRA.Szal); chart1.Series["Тол меж2"].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib) + CRA.T * CRA.Szal); } for (double x0 = gr.Min.Q; x0 <= gr.Max.Q; x0 += gr.Len.Q * 0.005) { chart1.Series["Лін Рег" + ":" + CRA.RegresTypeVib].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib)); } } else if (CRA.RegresTypeVib == RegresTypeName.ParabRegresion) { double x2 = InitialStatisticalAnalys.StartMoment(gr.l, 2); double x3 = InitialStatisticalAnalys.StartMoment(gr.l, 3); double x4 = InitialStatisticalAnalys.StartMoment(gr.l, 4); double Tt = Distributions.StudentQuantile(1 - gr.alf.Q / 2, gr.unsortl.Length - 3); for (double x0 = gr.Min.Q; x0 <= gr.Max.Q; x0 += gr.Len.Q * 0.005) { double Sx0 = Math.Sqrt(Math.Pow(CRA.Szal2, 2) * (1 + 1.0 / gr.l.Count) + Math.Pow(CRA.Q[4].QSigma * Correlation_RegressionAnalysis.fi1F(x0, gr.Mx.Q), 2) + Math.Pow(CRA.Q[5].QSigma * Correlation_RegressionAnalysis.fi2F(x0, gr.Dx.Q, gr.Mx.Q, x2, x3), 2)); /* * chart1.Series["Дов інтр"].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib) - CRA.T * Sx0); * chart1.Series["Дов інтр2"].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib) + CRA.T * Sx0);*/ chart1.Series["Дов інтр"].Points.AddXY(x0, CRA.Q[3].Q + CRA.Q[4].Q * Correlation_RegressionAnalysis.fi1F(x0, gr.Mx.Q) + CRA.Q[5].Q * Correlation_RegressionAnalysis.fi2F(x0, gr.Dx.Q, gr.Mx.Q, x2, x3) - Tt * Sx0); chart1.Series["Дов інтр2"].Points.AddXY(x0, CRA.Q[3].Q + CRA.Q[4].Q * Correlation_RegressionAnalysis.fi1F(x0, gr.Mx.Q) + CRA.Q[5].Q * Correlation_RegressionAnalysis.fi2F(x0, gr.Dx.Q, gr.Mx.Q, x2, x3) + Tt * Sx0); chart1.Series["Тол меж"].Points.AddXY(x0, CRA.Q[3].Q + CRA.Q[4].Q * Correlation_RegressionAnalysis.fi1F(x0, gr.Mx.Q) + CRA.Q[5].Q * Correlation_RegressionAnalysis.fi2F(x0, gr.Dx.Q, gr.Mx.Q, x2, x3) - Tt * CRA.Szal2); chart1.Series["Тол меж2"].Points.AddXY(x0, CRA.Q[3].Q + CRA.Q[4].Q * Correlation_RegressionAnalysis.fi1F(x0, gr.Mx.Q) + CRA.Q[5].Q * Correlation_RegressionAnalysis.fi2F(x0, gr.Dx.Q, gr.Mx.Q, x2, x3) + Tt * CRA.Szal2); } for (double x0 = gr.Min.Q; x0 <= gr.Max.Q; x0 += gr.Len.Q * 0.005) { chart1.Series["Лін Рег" + ":" + CRA.RegresTypeVib].Points.AddXY(x0, CRA.Q[3].Q + CRA.Q[4].Q * Correlation_RegressionAnalysis.fi1F(x0, gr.Mx.Q) + CRA.Q[5].Q * Correlation_RegressionAnalysis.fi2F(x0, gr.Dx.Q, gr.Mx.Q, x2, x3)); } } } }
/// <summary> /// Creates a brush from the given <see cref="T:Dataweb.NShape.IFillStyle"/>. /// Depending of the fill mode of the fill style, the result can be a <see cref="T:System.Drawing.SolidBrush"/>, /// a <see cref="T:System.Drawing.Drawing2D.HatchBrush"/>, a a <see cref="T:System.Drawing.Drawing2D.LinerGradientBrush"/> or /// a <see cref="T:System.Drawing.TextureBrush"/>. /// </summary> public static Brush GetBrush(IFillStyle fillStyle) { if (fillStyle == null) { throw new ArgumentNullException("fillStyle"); } BrushKey brushKey; brushKey.FillStyle = fillStyle; brushKey.Image = null; Brush brush = null; if (!_brushCache.TryGetValue(brushKey, out brush)) { switch (fillStyle.FillMode) { case FillMode.Solid: brush = new SolidBrush(GetColor(fillStyle.BaseColorStyle, fillStyle.ConvertToGrayScale)); break; case FillMode.Pattern: brush = new HatchBrush(fillStyle.FillPattern, GetColor(fillStyle.BaseColorStyle, fillStyle.ConvertToGrayScale), GetColor(fillStyle.AdditionalColorStyle, fillStyle.ConvertToGrayScale)); break; case FillMode.Gradient: _rectBuffer.X = 0; _rectBuffer.Y = 0; _rectBuffer.Width = 100; _rectBuffer.Height = 100; brush = new LinearGradientBrush(_rectBuffer, GetColor(fillStyle.AdditionalColorStyle, fillStyle.ConvertToGrayScale), GetColor(fillStyle.BaseColorStyle, fillStyle.ConvertToGrayScale), fillStyle.GradientAngle); break; case FillMode.Image: if (NamedImage.IsNullOrEmpty(fillStyle.Image)) { brush = new SolidBrush(Color.Transparent); } else { // Get ImageAttributes ImageAttributes imgAttribs = null; if (!_imageAttribsCache.TryGetValue(brushKey, out imgAttribs)) { imgAttribs = GdiHelpers.GetImageAttributes(fillStyle.ImageLayout, fillStyle.ImageGammaCorrection, fillStyle.ImageTransparency, fillStyle.ConvertToGrayScale); _imageAttribsCache.Add(brushKey, imgAttribs); } // Create Brush _rectBuffer.X = 0; _rectBuffer.Y = 0; _rectBuffer.Width = fillStyle.Image.Width; _rectBuffer.Height = fillStyle.Image.Height; brush = new TextureBrush(fillStyle.Image.Image, _rectBuffer, imgAttribs); } break; default: throw new NShapeUnsupportedValueException(fillStyle.FillMode); } // Add created brush to the BrushCache _brushCache.Add(brushKey, brush); } return(brush); }
public void Insert(int index, NamedImage value) { Insert(index, (object)value); }
public void Remove(NamedImage value) { array.Remove(value); }
public ImageNodeInfo(NamedImage namedImage, Vector3 offset, float scale, float opacity = 1.0f) : base(offset, scale, opacity) { NamedImage = namedImage; }
//private Image BrushImage { // get { // if (brushImage == null // && !NamedImage.IsNullOrEmpty(image) // && (image.Width >= 2 * Width || image.Height >= 2 * Height)) // brushImage = GdiHelpers.GetBrushImage(image.Image, Width, Height); // return brushImage; // } //} private void Construct(string resourceBaseName, Assembly resourceAssembly) { if (resourceBaseName == null) throw new ArgumentNullException("resourceBaseName"); System.IO.Stream stream = resourceAssembly.GetManifestResourceStream(resourceBaseName); if (stream == null) throw new ArgumentException(string.Format("'{0}' is not a valid resource in '{1}'.", resourceBaseName, resourceAssembly), "resourceBaseName"); var customimage = System.Drawing.Image.FromStream(stream); if (customimage == null) throw new ArgumentException(string.Format("'{0}' is not a valid image resource.", resourceBaseName), "resourceBaseName"); this.resourceName = resourceBaseName; this.resourceAssembly = resourceAssembly; image = new NamedImage(customimage, "customimage"); // this fillStyle holds the image of the shape imageGrayScale = false; compressionQuality = 100; imageGamma = 1; imageLayout = ImageLayoutMode.Original; imageTransparency = 0; //FitShapeToImageSize(); }
void IEntity.LoadFields(IRepositoryReader reader, int version) { name = reader.ReadString(); if (version >= 3) title = reader.ReadString(); if (version >= 4) securityDomainName = reader.ReadChar(); size.Width = reader.ReadInt32(); size.Height = reader.ReadInt32(); backColor = Color.FromArgb(reader.ReadInt32()); targetColor = Color.FromArgb(reader.ReadInt32()); string imgName = reader.ReadString(); Image img = reader.ReadImage(); if (img != null) backImage = new NamedImage(img, imgName); imageLayout = (ImageLayoutMode)reader.ReadByte(); imageGamma = reader.ReadFloat(); imageTransparency = reader.ReadByte(); imageGrayScale = reader.ReadBool(); imageTransparentColor = Color.FromArgb(reader.ReadInt32()); }
public int Add(NamedImage value) { return(array.Add(value)); }
public bool Contains(NamedImage value) { return(array.Contains(value)); }
/// <override></override> protected override void LoadFieldsCore(IRepositoryReader reader, int version) { base.LoadFieldsCore(reader, version); imageLayout = (ImageLayoutMode)reader.ReadByte(); imageTransparency = reader.ReadByte(); imageGamma = reader.ReadFloat(); compressionQuality = reader.ReadByte(); imageGrayScale = reader.ReadBool(); string name = reader.ReadString(); Image img = reader.ReadImage(); if (name != null && img != null) image = new NamedImage(img, name); transparentColor = Color.FromArgb(reader.ReadInt32()); }
public int IndexOf(NamedImage value) { return(array.IndexOf(value)); }
private void Construct() { // this fillStyle holds the image of the shape image = null; imageGrayScale = false; compressionQuality = 100; imageGamma = 1; imageLayout = ImageLayoutMode.Original; imageTransparency = 0; }
private void ReadSkillDB() { string sPath = oParentWindow.sLoadSkillFile; string sCSVPath = oParentWindow.sLoadFile; if (this.IsDisposed) { return; } Graphics G = CreateGraphics(); int nSkills = 0; if (File.Exists(sPath)) { string[] sLines; string[] sCSVLines; try { sLines = WriteSafeReadAllLines(sPath); sCSVLines = WriteSafeReadAllLines(sCSVPath); } catch { return; } this.SuspendLayout(); Font oFont = new Font("MS UI Gothic", 11f, FontStyle.Bold); Font oMonoFont = new Font("Consolas", 10f, FontStyle.Bold); if (nCurrentInstanceID == 0) { nCurrentInstanceID = oParentWindow.nInstanceID; } if (nCurrentInstanceID != oParentWindow.nInstanceID) { ColorRemember.Clear(); nCurrentInstanceID = oParentWindow.nInstanceID; } // Read InstanceData.csv to gather data of this player ID int nLine = 0; string sTopHeader = ""; foreach (string line in sCSVLines) { nLine++; if (nLine < 3) { continue; } string[] tmp = line.Split(','); uint uID = 0; try { uID = Convert.ToUInt32(tmp[0]); } catch (Exception e) { uID = 0; LogError(e, "SkillDB Error! Can't convert uID while parsing InstanceData.csv - " + line); } if (uID == uPlayerID) { sTopHeader = "Class: " + tmp[3] + " ・ " + tmp[5]; break; } } if (sTopHeader != "") { SizeF oStringSize = G.MeasureString(sTopHeader, oFont); oStringSize.Width += 4; oStringSize.Height += 4; Image oLabelImage = new Bitmap((int)oStringSize.Width, (int)oStringSize.Height); using (Graphics oG = Graphics.FromImage(oLabelImage)) { oG.Clear(Color.Transparent); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 0, 0); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 1, 0); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 2, 0); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 3, 0); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 4, 0); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 0, 1); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 1, 1); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 2, 1); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 3, 1); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 4, 1); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 0, 3); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 1, 3); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 2, 3); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 3, 3); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 4, 3); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 0, 4); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 1, 4); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 2, 4); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 3, 4); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 4, 4); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 0, 2); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 1, 2); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 3, 2); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.White), 4, 2); oG.DrawString(sTopHeader, oFont, new SolidBrush(Color.Black), 2, 2); TopHeader.Image = oLabelImage; TopHeader.ImageAlign = ContentAlignment.MiddleLeft; } } if (this.InvokeRequired) { BeginInvoke((Action)(() => { if (!this.Visible) { this.Show(); } })); } else { if (!this.Visible) { this.Show(); } } Chart oEncounterGraph = SGraph; if (SGraph.InvokeRequired) { BeginInvoke((Action)(() => { SGraph.Series.Clear(); SGraph.ChartAreas.Clear(); oEncounterGraph.Palette = ChartColorPalette.SemiTransparent; oEncounterGraph.BackColor = Color.FromArgb(222, 222, 222); })); } else { SGraph.Series.Clear(); SGraph.ChartAreas.Clear(); oEncounterGraph.Palette = ChartColorPalette.SemiTransparent; oEncounterGraph.BackColor = Color.FromArgb(222, 222, 222); } ChartArea chA = new ChartArea(); chA.BackColor = Color.FromArgb(180, 180, 180); chA.Name = "EncounterGraph"; chA.AxisX.MaximumAutoSize = 100; chA.AxisX.IsMarginVisible = false; chA.AxisX.LabelStyle.Enabled = true; chA.AxisX.MajorTickMark.Enabled = false; chA.AxisX.MajorGrid.Enabled = true; chA.AxisY.MajorTickMark.Enabled = false; chA.AxisY.MajorGrid.Enabled = false; chA.AxisY.MajorGrid.LineColor = Color.LightGray; chA.AxisY.LabelStyle.Enabled = false; chA.AxisX2.Enabled = AxisEnabled.True; chA.AxisX2.IsMarginVisible = false; chA.AxisX2.LabelStyle.Enabled = false; chA.AxisX2.MajorTickMark.Enabled = false; chA.AxisX2.MajorGrid.Enabled = false; chA.Position.X = 0; chA.Position.Y = 0; chA.Position.Width = 100; chA.Position.Height = 100; chA.BorderWidth = 0; chA.BorderColor = Color.Transparent; chA.AxisX.LabelStyle.Font = new System.Drawing.Font("MS UI Gothic", 11f, FontStyle.Bold); if (oEncounterGraph.InvokeRequired) { BeginInvoke((Action)(() => { oEncounterGraph.ChartAreas.Add(chA); })); } else { oEncounterGraph.ChartAreas.Add(chA); } Series oBottom = new Series("Bottom") { ChartType = SeriesChartType.StackedBar }; oBottom.SmartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.No; Series oSeries = new Series("Players") { ChartType = SeriesChartType.StackedBar, BorderColor = Color.Black, BorderWidth = 1 }; oSeries["PointWidth"] = "1"; oSeries.SmartLabelStyle.Enabled = false; int nPos = 0; long lYMax = 0; for (int n = 0; n < oParentWindow.nColorOffset; n++) { if (oColorList.Count > 0) { oColorList.RemoveAt(0); } else { break; } } foreach (string sLine in sLines) { if (sLine == "PID,AID,Damage,Min,Max,JA,Crit") { continue; } string[] tmp = sLine.Split(','); uint uPID = 0; string sName = ""; long lDamage = 0; long lMinDamage = 0; long lMaxDamage = 0; int nJA = 0; int nCrit = 0; try { uPID = Convert.ToUInt32(tmp[0]); } catch (Exception e) { uPID = 0; LogError(e, "Error parsing skilldb line - " + sLine); } sName = oParentWindow.ShortenSkillName(tmp[1]); try { lDamage = Convert.ToInt64(tmp[2]); } catch (Exception e) { lDamage = 0; LogError(e, "Error parsing skilldb line - " + sLine); } try { lMinDamage = Convert.ToInt64(tmp[3]); } catch (Exception e) { lMinDamage = 0; LogError(e, "Error parsing skilldb line - " + sLine); } try { lMaxDamage = Convert.ToInt64(tmp[4]); } catch (Exception e) { lMaxDamage = 0; LogError(e, "Error parsing skilldb line - " + sLine); } try { nJA = Convert.ToInt32(tmp[5]); } catch (Exception e) { nJA = 0; LogError(e, "Error parsing skilldb line - " + sLine); } try { nCrit = Convert.ToInt32(tmp[6]); } catch (Exception e) { nCrit = 0; LogError(e, "Error parsing skilldb line - " + sLine); } if (uPID == uPlayerID) { if (lDamage > lYMax) { lYMax = lDamage; } SizeF oStringSize; Image oLabelImage = null; NamedImage oImageAdd = null; DataPoint oPoint = new DataPoint(nPos, lDamage); DataPoint oPBottom = new DataPoint(nPos, 0); CustomLabel cl1 = new CustomLabel { FromPosition = nPos - 0.5, ToPosition = nPos + 0.5 }; Color oPointColor = new Color(); oPoint.IsValueShownAsLabel = false; if (oColorList.Count == 0) { oColorList = Extensions.Colors.ChartColorPallets.Pastel; } oPointColor = oColorList.First(); oColorList.RemoveAt(0); if (ColorRemember.ContainsKey(uPID.ToString() + "_" + sName)) { oPoint.Color = ColorRemember[uPID.ToString() + "_" + sName]; } else { ColorRemember.Add(uPID.ToString() + "_" + sName, oPointColor); oPoint.Color = oPointColor; } oStringSize = G.MeasureString(sName, oFont); oStringSize.Width += 4; oStringSize.Height += 4; oLabelImage = new Bitmap((int)oStringSize.Width, (int)oStringSize.Height); using (Graphics oG = Graphics.FromImage(oLabelImage)) { oG.Clear(Color.Transparent); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 0, 0); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 1, 0); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 2, 0); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 3, 0); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 4, 0); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 0, 1); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 1, 1); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 2, 1); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 3, 1); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 4, 1); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 0, 3); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 1, 3); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 2, 3); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 3, 3); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 4, 3); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 0, 4); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 1, 4); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 2, 4); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 3, 4); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 4, 4); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 0, 2); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 1, 2); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 3, 2); oG.DrawString(sName, oFont, new SolidBrush(Color.White), 4, 2); oG.DrawString(sName, oFont, new SolidBrush(Color.Black), 2, 2); oImageAdd = new NamedImage("SkillName" + nPos.ToString(), oLabelImage); bool bImageFound = false; foreach (NamedImage oCheck in SGraph.Images) { if (oCheck.Name == "SkillName" + nPos.ToString()) { bImageFound = true; oCheck.Image = oLabelImage; break; } } if (!bImageFound) { SGraph.Images.Add(oImageAdd); } cl1.Image = "SkillName" + nPos.ToString(); } // Setting DPS Text string sLabel = ""; string sDamage = lDamage.ToString("N0"); if (lDamage > 1000) { sDamage = (lDamage / 1000.0).ToString("N1") + "K"; } if (lDamage > 1000000) { sDamage = (lDamage / 1000000.0).ToString("N2") + "M"; } string sMinDamage = lMinDamage.ToString("N0"); if (lMinDamage > 1000) { sMinDamage = (lMinDamage / 1000.0).ToString("N1") + "K"; } if (lMinDamage > 1000000) { sMinDamage = (lMinDamage / 1000000.0).ToString("N2") + "M"; } string sMaxDamage = lMaxDamage.ToString("N0"); if (lMaxDamage > 1000) { sMaxDamage = (lMaxDamage / 1000.0).ToString("N1") + "K"; } if (lMaxDamage > 1000000) { sMaxDamage = (lMaxDamage / 1000000.0).ToString("N2") + "M"; } sLabel = $"Damage: {sDamage.PadLeft(7)} ・ Min: {sMinDamage.PadLeft(7)} ・ Max: {sMaxDamage.PadLeft(7)} ・ JA: {nJA.ToString("N0").PadLeft(3)}% ・ Crit: {nCrit.ToString("N0").PadLeft(3)}%"; oPBottom.Label = sLabel; if (SGraph.InvokeRequired) { BeginInvoke((Action)(() => { SGraph.ChartAreas[0].AxisX.CustomLabels.Add(cl1); })); } else { SGraph.ChartAreas[0].AxisX.CustomLabels.Add(cl1); } oBottom.Points.Add(oPBottom); oSeries.Points.Add(oPoint); nSkills++; nPos++; } } if (SGraph.InvokeRequired) { BeginInvoke((Action)(() => { SGraph.ChartAreas[0].AxisX.Minimum = -0.5; SGraph.ChartAreas[0].AxisX.Maximum = Convert.ToDouble(nPos - 0.5); SGraph.ChartAreas[0].AxisX2.Minimum = -0.5; SGraph.ChartAreas[0].AxisX2.Maximum = Convert.ToDouble(nPos - 0.5); SGraph.ChartAreas[0].AxisY.Maximum = lYMax; if (nSkills > 10) { SGraph.ChartAreas[0].AxisX.ScaleView.Zoomable = true; SGraph.ChartAreas[0].AxisX.ScrollBar.Enabled = true; SGraph.ChartAreas[0].AxisX.ScaleView.Size = 10; SGraph.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll; SGraph.ChartAreas[0].AxisX.ScaleView.Scroll(ScrollType.Last); SGraph.ChartAreas[0].AxisX.ScaleView.Scroll(ScrollType.First); SGraph.ChartAreas[0].AxisX.ScaleView.Scroll(ScrollType.Last); } SGraph.Series.Add(oBottom); SGraph.Series.Add(oSeries); })); } else { SGraph.ChartAreas[0].AxisX.Minimum = -0.5; SGraph.ChartAreas[0].AxisX.Maximum = Convert.ToDouble(nPos - 0.5); SGraph.ChartAreas[0].AxisX2.Minimum = -0.5; SGraph.ChartAreas[0].AxisX2.Maximum = Convert.ToDouble(nPos - 0.5); SGraph.ChartAreas[0].AxisY.Maximum = lYMax; if (nSkills > 10) { SGraph.ChartAreas[0].AxisX.ScaleView.Zoomable = true; SGraph.ChartAreas[0].AxisX.ScrollBar.Enabled = true; SGraph.ChartAreas[0].AxisX.ScaleView.Size = 10; SGraph.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll; SGraph.ChartAreas[0].AxisX.ScrollBar.ButtonColor = Color.LightGray; SGraph.ChartAreas[0].AxisX.ScrollBar.BackColor = Color.Gray; SGraph.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = false; SGraph.ChartAreas[0].AxisX.ScaleView.Scroll(ScrollType.Last); SGraph.ChartAreas[0].AxisX.ScaleView.Scroll(ScrollType.First); SGraph.ChartAreas[0].AxisX.ScaleView.Scroll(ScrollType.Last); } SGraph.Series.Add(oBottom); SGraph.Series.Add(oSeries); } } this.ResumeLayout(); int nNewHeight = 0; if (this.FormBorderStyle == FormBorderStyle.SizableToolWindow) { nNewHeight = 83; } else { nNewHeight = 58; } if (nSkills < 11) { nNewHeight += (28 * (nSkills)); } else { nNewHeight += (28 * 10); } if (this.InvokeRequired) { BeginInvoke((Action)(() => { this.Size = new System.Drawing.Size(this.Width, nNewHeight); })); } else { this.Size = new System.Drawing.Size(this.Width, nNewHeight); } }