void pSubShapeRef_UI(TableLayout tl)
        {
            TableRow tr = new TableRow();

            tl.Rows.Add(tr);

            lbl_subShapeRef = new Label
            {
                Text    = "Subshape Reference",
                ToolTip = "Which subshape to use for placement with respect to the world origin"
            };

            tr.Cells.Add(new TableCell()
            {
                Control = lbl_subShapeRef
            });

            comboBox_subShapeRef = new DropDown
            {
                DataContext   = DataContext,
                SelectedIndex = 0,
                ToolTip       = "Which subshape to use for placement with respect to the world origin"
            };
            comboBox_subShapeRef.BindDataContext(c => c.DataStore, (UIStringLists m) => m.subShapeList);

            tr.Cells.Add(new TableCell()
            {
                Control = TableLayout.AutoSized(comboBox_subShapeRef)
            });

            tr.Cells.Add(new TableCell()
            {
                Control = null
            });
        }
        public ShipView()
        {
            XamlReader.Load(this);
            Systems.BindDataContext(c => c.DataStore, (DictionaryVM <object, string> m) => m.DisplayList);
            Systems.SelectedIndexBinding.BindDataContext((DictionaryVM <object, string> m) => m.SelectedIndex);

            ShipList.BindDataContext(c => c.DataStore, (DictionaryVM <object, string> m) => m.DisplayList);
            ShipList.SelectedIndexBinding.BindDataContext((DictionaryVM <object, string> m) => m.SelectedIndex);
        }
        public ShipMoveView()
        {
            XamlReader.Load(this);
            TargetDropDown.BindDataContext(c => c.DataStore, (DictionaryVM <object, string> m) => m.DisplayList);
            TargetDropDown.SelectedIndexBinding.BindDataContext((DictionaryVM <object, string> m) => m.SelectedIndex);

            OrdersPossible.BindDataContext(c => c.DataStore, (DictionaryVM <object, string> m) => m.DisplayList);
            OrdersPossible.SelectedIndexBinding.BindDataContext((DictionaryVM <object, string> m) => m.SelectedIndex);

            OrderList.BindDataContext(c => c.DataStore, (DictionaryVM <object, string> m) => m.DisplayList);
            OrderList.SelectedIndexBinding.BindDataContext((DictionaryVM <object, string> m) => m.SelectedIndex);
        }
Exemple #4
0
        public SystemInfoView()
        {
            XamlReader.Load(this);
            SystemSelection.BindDataContext(c => c.DataStore, (DictionaryVM <object, string> m) => m.DisplayList);
            SystemSelection.SelectedIndexBinding.BindDataContext((DictionaryVM <object, string> m) => m.SelectedIndex);
            EntitySelection.BindDataContext(c => c.DataStore, (DictionaryVM <object, string> m) => m.DisplayList);
            EntitySelection.SelectedIndexBinding.BindDataContext((DictionaryVM <object, string> m) => m.SelectedIndex);
            BlobSelection.BindDataContext(c => c.DataStore, (DictionaryVM <object, string> m) => m.DisplayList);
            BlobSelection.SelectedIndexBinding.BindDataContext((DictionaryVM <object, string> m) => m.SelectedIndex);

            DataContextChanged += SystemInfoView_DataContextChanged;
        }
Exemple #5
0
        public SystemView(StarSystemVM viewmodel)
        {
            DataContext = viewmodel;
            XamlReader.Load(this);

            #region OpenGL stuff
            //intend to make opengl vs drawable system view an option. an openGL pannel could be a bit fancier.

            //RenderVM = new RenderVM(GameVM.CurrentAuthToken);
            //Renderer = new OpenGLRenderer(RenderVM);
            //RenderCanvas = new RenderCanvas(GraphicsMode.Default, 3, 3, GraphicsContextFlags.Default);
            //systems.BindDataContext(s => s.DataStore, (GameVM g) => g.StarSystems);
            //systems.ItemTextBinding = Binding.Property((SystemVM vm) => vm.Name);
            //systems.ItemKeyBinding = Binding.Property((SystemVM vm) => vm.ID).Convert((Guid ID) => ID.ToString());

            //direct binding - might need to be replaced later
            //systems.Bind(s => s.SelectedValue, RenderVM, (RenderVM rvm) => rvm.ActiveSystem);

            // @Hack: so far the only way I've found to make the RenderCanvas properly update the
            //        size information when the window is resized is to completely detach it from
            //        the window, and then re-attach it, before calling Resize.
            //
            //        There's nothing 'right' about doing it this way, except that it works.
            //   SizeChanged += (sender, args) =>
            //   {
            //       RenderCanvasLocation.Remove(RenderCanvas);
            //       RenderCanvasLocation.Content = RenderCanvas;
            //       Resize(sender, args);
            //   };

            //RenderCanvas.GLInitalized += Initialize;
            //RenderCanvas.GLDrawNow += DrawNow;
            //RenderCanvas.GLShuttingDown += Teardown;
            ////RenderCanvas.GLResize += Resize; // replaced by the @Hack above ^^^
            //RenderCanvas.MouseMove += WhenMouseMove;
            //RenderCanvas.MouseDown += WhenMouseDown;
            //RenderCanvas.MouseUp += WhenMouseUp;
            //RenderCanvas.MouseWheel += WhenMouseWheel;
            //RenderCanvas.MouseLeave += WhenMouseLeave;

            //RenderCanvasLocation.Content = RenderCanvas;
            //RenderCanvasLocation.Content = SysMapDrawable;
            //SysMapDrawable = new SystemMap_DrawableView(GameVM.StarSystemViewModel.SelectedSystemVM);
            #endregion


            systems.DataContext = viewmodel.StarSystems;
            systems.BindDataContext(c => c.DataStore, (DictionaryVM <object, string> m) => m.DisplayList);
            systems.SelectedIndexBinding.BindDataContext((DictionaryVM <object, string> m) => m.SelectedIndex);

            SysMapDrawable.SetViewmodel(viewmodel.SelectedSystemVM);
        }
Exemple #6
0
        private void ConfigureBinding()
        {
            _textTcpListenerIp.BindDataContext(x => x.Text, (PreferencesViewModel vm) => vm.TcpListenerIp);
            _textTcpListenerPort.BindDataContext(x => x.Value, (PreferencesViewModel vm) => vm.TcpListenerPort);

            _textTcpClientIp.BindDataContext(x => x.Text, (PreferencesViewModel vm) => vm.TcpClientIp);
            _textTcpClientPort.BindDataContext(x => x.Value, (PreferencesViewModel vm) => vm.TcpClientPort);

            _dropDownBaudRate.BindDataContext(
                c => c.DataStore,
                Binding.Property((PreferencesViewModel vm) => vm.BaudRateOptions).Convert(x => x.Cast <object>()));
            _dropDownBaudRate.SelectedValueBinding.BindDataContext(
                (PreferencesViewModel m) => m.SelectedBaudRate);

            _dropDownHandshake.SelectedValueBinding.BindDataContext(
                Binding.Property((PreferencesViewModel m) => m.SelectedHandshake)
                .Convert(x => (Handshake)x, x => (int)x));

            _dropDownParity.SelectedValueBinding.BindDataContext(
                Binding.Property((PreferencesViewModel m) => m.SelectedParity)
                .Convert(x => (Parity)x, x => (int)x));

            _radDataBits.BindDataContext(
                c => c.DataStore,
                Binding.Property((PreferencesViewModel vm) => vm.DataBitsOptions).Convert(x => x.Cast <object>()));
            _radDataBits.SelectedValueBinding.BindDataContext(
                (PreferencesViewModel m) => m.SelectedDataBits);

            //_radStopBits.BindDataContext(
            //c => c.DataStore,
            //Binding.Property((MainViewModel vm) => vm.StopBitsOptions).Convert(x => x.Cast<object>()));
            _radStopBits.SelectedValueBinding.BindDataContext(
                Binding.Property((PreferencesViewModel m) => m.SelectedStopBits)
                .Convert(x => (StopBits)x, x => (int)x));

            _chkDtr.CheckedBinding.BindDataContext(
                Binding.Property((PreferencesViewModel m) => m.IsDtrEnable)
                .Convert(x => (bool?)x, x => x == true));

            _chkRts.CheckedBinding.BindDataContext(
                Binding.Property((PreferencesViewModel m) => m.IsRtsEnable)
                .Convert(x => (bool?)x, x => x == true));

            _btnResetTcpListener.BindDataContext(c => c.Command, (PreferencesViewModel vm) => vm.ResetTcpListenerCommand);
            _btnResetTcpClient.BindDataContext(c => c.Command, (PreferencesViewModel vm) => vm.ResetTcpClientCommand);
            _btnResetSerial.BindDataContext(c => c.Command, (PreferencesViewModel vm) => vm.ResetSerialComCommand);
        }
Exemple #7
0
        public SystemView(StarSystemSelectionVM viewmodel)
        {
            DataContext = viewmodel;
            _viewmodel  = viewmodel;
            XamlReader.Load(this);

            systems.DataContext = viewmodel.StarSystems;

            systems.BindDataContext(c => c.DataStore, (DictionaryVM <object, string> m) => m.DisplayList);
            systems.SelectedIndexBinding.BindDataContext((DictionaryVM <object, string> m) => m.SelectedIndex);


            if (!viewmodel.Enable)
            {
                viewmodel.StarSystems.SelectionChangedEvent += StarSystems_SelectionChangedEvent;
            }
            else
            {
                SysMapDrawable.SetViewmodel(viewmodel.SelectedSystemVM);
            }
        }
Exemple #8
0
        //private ModelEnergyProperties ModelEnergyProperties { get; set; }
        public Dialog_OpsHVACs(ref HoneybeeSchema.ModelEnergyProperties libSource, HoneybeeSchema.Energy.IHvac hvac = default, bool lockedMode = false)
        {
            this.Padding = new Padding(10);
            Title        = $"From OpenStudio HVAC library - {DialogHelper.PluginName}";
            WindowStyle  = WindowStyle.Default;
            Width        = 450;
            this.Icon    = DialogHelper.HoneybeeIcon;

            if (hvac == null) // add a new system
            {
                _vm = new OpsHVACsViewModel(libSource, this);
            }
            else  // edit existing system
            {
                _vm = new OpsHVACsViewModel(libSource, hvac, this);
            }

            var layout = new DynamicLayout()
            {
                DataContext = _vm
            };

            layout.DefaultSpacing = new Size(5, 5);
            layout.DefaultPadding = new Padding(5);


            // add a new system from lib
            if (hvac == null)
            {
                // UI for system groups
                var hvacGroups     = new DropDown();
                var hvacTypes      = new DropDown();
                var hvacEquipments = new DropDown();

                hvacGroups.BindDataContext(c => c.DataStore, (OpsHVACsViewModel m) => m.HvacGroups);
                hvacGroups.SelectedKeyBinding.BindDataContext((OpsHVACsViewModel m) => m.HvacGroup);

                hvacTypes.BindDataContext(c => c.DataStore, (OpsHVACsViewModel m) => m.HvacTypes);
                hvacTypes.ItemTextBinding = Binding.Delegate <Type, string>(t => _vm.HVACTypesDic[t]);
                hvacTypes.SelectedValueBinding.BindDataContext((OpsHVACsViewModel m) => m.HvacType);

                hvacEquipments.BindDataContext(c => c.DataStore, (OpsHVACsViewModel m) => m.HvacEquipmentTypes);
                hvacEquipments.ItemTextBinding = Binding.Delegate <string, string>(t => _vm.HVACsDic[t]);
                hvacEquipments.SelectedKeyBinding.BindDataContext((OpsHVACsViewModel m) => m.HvacEquipmentType);

                layout.AddRow("HVAC Groups:");
                layout.AddRow(hvacGroups);
                layout.AddRow("HVAC Types:");
                layout.AddRow(hvacTypes);
                layout.AddRow("HVAC Equipment Types:");
                layout.AddRow(hvacEquipments);
                layout.AddRow(null);
            }



            var year       = new DropDown();
            var nameText   = new TextBox();
            var economizer = new DropDown();
            var sensible   = new NumericStepper()
            {
                MinValue = 0, MaxValue = 1, MaximumDecimalPlaces = 2, Increment = 0.1
            };
            var latent = new NumericStepper()
            {
                MinValue = 0, MaxValue = 1, MaximumDecimalPlaces = 2, Increment = 0.1
            };


            nameText.TextBinding.BindDataContext((OpsHVACsViewModel m) => m.Name);

            year.BindDataContext(c => c.DataStore, (OpsHVACsViewModel m) => m.Vintages);
            year.SelectedKeyBinding.BindDataContext((OpsHVACsViewModel m) => m.Vintage);

            var economizerTitle = new Label()
            {
                Text = "Economizer:"
            };

            economizer.BindDataContext(c => c.DataStore, (OpsHVACsViewModel m) => m.Economizers);
            economizer.SelectedKeyBinding.BindDataContext((OpsHVACsViewModel m) => m.Economizer);
            economizer.BindDataContext(c => c.Enabled, (OpsHVACsViewModel m) => m.EconomizerVisable);
            economizer.BindDataContext(c => c.Visible, (OpsHVACsViewModel m) => m.EconomizerVisable);
            economizerTitle.BindDataContext(c => c.Visible, (OpsHVACsViewModel m) => m.EconomizerVisable);

            var sensibleTitle = new Label()
            {
                Text = "Sensible Heat Recovery:"
            };

            sensible.BindDataContext(c => c.Value, (OpsHVACsViewModel m) => m.SensibleHR);
            sensible.BindDataContext(c => c.Visible, (OpsHVACsViewModel m) => m.SensibleHRVisable);
            sensibleTitle.BindDataContext(c => c.Visible, (OpsHVACsViewModel m) => m.SensibleHRVisable);


            var latentTitle = new Label()
            {
                Text = "Latent Heat Recovery:"
            };

            latent.BindDataContext(c => c.Value, (OpsHVACsViewModel m) => m.LatentHR);
            latent.BindDataContext(c => c.Visible, (OpsHVACsViewModel m) => m.LatentHRVisable);
            latentTitle.BindDataContext(c => c.Visible, (OpsHVACsViewModel m) => m.LatentHRVisable);

            var dcv = new CheckBox()
            {
                Text = "Demand Control Ventilation"
            };

            dcv.Bind(_ => _.Checked, _vm, _ => _.DcvChecked);
            dcv.Bind(c => c.Visible, _vm, _ => _.DcvVisable);

            var availabilityTitle = new Label()
            {
                Text = "DOAS Availability Schedule:"
            };

            availabilityTitle.Bind(c => c.Visible, _vm, _ => _.AvaliabilityVisable);
            var availability = new OptionalButton();

            availability.Bind(c => c.Visible, _vm, _ => _.AvaliabilityVisable);
            availability.TextBinding.Bind(_vm, _ => _.AvaliabilitySchedule.BtnName);
            availability.Bind(_ => _.Command, _vm, _ => _.AvaliabilityCommand);
            availability.Bind(_ => _.RemoveCommand, _vm, _ => _.RemoveAvaliabilityCommand);
            availability.Bind(_ => _.IsRemoveVisable, _vm, _ => _.AvaliabilitySchedule.IsRemoveVisable);

            var radSettings = GenRadSettingsPanel();

            var gp = new GroupBox()
            {
                Text = "HVAC System settings"
            };
            var gpLayout = new DynamicLayout();

            gpLayout.DefaultPadding = new Padding(5);

            // fix the height of layout in case of creating a new system, otherwise, autosize height
            if (hvac == null)
            {
                gpLayout.Height = 250;
                gpLayout.BeginScrollable(BorderType.None);
            }

            var gpGeneralLayout = new DynamicLayout();

            //gpLayout.BeginGroup("HVAC System settings", new Padding(5), new Size(5, 0));
            gpGeneralLayout.Spacing = new Size(5, 2);


            gpGeneralLayout.AddRow("Name:");
            gpGeneralLayout.AddRow(nameText);
            gpGeneralLayout.AddRow("Vintage:");
            gpGeneralLayout.AddRow(year);
            gpGeneralLayout.AddRow(economizerTitle);
            gpGeneralLayout.AddRow(economizer);
            gpGeneralLayout.AddRow(sensibleTitle);
            gpGeneralLayout.AddRow(sensible);
            gpGeneralLayout.AddRow(latentTitle);
            gpGeneralLayout.AddRow(latent);

            gpGeneralLayout.AddRow(availabilityTitle);
            gpGeneralLayout.AddRow(availability);
            gpGeneralLayout.AddRow(dcv);

            gpLayout.AddRow(gpGeneralLayout);
            gpLayout.AddRow(radSettings);
            //gpLayout.EndGroup();
            gp.Content = gpLayout;

            layout.AddRow(gp);

            var locked = new CheckBox()
            {
                Text = "Locked", Enabled = false
            };

            locked.Checked = lockedMode;

            var OKButton = new Button {
                Text = "OK", Enabled = !lockedMode
            };

            OKButton.Click += (sender, e) =>
            {
                var obj = _vm.GreateHvac(hvac);
                OkCommand.Execute(obj);
            };

            AbortButton = new Button {
                Text = "Cancel"
            };
            AbortButton.Click += (sender, e) => Close();

            layout.AddSeparateRow(locked, null, OKButton, this.AbortButton, null, null);
            //layout.AddRow(null);
            Content = layout;
        }
    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
{
Exemple #10
0
        //private ModelEnergyProperties ModelEnergyProperties { get; set; }
        public Dialog_IdealAirLoad(ref HoneybeeSchema.ModelEnergyProperties libSource, IdealAirSystemAbridged hvac = default, bool lockedMode = false)
        {
            var sys = hvac ?? new IdealAirSystemAbridged($"IdealAirSystem_{Guid.NewGuid().ToString().Substring(0, 8)}");
            var vm  = new IdealAirLoadViewModel(libSource, sys, this);

            //Padding = new Padding(4);
            Title       = $"Ideal Air Load - {DialogHelper.PluginName}";
            WindowStyle = WindowStyle.Default;
            Width       = 450;
            this.Icon   = DialogHelper.HoneybeeIcon;

            var layout = new DynamicLayout()
            {
                DataContext = vm
            };

            layout.DefaultSpacing = new Size(4, 4);
            layout.Padding        = new Padding(10);


            // string displayName = null,
            // EconomizerType economizerType = EconomizerType.DifferentialDryBulb,
            // bool demandControlledVentilation = false,
            // double sensibleHeatRecovery = 0,
            // double latentHeatRecovery = 0,
            // double heatingAirTemperature = 50,
            // double coolingAirTemperature = 13,
            // AnyOf<Autosize, NoLimit, double> heatingLimit = null,
            // AnyOf<Autosize, NoLimit, double> coolingLimit = null,
            // string heatingAvailability = null,
            // string coolingAvailability

            var nameText   = new TextBox();
            var economizer = new DropDown();
            var DCV        = new CheckBox()
            {
                Text = "Demand Controlled Ventilation"
            };

            var sensible = new NumericStepper()
            {
                MinValue = 0, MaxValue = 1, MaximumDecimalPlaces = 2, Increment = 0.1
            };
            var latent = new NumericStepper()
            {
                MinValue = 0, MaxValue = 1, MaximumDecimalPlaces = 2, Increment = 0.1
            };

            var heatingAirT = new NumericStepper()
            {
                MinValue = -50, MaxValue = 100, MaximumDecimalPlaces = 2
            };
            var coolingAirT = new NumericStepper()
            {
                MinValue = -50, MaxValue = 100, MaximumDecimalPlaces = 2
            };

            var heatingLimitAuto = new RadioButton()
            {
                Text = "Autosize"
            };
            var heatingLimitNoLimit = new RadioButton()
            {
                Text = "No Limit"
            };
            var heatingLimitNumber = new RadioButton();
            var heatingLimit       = new NumericStepper();

            var coolingLimitAuto = new RadioButton()
            {
                Text = "Autosize"
            };
            var coolingLimitNoLimit = new RadioButton()
            {
                Text = "No Limit"
            };
            var coolingLimitNumber = new RadioButton();
            var coolingLimit       = new NumericStepper();

            var heatingAvailability = new OptionalButton();

            heatingAvailability.TextBinding.Bind(vm, _ => _.HeatingAvaliabilitySchedule.BtnName);
            heatingAvailability.Bind(_ => _.Command, vm, _ => _.HeatingAvaliabilityCommand);
            heatingAvailability.Bind(_ => _.RemoveCommand, vm, _ => _.RemoveHeatingAvaliabilityCommand);
            heatingAvailability.Bind(_ => _.IsRemoveVisable, vm, _ => _.HeatingAvaliabilitySchedule.IsRemoveVisable);

            var coolingAvailability = new OptionalButton();

            coolingAvailability.TextBinding.Bind(vm, _ => _.CoolingAvaliabilitySchedule.BtnName);
            coolingAvailability.Bind(_ => _.Command, vm, _ => _.CoolingAvaliabilityCommand);
            coolingAvailability.Bind(_ => _.RemoveCommand, vm, _ => _.RemoveCoolingAvaliabilityCommand);
            coolingAvailability.Bind(_ => _.IsRemoveVisable, vm, _ => _.CoolingAvaliabilitySchedule.IsRemoveVisable);


            nameText.TextBinding.BindDataContext((IdealAirLoadViewModel m) => m.Name);

            economizer.BindDataContext(c => c.DataStore, (IdealAirLoadViewModel m) => m.Economizers);
            economizer.SelectedKeyBinding.BindDataContext((IdealAirLoadViewModel m) => m.Economizer);

            DCV.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.DCV);

            sensible.BindDataContext(c => c.Value, (IdealAirLoadViewModel m) => m.SensibleHR);
            latent.BindDataContext(c => c.Value, (IdealAirLoadViewModel m) => m.LatentHR);

            heatingAirT.BindDataContext(c => c.Value, (IdealAirLoadViewModel m) => m.HeatingAirTemperature);
            coolingAirT.BindDataContext(c => c.Value, (IdealAirLoadViewModel m) => m.CoolingAirTemperature);

            heatingLimitAuto.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.HeatingLimitAutosized);
            heatingLimitNoLimit.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.HeatingLimitNoLimit);
            heatingLimitNumber.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.HeatingLimitNumber);
            heatingLimit.BindDataContext(c => c.Value, (IdealAirLoadViewModel m) => m.HeatingLimit);
            heatingLimit.BindDataContext(c => c.Enabled, (IdealAirLoadViewModel m) => m.HeatingLimitNumber);

            coolingLimitAuto.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.CoolingLimitAutosized);
            coolingLimitNoLimit.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.CoolingLimitNoLimit);
            coolingLimitNumber.BindDataContext(c => c.Checked, (IdealAirLoadViewModel m) => m.CoolingLimitNumber);
            coolingLimit.BindDataContext(c => c.Value, (IdealAirLoadViewModel m) => m.CoolingLimit);
            coolingLimit.BindDataContext(c => c.Enabled, (IdealAirLoadViewModel m) => m.CoolingLimitNumber);

            layout.AddRow("Name:");
            layout.AddRow(nameText);
            layout.AddRow("Economizer:");
            layout.AddRow(economizer);
            layout.AddSeparateRow(DCV);
            layout.AddRow("Sensible Heat Recovery: [0-1]");
            layout.AddRow(sensible);
            layout.AddRow("Latent Heat Recovery: [0-1]");
            layout.AddRow(latent);
            layout.AddRow("Heating Supply Air Temperature: [C]");
            layout.AddRow(heatingAirT);
            layout.AddRow("Cooling Supply Air Temperature: [C]");
            layout.AddRow(coolingAirT);

            layout.AddRow("Heating Capacity Limit: [Watts]");
            layout.AddRow(heatingLimitAuto);
            layout.AddRow(heatingLimitNoLimit);
            layout.AddSeparateRow(heatingLimitNumber, heatingLimit);

            layout.AddRow("Cooling Capacity Limit: [Watts]");
            layout.AddRow(coolingLimitAuto);
            layout.AddRow(coolingLimitNoLimit);
            layout.AddSeparateRow(coolingLimitNumber, coolingLimit);

            layout.AddRow("Heating Availability");
            layout.AddRow(heatingAvailability);
            layout.AddRow("Cooling Availability");
            layout.AddRow(coolingAvailability);

            var locked = new CheckBox()
            {
                Text = "Locked", Enabled = false
            };

            locked.Checked = lockedMode;

            var OKButton = new Button {
                Text = "OK", Enabled = !lockedMode
            };

            OKButton.Click += (sender, e) => OkCommand.Execute(vm.GreateHvac(hvac));

            AbortButton = new Button {
                Text = "Cancel"
            };
            AbortButton.Click += (sender, e) => Close();

            var hbData = new Button {
                Text = "Schema Data"
            };

            hbData.Click += (sender, e) => Dialog_Message.Show(this, vm.GreateHvac(hvac).ToJson(true), "Schema Data");

            layout.AddSeparateRow(locked, null, OKButton, this.AbortButton, null, hbData);
            layout.AddRow(null);
            Content = layout;
        }
        public ProjectWizardPageView(ProjectWizardPageModel model)
        {
            var radioSpacing = Platform.IsGtk ? Size.Empty : new Size(2, 2);

            var content = new DynamicLayout
            {
                Spacing = new Size(10, 10)
            };

            if (model.SupportsAppName)
            {
                var nameBox = new TextBox();
                nameBox.TextBinding.BindDataContext((ProjectWizardPageModel m) => m.AppName);
                Application.Instance.AsyncInvoke(nameBox.Focus);

                var nameValid = new Label {
                    TextColor = Global.Theme.ErrorForeground
                };
                nameValid.BindDataContext(c => c.Visible, (ProjectWizardPageModel m) => m.AppNameInvalid);
                nameValid.BindDataContext(c => c.Text, (ProjectWizardPageModel m) => m.AppNameValidationText);


                content.BeginHorizontal();
                content.Add(HeadingLabel((model.IsLibrary ? "Library" : "App") + " Name:"));
                content.AddColumn(nameBox, nameValid);
                content.EndHorizontal();
            }
            else if (!string.IsNullOrEmpty(model.AppName))
            {
                var label = new Label {
                    Text = model.AppName, VerticalAlignment = VerticalAlignment.Center
                };
                content.AddRow(HeadingLabel((model.IsLibrary ? "Library" : "App") + " Name:"), label);
            }

            if (model.SupportsFramework)
            {
                var frameworkDropDown = new DropDown();
                frameworkDropDown.BindDataContext(c => c.DataStore, (ProjectWizardPageModel m) => m.SupportedFrameworks);
                frameworkDropDown.ItemTextBinding = Binding.Property((ProjectWizardPageModel.FrameworkInfo i) => i.Text);
                frameworkDropDown.ItemKeyBinding  = Binding.Property((ProjectWizardPageModel.FrameworkInfo i) => i.Value);
                frameworkDropDown.SelectedValueBinding.BindDataContext((ProjectWizardPageModel m) => m.SelectedFramework);

                /*
                 * var frameworkCheckBoxes = new CheckBoxList();
                 * frameworkCheckBoxes.BindDataContext(c => c.DataStore, (ProjectWizardPageModel m) => m.SupportedFrameworks);
                 * frameworkCheckBoxes.ItemTextBinding = Binding.Property((ProjectWizardPageModel.FrameworkInfo i) => i.Text);
                 * frameworkCheckBoxes.ItemKeyBinding = Binding.Property((ProjectWizardPageModel.FrameworkInfo i) => i.Value);
                 * frameworkCheckBoxes.SelectedValuesBinding.BindDataContext((ProjectWizardPageModel m) => m.SelectedFrameworks);
                 */

                content.AddRow(HeadingLabel("Framework:"), frameworkDropDown);
            }

            if (model.SupportsCombined)
            {
                var platformTypeList = new RadioButtonList
                {
                    Orientation = Orientation.Vertical,
                    Spacing     = radioSpacing,
                    Items       =
                    {
                        new ListItem {
                            Text = "Separate projects for each platform", Key = "separate"
                        },
                        new ListItem {
                            Text = "Single Windows, Linux, and Mac desktop project", Key = "combined"
                        }
                    }
                };
                platformTypeList.BindDataContext(c => c.Visible, (ProjectWizardPageModel m) => m.AllowCombined);
                platformTypeList.SelectedKeyBinding
                .Convert(v => v == "combined", v => v ? "combined" : "separate")
                .BindDataContext((ProjectWizardPageModel m) => m.Combined);
                var heading = HeadingLabel("Launcher:");
                heading.BindDataContext(c => c.Visible, (ProjectWizardPageModel m) => m.AllowCombined);
                content.AddRow(heading, platformTypeList);
            }

            if (model.SupportsXamMac)
            {
                var cb = new CheckBox
                {
                    Text    = "Include Xamarin.Mac project",
                    ToolTip = "This enables you to bundle mono with your app so your users don't have to install it separately.  You can only compile this on a Mac"
                };
                cb.CheckedBinding.BindDataContext((ProjectWizardPageModel m) => m.IncludeXamMac);
                content.AddRow(HeadingLabel(string.Empty), cb);
            }

            /*
             * eventually select platforms to include?
             *
             * var platformCheckBoxes = new DynamicLayout();
             * platformCheckBoxes.BeginHorizontal();
             * platformCheckBoxes.Add(new CheckBox { Text = "Gtk2" });
             * platformCheckBoxes.Add(new CheckBox { Text = "Gtk3" });
             * platformCheckBoxes.EndBeginHorizontal();
             * platformCheckBoxes.Add(new CheckBox { Text = "WinForms" });
             * platformCheckBoxes.Add(new CheckBox { Text = "Wpf" });
             * platformCheckBoxes.Add(new CheckBox { Text = "Direct2D" });
             * platformCheckBoxes.EndBeginHorizontal();
             * platformCheckBoxes.Add(new CheckBox { Text = "Mac" });
             * platformCheckBoxes.Add(new CheckBox { Text = "XamMac" });
             * platformCheckBoxes.Add(new CheckBox { Text = "XamMac2" });
             * platformCheckBoxes.EndHorizontal();
             *
             * content.Rows.Add(new TableRow(new Label { Text = "Platforms:", TextAlignment = TextAlignment.Right }, platformCheckBoxes));
             * /**/

            if (model.SupportsProjectType)
            {
                var sharedCodeList = new RadioButtonList
                {
                    Orientation = Orientation.Vertical,
                    Spacing     = radioSpacing,
                };
                if (model.SupportsPCL)
                {
                    sharedCodeList.Items.Add(new ListItem {
                        Text = "Portable Class Library", Key = "pcl"
                    });
                    sharedCodeList.SelectedKeyBinding.Convert(v => v == "pcl", v => v ? "pcl" : sharedCodeList.SelectedKey).BindDataContext((ProjectWizardPageModel m) => m.UsePCL);
                }
                if (model.SupportsNetStandard)
                {
                    sharedCodeList.Items.Add(new ListItem {
                        Text = ".NET Standard", Key = "netstandard"
                    });
                    sharedCodeList.SelectedKeyBinding.Convert(v => v == "netstandard", v => v ? "netstandard" : sharedCodeList.SelectedKey).BindDataContext((ProjectWizardPageModel m) => m.UseNetStandard);
                }
                if (model.SupportsSAL)
                {
                    sharedCodeList.Items.Add(new ListItem {
                        Text = "Shared Project", Key = "sal"
                    });
                    sharedCodeList.SelectedKeyBinding.Convert(v => v == "sal", v => v ? "sal" : sharedCodeList.SelectedKey).BindDataContext((ProjectWizardPageModel m) => m.UseSAL);
                }

                sharedCodeList.Items.Add(new ListItem {
                    Text = "Full .NET", Key = "net"
                });
                sharedCodeList.SelectedKeyBinding.Convert(v => v == "net", v => v ? "net" : sharedCodeList.SelectedKey).BindDataContext((ProjectWizardPageModel m) => m.UseNET);

                content.AddRow(new Label {
                    Text = model.IsLibrary ? "Type:" : "Shared Code:", TextAlignment = TextAlignment.Right
                }, sharedCodeList);
            }

            if (model.SupportsPanelType)
            {
                var panelTypeList = new RadioButtonList
                {
                    Orientation = Orientation.Horizontal,
                    Spacing     = radioSpacing,
                };

                panelTypeList.Items.Add(new ListItem {
                    Text = "Code", Key = "code"
                });
                panelTypeList.SelectedKeyBinding.BindDataContext((ProjectWizardPageModel m) => m.Mode);

                if (model.SupportsXeto)
                {
                    panelTypeList.Items.Add(new ListItem {
                        Text = "Xaml", Key = "xaml"
                    });
                }
                if (model.SupportsJeto)
                {
                    panelTypeList.Items.Add(new ListItem {
                        Text = "Json", Key = "json"
                    });
                }
                if (model.SupportsCodePreview)
                {
                    panelTypeList.Items.Add(new ListItem {
                        Text = "Code Preview", Key = "preview"
                    });
                }

                content.AddRow(HeadingLabel("Form:"), panelTypeList);
            }

            if (model.SupportsBase)
            {
                var baseTypeList = new RadioButtonList
                {
                    Orientation = Orientation.Horizontal,
                    Spacing     = radioSpacing,
                };

                baseTypeList.Items.Add(new ListItem {
                    Text = "Panel", Key = "Panel"
                });
                baseTypeList.Items.Add(new ListItem {
                    Text = "Dialog", Key = "Dialog"
                });
                baseTypeList.Items.Add(new ListItem {
                    Text = "Form", Key = "Form"
                });
                baseTypeList.SelectedKeyBinding.BindDataContext((ProjectWizardPageModel m) => m.Base);

                content.AddRow(HeadingLabel("Base:"), baseTypeList);
            }

#if DEBUG
            //var showColorsButton = new Button { Text = "Show all themed colors" };
            //showColorsButton.Click += (sender, e) => new ThemedColorsDialog().ShowModal(this);
            //content.AddRow(new Panel(), showColorsButton);
#endif

            var informationLabel = new Label();
            informationLabel.TextBinding.BindDataContext((ProjectWizardPageModel m) => m.Information);
            Information = informationLabel;

            Content     = content;
            DataContext = model;
        }
Exemple #12
0
        private void ConfigureDataBindings()
        {
            _btnSend.BindDataContext(x => x.Command, (MainViewModel vm) => vm.SendCommand);

            _grpDeviceSetting.BindDataContext(x => x.Enabled, Binding.Property((MainViewModel vm) => vm.IsRunning).Convert(x => !x), DualBindingMode.OneWay);

            //_radActivityMode.BindDataContext(x => x.Enabled, (MainViewModel vm) => vm.IsRunning, DualBindingMode.OneWay);
            //_chkIsCR.BindDataContext(x => x.Enabled, (MainViewModel vm) => vm.IsRunning, DualBindingMode.OneWay);
            //_chkIsLF.BindDataContext(x => x.Enabled, (MainViewModel vm) => vm.IsRunning, DualBindingMode.OneWay);
            //_textSendCommand.BindDataContext(x => x.Enabled, (MainViewModel vm) => vm.IsRunning, DualBindingMode.OneWay);
            _btnSend.BindDataContext(x => x.Enabled, (MainViewModel vm) => vm.IsRunning, DualBindingMode.OneWay);
            _btnTestBot.BindDataContext(x => x.Enabled, (MainViewModel vm) => vm.IsRunning, DualBindingMode.OneWay);

            _dropDownSerialPort.BindDataContext(
                c => c.DataStore,
                Binding.Property((MainViewModel vm) => vm.SerialPortList).Convert(x => x.Cast <object>()));
            _dropDownSerialPort.SelectedValueBinding.BindDataContext(
                (MainViewModel m) => m.SelectedSerialPortName);
            //_dropDownSerialPort.SelectedIndexBinding.BindDataContext(
            //    (MainViewModel m) => m.SelectedSerialPortIndex);
            _dropDownSerialPort.BindDataContext(
                c => c.Enabled,
                Binding.Property((MainViewModel vm) => vm.IsRunning).Convert(x => !x));

            _dropDownBaudRate.BindDataContext(
                c => c.DataStore,
                Binding.Property((MainViewModel vm) => vm.BaudRateOptions).Convert(x => x.Cast <object>()));
            _dropDownBaudRate.SelectedValueBinding.BindDataContext(
                (MainViewModel m) => m.SelectedBaudRate);

            _dropDownHandshake.SelectedValueBinding.BindDataContext(
                Binding.Property((MainViewModel m) => m.SelectedHandshake)
                .Convert(x => (Handshake)x, x => (int)x));

            _dropDownParity.SelectedValueBinding.BindDataContext(
                Binding.Property((MainViewModel m) => m.SelectedParity)
                .Convert(x => (Parity)x, x => (int)x));

            _radDataBits.BindDataContext(
                c => c.DataStore,
                Binding.Property((MainViewModel vm) => vm.DataBitsOptions).Convert(x => x.Cast <object>()));
            _radDataBits.SelectedValueBinding.BindDataContext(
                (MainViewModel m) => m.SelectedDataBits);

            //_radStopBits.BindDataContext(
            //c => c.DataStore,
            //Binding.Property((MainViewModel vm) => vm.StopBitsOptions).Convert(x => x.Cast<object>()));
            _radStopBits.SelectedValueBinding.BindDataContext(
                Binding.Property((MainViewModel m) => m.SelectedStopBits)
                .Convert(x => (StopBits)x, x => (int)x));

            _radActivityMode.BindDataContext(
                c => c.DataStore,
                Binding.Property((MainViewModel vm) => vm.ActivityModeOptions).Convert(x => x.Cast <object>()));
            _radActivityMode.SelectedValueBinding.BindDataContext(
                (MainViewModel m) => m.SelectedActivityMode);

            _chkIsCR.CheckedBinding.BindDataContext(
                (MainViewModel m) => m.IsCR);
            _chkIsLF.CheckedBinding.BindDataContext(
                (MainViewModel m) => m.IsLF);

            _btnRun.BindDataContext(x => x.Text, (MainViewModel vm) => vm.RunText);
            _btnRun.BindDataContext(x => x.Command, (MainViewModel vm) => vm.RunCommand);
            _btnRun.BindDataContext(x => x.Enabled, (MainViewModel vm) => vm.CanRun);

            _lblConnected.BindDataContext(x => x.Text, (MainViewModel vm) => vm.ConnectedText);

            _btnRefresh.BindDataContext(x => x.Command, (MainViewModel vm) => vm.RefreshCommand);
            _btnRefresh.BindDataContext(x => x.Enabled, Binding.Property((MainViewModel vm) => vm.IsRunning).Convert(x => !x), DualBindingMode.OneWay);

            _textSendCommand.BindDataContext(x => x.Text, (MainViewModel vm) => vm.SendCommandText);
        }
Exemple #13
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;
        }