private void GraphViewer_Load(object sender, EventArgs e) { tb_TimeRange.Text = TimeRange.ToString(); tb_Xmin.Text = Xmin.ToString(); tb_Xmax.Text = Xmax.ToString(); tb_Ymin.Text = Ymin.ToString(); tb_Ymax.Text = Ymax.ToString(); chbox_swapXY.Checked = SwapXY; }
public Form1() { InitializeComponent(); Xmin = 0.2; Xmax = 8.2; Ymin = 0.5; Ymax = 6.5; textBox1.Text = Xmin.ToString(); textBox2.Text = Ymin.ToString(); textBox3.Text = Xmax.ToString(); textBox4.Text = Ymax.ToString(); dc = pictureBox1.CreateGraphics(); p = new Pen(Brushes.Black, 1); }
public Form1() { InitializeComponent(); flag = false; graphics = pictureBox1.CreateGraphics(); Xmin = 0.2; Xmax = 8.2; Ymin = 0.5; Ymax = 6.5; textBox1.Text = Xmin.ToString(); textBox2.Text = Xmax.ToString(); textBox3.Text = Ymin.ToString(); textBox4.Text = Ymax.ToString(); }
public Form1() { InitializeComponent(); /* Задание границ области вывода по умолчанию */ Xmin = 0.2; Xmax = 8.2; Ymin = 0.5; Ymax = 6.5; textBox1.Text = Xmin.ToString(); textBox2.Text = Ymin.ToString(); textBox3.Text = Xmax.ToString(); textBox4.Text = Ymax.ToString(); dc = pictureBox1.CreateGraphics(); p = new Pen(Brushes.Black, 1); }
private void button_Reset_Click(object sender, EventArgs e) { Xmin = -10; Xmax = 10; Ymin = -10; Ymax = 10; Xstep = 1; Ystep = 2; textBox_Xmin.Text = Xmin.ToString(); textBox_Xmax.Text = Xmax.ToString(); textBox_Ymin.Text = Ymin.ToString(); textBox_Ymax.Text = Ymax.ToString(); pictureBox_Surface.Refresh(); }
private void button_ToCentre_Click(object sender, EventArgs e) { float aux = Xmax - Xmin; Xmax = aux / 2; Xmin = -aux / 2; aux = Ymax - Ymin; Ymax = aux / 2; Ymin = -aux / 2; textBox_Xmin.Text = Xmin.ToString(); textBox_Xmax.Text = Xmax.ToString(); textBox_Ymin.Text = Ymin.ToString(); textBox_Ymax.Text = Ymax.ToString(); pictureBox_Surface.Refresh(); }
private void button6_Click(object sender, EventArgs e) { float aux = (Xmax - Xmin); Xmax = aux / 2; Xmin = -aux / 2; aux = (Ymax - Ymin); Ymax = aux / 2; Ymin = -aux / 2; textBox1.Text = Xmin.ToString(); textBox3.Text = Xmax.ToString(); textBox2.Text = Ymin.ToString(); textBox4.Text = Ymax.ToString(); this.Refresh(); }
private void timer1_Tick(object sender, EventArgs e) { float X = Xcursor - Cursor.Position.X; float Y = Ycursor - Cursor.Position.Y; Xmax = Xmax_aux + X/Xdim; Xmin = Xmin_aux + X/Xdim; Ymax = Ymax_aux - Y/Ydim; Ymin = Ymin_aux - Y/Ydim; label11.Text = X.ToString(); label12.Text = Y.ToString(); textBox1.Text = Xmin.ToString(); textBox3.Text = Xmax.ToString(); textBox2.Text = Ymin.ToString(); textBox4.Text = Ymax.ToString(); this.Refresh(); }
public override string ToString() { System.Text.StringBuilder sb = new System.Text.StringBuilder(200); sb.AppendFormat("[Table2D @ {0:X6} | Selected={1} Count={2} Type={3} | RangeX={4}, RangeY={5} | xMin={6} xMax={7} | yMin={8} yMax={9} yAvg={10}", location, selected, CountX, TableType.ToStr(), rangeX.ToString(), rangeY.ToString(), Xmin.ToString(), Xmax.ToString(), Ymin.ToString(), Ymax.ToString(), Yavg.ToString()); if (hasMAC) { sb.AppendFormat(" | Multiplier={0}, Offset={1}]", Multiplier, Offset); } else { sb.Append("]"); } return(sb.ToString()); }
private void pictureBox_Surface_MouseMove(object sender, MouseEventArgs e) { if (pressed) { // float x = cursorX_initial - e.X; float y = cursorY_initial - e.Y; Xmax = Xmax_initial + x / Xdim; Xmin = Xmin_initial + x / Xdim; Ymax = Ymax_initial - y / Ydim; Ymin = Ymin_initial - y / Ydim; textBox_Xmin.Text = Xmin.ToString(); textBox_Xmax.Text = Xmax.ToString(); textBox_Ymin.Text = Ymin.ToString(); textBox_Ymax.Text = Ymax.ToString(); pictureBox_Surface.Refresh(); } }
public void AddChartStyle(TextBlock tbTitle, TextBlock tbXLabel, TextBlock tbYLabel) { TextBlock tb = new TextBlock { Text = Xmax.ToString() }; tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); rightOffset = tb.DesiredSize.Width / 2 + 2; leftOffset = this.CalculateLeftOffset(); Canvas.SetLeft(ChartCanvas, leftOffset); Canvas.SetBottom(ChartCanvas, bottomOffset); ChartCanvas.Width = Math.Abs(TextCanvas.Width - leftOffset - rightOffset); ChartCanvas.Height = Math.Abs(TextCanvas.Height - bottomOffset - tb.DesiredSize.Height / 2); Rectangle chartRectangle = new Rectangle { Stroke = Brushes.Black, Width = ChartCanvas.Width, Height = ChartCanvas.Height }; ChartCanvas.Children.Add(chartRectangle); if (IsYGrid) { this.GenerateYGrids(this); } if (IsXGrid) { this.GenerateXGrids(this); } this.GenerateXLabels(leftOffset); this.GenerateYLabels(); tbTitle.Text = Title; tbXLabel.Text = XLabel; tbYLabel.Text = YLabel; tbXLabel.Margin = new Thickness(leftOffset + 2, 2, 2, 2); tbTitle.Margin = new Thickness(leftOffset + 2, 2, 2, 2); }
public void SavegarderFichierCarte(string pth) { if (carte == null) { return; } if (name == null && pth == null && path == null) { path = Application.dataPath + "/Resources/Cartes/Carte" + DateTime.Now.ToString(); } else if (pth != null) { path = pth; } else { path = name; File.Create(path); } string strEntete = Xmax.ToString() + "\n" + Ymax.ToString() + "\n"; List <string> lines = new List <string>(); for (int i = 0; i < Xmax; i++) { for (int j = 0; j < Ymax; j++) { if (carte[i, j] != null && carte[i, j].EstOccupe) { string str = i.ToString() + ":" + j.ToString() + ":" + carte[i, j].Hauteur.ToString() + ":" + carte[i, j].Element() + "\n"; lines.Add(str); } } } File.AppendAllLines(path, lines.ToArray()); }
private void pictureBox_Surface__MouseWheel(object sender, MouseEventArgs e) { float Xval = 0, Yval = 0; int sign = 0; if (radioButton_Horizontal.Checked == false) { Yval = (Ymax - Ymin) * 0.025F; } if (radioButton_Vertical.Checked == false) { Xval = (Xmax - Xmin) * 0.025F; } if (e.Delta < 0) { sign = -1; } else if (Xstep > 0.01F) { sign = 1; } if (sign != 0) { Xmax -= sign * Xval; Xmin += sign * Xval; Ymax -= sign * Yval; Ymin += sign * Yval; UpdateSteps(); textBox_Xmin.Text = Xmin.ToString("F3"); textBox_Xmax.Text = Xmax.ToString("F3"); textBox_Ymin.Text = Ymin.ToString("F3"); textBox_Ymax.Text = Ymax.ToString("F3"); pictureBox_Surface.Refresh(); } }
private void pictureBox2_MouseWheel(object sender, MouseEventArgs e) { if (ok) { const int proc = 4; float Xval = 0; float Yval = 0; if (hor) { Xval = (float)(Xmax - Xmin) * proc / 100; } if (vert) { Yval = (float)(Ymax - Ymin) * proc / 100; } if (e.Delta < 0) { Xmax += Xval; Xmin -= Xval; Ymax += Yval; Ymin -= Yval; } else if (((Xmax - Xmin) > 0.1) && (Ymax - Ymin) > 0.1) { Xmax -= Xval; Xmin += Xval; Ymax -= Yval; Ymin += Yval; } textBox1.Text = Xmin.ToString(); textBox3.Text = Xmax.ToString(); textBox2.Text = Ymin.ToString(); textBox4.Text = Ymax.ToString(); this.Refresh(); } }
/*public void startThread() * { * Thread thread = new Thread(startThread); * }*/ public void AddChartStyle(TextBlock tbTitle, TextBlock tbXLabel, TextBlock tbYLabel) { //clear_chartcanvas(); Point pt = new Point(); Line tick = new Line(); double offset = 0; double dx, dy; TextBlock tb = new TextBlock(); // determine right offset: tb.Text = Xmax.ToString(); tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); Size size = tb.DesiredSize; rightOffset = size.Width / 2 + 2; // Determine left offset: for (dy = Ymin; dy <= Ymax; dy += YTick) { pt = NormalizePoint(new Point(Xmin, dy)); tb = new TextBlock(); tb.Text = dy.ToString(); tb.TextAlignment = TextAlignment.Right; tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); size = tb.DesiredSize; if (offset < size.Width) { offset = size.Width; } } leftOffset = offset + 5; Canvas.SetLeft(ChartCanvas, leftOffset); Canvas.SetBottom(ChartCanvas, bottomOffset); ChartCanvas.Width = TextCanvas.Width - leftOffset - rightOffset; ChartCanvas.Height = TextCanvas.Height - bottomOffset - size.Height / 2; Rectangle chartRect = new Rectangle(); chartRect.Stroke = Brushes.Red; chartRect.Width = ChartCanvas.Width; chartRect.Height = ChartCanvas.Height; ChartCanvas.Children.Add(chartRect); // Create vertical gridlines: if (IsYGrid == true) { for (dx = Xmin + XTick; dx < Xmax; dx += XTick) { gridline = new Line(); AddLinePattern(); gridline.X1 = NormalizePoint(new Point(dx, Ymin)).X; gridline.Y1 = NormalizePoint(new Point(dx, Ymin)).Y; gridline.X2 = NormalizePoint(new Point(dx, Ymax)).X; gridline.Y2 = NormalizePoint(new Point(dx, Ymax)).Y; ChartCanvas.Children.Add(gridline); } } // Create horizontal gridlines: if (IsXGrid == true) { for (dy = Ymin + YTick; dy < Ymax; dy += YTick) { gridline = new Line(); AddLinePattern(); gridline.X1 = NormalizePoint(new Point(Xmin, dy)).X; gridline.Y1 = NormalizePoint(new Point(Xmin, dy)).Y; gridline.X2 = NormalizePoint(new Point(Xmax, dy)).X; gridline.Y2 = NormalizePoint(new Point(Xmax, dy)).Y; ChartCanvas.Children.Add(gridline); } } // Create x-axis tick marks: for (dx = Xmin; dx <= Xmax; dx += xTick) { pt = NormalizePoint(new Point(dx, Ymin)); tick = new Line(); tick.Stroke = Brushes.Black; tick.X1 = pt.X; tick.Y1 = pt.Y; tick.X2 = pt.X; tick.Y2 = pt.Y - 5; ChartCanvas.Children.Add(tick); tb = new TextBlock(); tb.Text = dx.ToString(); tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); size = tb.DesiredSize; tb_array.Add(tb); TextCanvas.Children.Add(tb); Canvas.SetLeft(tb, leftOffset + pt.X - size.Width / 2); Canvas.SetTop(tb, pt.Y + 2 + size.Height / 2); } // Create y-axis tick marks: for (dy = Ymin; dy <= Ymax; dy += YTick) { pt = NormalizePoint(new Point(Xmin, dy)); tick = new Line(); tick.Stroke = Brushes.Black; tick.X1 = pt.X; tick.Y1 = pt.Y; tick.X2 = pt.X + 5; tick.Y2 = pt.Y; ChartCanvas.Children.Add(tick); tb = new TextBlock(); tb.Text = dy.ToString(); tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); size = tb.DesiredSize; tb_array.Add(tb); TextCanvas.Children.Add(tb); Canvas.SetRight(tb, ChartCanvas.Width + 10); Canvas.SetTop(tb, pt.Y); } // Add title and labels: tbTitle.Text = Title; tbXLabel.Text = XLabel; tbYLabel.Text = YLabel; }
//Adding style to the bars control public void SetBoxPlotControl(BindableCollection <BoxWhiskerPlot> BarSeries = null) { // determine right offset: TextBlock tb1 = new TextBlock(); tb1.Text = Xmax.ToString(); tb1.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); Size size = tb1.DesiredSize; double offset = 20; double rightOffset = size.Width / 2 + 15; // Determine left offset through iterating through all y axis labels: for (double dy = Ymin; dy <= Ymax; dy += YTick) { Point pt = NormalizePoint(new Point(Xmin, dy)); tb1.Text = dy.ToString(); tb1.TextAlignment = TextAlignment.Right; tb1.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); size = tb1.DesiredSize; if (offset < size.Width) { offset = size.Width; } } double leftOffset = offset + 15; foreach (var bar in BoxWhiskerCollection) { Polygon rect = new Polygon(); rect.Stroke = bar.BorderColor; rect.Fill = bar.FillColor; rect.StrokeThickness = bar.BorderThickness; rect.Points = bar.PolygonPoints; ChartCanvas.Children.Add(rect); Polyline pl = new Polyline(); TextBlock tb = new TextBlock(); try { tb.Text = bar.Name.ToString(); } catch { tb.Text = ""; } foreach (var whiskerLine in bar.WhiskerLines) { whisker = new Line(); whisker.StrokeThickness = bar.BorderThickness; whisker.Stroke = bar.BorderColor; whisker.X1 = whiskerLine.LinePoints[0].X; whisker.Y1 = whiskerLine.LinePoints[0].Y; whisker.X2 = whiskerLine.LinePoints[1].X; whisker.Y2 = whiskerLine.LinePoints[1].Y; ChartCanvas.Children.Add(whisker); } foreach (var lin in bar.Outliers.LinePoints) { bar.Outliers.Symbols.AddSymbol(ChartCanvas, lin); } tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); ChartCanvas.Children.Add(tb); Canvas.SetLeft(tb, 4); Canvas.SetTop(tb, Math.Abs((bar.PolygonPoints.Min(y => y.Y))) - tb.DesiredSize.Height); } }
public void AddChartStyle(TextBlock tbTitle, TextBlock tbXLabel, TextBlock tbYLabel) { Point pt = new Point(); Line tick = new Line(); double offset = 0; double dx, dy; TextBlock tb = new TextBlock(); tb.Text = Xmax.ToString(); tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); Size size = tb.DesiredSize; rightOffset = size.Width / 2 + 2; for (dy = Ymin; dy <= Ymax; dy += YTick) { pt = NormalizePoint(new Point(Xmin, dy)); tb = new TextBlock(); tb.Text = dy.ToString(); tb.TextAlignment = TextAlignment.Right; tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); size = tb.DesiredSize; if (offset < size.Width) { offset = size.Width; } } leftOffset = offset + 5; Canvas.SetLeft(ChartCanvas, leftOffset); Canvas.SetBottom(ChartCanvas, bottomOffset); ChartCanvas.Width = Math.Abs(TextCanvas.Width - leftOffset - rightOffset); ChartCanvas.Height = Math.Abs(TextCanvas.Height - bottomOffset - size.Height / 2); Rectangle chartRect = new Rectangle(); chartRect.Stroke = Brushes.Black; chartRect.Width = ChartCanvas.Width; chartRect.Height = ChartCanvas.Height; ChartCanvas.Children.Add(chartRect); if (IsYGrid == true) { for (dx = Xmin + XTick; dx < Xmax; dx += XTick) { gridline = new Line(); AddLinePattern(); gridline.X1 = NormalizePoint(new Point(dx, Ymin)).X; gridline.Y1 = NormalizePoint(new Point(dx, Ymin)).Y; gridline.X2 = NormalizePoint(new Point(dx, Ymax)).X; gridline.Y2 = NormalizePoint(new Point(dx, Ymax)).Y; ChartCanvas.Children.Add(gridline); } } if (IsXGrid == true) { for (dy = Ymin + YTick; dy < Ymax; dy += YTick) { gridline = new Line(); AddLinePattern(); gridline.X1 = NormalizePoint(new Point(Xmin, dy)).X; gridline.Y1 = NormalizePoint(new Point(Xmin, dy)).Y; gridline.X2 = NormalizePoint(new Point(Xmax, dy)).X; gridline.Y2 = NormalizePoint(new Point(Xmax, dy)).Y; ChartCanvas.Children.Add(gridline); } } for (dx = Xmin; dx <= Xmax; dx += xTick) { pt = NormalizePoint(new Point(dx, Ymin)); tick = new Line(); tick.Stroke = Brushes.Black; tick.X1 = pt.X; tick.Y1 = pt.Y; tick.X2 = pt.X; tick.Y2 = pt.Y - 5; ChartCanvas.Children.Add(tick); tb = new TextBlock(); tb.Text = dx.ToString(); tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); size = tb.DesiredSize; TextCanvas.Children.Add(tb); Canvas.SetLeft(tb, leftOffset + pt.X - size.Width / 2); Canvas.SetTop(tb, pt.Y + 2 + size.Height / 2); } for (dy = Ymin; dy <= Ymax; dy += YTick) { pt = NormalizePoint(new Point(Xmin, dy)); tick = new Line(); tick.Stroke = Brushes.Black; tick.X1 = pt.X; tick.Y1 = pt.Y; tick.X2 = pt.X + 5; tick.Y2 = pt.Y; ChartCanvas.Children.Add(tick); tb = new TextBlock(); tb.Text = dy.ToString(); tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); size = tb.DesiredSize; TextCanvas.Children.Add(tb); Canvas.SetRight(tb, ChartCanvas.Width + 10); Canvas.SetTop(tb, pt.Y); } tbTitle.Text = Title; tbXLabel.Text = XLabel; tbYLabel.Text = YLabel; tbXLabel.Margin = new Thickness(leftOffset + 2, 2, 2, 2); tbTitle.Margin = new Thickness(leftOffset + 2, 2, 2, 2); }
private void Btn_load_path_Click(object sender, EventArgs e) { String DllPath = tBox_DllPath.Text.ToString(); IntPtr pDll = NativeMethods.LoadLibrary(@DllPath); if (pDll != IntPtr.Zero) { btn_Run.Enabled = true; btn_set_optimizer.Enabled = true; SetImportingDllPath(DllPath, DllPath.Length); label5.Text = "Loading status: loaded"; label5.BackColor = Color.LightGreen; TaskLoaded = true; IntPtr pAddressOfFunctionToCall1 = NativeMethods.GetProcAddress(pDll, "GetTaskArea"); IntPtr pAddressOfFunctionToCall2 = NativeMethods.GetProcAddress(pDll, "GetTaskLinesCalcParams"); IntPtr pAddressOfFunctionToCall3 = NativeMethods.GetProcAddress(pDll, "GetDensity"); GetTaskArea getTaskArea = (GetTaskArea)Marshal.GetDelegateForFunctionPointer( pAddressOfFunctionToCall1, typeof(GetTaskArea)); GetTaskLinesCalcParams getTaskLinesCalcParams = (GetTaskLinesCalcParams)Marshal.GetDelegateForFunctionPointer( pAddressOfFunctionToCall2, typeof(GetTaskLinesCalcParams)); GetDensity getDensity = (GetDensity)Marshal.GetDelegateForFunctionPointer( pAddressOfFunctionToCall3, typeof(GetDensity)); Xmin = getTaskArea(0); Xmax = getTaskArea(1); Ymin = getTaskArea(2); Ymax = getTaskArea(3); int N = getTaskLinesCalcParams(0); int M1 = getTaskLinesCalcParams(1); int M2 = getTaskLinesCalcParams(2); int M3 = getTaskLinesCalcParams(3); int Density = getDensity(); tBox_Xmin.Text = Xmin.ToString(); tBox_Xmax.Text = Xmax.ToString(); tBox_Ymin.Text = Ymin.ToString(); tBox_Ymax.Text = Ymax.ToString(); tBox_N.Text = N.ToString(); tBox_M1.Text = M1.ToString(); tBox_M2.Text = M2.ToString(); tBox_M3.Text = M3.ToString(); dataGridView1.Rows.Add(0, 1, 0, Color.Black, Xmin, Xmax, Ymin, Ymax, N, M1, M2, M3); dataGridView1.Rows.Add(0, 2, Density, Color.Red, Xmin, Xmax, Ymin, Ymax, N, M1, M2, M3); dataGridView1.Rows.Add(0, 3, 0, Color.Red, Xmin, Xmax, Ymin, Ymax, N, M1, M2, M3); //bool result = NativeMethods.FreeLibrary(pDll); } //double Xmin = -6; //double Xmax = -0.1; //double Ymin = 0; //double Ymax = 3.05; //int N = 100; //int M1 = 80; //int M2 = 40; //int M3 = 20; ////int Density = getDensity(); //tBox_Xmin.Text = Xmin.ToString(); //tBox_Xmax.Text = Xmax.ToString(); //tBox_Ymin.Text = Ymin.ToString(); //tBox_Ymax.Text = Ymax.ToString(); //tBox_N.Text = N.ToString(); //tBox_M1.Text = M1.ToString(); //tBox_M2.Text = M2.ToString(); //tBox_M3.Text = M3.ToString(); //dataGridView1.Rows.Add(0, 1, 0, Color.Black, //Xmin, Xmax, Ymin, Ymax, N, M1, M2, M3); }
public override string ToString() { return(Xmin.ToString("F2") + " ~ " + Xmax.ToString("F2") + ", " + Ymin.ToString("F2") + " ~ " + Ymax.ToString("F2")); }
public void AddChartStyle2D(DrawSurfaceChart dsc) { colorbarWidth = ChartCanvas.Width / 7; ChartCanvas.Children.Add(chart2dBorder); Point pt = new Point(); Line tick = new Line(); double offset = 0; double dx, dy; TextBlock tb = new TextBlock(); // determine right offset: tb.Text = Xmax.ToString(); tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); Size size = tb.DesiredSize; rightOffset = size.Width / 2 + 2; // Determine left offset: for (dy = Ymin; dy <= Ymax; dy += YTick) { pt = NormalizePoint(new Point(Xmin, dy)); tb = new TextBlock(); tb.Text = dy.ToString(); tb.TextAlignment = TextAlignment.Right; tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); size = tb.DesiredSize; if (offset < size.Width) { offset = size.Width; } } leftOffset = offset + 5 + 30; Canvas.SetLeft(chart2dBorder, leftOffset); Canvas.SetBottom(chart2dBorder, bottomOffset); if (!IsColorBar) { colorbarWidth = 0; } chart2dCanvas.Width = ChartCanvas.Width - leftOffset - rightOffset - colorbarWidth; chart2dCanvas.Height = ChartCanvas.Height - bottomOffset - size.Height / 2; // Create vertical gridlines: if (IsYGrid == true) { for (dx = Xmin + XTick; dx < Xmax; dx += XTick) { gridline = new Line(); gridline.Stroke = GridlineColor; gridline.StrokeThickness = GridlineThickness; gridline.X1 = NormalizePoint(new Point(dx, Ymin)).X; gridline.Y1 = NormalizePoint(new Point(dx, Ymin)).Y; gridline.X2 = NormalizePoint(new Point(dx, Ymax)).X; gridline.Y2 = NormalizePoint(new Point(dx, Ymax)).Y; chart2dCanvas.Children.Add(gridline); } } // Create horizontal gridlines: if (IsXGrid == true) { for (dy = Ymin + YTick; dy < Ymax; dy += YTick) { gridline = new Line(); gridline.Stroke = GridlineColor; gridline.StrokeThickness = GridlineThickness; gridline.X1 = NormalizePoint(new Point(Xmin, dy)).X; gridline.Y1 = NormalizePoint(new Point(Xmin, dy)).Y; gridline.X2 = NormalizePoint(new Point(Xmax, dy)).X; gridline.Y2 = NormalizePoint(new Point(Xmax, dy)).Y; chart2dCanvas.Children.Add(gridline); } } // Create x-axis tick marks: for (dx = Xmin; dx <= Xmax; dx += XTick) { pt = NormalizePoint(new Point(dx, Ymin)); tick = new Line(); tick.Stroke = Brushes.Black; tick.X1 = pt.X; tick.Y1 = pt.Y; tick.X2 = pt.X; tick.Y2 = pt.Y - 5; chart2dCanvas.Children.Add(tick); tb = new TextBlock(); tb.Text = dx.ToString(); tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); size = tb.DesiredSize; ChartCanvas.Children.Add(tb); Canvas.SetLeft(tb, leftOffset + pt.X - size.Width / 2); Canvas.SetTop(tb, pt.Y + 2 + size.Height / 2); } // Create y-axis tick marks: for (dy = Ymin; dy <= Ymax; dy += YTick) { pt = NormalizePoint(new Point(Xmin, dy)); tick = new Line(); tick.Stroke = Brushes.Black; tick.X1 = pt.X; tick.Y1 = pt.Y; tick.X2 = pt.X + 5; tick.Y2 = pt.Y; chart2dCanvas.Children.Add(tick); tb = new TextBlock(); tb.Text = dy.ToString(); tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); size = tb.DesiredSize; ChartCanvas.Children.Add(tb); Canvas.SetRight(tb, chart2dCanvas.Width + 10 + colorbarWidth); Canvas.SetTop(tb, pt.Y); } tb = new TextBlock(); tb.Text = XLabel; tb.FontFamily = LabelFont; tb.FontSize = LabelFontSize; tb.Foreground = LabelColor; tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); size = tb.DesiredSize; ChartCanvas.Children.Add(tb); Canvas.SetBottom(tb, bottomOffset / 10); Canvas.SetLeft(tb, leftOffset + chart2dCanvas.Width / 2 - size.Width / 2); tb = new TextBlock(); tb.Text = YLabel; tb.FontFamily = LabelFont; tb.FontSize = LabelFontSize; tb.Foreground = LabelColor; tb.RenderTransform = new RotateTransform(-90, 0.5, 0.5); tb.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); size = tb.DesiredSize; ChartCanvas.Children.Add(tb); Canvas.SetBottom(tb, chart2dCanvas.Height / 2 + size.Width / 3); Canvas.SetLeft(tb, leftOffset / 10); }