示例#1
0
 private void button4_Click(object sender, EventArgs e)
 {
     AutoRescale = false;
     try
     {
         YMax = Double.Parse(textBox2.Text);
     }
     catch (System.FormatException) { textBox2.Text = YMax.ToString("F0"); }
     try
     {
         YMin = Double.Parse(textBox3.Text);
     }
     catch (System.FormatException) { textBox3.Text = YMin.ToString("F0"); }
     try
     {
         XMin = Double.Parse(textBox4.Text);
     }
     catch (System.FormatException) { textBox4.Text = XMin.ToString("F0"); }
     try
     {
         XMax = Double.Parse(textBox5.Text);
     }
     catch (System.FormatException) { textBox5.Text = XMax.ToString("F0"); }
     PlotRescale();
 }
示例#2
0
        /// <summary>
        /// Generate data info text
        /// </summary>
        /// <returns>info text</returns>
        public override string GenerateInfoText()
        {
            string dataInfo;

            dataInfo  = "File Name: " + FileName;
            dataInfo += Environment.NewLine + "Data Type: ASCII Grid";
            dataInfo += Environment.NewLine + "XNum = " + XNum.ToString() +
                        "  YNum = " + YNum.ToString();
            dataInfo += Environment.NewLine + "XMin = " + XMin.ToString() +
                        "  YMin = " + YMin.ToString();
            dataInfo += Environment.NewLine + "XSize = " + XDelt.ToString() +
                        "  YSize = " + YDelt.ToString();
            dataInfo += Environment.NewLine + "MissingValue = " + MissingValue.ToString();

            return(dataInfo);
        }
示例#3
0
    // Start is called before the first frame update
    void Start()
    {
        Camera myCamera = Camera.main;

        XMin = myCamera.ViewportToWorldPoint(new Vector3(0, 0, 0)).x + padding;
        Debug.Log("XMin: " + XMin.ToString());
        XMax = myCamera.ViewportToWorldPoint(new Vector3(1, 0, 0)).x - padding;
        Debug.Log("XMax: " + XMax.ToString());
        YMin = myCamera.ViewportToWorldPoint(new Vector3(0, 0, 0)).y + padding;
        Debug.Log("YMin: " + YMin.ToString());
        YMax = myCamera.ViewportToWorldPoint(new Vector3(0, 1, 0)).y - padding;
        Debug.Log("YMax: " + YMax.ToString());

        // myCirclePrefab = (GameObject)Resources.Load("Circle");
        Instantiate(myCirclePrefab, new Vector3(XMin, YMin, 0), Quaternion.identity);
        Instantiate(myCirclePrefab, new Vector3(XMin, YMax, 0), Quaternion.identity);
        Instantiate(myCirclePrefab, new Vector3(XMax, YMin, 0), Quaternion.identity);
        Instantiate(myCirclePrefab, new Vector3(XMax, YMax, 0), Quaternion.identity);
    }
 public virtual void Grid(System.Windows.Forms.PaintEventArgs e)
 {
     try
     {
         SolidBrush.Color = GridColor;
         e.Graphics.FillRectangle(SolidBrush, XPos, YPos, Width, Height);
         if (ShowMinMax)
         {
             bool fontcreated = false;
             System.Globalization.NumberFormatInfo nfi = System.Globalization.NumberFormatInfo.CurrentInfo;
             System.Globalization.RegionInfo       ri  = System.Globalization.RegionInfo.CurrentRegion;
             if (TextFont == null)
             {
                 TextFont    = new System.Drawing.Font(System.Drawing.FontFamily.GenericSansSerif.Name, 7, System.Drawing.FontStyle.Bold);
                 fontcreated = true;
             }
             if (IsCurrency)
             {
                 e.Graphics.DrawString(YMax.ToString("n", nfi) + " " + ri.ISOCurrencySymbol, TextFont, TextBrush, XPos, YPos);
                 e.Graphics.DrawString(YMin.ToString("n", nfi) + " " + ri.ISOCurrencySymbol, TextFont, TextBrush, XPos, YPos + Height - TextFont.Height);
             }
             else
             {
                 e.Graphics.DrawString(YMax.ToString("n", nfi), TextFont, TextBrush, XPos, YPos);
                 e.Graphics.DrawString(YMin.ToString("n", nfi), TextFont, TextBrush, XPos, YPos + Height - TextFont.Height);
             }
             if (fontcreated)
             {
                 TextFont.Dispose();
                 TextFont = null;
             }
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
示例#5
0
 public override string ToString()
 {
     return($"{XMin.ToString(CultureInfo.InvariantCulture)},{YMin.ToString(CultureInfo.InvariantCulture)},{ZMin.ToString(CultureInfo.InvariantCulture)},{XMax.ToString((CultureInfo.InvariantCulture))},{YMax.ToString((CultureInfo.InvariantCulture))},{ZMax.ToString((CultureInfo.InvariantCulture))}");
 }
示例#6
0
 public override string ToString()
 {
     return(XMin.ToString() + "," + YMin.ToString() + "," + XMax.ToString() + "," + YMax.ToString());
 }
示例#7
0
        private void ChangeOperationMode(int NewMode)
        {
            if (OperationMode == NewMode)
            {
                return;
            }
            if (NewMode == MODE_IDLE)
            {
                if (OutputFile != null)
                {
                    OutputFile.Close();
                }
                button2.Enabled  = false;
                button3.Enabled  = false;
                textBox1.Enabled = true;
                timer1.Enabled   = false;
                OperationMode    = MODE_IDLE;
            }
            if (NewMode == MODE_MAIN)
            {
                SerialWriteBuffer[0] = 'm';
                StartExperiment      = DateTime.Now;
                FileName             = String.Format("polar{0,4:0000}_{1,2:00}_{2,2:00}-{3,2:00}_{4,2:00}_{5,2:00}.out",
                                                     StartExperiment.Year,
                                                     StartExperiment.Month,
                                                     StartExperiment.Day,
                                                     StartExperiment.Hour,
                                                     StartExperiment.Minute,
                                                     StartExperiment.Second);
                if (OutputFile != null)
                {
                    OutputFile.Close();
                }

                OutputFile = new StreamWriter(FileName);        // create file
                OutputFile.Close();

                label1.Text         = FileName;
                YMIN                = 0; YMAX = 0;
                NPlot1              = new LinePlot();
                NPoints             = 0;
                AutoRescale         = true;
                XX                  = new double[1];
                YY                  = new double[1];
                NPlot1.AbscissaData = XX;
                NPlot1.DataSource   = YY;
                plotSurface2D1.Clear();
                plotSurface2D1.Add(NPlot1);
                button2.Enabled  = true;
                button3.Enabled  = true;
                button3.Text     = "Scan";
                timer1.Interval  = 100;
                timer1.Enabled   = true;
                textBox1.Enabled = false;
                OperationMode    = MODE_MAIN;
                TakeEachPoint    = 1;
                TakeEachPointNow = 0;
            }
            if (NewMode == SCAN_CELL)
            {
                //SerialWriteBuffer[0] = 'm';
                StartExperiment = DateTime.Now;
                AutoRescale     = true;
                FileName        = String.Format("scan{0,4:0000}_{1,2:00}_{2,2:00}-{3,2:00}_{4,2:00}_{5,2:00}.out",
                                                StartExperiment.Year,
                                                StartExperiment.Month,
                                                StartExperiment.Day,
                                                StartExperiment.Hour,
                                                StartExperiment.Minute,
                                                StartExperiment.Second);
                if (OutputFile != null)
                {
                    OutputFile.Close();
                }
                OutputFile = new StreamWriter(FileName);
                OutputFile.Close();

                label1.Text         = FileName;
                YMIN                = -3.0; YMAX = 3.0;
                NPlot1              = new LinePlot();
                NPoints             = 0;
                XX                  = new double[1];
                YY                  = new double[1];
                NPlot1.AbscissaData = XX;
                NPlot1.DataSource   = YY;
                plotSurface2D1.Clear();
                plotSurface2D1.Add(NPlot1);

                plotSurface2D1.XAxis1.WorldMin = -0.5;
                plotSurface2D1.XAxis1.WorldMax = 10.5;
                plotSurface2D1.YAxis1.WorldMin = -3.0;
                plotSurface2D1.YAxis1.WorldMax = 0.5;

                XMin = -0.5;
                XMax = 10.5;
                YMin = -2.5;
                YMax = 0.5;

                textBox2.Text = YMax.ToString();
                textBox3.Text = YMin.ToString();
                textBox4.Text = XMin.ToString();
                textBox5.Text = XMax.ToString();

                plotSurface2D1.Refresh();

                button2.Enabled  = true;
                button3.Enabled  = true;
                button3.Text     = "Stop Scan";
                timer1.Interval  = 100;
                timer1.Enabled   = true;
                textBox1.Enabled = false;
                OperationMode    = SCAN_CELL;
            }
        }
示例#8
0
        private void PlotRescale()
        {
            if (AutoRescale)
            {
                if (OperationMode == MODE_MAIN)
                {
                    plotSurface2D1.XAxis1.WorldMin = 0;
                    plotSurface2D1.XAxis1.WorldMax = time;
                    plotSurface2D1.YAxis1.WorldMin = YMIN;
                    plotSurface2D1.YAxis1.WorldMax = YMAX;

                    plotSurface2D1.XAxis1.WorldMin -= plotSurface2D1.XAxis1.WorldLength * 0.1;
                    plotSurface2D1.XAxis1.WorldMax += plotSurface2D1.XAxis1.WorldLength * 0.5;
                    plotSurface2D1.YAxis1.WorldMin -= plotSurface2D1.YAxis1.WorldLength * 0.1;
                    plotSurface2D1.YAxis1.WorldMax += plotSurface2D1.YAxis1.WorldLength * 0.1;

                    textBox2.Text = plotSurface2D1.YAxis1.WorldMax.ToString("F0");
                    textBox3.Text = plotSurface2D1.YAxis1.WorldMin.ToString("F0");
                    textBox4.Text = plotSurface2D1.XAxis1.WorldMin.ToString("F0");
                    textBox5.Text = plotSurface2D1.XAxis1.WorldMax.ToString("F0");

                    XMin = plotSurface2D1.XAxis1.WorldMin;
                    XMax = plotSurface2D1.XAxis1.WorldMax;
                    YMin = plotSurface2D1.YAxis1.WorldMin;
                    YMax = plotSurface2D1.YAxis1.WorldMax;

                    textBox2.BackColor = SystemColors.Menu;
                    textBox3.BackColor = SystemColors.Menu;
                    textBox4.BackColor = SystemColors.Menu;
                    textBox5.BackColor = SystemColors.Menu;

                    plotSurface2D1.Refresh();
                }
                if (OperationMode == SCAN_CELL)
                {
                    plotSurface2D1.XAxis1.WorldMin = 0;
                    plotSurface2D1.XAxis1.WorldMax = time;
                    plotSurface2D1.YAxis1.WorldMin = YMIN;
                    plotSurface2D1.YAxis1.WorldMax = YMAX;

                    plotSurface2D1.XAxis1.WorldMin -= plotSurface2D1.XAxis1.WorldLength * 0.1;
                    plotSurface2D1.XAxis1.WorldMax += plotSurface2D1.XAxis1.WorldLength * 0.5;
                    plotSurface2D1.YAxis1.WorldMin -= plotSurface2D1.YAxis1.WorldLength * 0.1;
                    plotSurface2D1.YAxis1.WorldMax += plotSurface2D1.YAxis1.WorldLength * 0.1;

                    plotSurface2D1.XAxis1.WorldMin -= plotSurface2D1.XAxis1.WorldLength * 0.1;
                    plotSurface2D1.XAxis1.WorldMax += plotSurface2D1.XAxis1.WorldLength * 0.5;
                    plotSurface2D1.YAxis1.WorldMin -= plotSurface2D1.YAxis1.WorldLength * 0.1;
                    plotSurface2D1.YAxis1.WorldMax += plotSurface2D1.YAxis1.WorldLength * 0.1;

                    textBox2.Text = YMax.ToString("F0");
                    textBox3.Text = YMin.ToString("F0");
                    textBox4.Text = XMin.ToString("F0");
                    textBox5.Text = XMax.ToString("F0");

                    textBox2.BackColor = SystemColors.Menu;
                    textBox3.BackColor = SystemColors.Menu;
                    textBox4.BackColor = SystemColors.Menu;
                    textBox5.BackColor = SystemColors.Menu;

                    plotSurface2D1.Refresh();
                }
            }
            else
            {
                plotSurface2D1.XAxis1.WorldMin = XMin;
                plotSurface2D1.XAxis1.WorldMax = XMax;
                plotSurface2D1.YAxis1.WorldMin = YMin;
                plotSurface2D1.YAxis1.WorldMax = YMax;

                textBox2.BackColor = SystemColors.Window;
                textBox3.BackColor = SystemColors.Window;
                textBox4.BackColor = SystemColors.Window;
                textBox5.BackColor = SystemColors.Window;

                plotSurface2D1.Refresh();
            }
        }