Example #1
0
        private void ConfigureDataBinding()
        {
            _btnCompile.BindDataContext(x => x.Command, Binding.Property((DeviceBotViewModel vm) => vm.CompileCommand));

            _btnNew.BindDataContext(x => x.Command, Binding.Property((DeviceBotViewModel vm) => vm.NewCommand));
            _btnOpen.BindDataContext(x => x.Command, Binding.Property((DeviceBotViewModel vm) => vm.OpenCommand));
            _btnSave.BindDataContext(x => x.Command, Binding.Property((DeviceBotViewModel vm) => vm.SaveCommand));
            _btnSaveAs.BindDataContext(x => x.Command, Binding.Property((DeviceBotViewModel vm) => vm.SaveAsCommand));

            _lblCompileStatus.BindDataContext(x => x.Visible, Binding.Property((DeviceBotViewModel vm) => vm.IsCompileStatusVisible), DualBindingMode.OneWay);

            _chkEnableBot.CheckedBinding.BindDataContext((DeviceBotViewModel vm) => vm.IsBotEnabled);

            _btnCompile.BindDataContext(x => x.Enabled, Binding.Property((DeviceBotViewModel vm) => vm.IsBotEnabled), DualBindingMode.OneWay);

            _textSourceCode.BindDataContext(x => x.Text, Binding.Property((DeviceBotViewModel vm) => vm.UserScript));
            _textSourceCode.BindDataContext(x => x.CodeLanguage, Binding.Property((DeviceBotViewModel vm) => vm.CodeLanguage), DualBindingMode.OneWay);

            _radBotLanguages.BindDataContext(
                c => c.DataStore,
                Binding.Property((DeviceBotViewModel vm) => vm.BotLanguages).Convert(x => x.Cast <object>()));
            _radBotLanguages.SelectedValueBinding.BindDataContext(
                (DeviceBotViewModel m) => m.SelectedBotLanguage);

            //_textSourceCode.BindDataContext(x => x.Enabled, Binding.Property((DeviceBotViewModel vm) => vm.IsBotEnabled), DualBindingMode.OneWay);
        }
        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;
        }
Example #3
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);
        }