private void Text1_TextChanged(object sender, EventArgs e) { //this.Picture1.Paint += Picture1_Paint; Picture1.Refresh(); //Picture1.Invalidate(); }
public void ShowRegion() { if (SourcePic == null) { return; } //TODO finish this line //StretchBlt Picture1.hDC, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, SourcePic.hDC, CenterX - GridHalfSide, CenterY - GridHalfSide, GridSide, GridSide, SRCCOPY; //Print image into picturebox with Stretch style //update pixel value labels long X = 0; long Y = 0; long i = 0; long h = 0; long j = 0; long color = 0; bool UseHistory = false; if (StatsEnabled & HistCount < m_HistoryLength) { HistCount = HistCount + 1; labelHistCount.ForeColor = Color.Red; } else { labelHistCount.ForeColor = Color.Black; } labelHistCount.Text = HistCount.ToString(); LastI = (LastI + 1) % m_HistoryLength; for (Y = -GridHalfSide; Y <= GridHalfSide; Y++) { for (X = -GridHalfSide; X <= GridHalfSide; X++) { // TODO replace the following Line //PixHistory(X, Y, LastI) = GetPixel(SourcePic.hDC, CenterX + X, CenterY + Y) & 0XFF; if (LabelsEnabled | lblPixVal(i).ForeColor == vbGreen) { if (StatsEnabled) { lblPixVal(i) = System.Convert.ToInt32(PixelAverage(X, Y)); } else { lblPixVal(i) = PixHistory(X, Y, LastI); } lblPixVal(i).Visible = true; } else { lblPixVal(i).Visible = false; } i = i + 1; } } lblStats.Visible = StatsEnabled; if (StatsEnabled) { //compute stats for (Y = -2; Y <= 2; Y++) { for (X = -2; X <= 2; X++) { PixAverageHistory(X, Y, LastI) = PixelAverage(X, Y); } } //lblStats = "Center Avg " & F(PixAverageHistory(0, 0, LastI), 1) & _ lblStats = "Avg all " + f(PixelAverageAll, 2) + ", STD " + f(PixelSTD(0, 0), 2) + ", STD(avg) " + f(STDofAverage(0, 0), 2); if (GridHalfSide >= 2) //find the average stats of a 5x5 grid at the center { Avg5x5 = 0; STD5x5 = 0; STDofAvg5x5 = 0; for (Y = -2; Y <= 2; Y++) { for (X = -2; X <= 2; X++) { Avg5x5 = Avg5x5 + PixAverageHistory(X, Y, LastI) / 25; //average of pixel, including this one STD5x5 = STD5x5 + PixelSTD(X, Y) / 25; STDofAvg5x5 = STDofAvg5x5 + STDofAverage(X, Y) / 25; } } lblStats = lblStats + System.Environment.NewLine + "5x5 Avg " + f(Avg5x5, 1) + ", STD " + f(STD5x5, 2) + ", STD(avg) " + f(f(STDofAvg5x5, 2), 2); } } Picture1.Refresh(); lblXY = "X: " + CenterX + " Y:" + CenterY; if (XPEnabled) { double[] Pos = new double[2]; double[] TCPos = new double[2]; double[] UnitV = null; int[] Val = new int[3]; long XPI = 0; object SideI = null; if (SourcePic == fMain.PictureB(0)) { SideI = 0; } else { SideI = 1; } XPI = NearbyXpointI(fMain.CurrCamera, SideI, CenterX / fMain.DisplayScale, CenterY / fMain.DisplayScale, 5); if (XPI >= 0) { if (GetXpoint(fMain.CurrCamera, SideI, XPI, Pos[0], Pos[1], TCPos[0], TCPos[1], UnitV, Val[0], Val[1], Val[2])) { //draw the lines double[] PC = new double[2]; double LineLen = 0; PC[0] = 0.5 * Picture1.ScaleWidth + (Pos[0] * fMain.DisplayScale - CenterX) * Picture1.ScaleWidth / (2 * GridHalfSide + 1); PC[1] = 0.5 * Picture1.ScaleHeight + (Pos[1] * fMain.DisplayScale - CenterY) * Picture1.ScaleHeight / (2 * GridHalfSide + 1); LineLen = Min(Picture1.Width, Picture1.Height); DrawLine PC[0] - LineLen * UnitV[0, 0], PC[1] - LineLen * UnitV[1, 0], PC[0] + LineLen * UnitV[0, 0], PC[1] + LineLen * UnitV[1, 0], vbBlue;