コード例 #1
0
        private void points_comboBox_SelectedValueChanged(object sender, System.EventArgs e)
        {
            if (!bDrawing && thread != null)
            {
                thread.Join();

                ExamplePoint p = new ExamplePoint();
                if (p.FromString(points_comboBox.SelectedItem.ToString()))
                {
                    xmin = p.xmin;
                    xmax = p.xmax;
                    ymin = p.ymin;
                    ymax = p.ymax;
                    nMax = p.max_iter;

                    if (p.name != null && p.name != "")
                    {
                        Text = "Mandelbrot Viewer - " + p.name;
                    }
                    else
                    {
                        Text = "Mandelbrot Viewer";
                    }

                    bDrawing = true;
                    ThreadStart threadProc = new ThreadStart(work_thread);
                    thread = new Thread(threadProc);
                    thread.Start();

                    rBox = new Rectangle(0, 0, 0, 0);
                    outputBox.Invalidate();
                }
            }
        }
コード例 #2
0
        private void demo_button_Click(object sender, System.EventArgs e)
        {
            if (demo_list == null)
            {
                demo_list = new ArrayList();
            }
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.InitialDirectory = "c:\\";
            dlg.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            dlg.FilterIndex      = 1;
            dlg.RestoreDirectory = true;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                using (StreamReader sr = new StreamReader(dlg.OpenFile()))
                {
                    String line;
                    bool   first = true;

                    while ((line = sr.ReadLine()) != null)
                    {
                        line.Trim();
                        if (line.Length > 0 && line[0] != '#')
                        {
                            ExamplePoint node = new ExamplePoint();
                            if (node.FromString(line))
                            {
                                if (first)
                                {
                                    demo_list.Clear();                                     // new list replaces the old
                                    first = false;
                                }
                                demo_list.Add(node);
                            }
                        }
                    }
                    sr.Close();

                    points_comboBox.Items.Clear();
                    for (int i = 0; i < demo_list.Count; i++)
                    {
                        //MessageBox.Show(((ExamplePoint)demo_list[i]).ToString(), String.Format("demo: {0}", i));
                        points_comboBox.Items.Add(((ExamplePoint)demo_list[i]).ToString());
                    }
                    points_comboBox.SelectedIndex = 0;
                    if (connect_button.Enabled == false)
                    {
                        go_stop_button.Enabled = true;
                    }
                }
            }
        }
コード例 #3
0
        private void outputBox_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (!bDrawing && thread != null)
                {
                    Rectangle r;
                    double    x1, y1, x2, y2;
                    double    width, height, pixel_width, pixel_height;
                    int       x, y;

                    if (p1.X == e.X && p1.Y == e.Y)
                    {
                        return;
                    }

                    p2 = new Point(e.X, e.Y);
                    x  = Math.Min(p1.X, p2.X);
                    y  = Math.Min(p1.Y, p2.Y);

                    thread.Join();

                    r            = new Rectangle(x, y, Math.Max(p1.X, p2.X) - x, Math.Max(p1.Y, p2.Y) - y);
                    width        = xmax - xmin;
                    height       = ymax - ymin;
                    pixel_width  = outputBox.Width;
                    pixel_height = outputBox.Height;
                    x1           = xmin + ((double)r.Left * width / pixel_width);
                    x2           = xmin + ((double)r.Right * width / pixel_width);
                    y2           = ymin + ((double)(pixel_height - r.Top) * height / pixel_height);
                    y1           = ymin + ((double)(pixel_height - r.Bottom) * height / pixel_height);
                    xmin         = x1;
                    xmax         = x2;
                    ymin         = y1;
                    ymax         = y2;

                    ExamplePoint ep = new ExamplePoint(xmin, ymin, xmax, ymax, nMax, "dragged");
                    Text = "Mandelbrot Viewer" + ep.ToShortString();

                    bDrawing = true;
                    ThreadStart threadProc = new ThreadStart(work_thread);
                    thread = new Thread(threadProc);
                    thread.Start();

                    rBox = new Rectangle(x, y, 0, 0);
                    outputBox.Invalidate();
                }
            }
            if (e.Button == MouseButtons.Right)
            {
                if (!bDrawing && thread != null)
                {
                    thread.Join();

                    xmin = -1.0;
                    xmax = 1.0;
                    ymin = -1.0;
                    ymax = 1.0;

                    bDrawing = true;
                    ThreadStart threadProc = new ThreadStart(work_thread);
                    thread = new Thread(threadProc);
                    thread.Start();

                    rBox = new Rectangle(0, 0, 0, 0);
                    outputBox.Invalidate();
                }
            }
        }
コード例 #4
0
ファイル: Form.cs プロジェクト: huangjun-pg/mpich2-yarn
        private void outputBox_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (!bDrawing && thread != null)
                {
                    Rectangle r;
                    double x1,y1,x2,y2;
                    double width, height, pixel_width, pixel_height;
                    int x, y;

                    if (p1.X == e.X && p1.Y == e.Y)
                    {
                        return;
                    }

                    p2 = new Point(e.X, e.Y);
                    x = Math.Min(p1.X, p2.X);
                    y = Math.Min(p1.Y, p2.Y);

                    thread.Join();

                    r = new Rectangle(x, y, Math.Max(p1.X, p2.X) - x, Math.Max(p1.Y, p2.Y) - y);
                    width = xmax - xmin;
                    height = ymax - ymin;
                    pixel_width = outputBox.Width;
                    pixel_height = outputBox.Height;
                    x1 = xmin + ((double)r.Left * width / pixel_width);
                    x2 = xmin + ((double)r.Right * width / pixel_width);
                    y2 = ymin + ((double)(pixel_height - r.Top) * height / pixel_height);
                    y1 = ymin + ((double)(pixel_height - r.Bottom) * height / pixel_height);
                    xmin = x1;
                    xmax = x2;
                    ymin = y1;
                    ymax = y2;

                    ExamplePoint ep = new ExamplePoint(xmin, ymin, xmax, ymax, nMax, "dragged");
                    Text = "Mandelbrot Viewer" + ep.ToShortString();

                    bDrawing = true;
                    ThreadStart threadProc = new ThreadStart(work_thread);
                    thread = new Thread(threadProc);
                    thread.Start();

                    rBox = new Rectangle(x, y, 0, 0);
                    outputBox.Invalidate();
                }
            }
            if (e.Button == MouseButtons.Right)
            {
                if (!bDrawing && thread != null)
                {
                    thread.Join();

                    xmin = -1.0;
                    xmax = 1.0;
                    ymin = -1.0;
                    ymax = 1.0;

                    bDrawing = true;
                    ThreadStart threadProc = new ThreadStart(work_thread);
                    thread = new Thread(threadProc);
                    thread.Start();

                    rBox = new Rectangle(0, 0, 0, 0);
                    outputBox.Invalidate();
                }
            }
        }
コード例 #5
0
ファイル: Form.cs プロジェクト: huangjun-pg/mpich2-yarn
        private void demo_button_Click(object sender, System.EventArgs e)
        {
            if (demo_list == null)
                demo_list = new ArrayList();
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.InitialDirectory = "c:\\";
            dlg.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            dlg.FilterIndex = 1;
            dlg.RestoreDirectory = true;

            if(dlg.ShowDialog() == DialogResult.OK)
            {
                using (StreamReader sr = new StreamReader(dlg.OpenFile()))
                {
                    String line;
                    bool first = true;

                    while ((line = sr.ReadLine()) != null)
                    {
                        line.Trim();
                        if (line.Length > 0 && line[0] != '#')
                        {
                            ExamplePoint node = new ExamplePoint();
                            if (node.FromString(line))
                            {
                                if (first)
                                {
                                    demo_list.Clear(); // new list replaces the old
                                    first = false;
                                }
                                demo_list.Add(node);
                            }
                        }
                    }
                    sr.Close();

                    points_comboBox.Items.Clear();
                    for (int i=0; i<demo_list.Count; i++)
                    {
                        //MessageBox.Show(((ExamplePoint)demo_list[i]).ToString(), String.Format("demo: {0}", i));
                        points_comboBox.Items.Add(((ExamplePoint)demo_list[i]).ToString());
                    }
                    points_comboBox.SelectedIndex = 0;
                    if (connect_button.Enabled == false)
                    {
                        go_stop_button.Enabled = true;
                    }
                }
            }
        }
コード例 #6
0
ファイル: Form.cs プロジェクト: huangjun-pg/mpich2-yarn
        private void points_comboBox_SelectedValueChanged(object sender, System.EventArgs e)
        {
            if (!bDrawing && thread != null)
            {
                thread.Join();

                ExamplePoint p = new ExamplePoint();
                if (p.FromString(points_comboBox.SelectedItem.ToString()))
                {
                    xmin = p.xmin;
                    xmax = p.xmax;
                    ymin = p.ymin;
                    ymax = p.ymax;
                    nMax = p.max_iter;

                    if (p.name != null && p.name != "")
                        Text = "Mandelbrot Viewer - " + p.name;
                    else
                        Text = "Mandelbrot Viewer";

                    bDrawing = true;
                    ThreadStart threadProc = new ThreadStart(work_thread);
                    thread = new Thread(threadProc);
                    thread.Start();

                    rBox = new Rectangle(0, 0, 0, 0);
                    outputBox.Invalidate();
                }
            }
        }