private static void OnEnableChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (((bool)e.NewValue == true) && ((bool)e.OldValue == false)) { BasicWaveChartUC basicwave = d as BasicWaveChartUC; basicwave.Loaded += new RoutedEventHandler(targetloaded_hdlr); } ; }
//redraw scale command public void ReDrawScaleCmd() { YAxisCtl yaxisctl = this.FindName("yaxis") as YAxisCtl; BasicWaveChartUC wavechartuc = this.FindName("ControlContainer") as BasicWaveChartUC; Canvas windowcanvas = wavechartuc.FindName("WindowCanvas") as Canvas; Polyline xaxis_ply = wavechartuc.FindName("xaxis_ply") as Polyline; xaxis_ply.Points.Clear(); double hlinevalue = this.Height - topblank; if (this.XScaleLineNumber == 0) { return; } int scalenumber = (int)(wavechartuc.NumberOfDValue / this.XScaleLineNumber); for (int i = 0; i <= scalenumber; i++) { xaxis_ply.Points.Add(new Point(i * XScaleLineNumber * granulity_width, hlinevalue)); if (i % this.XCommentNumber == 0) { xaxis_ply.Points.Add(new Point(i * XScaleLineNumber * granulity_width, hlinevalue - bigScaleHeight)); } else { xaxis_ply.Points.Add(new Point(i * XScaleLineNumber * granulity_width, hlinevalue - littleScaleHeight)); } xaxis_ply.Points.Add(new Point(i * XScaleLineNumber * granulity_width, hlinevalue)); } xaxis_ply.Points.Add(new Point(wavechartuc.NumberOfDValue * granulity_width, hlinevalue)); //todo replace xaxis_ply.Points.Add(new Point(wavechartuc.NumberOfDValue * granulity_width, hlinevalue - 20)); //todo replace xaxis_ply.Points.Add(new Point(wavechartuc.NumberOfDValue * granulity_width, hlinevalue)); //todo replace switch (this.XArrowStyle) { case ArrowStyleEnm.SOLID: case ArrowStyleEnm.HOLLOW: { xaxis_ply.Points.Add(new Point(this.Width - wavechartuc.RightBlankZone - this.arrowheight, hlinevalue)); xaxis_ply.Points.Add(new Point(this.Width - wavechartuc.RightBlankZone - this.arrowheight, hlinevalue - this.arrowheight / 2)); xaxis_ply.Points.Add(new Point(this.Width - wavechartuc.RightBlankZone - this.arrowheight, hlinevalue + this.arrowheight / 2)); xaxis_ply.Points.Add(new Point(this.Width - wavechartuc.RightBlankZone, hlinevalue)); xaxis_ply.Points.Add(new Point(this.Width - wavechartuc.RightBlankZone - this.arrowheight, hlinevalue - this.arrowheight / 2)); //pf.IsFilled = true; break; } case ArrowStyleEnm.NONE: default: { xaxis_ply.Points.Add(new Point(this.Width - wavechartuc.RightBlankZone, hlinevalue)); break; } } }
public double GetGranulity() { Canvas cp = this.Parent as Canvas; ZoomPanel zp = cp.Parent as ZoomPanel; BasicWaveChartUC p = zp.Parent as BasicWaveChartUC; granulity_width = p.WindowCanvas_pen.Width / XScaleMaxValue; return(granulity_width); }
//self event private void self_Loaded(object sender, RoutedEventArgs e) { parent = this.FindName("ControlContainer") as BasicWaveChartUC; xaxis = this.FindName("xaxis") as XAxisCtl; yaxis = this.FindName("yaxis") as YAxisCtl; moveslider = this.FindName("moveslider") as Slider; wincanvas = this.FindName("WindowCanvas") as Canvas; ; }
private static void YScaleMaxValue_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) { YAxisCtl self = d as YAxisCtl; XAxisCtl xaxisctl = self.FindName("xaxis") as XAxisCtl; BasicWaveChartUC wavechartuc = self.FindName("ControlContainer") as BasicWaveChartUC; if (xaxisctl == null || wavechartuc == null) { return; } self.granulity_width = (self.Height - xaxisctl.Height - self.arrowheight - wavechartuc.TopBlankZone) / self.YScaleMaxValue; }
private IntegralWorker(BasicWaveChartUC param) { ucctl = param; areagon = new Polygon(); areagon.Name = "areagon"; areagon.Visibility = Visibility.Visible; commenttx = new TextBlock(); commenttx.Width = 80; commenttx.Height = 20; commenttx.Visibility = Visibility.Visible; commenttx.Name = "commenttx"; commenttx.TextAlignment = TextAlignment.Center; //main handle mainhandle = new HandleCtl(new HandleCtl()); }
//redraw text command public void ReDrawTextCommentCmd() { Canvas xaxis_text_canvas = this.FindName("xaxis_text_canvas") as Canvas; BasicWaveChartUC wavechartuc = this.FindName("ControlContainer") as BasicWaveChartUC; XAxisCtl xaxis = this.FindName("xaxis") as XAxisCtl; YAxisCtl yaxis = this.FindName("yaxis") as YAxisCtl; //add the scale text xaxis_text_canvas.Children.Clear(); //0 xaxis_text_canvas.Children.Add(new TextBlock()); (xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock).Text = "0"; (xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock).FontSize = 8; Canvas.SetLeft((xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock), 0); Canvas.SetBottom((xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock), 0); if (xaxis.XScaleLineNumber == 0) { return; } int loop = (int)(wavechartuc.NumberOfDValue / xaxis.XScaleLineNumber / xaxis.XCommentNumber); for (int i = 1; i < loop; i++) { xaxis_text_canvas.Children.Add(new TextBlock()); (xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock).Text = (i * xaxis.XScaleLineNumber * xaxis.XCommentNumber).ToString(); (xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock).FontSize = 8; Canvas.SetLeft((xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock), (i * xaxis.XScaleLineNumber * xaxis.XCommentNumber) * xaxis.GetGranulity()); Canvas.SetBottom((xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock), 0); } //the text of last big scale xaxis_text_canvas.Children.Add(new TextBlock()); (xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock).Text = (loop * xaxis.XScaleLineNumber * xaxis.XCommentNumber).ToString(); (xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock).FontSize = 8; Canvas.SetLeft((xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock), (loop * xaxis.XScaleLineNumber * xaxis.XCommentNumber) * xaxis.GetGranulity()); Canvas.SetBottom((xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock), 0); //the max of dvalue xaxis_text_canvas.Children.Add(new TextBlock()); (xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock).Text = wavechartuc.NumberOfDValue.ToString(); //todo replace 1187 (xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock).FontSize = 8; Canvas.SetLeft((xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock), wavechartuc.NumberOfDValue * xaxis.GetGranulity()); Canvas.SetBottom((xaxis_text_canvas.Children[xaxis_text_canvas.Children.Count - 1] as TextBlock), 0); }
public static IntegralWorker Create(BasicWaveChartUC param) { IntegralWorker w = new IntegralWorker(param); return(w); }