void TestImage() { WriteableBitmap b = LChartPhoto.getPhoto(); if (b == null) { SilverlightLFC.common.Environment.ShowMessage("没有要测试的照片"); return; } decimal d = 0m; try { d = xt.getAberration(b); } catch (Exception xe) //未知的异常 { if (xe is LFCException) //已经是系统约定的错误类型,直接往上抛 { SilverlightLFC.common.Environment.ShowMessage(xe.Message); } else { SilverlightLFC.common.Environment.ShowMessage("广角端畸变测试错误"); } } try{ double leftCirclePoint = Convert.ToDouble(xt.ProcessInfor["AberrationLCP"]); double rightCirclePoint = Convert.ToDouble(xt.ProcessInfor["AberrationRCP"]); double lv = Convert.ToDouble(xt.ProcessInfor["AberrationLVP"]); double rv = Convert.ToDouble(xt.ProcessInfor["AberrationRVP"]); leftCirclePoint = leftCirclePoint / b.PixelWidth; rightCirclePoint = rightCirclePoint / b.PixelWidth; lv = lv / b.PixelWidth; rv = rv / b.PixelWidth; dg.DrawLine(leftCirclePoint * LChartPhoto.Width, 0, leftCirclePoint * LChartPhoto.Width, LChartPhoto.Height, false, 3, new SolidColorBrush(Colors.Green)); dg.DrawLine(rightCirclePoint * LChartPhoto.Width, 0, rightCirclePoint * LChartPhoto.Width, LChartPhoto.Height, false, 3, new SolidColorBrush(Colors.Green)); dg.DrawLine(lv * LChartPhoto.Width, 0, lv * LChartPhoto.Width, LChartPhoto.Height, false, 3, new SolidColorBrush(Colors.Red)); dg.DrawLine(rv * LChartPhoto.Width, 0, rv * LChartPhoto.Width, LChartPhoto.Height, false, 3, new SolidColorBrush(Colors.Red)); textBlockAberration.Text = d.ToString(); textBlockStandardLong.Text = (rightCirclePoint - leftCirclePoint).ToString(); textBlockTrueLong.Text = (rv - lv).ToString(); } catch (Exception xe) //未知的异常 { if (xe is LFCException) //已经是系统约定的错误类型,直接往上抛 { SilverlightLFC.common.Environment.ShowMessage(xe.Message); } else { SilverlightLFC.common.Environment.ShowMessage("广角端畸变测试错误"); } } }
//Color FillColor = Colors.Green; void c_PointerReleased(object sender, PointerRoutedEventArgs e) { if (type == 1) { ep = e.GetCurrentPoint(pc.SelectLayer).Position; dg.DrawLine(sp.X, sp.Y, ep.X, ep.Y, false, Convert.ToInt32(textW.Text), new SolidColorBrush(ForeColor)); } if (type == 2) { ep = e.GetCurrentPoint(pc.SelectLayer).Position; dg.DrawRectangle(sp.X, sp.Y, ep.X, ep.Y, checkBox1.IsChecked == true, Convert.ToInt32(textW.Text), new SolidColorBrush(ForeColor), new SolidColorBrush(ForeColor)); } if (type == 3) { ep = e.GetCurrentPoint(pc.SelectLayer).Position; dg.DrawEllipse(sp.X, sp.Y, ep.X, ep.Y, checkBox1.IsChecked == true, Convert.ToInt32(textW.Text), new SolidColorBrush(ForeColor), new SolidColorBrush(ForeColor)); } if (type == 4) { ep = e.GetCurrentPoint(pc.SelectLayer).Position; TextBox tb = dg.DrawEditText(sp.X, sp.Y, ep.X, ep.Y, "Text", new SolidColorBrush(ForeColor), ForeFont); tb.LostFocus += new RoutedEventHandler(tb_LostFocus); } if (type == 5) { begin = false; c.PointerMoved -= new PointerEventHandler(c_PointerMoved); } c.PointerPressed -= new PointerEventHandler(c_PointerPressed); c.PointerReleased -= new PointerEventHandler(c_PointerReleased); e.Handled = true; }