예제 #1
0
    public MainForm()
    {
        myList = new List <ObservableCollection <string> > {
            new() { "First", "Second" }
        };

        DataContext = new myStuff
        {
            entries = myList
        };

        refPoly    = new PointF[5];
        refPoly[0] = new PointF(-50, 50);
        refPoly[1] = new PointF(50, 50);
        refPoly[2] = new PointF(50, -50);
        refPoly[3] = new PointF(-50, -50);
        refPoly[4] = refPoly[0];

        drawingLock = new object();

        MinimumSize = new Size(200, 200);

        updateSimUIMTFunc = updateSimUIMT_;

        configureProgressBarFunc = configureProgressBar_;

        numberOfCases  = 25000;
        timer_interval = 10;

        ovpSettings  = new OVPSettings();
        ovp2Settings = new OVPSettings
        {
            zoomFactor = 3
        };

        Title = "My Eto Form";

        /*
         * Test flags.
         * 0 : stamdard viewports in splitter test.
         * 1 : viewports in tabs (WPF has issues here due to the deferred evaluation; still need a better fix)
         * 3 : single viewport in panel, dropdown switches out the view settings.
         */

        int mode = 0;

        switch (mode)
        {
        case 0:
        {
            viewport      = new TestViewport(ref ovpSettings);
            viewport.Size = new Size(250, 250);

            viewport2      = new TestViewport(ref ovp2Settings);
            viewport2.Size = new Size(200, 200);

            Panel testing = new();
            testing.Size    = new Size(viewport.Width + viewport2.Width, viewport.Height);
            testing.Content = new Splitter
            {
                Orientation = Orientation.Horizontal,
                FixedPanel  = SplitterFixedPanel.None,
                Panel1      = viewport,
                Panel2      = viewport2
            };

            Panel testing2 = new();
            testing2.Content = new Splitter
            {
                Orientation = Orientation.Horizontal,
                FixedPanel  = SplitterFixedPanel.None,
                Panel1      = statusLine,
                Panel2      = progressBar
            };

            testComboBox_SelEntry        = new Button();
            testComboBox_SelEntry.Text   = "Change";
            testComboBox_SelEntry.Click += changeSelEntry;

            testComboBox             = new DropDown();
            testComboBox.DataContext = DataContext;
            testComboBox.BindDataContext(c => c.DataStore, (myStuff m) => m.entries[0]);
            testComboBox.SelectedIndex = 0;
            //testComboBox.SelectedIndexBinding.BindDataContext((myStuff m) => m.index);

            Panel testing3 = new();
            testing3.Content = new Splitter
            {
                Orientation = Orientation.Horizontal,
                FixedPanel  = SplitterFixedPanel.None,
                Panel1      = testComboBox_SelEntry,
                Panel2      = testComboBox
            };

            Panel testing4 = new();
            testing4.Content = new Splitter
            {
                Orientation = Orientation.Vertical,
                FixedPanel  = SplitterFixedPanel.None,
                Panel1      = testing3,
                Panel2      = testing
            };

            Splitter mySplitter = new()
            {
                Orientation = Orientation.Vertical,
                FixedPanel  = SplitterFixedPanel.None,
                Panel1      = testing4,
                Panel2      = testing2
            };

            Content = mySplitter;
            break;
        }

        case 1:
        {
            TabControl tabControl_main = new();
            tabControl_main.Size = new Size(300, 300);
            Content = tabControl_main;

            TabPage tab_0 = new();
            tab_0.Text = "0";
            tabControl_main.Pages.Add(tab_0);
            PixelLayout tabPage_0_content = new();
            tabPage_0_content.Size = new Size(280, 280);

            TabPage tab_1 = new();
            tab_1.Text = "1";
            tabControl_main.Pages.Add(tab_1);
            PixelLayout tabPage_1_content = new();
            tabPage_1_content.Size = new Size(280, 280);
            tab_1.Content          = tabPage_1_content;

            TabPage tab_2 = new();
            tab_2.Text = "2";
            tabControl_main.Pages.Add(tab_2);

            viewport      = new TestViewport(ref ovpSettings);
            viewport.Size = new Size(200, 200);
            tabPage_1_content.Add(viewport, 5, 5);

            viewport2      = new TestViewport(ref ovp2Settings);
            viewport2.Size = new Size(200, 200);
            tab_2.Content  = viewport2;
            break;
        }

        case 2:
        {
            ovpSettings.addPolygon(refPoly, Color.FromArgb(0, 255, 0), 0.7f, false, 0);
            ovp2Settings.addPolygon(refPoly, Color.FromArgb(255, 0, 0), 0.7f, false, 0);

            vSettings     = new OVPSettings();
            viewport      = new TestViewport(ref vSettings);
            viewport.Size = new Size(250, 250);

            Panel testing = new();
            testing.Size = new Size(viewport.Width, viewport.Height);
            PixelLayout p = new();
            p.Add(viewport, 0, 0);
            testing.Content = p;

            testComboBox_SelEntry        = new Button();
            testComboBox_SelEntry.Text   = "Change";
            testComboBox_SelEntry.Click += changeSelEntry;

            testComboBox             = new DropDown();
            testComboBox.DataContext = DataContext;
            testComboBox.BindDataContext(c => c.DataStore, (myStuff m) => m.entries[0]);
            testComboBox.SelectedIndex         = 0;
            testComboBox.SelectedIndexChanged += adjustView_;
            //testComboBox.SelectedIndexBinding.BindDataContext((myStuff m) => m.index);

            Splitter testing3 = new()
            {
                Orientation = Orientation.Horizontal,
                FixedPanel  = SplitterFixedPanel.None,
                Panel1      = testComboBox_SelEntry,
                Panel2      = testComboBox
            };

            Splitter testing4 = new()
            {
                Orientation = Orientation.Vertical,
                FixedPanel  = SplitterFixedPanel.None,
                Panel1      = testing3,
                Panel2      = testing
            };

            Splitter mySplitter = new()
            {
                Orientation = Orientation.Vertical,
                FixedPanel  = SplitterFixedPanel.None,
                Panel1      = testing4,
                Panel2      = new Panel()
            };

            Content = mySplitter;
            break;
        }
        }

        statusLine      = new Label();
        statusLine.Size = new Size(150, 11);
        statusLine.Text = "Hello world";

        progressBar          = new ProgressBar();
        progressBar.Height   = 15;
        progressBar.MaxValue = numberOfCases;

        // create a few commands that can be used for the menu and toolbar
        Command clickMe = new() { MenuText = "Run", ToolBarText = "Run" };

        clickMe.Executed += runCases;

        Command abort = new() { MenuText = "Abort", ToolBarText = "Abort" };

        abort.Executed += abortTheRun;

        Command adjustList = new() { MenuText = "Add to list", ToolBarText = "Add" };

        if (mode != 3)
        {
            adjustList.Executed += adjustList_;
        }

        Command quitCommand = new() { MenuText = "Quit", Shortcut = Application.Instance.CommonModifier | Keys.Q };

        quitCommand.Executed += (sender, e) => Application.Instance.Quit();

        Command aboutCommand = new() { MenuText = "About..." };

        aboutCommand.Executed += (sender, e) => MessageBox.Show(this, "About my app...");

        // create menu
        Menu = new MenuBar {
            Items =
            {
                // File submenu
                new ButtonMenuItem {
                    Text = "&File", Items ={ clickMe          }
                },
                // new ButtonMenuItem { Text = "&Edit", Items = { /* commands/items */ } },
                // new ButtonMenuItem { Text = "&View", Items = { /* commands/items */ } },
            },
            ApplicationItems =
            {
                // application (OS X) or file menu (others)
                new ButtonMenuItem {
                    Text = "&Preferences..."
                },
            },
            QuitItem  = quitCommand,
            AboutItem = aboutCommand
        };

        // create toolbar
        ToolBar = new ToolBar {
            Items = { clickMe, abort, adjustList }
        };

        //mySplitter.Panel1.SizeChanged += splitterSize;
        //mySplitter.Panel2.SizeChanged += splitterSize;
    }

    private void adjustView_(object sender, EventArgs e)
    {
        switch (testComboBox.SelectedIndex)
        {
        case 0:
            viewport.changeSettingsRef(ref ovpSettings);
            break;

        default:
            viewport.changeSettingsRef(ref ovp2Settings);
            break;
        }
    }

    private void adjustList_(object sender, EventArgs e)
    {
        myList[0].Add("Entry " + myList[0].Count.ToString(CultureInfo.InvariantCulture));
        testComboBox.SelectedIndex = testComboBox.SelectedIndex switch
        {
            -1 => 0,
            _ => testComboBox.SelectedIndex
        };
        if (testComboBox.SelectedIndex >= myList[0].Count)
        {
            testComboBox.SelectedIndex = myList[0].Count - 1;
        }
//			testComboBox.SelectedIndex = 1;
    }

    /* These shouldn't be necessary
     * protected override void OnWindowStateChanged(EventArgs e)
     * {
     *      base.OnWindowStateChanged(e);
     *      viewport.updateViewport();
     *      viewport.updateViewport();
     *      if (viewport2 != null)
     *      {
     *              viewport2.updateViewport();
     *      }
     * }
     *
     * void splitterSize(object sender, EventArgs e)
     * {
     *      viewport.updateViewport();
     *      viewport.updateViewport();
     *      if (viewport2 != null)
     *      {
     *              viewport2.updateViewport();
     *      }
     * }
     *
     * protected override void OnSizeChanged(EventArgs e)
     * {
     *      base.OnSizeChanged(e);
     *      viewport.updateViewport();
     *      if (viewport2 != null)
     *      {
     *              viewport2.updateViewport();
     *      }
     * }
     *
     * protected override void OnShown(EventArgs e)
     * {
     *      base.OnShown(e);
     *      viewport.updateViewport();
     *      viewport.updateViewport();
     *      if (viewport2 != null)
     *      {
     *              viewport2.updateViewport();
     *      }
     * }
     */
}


public static class RNG
{
예제 #2
0
        public MainForm()
        {
            myList = new List <ObservableCollection <string> >();
            myList.Add(new ObservableCollection <string> {
                "First", "Second"
            });

            DataContext = new myStuff
            {
                entries = myList
            };

            refPoly    = new PointF[5];
            refPoly[0] = new PointF(-50, 50);
            refPoly[1] = new PointF(50, 50);
            refPoly[2] = new PointF(50, -50);
            refPoly[3] = new PointF(-50, -50);
            refPoly[4] = refPoly[0];

            drawingLock = new object();

            MinimumSize = new Size(200, 200);

            updateSimUIMTFunc = updateSimUIMT_;

            configureProgressBarFunc = configureProgressBar_;

            numberOfCases  = 25000;
            timer_interval = 10;

            ovpSettings  = new OVPSettings();
            ovp2Settings = new OVPSettings();

            ovp2Settings.zoomFactor = 3;

            Title = "My Eto Form";

            /*
             * Test flags.
             * 0 : stamdard viewports in splitter test.
             * 1 : viewports in tabs (WPF has issues here due to the deferred evaluation; still need a better fix)
             * 3 : single viewport in panel, dropdown switches out the view settings.
             */

            int mode = 0;

            if (mode == 0)
            {
                viewport      = new TestViewport(ref ovpSettings);
                viewport.Size = new Size(250, 250);

                viewport2      = new TestViewport(ref ovp2Settings);
                viewport2.Size = new Size(200, 200);

                Panel testing = new Panel();
                testing.Size    = new Size(viewport.Width + viewport2.Width, viewport.Height);
                testing.Content = new Splitter
                {
                    Orientation = Orientation.Horizontal,
                    FixedPanel  = SplitterFixedPanel.None,
                    Panel1      = viewport,
                    Panel2      = viewport2
                };

                Panel testing2 = new Panel();
                testing2.Content = new Splitter
                {
                    Orientation = Orientation.Horizontal,
                    FixedPanel  = SplitterFixedPanel.None,
                    Panel1      = statusLine,
                    Panel2      = progressBar
                };

                testComboBox_SelEntry        = new Button();
                testComboBox_SelEntry.Text   = "Change";
                testComboBox_SelEntry.Click += changeSelEntry;

                testComboBox             = new DropDown();
                testComboBox.DataContext = DataContext;
                testComboBox.BindDataContext(c => c.DataStore, (myStuff m) => m.entries[0]);
                testComboBox.SelectedIndex = 0;
                //testComboBox.SelectedIndexBinding.BindDataContext((myStuff m) => m.index);

                Panel testing3 = new Panel();
                testing3.Content = new Splitter
                {
                    Orientation = Orientation.Horizontal,
                    FixedPanel  = SplitterFixedPanel.None,
                    Panel1      = testComboBox_SelEntry,
                    Panel2      = testComboBox
                };

                Panel testing4 = new Panel();
                testing4.Content = new Splitter
                {
                    Orientation = Orientation.Vertical,
                    FixedPanel  = SplitterFixedPanel.None,
                    Panel1      = testing3,
                    Panel2      = testing
                };

                Splitter mySplitter = new Splitter
                {
                    Orientation = Orientation.Vertical,
                    FixedPanel  = SplitterFixedPanel.None,
                    Panel1      = testing4,
                    Panel2      = testing2
                };

                Content = mySplitter;
            }
            if (mode == 1)
            {
                TabControl tabControl_main = new TabControl();
                tabControl_main.Size = new Size(300, 300);
                Content = tabControl_main;

                TabPage tab_0 = new TabPage();
                tab_0.Text = "0";
                tabControl_main.Pages.Add(tab_0);
                PixelLayout tabPage_0_content = new PixelLayout();
                tabPage_0_content.Size = new Size(280, 280);

                TabPage tab_1 = new TabPage();
                tab_1.Text = "1";
                tabControl_main.Pages.Add(tab_1);
                PixelLayout tabPage_1_content = new PixelLayout();
                tabPage_1_content.Size = new Size(280, 280);
                tab_1.Content          = tabPage_1_content;

                TabPage tab_2 = new TabPage();
                tab_2.Text = "2";
                tabControl_main.Pages.Add(tab_2);

                viewport      = new TestViewport(ref ovpSettings);
                viewport.Size = new Size(200, 200);
                tabPage_1_content.Add(viewport, 5, 5);

                viewport2      = new TestViewport(ref ovp2Settings);
                viewport2.Size = new Size(200, 200);
                tab_2.Content  = viewport2;
            }
            if (mode == 2)
            {
                ovpSettings.addPolygon(refPoly, Color.FromArgb(0, 255, 0), 0.7f, false);
                ovp2Settings.addPolygon(refPoly, Color.FromArgb(255, 0, 0), 0.7f, false);

                vSettings     = new OVPSettings();
                viewport      = new TestViewport(ref vSettings);
                viewport.Size = new Size(250, 250);

                Panel testing = new Panel();
                testing.Size = new Size(viewport.Width, viewport.Height);
                PixelLayout p = new PixelLayout();
                p.Add(viewport, 0, 0);
                testing.Content = p;

                testComboBox_SelEntry        = new Button();
                testComboBox_SelEntry.Text   = "Change";
                testComboBox_SelEntry.Click += changeSelEntry;

                testComboBox             = new DropDown();
                testComboBox.DataContext = DataContext;
                testComboBox.BindDataContext(c => c.DataStore, (myStuff m) => m.entries[0]);
                testComboBox.SelectedIndex         = 0;
                testComboBox.SelectedIndexChanged += adjustView_;
                //testComboBox.SelectedIndexBinding.BindDataContext((myStuff m) => m.index);

                var testing3 = new Splitter
                {
                    Orientation = Orientation.Horizontal,
                    FixedPanel  = SplitterFixedPanel.None,
                    Panel1      = testComboBox_SelEntry,
                    Panel2      = testComboBox
                };

                var testing4 = new Splitter
                {
                    Orientation = Orientation.Vertical,
                    FixedPanel  = SplitterFixedPanel.None,
                    Panel1      = testing3,
                    Panel2      = testing
                };

                var mySplitter = new Splitter
                {
                    Orientation = Orientation.Vertical,
                    FixedPanel  = SplitterFixedPanel.None,
                    Panel1      = testing4,
                    Panel2      = new Panel()
                };

                Content = mySplitter;
            }

            statusLine      = new Label();
            statusLine.Size = new Size(150, 11);
            statusLine.Text = "Hello world";

            progressBar          = new ProgressBar();
            progressBar.Height   = 15;
            progressBar.MaxValue = numberOfCases;

            // create a few commands that can be used for the menu and toolbar
            var clickMe = new Command {
                MenuText = "Run", ToolBarText = "Run"
            };

            clickMe.Executed += runCases;

            var abort = new Command {
                MenuText = "Abort", ToolBarText = "Abort"
            };

            abort.Executed += abortTheRun;

            var adjustList = new Command {
                MenuText = "Add to list", ToolBarText = "Add"
            };

            if (mode != 3)
            {
                adjustList.Executed += adjustList_;
            }

            var quitCommand = new Command {
                MenuText = "Quit", Shortcut = Application.Instance.CommonModifier | Keys.Q
            };

            quitCommand.Executed += (sender, e) => Application.Instance.Quit();

            var aboutCommand = new Command {
                MenuText = "About..."
            };

            aboutCommand.Executed += (sender, e) => MessageBox.Show(this, "About my app...");

            // create menu
            Menu = new MenuBar {
                Items =
                {
                    // File submenu
                    new ButtonMenuItem {
                        Text = "&File", Items ={ clickMe          }
                    },
                    // new ButtonMenuItem { Text = "&Edit", Items = { /* commands/items */ } },
                    // new ButtonMenuItem { Text = "&View", Items = { /* commands/items */ } },
                },
                ApplicationItems =
                {
                    // application (OS X) or file menu (others)
                    new ButtonMenuItem {
                        Text = "&Preferences..."
                    },
                },
                QuitItem  = quitCommand,
                AboutItem = aboutCommand
            };

            // create toolbar
            ToolBar = new ToolBar {
                Items = { clickMe, abort, adjustList }
            };

            //mySplitter.Panel1.SizeChanged += splitterSize;
            //mySplitter.Panel2.SizeChanged += splitterSize;
        }