Inheritance: Xwt.Widget
 /// <summary>
 /// Add Frequency item to combo box.
 /// </summary>
 /// <param name="_combo"></param>
 public static void FillComboBox(ComboBox _combo)
 {
     _combo.Items.Add(Director.Properties.Resources.Every5Minutes);
     _combo.Items.Add(Director.Properties.Resources.Every10Minutes);
     _combo.Items.Add(Director.Properties.Resources.Every30Minutes);
     _combo.Items.Add(Director.Properties.Resources.EveryHour);
     _combo.Items.Add(Director.Properties.Resources.Every6Hours);
     _combo.Items.Add(Director.Properties.Resources.Every12Hours);
     _combo.Items.Add(Director.Properties.Resources.EveryDay);
 }
        public override Xwt.Widget Makeup(IXwtWrapper Parent)
        {
            Xwt.ComboBox Target = new Xwt.ComboBox();
            if (this.DataSource != "")
            {
                Target.ItemsSource = (IListDataSource)Parent.GetType().GetField(this.DataSource).GetValue(Parent);
                Type BackgroundType = (Target.ItemsSource).GetType().GetGenericArguments()[0];
                if (ColumnDefinition != null && ColumnDefinition.Count() > 0)
                {
                    foreach (XwtColumnDefinitionNode N in ColumnDefinition)
                    {
                        IDataField X = DataField.GenerateDataField(N.Source, BackgroundType);
                        Target.Views.Add(CellViewFactory.Make(X, false));
                    }
                }
            }
            else
            {
                if (Items != null && Items.Count() > 0)
                {
                    foreach (XwtSimpleBindingNode N in Items)
                    {
                        if (N.Value != "")
                        {
                            object value = Parent.GetType().GetField(N.Value).GetValue(Parent);
                            Target.Items.Add(value, N.Text);
                        }
                        else
                        {
                            Target.Items.Add((object)N.Text, N.Text);
                        }
                    }
                }
            }
            Target.SelectedIndex = this.Selection;
            if (this.Source != "")
            {
                Target.SelectedItem = PathBind.GetValue(Source, Parent, Target.Items[0]);
                Parent.PropertyChanged += (o, e) =>
                {
                    if (e.PropertyName == this.Source.Split('.')[0])
                        Xwt.Application.Invoke(() => Target.SelectedItem = PathBind.GetValue(Source, Parent, Target.Items[0]));
                };
                Target.SelectionChanged += (o, e) =>
                {
                    PathBind.SetValue(Source, Parent, Target.SelectedItem);
                };
            }
            WindowController.TryAttachEvent(Target, "SelectionChanged", Parent, Changed);

            InitWidget(Target, Parent);
            return Target;
        }
		public ComboBoxDialog()
		{
			Title = "Xwt Combo Box Dialog";
			Width = 500;
			Height = 400;

			var vbox = new VBox ();
			Content = vbox;

			comboBox = new ComboBox ();
			vbox.PackStart (comboBox, false, false);

			AddItems ();
		}
        public static ComboBox GetLockLevelComboBox(bool forceLock = false)
        {
            ComboBox lockLevelBox = new ComboBox();
            lockLevelBox.WidthRequest = 150;

            if (!forceLock)
                lockLevelBox.Items.Add(CheckOutLockLevel.Unchanged, "Unchanged - Keep any existing lock.");
            lockLevelBox.Items.Add(CheckOutLockLevel.CheckOut, "Check Out - Prevent other users from checking out and checking in");
            lockLevelBox.Items.Add(CheckOutLockLevel.CheckIn, "Check In - Prevent other users from checking in but allow checking out");
            if (forceLock && TFSVersionControlService.Instance.CheckOutLockLevel == CheckOutLockLevel.Unchanged)
                lockLevelBox.SelectedItem = CheckOutLockLevel.CheckOut;
            else
                lockLevelBox.SelectedItem = TFSVersionControlService.Instance.CheckOutLockLevel;
            return lockLevelBox;
        }
Exemple #5
0
        public ComboBoxes()
        {
            HBox box = new HBox ();
            ComboBox c = new ComboBox ();
            c.Items.Add ("One");
            c.Items.Add ("Two");
            c.Items.Add ("Three");
            c.SelectedIndex = 1;
            box.PackStart (c);
            Label la = new Label ();
            box.PackStart (la);
            c.SelectionChanged += delegate {
                la.Text = "Selected: " + (string)c.SelectedItem;
            };
            PackStart (box);

            box = new HBox ();
            ComboBox c2 = new ComboBox ();
            box.PackStart (c2);
            Button b = new Button ("Fill combo (should grow)");
            box.PackStart (b);
            b.Clicked += delegate {
                for (int n=0; n<10; n++) {
                    c2.Items.Add ("Item " + new string ('#', n));
                }
            };
            PackStart (box);

            // Combo with custom labels

            box = new HBox ();
            ComboBox c3 = new ComboBox ();
            c3.Items.Add (0, "Combo with custom labels");
            c3.Items.Add (1, "One");
            c3.Items.Add (2, "Two");
            c3.Items.Add (3, "Three");
            la = new Label ();
            box.PackStart (c3);
            box.PackStart (la);
            c3.SelectionChanged += delegate {
                la.Text = "Selected item: " + c3.SelectedItem;
            };
            PackStart (box);
        }
Exemple #6
0
        public Designer()
        {
            VBox box = new VBox ();
            Button b = new Button ("Hi there");
            box.PackStart (b);
            Label la = new Label ("Some label");
            box.PackStart (la);
            HBox hb = new HBox ();
            hb.PackStart (new Label ("Text"));
            var cb = new ComboBox ();
            cb.Items.Add ("One");
            cb.Items.Add ("Two");
            cb.SelectedIndex = 0;
            hb.PackStart (cb);
            box.PackStart (hb);

            DesignerSurface ds = new DesignerSurface ();
            ds.Load (box);
            PackStart (ds, BoxMode.FillAndExpand);
        }
		public HexEditorDebugger ()
		{
			var comboBox = new ComboBox ();
			comboBox.Items.Add ("Hex 8");
			comboBox.Items.Add ("Hex 16");
			comboBox.SelectedIndex = 0;
			editor.Options.StringRepresentationType = StringRepresentationTypes.ASCII;
			comboBox.SelectionChanged += delegate {
				switch (comboBox.SelectedIndex) {
				case 0:
					editor.Options.StringRepresentationType = StringRepresentationTypes.ASCII;
					break;
				case 1:
					editor.Options.StringRepresentationType = StringRepresentationTypes.UTF16;
					break;
				}
			};
			comboBox.HorizontalPlacement = WidgetPlacement.End;
			Spacing = 0;
			PackStart (comboBox);
			PackStart (new ScrollView (editor), true);
		}
Exemple #8
0
		void HandleClicked (object sender, EventArgs e)
		{
			if (popover == null) {
				popover = new Popover ();
				popover.Padding = 20;

				var table = new Table () { DefaultColumnSpacing = 20, DefaultRowSpacing = 10 };
//					table.Margin.SetAll (60);
				table.Add (new Label ("Font") { TextAlignment = Alignment.End }, 0, 0);
				table.Add (new ComboBox (), 1, 0, vexpand:true);

				table.Add (new Label ("Family")  { TextAlignment = Alignment.End }, 0, 1);
				table.Add (new ComboBox (), 1, 1, vexpand:true);

				var cmbStyle = new ComboBox ();
				cmbStyle.Items.Add ("Normal");
				cmbStyle.Items.Add ("Bold");
				cmbStyle.Items.Add ("Italic");

				table.Add (new Label ("Style")  { TextAlignment = Alignment.End }, 0, 2);
				table.Add (cmbStyle, 1, 2, vexpand:true);

				table.Add (new Label ("Size")  { TextAlignment = Alignment.End }, 0, 3);
				table.Add (new SpinButton (), 1, 3, vexpand:true);

				var b = new Button ("Add more");
				table.Add (b, 0, 4);
				int next = 5;
				b.Clicked += delegate {
					table.Add (new Label ("Row " + next), 0, next++);
				};

				table.Margin = 20;
				popover.Content = table;
			}
//			popover.Padding.SetAll (20);
			popover.BackgroundColor = Xwt.Drawing.Colors.Yellow.WithAlpha(0.9);
			popover.Show (Popover.Position.Top, (Button)sender, new Rectangle (50, 10, 5, 5));
		}
		public RunWithCustomParametersDialog (Project project)
		{
			this.project = project;
			runConfig = project.CreateRunConfiguration ("Custom");

			Title = GettextCatalog.GetString ("Custom Parameters");

			Width = 650;
			Height = 400;

			editor = RunConfigurationService.CreateEditorForConfiguration (runConfig);
			editor.Load (project, runConfig);

			var box = new VBox ();
			Content = box;
			var c = editor.CreateControl ().GetNativeWidget<Gtk.Widget> ();
			box.PackStart (box.Surface.ToolkitEngine.WrapWidget (c, NativeWidgetSizing.DefaultPreferredSize), true);

			box.PackStart (new HSeparator ());

			var hbox = new HBox ();
			hbox.PackStart (new Label ("Run Action: "));
			hbox.PackStart (modeCombo = new ComboBox ());
			box.PackStart (hbox);

			runButton = new DialogButton (new Command ("run", GettextCatalog.GetString ("Run")));

			Buttons.Add (Command.Cancel);
			Buttons.Add (runButton);

			LoadModes ();
			UpdateStatus ();

			editor.Changed += Editor_Changed;
			modeCombo.SelectionChanged += (s,a) => UpdateStatus ();
		}
        /// <summary>
        /// Initialize window.
        /// </summary>
        public override void _initializeComponents()
        {
            // Server Name + URL + Periodicity window
            Frame f = new Frame();
            f.Label = Director.Properties.Resources.ServerSettings;
            f.Padding = 10;

            // Create VBOX
            VBox ServerSettings = new VBox();

            // Prepare text box
            ServerSettings.PackStart(new Label()
            {
                Text = Director.Properties.Resources.ServerName
            });
            ServerName = new TextEntry();
            ServerName.Changed += ServerName_Changed;
            ServerSettings.PackStart(ServerName);

            // Add invalid server name
            ServerSettings.PackStart(InvalidServerName);

            // Server URL
            ServerSettings.PackStart(new Label()
            {
                Text = Director.Properties.Resources.ServerURL
            });
            ServerURL = new TextEntry();
            ServerURL.Changed += ServerURL_Changed;
            ServerSettings.PackStart(ServerURL);

            // Invalid URL
            ServerSettings.PackStart(InvalidServerURL);

            // Frequency settings
            ServerSettings.PackStart(new Label()
            {
                Text = Director.Properties.Resources.RunningPeriodicity
            });
            FrequencyRunning = new ComboBox();
            FrequencyHelper.FillComboBox(FrequencyRunning);
            ServerSettings.PackStart(FrequencyRunning);
            FrequencyRunning.SelectedIndex = 0;
            FrequencyRunning.SelectionChanged += FrequencyRunning_SelectionChanged;

            // Add Frame to server settings
            f.Content = ServerSettings;
            PackStart(f);

            // Authorization
            AuthRequired = new CheckBox(Director.Properties.Resources.Authorization);
            AuthRequired.MarginLeft = 10;
            PackStart(AuthRequired);

            // Create Authentication Frame
            Authentication = new Frame()
            {
                Label = Director.Properties.Resources.AuthorizationSettings,
                Padding = 10
            };

            // Login and Password fields
            VBox AuthBox = new VBox();

            AuthBox.PackStart(new Label()
            {
                Text = Director.Properties.Resources.Username
            });
            AuthUserName = new TextEntry();
            AuthUserName.Changed += AuthUserName_Changed;
            AuthBox.PackStart(AuthUserName);

            AuthBox.PackStart(new Label()
            {
                Text = Director.Properties.Resources.Password
            });
            AuthUserPassword = new PasswordEntry();
            AuthUserPassword.Changed += AuthUserPassword_Changed;
            AuthBox.PackStart(AuthUserPassword);

            // Authentication content
            Authentication.Content = AuthBox;
            PackStart(Authentication);

            // Change value
            AuthRequired.Toggled += AuthRequired_Toggled;

            // Email settings
            Frame EmailFrame = new Frame()
            {
                Label = Director.Properties.Resources.EmailNotifications,
                Padding = 10,
                MinHeight = 180
            };

            // Create EmailList widget
            EmailWidget = new EmailList();
            EmailFrame.Content = EmailWidget;
            PackStart(EmailFrame, expand: true, fill: true);
        }
Exemple #11
0
        /// <summary>
        /// Create set window.
        /// </summary>
        public SetWindow(RequestWidget _reqW, ResponseWidget _resP)
        {
            // Set
            ReqWidget = _reqW;
            ResWidget = _resP;

            // Set default size
            Width = 450;
            Height = 500;

            // This window can not be maximalized
            Resizable = true;

            // Icon
            Icon = Image.FromResource(DirectorImages.EDIT_ICON);

            // Set content
            Title = Director.Properties.Resources.SetContentTitle;

            // Center screen
            InitialLocation = WindowLocation.CenterScreen;

            // Create input area
            VBox InputArea = new VBox();

            // Prepare input
            TextInput = new TextEntry()
            {
                ExpandVertical = true,
                ExpandHorizontal = true,
                MultiLine = true
            };

            TextInput.Text = "";

            // Content type combo box
            ContentTypeSelect = new ComboBox ();
            ContentTypeSelect.Items.Add (ContentType.JSON, "JSON");
            ContentTypeSelect.Items.Add (ContentType.XML, "XML");
            ContentTypeSelect.Items.Add (ContentType.PLAIN, "PLAIN");
            ContentTypeSelect.SelectedIndex = 0;

            if (ReqWidget != null)
            {
                if (ReqWidget.ActiveRequest.RequestTemplateType == ContentType.JSON) {
                    TextInput.Text = JSONFormatter.Format (ReqWidget.ActiveRequest.RequestTemplate);
                }
                if (TextInput.Text.Length == 0) {
                    TextInput.Text = ReqWidget.ActiveRequest.RequestTemplate;
                }
                ContentTypeSelect.SelectedItem = ReqWidget.ActiveRequest.RequestTemplateType;
            }
            else if (ResWidget != null)
            {
                if (ResWidget.ActiveRequest.ResponseTemplateType == ContentType.JSON) {
                    TextInput.Text = JSONFormatter.Format (ResWidget.ActiveRequest.ResponseTemplate);
                }
                if (TextInput.Text.Length == 0) {
                    TextInput.Text = ResWidget.ActiveRequest.ResponseTemplate;
                }
                ContentTypeSelect.SelectedItem = ResWidget.ActiveRequest.ResponseTemplateType;
            }

            // Add
            InputArea.PackStart(new Label() { Markup = "<b>Content type:</b>" });
            InputArea.PackStart (ContentTypeSelect, false, true);

            ScrollView ScrollTextInput = new ScrollView()
            {
                Content = TextInput
            };
            InputArea.PackStart(new Label() { Markup = "<b>" + Director.Properties.Resources.PasteInput + "</b>" });
            InputArea.PackStart(ScrollTextInput, true, true);

            // Prepare output
            InputArea.PackStart(new Label() { Markup = "<b>" + Director.Properties.Resources.Output + "</b>" });
            ErrorReport = new MarkdownView();
            InputArea.PackStart(ErrorReport, true, true);

            // Btn
            Button ConfirmButton = new Button(Image.FromResource(DirectorImages.OK_ICON),
                Director.Properties.Resources.ConfirmInput)
            {
                WidthRequest = 150,
                ExpandHorizontal = false,
                ExpandVertical = false
            };
            InputArea.PackStart(ConfirmButton, expand: false, hpos: WidgetPlacement.End);

            // Save
            ConfirmButton.Clicked += ConfirmButton_Clicked;

            // Content is input area
            Content = InputArea;
        }
Exemple #12
0
        public ComboBoxes()
        {
            HBox box = new HBox ();
            ComboBox c = new ComboBox ();
            c.Items.Add ("One");
            c.Items.Add ("Two");
            c.Items.Add ("Three");
            c.SelectedIndex = 1;
            box.PackStart (c);
            Label la = new Label ();
            box.PackStart (la);
            c.SelectionChanged += delegate {
                la.Text = "Selected: " + (string)c.SelectedItem;
            };
            PackStart (box);

            box = new HBox ();
            ComboBox c2 = new ComboBox ();
            box.PackStart (c2);
            Button b = new Button ("Fill combo (should grow)");
            box.PackStart (b);
            b.Clicked += delegate {
                for (int n=0; n<10; n++) {
                    c2.Items.Add ("Item " + new string ('#', n));
                }
            };
            PackStart (box);

            // Combo with custom labels

            box = new HBox ();
            ComboBox c3 = new ComboBox ();
            c3.Items.Add (0, "Combo with custom labels");
            c3.Items.Add (1, "One");
            c3.Items.Add (2, "Two");
            c3.Items.Add (3, "Three");
            c3.Items.Add (ItemSeparator.Instance);
            c3.Items.Add (4, "Maybe more");
            var la3 = new Label ();
            box.PackStart (c3);
            box.PackStart (la3);
            c3.SelectionChanged += delegate {
                la3.Text = "Selected item: " + c3.SelectedItem;
            };
            PackStart (box);

            box = new HBox ();
            var c4 = new ComboBoxEntry ();
            var la4 = new Label ();
            box.PackStart (c4);
            box.PackStart (la4);

            c4.Items.Add (1, "One");
            c4.Items.Add (2, "Two");
            c4.Items.Add (3, "Three");
            c4.TextEntry.PlaceholderText = "This is an entry";
            c4.TextEntry.Changed += delegate {
                la4.Text = "Selected text: " + c4.TextEntry.Text;
            };
            PackStart (box);
        }
		public XwtSourcePageWidget (XwtSourceWizardPage page)
		{
			Page = page;

			cGitHub = new Octokit.GitHubClient (new Octokit.ProductHeaderValue ("xwt_addin")).Repository;

			var optBuiltIn = new RadioButton(GettextCatalog.GetString ("Local Package / GAC")) {
				TooltipText = GettextCatalog.GetString (
					"Xwt must be installed to the GAC (Global Assembly Cache),\n" +
					"otherwise you will have to add a HintPath property manually.")
			};
			var optGithub = new RadioButton(GettextCatalog.GetString ("GitHub:")) {
				TooltipText = GettextCatalog.GetString (
					"A separate solution folder named 'Xwt' will be added to the solution.\n" +
					"If the solution already contains the Xwt project,\nit will be referenced instead " +
					"and the git checkout will be skipped.")
			};
			var linkGithub = new Label {
				Markup = "(<a href='https://github.com/mono/xwt'>Official Repository</a>)",
				TooltipText = "https://github.com/mono/xwt"
			};
			var optNuGet = new RadioButton(GettextCatalog.GetString ("NuGet package")) {
				TooltipText = GettextCatalog.GetString ("All registered NuGet repositories will be searched.")
			};
			                               
			var sourceGroup = optBuiltIn.Group = optGithub.Group = optNuGet.Group;
			sourceGroup.ActiveRadioButtonChanged += (sender, e) => {
				if (sourceGroup.ActiveRadioButton == optGithub)
					Page.XwtReferenceSource = XwtSource.Github;
				else if (sourceGroup.ActiveRadioButton == optNuGet)
					Page.XwtReferenceSource = XwtSource.NuGet;
				else
					Page.XwtReferenceSource = XwtSource.Local;
			};
			optGithub.Active = true;

			CheckBox chkGitSubmodule = null;

			if (page.Wizard.Parameters["CreateSolution"] == true.ToString ()) {
				chkGitSubmodule = new CheckBox(GettextCatalog.GetString ("Register Git Submodule\n(will be committed automatically)")) {
					TooltipText = GettextCatalog.GetString (
						"Only if you enable git version control for the new project in the last creation step.\n" +
						"The Xwt submodule will be registered and initialized during the creation process.")
				};
				chkGitSubmodule.MarginLeft = 30;
				chkGitSubmodule.Toggled += (sender, e) => Page.XwtGitSubmodule = chkGitSubmodule.Active;

				sourceGroup.ActiveRadioButtonChanged += (sender, e) => {
					if (sourceGroup.ActiveRadioButton == optGithub)
						chkGitSubmodule.Sensitive = true;
					else
						chkGitSubmodule.Sensitive = false;
				};
			}

			var tbl = new Table ();
			BackgroundColor = Styles.NewProjectDialog.ProjectConfigurationLeftHandBackgroundColor;

			// use inner table for selection to make it easier to add more options
			var tblSource = new Table ();
			var boxGithub = new HBox ();
			boxGithub.PackStart (optGithub);
			boxGithub.PackStart (linkGithub);
			tblSource.Add (boxGithub, 0, 0);

			var tblGithubRepo = new Table ();
			tblGithubRepo.MarginLeft = 30;

			tblGithubRepo.Add (new Label (GettextCatalog.GetString ("Repository:")), 0, 0);
			cmbGithubRepo = new ComboBox ();
			cmbGithubRepo.Items.Add ("mono/xwt");
			cmbGithubRepo.SelectedIndex = 0;
			cmbGithubRepo.SelectionChanged += (sender, e) => UpdateBranches (cmbGithubRepo.SelectedText);
			tblGithubRepo.Add (cmbGithubRepo, 1, 0);
			spinnerRepo = new Spinner { Visible = false };
			tblGithubRepo.Add (spinnerRepo, 2, 0);


			tblGithubRepo.Add (new Label (GettextCatalog.GetString ("Branch:")), 0, 1);
			cmbGithubBranch = new ComboBox ();
			cmbGithubBranch.Items.Add ("master");
			cmbGithubBranch.SelectedIndex = 0;
			cmbGithubBranch.SelectionChanged += (sender, e) => Page.XwtGithubBranch = cmbGithubBranch.SelectedText;
			tblGithubRepo.Add (cmbGithubBranch, 1, 1);
			spinnerBranches = new Spinner { Visible = false };
			tblGithubRepo.Add (spinnerBranches, 2, 1);

			tblSource.Add (tblGithubRepo, 0, 1);

			if (chkGitSubmodule != null) tblSource.Add (chkGitSubmodule, 0, 2);
			tblSource.Add (optNuGet, 0, 3);
			tblSource.Add (optBuiltIn, 0, 4);

			tbl.Add (new Label (GettextCatalog.GetString ("Xwt reference source:")), 0, 0, vpos: WidgetPlacement.Start, hpos: WidgetPlacement.End);
			tbl.Add (tblSource, 1, 0);

			var rightFrame = new FrameBox ();
			rightFrame.BackgroundColor = Styles.NewProjectDialog.ProjectConfigurationRightHandBackgroundColor; ;
			rightFrame.WidthRequest = 280;

			Spacing = 0;
			PackStart (tbl, true, WidgetPlacement.Center, marginLeft: 30, marginRight: 30);

			PackStart (rightFrame, false, false);
			UpdateForks ();
			UpdateBranches ("mono/xwt");
		}
Exemple #14
0
        private void Build()
        {
            if(Toolkit.CurrentEngine.Type == ToolkitType.Wpf)
                this.BackgroundColor = (new Button()).BackgroundColor;

            vbox1 = new VBox();

            label1 = new Label("Select Font:");
            label1.MarginTop = 4;
            label1.MarginRight = 4;
            label1.MarginLeft = 4;
            vbox1.PackStart(label1);

            table1 = new Table();
            table1.MarginRight = 4;
            table1.MarginLeft = 4;

            radioButton1 = new RadioButton("From System: ");
            table1.Add(radioButton1, 0, 0);

            combo_font = new ComboBox();

            List<string> fonts = new List<string>();
            foreach (System.Drawing.FontFamily font in System.Drawing.FontFamily.Families)
                fonts.Add(font.Name);
            fonts.Sort();
            foreach (string font in fonts)
                combo_font.Items.Add(font);

            if(combo_font.Items.Contains("Arial"))
                combo_font.SelectedText = "Arial";
            else if(combo_font.Items.Count > 0)
                combo_font.SelectedIndex = 0;
            combo_font.Font = Xwt.Drawing.Font.FromName(combo_font.SelectedText).WithSize(combo_font.Font.Size);

            table1.Add(combo_font, 1, 0, 1, 1, true);

            radioButton2 = new RadioButton();
            radioButton2.Label = "From File: ";
            radioButton2.Sensitive = true;
            radioButton2.Group = radioButton1.Group;
            table1.Add(radioButton2, 0, 1);

            hbox1 = new HBox();

            entry_font = new TextEntry();
            entry_font.Sensitive = false;
            hbox1.PackStart(entry_font, true);

            button_font = new Button("Browse");
            button_font.Sensitive = false;
            hbox1.PackStart(button_font);

            table1.Add(hbox1, 1, 1);

            vbox1.PackStart(table1);

            notebook1 = new Notebook();
            notebook1.ExpandHorizontal = true;
            notebook1.ExpandVertical = true;

            table2 = new Table();
            table2.Margin = 4;

            label4 = new Label("Style:");
            table2.Add(label4, 0, 0);

            hbox2 = new HBox();

            check_bold = new CheckBox("Bold ");
            check_bold.BackgroundColor = Color.FromBytes(0, 0, 0, 0);
            hbox2.PackStart(check_bold);

            check_italic = new CheckBox("Italic ");
            check_italic.BackgroundColor = Color.FromBytes(0, 0, 0, 0);
            hbox2.PackStart(check_italic);

            check_kerning = new CheckBox("Kerning ");
            check_kerning.BackgroundColor = Color.FromBytes(0, 0, 0, 0);
            hbox2.PackStart(check_kerning);

            table2.Add(hbox2, 0, 1, 1, 1);

            label2 = new Label("Size:");
            table2.Add(label2, 0, 2);

            entry_size = new NumericEntry("0", "WARNING: Size needs to be a number");
            table2.Add(entry_size, 0, 3, 1, 1, true);

            label3 = new Label("Spacing:");
            table2.Add(label3, 0, 4);

            entry_spacing = new NumericEntry("0", "WARNING: Spacing needs to be a number");
            table2.Add(entry_spacing, 0, 5, 1, 1, true);

            check_defchar = new CheckBox("Default Character:");
            check_defchar.BackgroundColor = Color.FromBytes(0, 0, 0, 0);
            table2.Add(check_defchar, 0, 6);

            entry_defchar = new TextEntry();
            entry_defchar.Sensitive = false;
            entry_defchar.TextAlignment = Alignment.Center;
            table2.Add(entry_defchar, 0, 7, 1, 1, true);

            notebook1.Add(table2, "Global");

            hbox3 = new HBox();

            listView1 = new ListView();
            hbox3.PackStart(listView1, true);

            vbox2 = new VBox();
            vbox2.MarginRight = 5;
            vbox2.MarginTop = 5;

            label8 = new Label(" Main:");
            vbox2.PackStart(label8);

            button_plus = new Button("Add");
            vbox2.PackStart(button_plus);

            button_minus = new Button("Remove");
            button_minus.Sensitive = false;
            vbox2.PackStart(button_minus);

            button_edit = new Button("Edit");
            button_edit.Sensitive = false;
            vbox2.PackStart(button_edit);

            vbox2.PackStart(new HSeparator());

            label9 = new Label(" Move:");
            vbox2.PackStart(label9);

            button_up  = new Button("Up");
            button_up.Sensitive = false;
            vbox2.PackStart(button_up);

            button_down  = new Button("Down");
            button_down.Sensitive = false;
            vbox2.PackStart(button_down);

            hbox3.PackStart(vbox2);

            notebook1.Add(hbox3, "Characters");

            var pa = new VBox();

            textEditor1 = new TextEditor();
            textEditor1.Document.MimeType = "application/xml";

            pa.PackStart(textEditor1, true);
            notebook1.Add(pa, "Xml");

            vbox3 = new VBox();

            hbox4 = new HBox();
            hbox4.Margin = 5;

            label5 = new Label("Font Color: ");
            hbox4.PackStart(label5);

            color_font = new ColorPicker();
            color_font.Color = Color.FromBytes(0, 0, 0);
            color_font.SupportsAlpha = false;
            hbox4.PackStart(color_font);

            label6 = new Label("Background Color: ");
            hbox4.PackStart(label6);

            color_back = new ColorPicker();
            color_back.Color = Color.FromBytes(224, 224, 209);
            color_back.SupportsAlpha = false;
            hbox4.PackStart(color_back);

            vbox3.PackStart(hbox4);

            hbox5 = new HBox();
            hbox5.MarginLeft = 5;
            hbox5.MarginRight = 5;

            label7 = new Label("Text: ");
            hbox5.PackStart(label7);

            entry_text = new TextEntry();
            entry_text.Text = "The quick brown fox jumps over the lazy dog";
            hbox5.PackStart(entry_text, true);

            button_preview = new Button("Preview");
            hbox5.PackStart(button_preview);

            vbox3.PackStart(hbox5);

            web1 = new WebView();

            scrollView2 = new ScrollView();
            scrollView2.HorizontalScrollPolicy = ScrollPolicy.Automatic;
            scrollView2.VerticalScrollPolicy = ScrollPolicy.Automatic;

            if (Toolkit.CurrentEngine.Type != ToolkitType.Gtk)
                scrollView2.Content = web1;

            vbox3.PackStart(scrollView2, true);

            notebook1.Add(vbox3, "Preview");

            vbox1.PackStart(notebook1, true);

            this.Content = vbox1;
        }
        /// <summary>
        /// Set variable.
        /// </summary>
        void VariableButton_Clicked(object sender, EventArgs e)
        {
            // Test if variables are ready
            if (ParentList.ActiveScenario.customVariables.Count == 0)
            {
                MessageDialog.ShowError(Director.Properties.Resources.NoVariablesFound);
                return;
            }

            // Create Dialog window
            var expressionDialog = new Dialog()
            {
                InitialLocation = WindowLocation.CenterParent,
                Width = 370,
                Resizable = false
            };

            // Set Title
            expressionDialog.Title = Director.Properties.Resources.HeaderSettings;

            // Prepare content
            VBox t = new VBox()
            {
                ExpandHorizontal = true,
                ExpandVertical = true
            };

            // Text before
            TextBefore = new TextEntry();
            t.PackStart(new Label(Director.Properties.Resources.TextBefore + ":"));
            t.PackStart(TextBefore, false, true);

            // Variable
            Variables = new ComboBox();
            t.PackStart(new Label(Director.Properties.Resources.Variable + ":"));
            Variables.Items.Add("");
            foreach (String k in ParentList.ActiveScenario.customVariables.Keys)
                Variables.Items.Add(k);
            t.PackStart(Variables, false, true);

            // Text after
            TextAfter = new TextEntry();
            t.PackStart(new Label(Director.Properties.Resources.TextAfter + ":"));
            t.PackStart(TextAfter, false, true);

            // Example
            Example = new Label();
            t.PackStart(new Label(Director.Properties.Resources.Example + ":"));
            t.PackStart(Example, false, true);

            // Expression solver split by $$
            String value = ActiveHeader.Value;
            var arr = value.Split('$');

            if (arr.Length == 1)
            {
                TextBefore.Text = arr[0];
                Variables.SelectedIndex = 0;
                TextAfter.Text = "";
            }
            else if (arr.Length == 3)
            {
                TextBefore.Text = arr[0];
                TextAfter.Text = arr[2];
                try
                {
                    Variables.SelectedText = arr[1];
                }
                catch
                {
                    TextBefore.Text = value;
                    TextAfter.Text = "";
                    Variables.SelectedIndex = 0;
                }
            }
            else
            {
                TextBefore.Text = value;
                TextAfter.Text = "";
                Variables.SelectedIndex = 0;
            }
            Example.Text = value;

            // Set hooks
            TextBefore.Changed += ExpressionSolver;
            TextAfter.Changed += ExpressionSolver;
            Variables.SelectionChanged += ExpressionSolver;

            // Image
            HBox ContentBox = new HBox()
            {
                ExpandHorizontal = true,
                ExpandVertical = true
            };

            // Image view
            ImageView ImageIcon = new ImageView(Image.FromResource(DirectorImages.HEADER_EDIT_IMAGE))
            {
                WidthRequest = 32, HeightRequest = 32,
                Margin = 20
            };
            ContentBox.PackStart(ImageIcon, false, false);
            ContentBox.PackStart(t, true, true);

            // Set content
            expressionDialog.Content = ContentBox;

            // Prepare buttons
            expressionDialog.Buttons.Add(new DialogButton(Director.Properties.Resources.OkComand, Command.Ok));
            expressionDialog.Buttons.Add(new DialogButton(Director.Properties.Resources.Cancel, Command.Cancel));

            // Run?
            var result = expressionDialog.Run(this.ParentList.ParentWindow);

            if (result == Command.Ok)
                Values.Text = ActiveHeader.Value = Example.Text;

            // Dispose dialog
            expressionDialog.Dispose();
        }
        /// <summary>
        /// Generate components.
        /// </summary>
        private void _initComponents()
        {
            Type = new ComboBox()
            {
                MarginLeft = 5,
                VerticalPlacement = WidgetPlacement.Center,
                HorizontalPlacement = WidgetPlacement.Fill,
                MarginRight = 5,
                MarginTop = 5
            };
            Type.Items.Add(WidgetTypes.TEXT, "Text");
            Type.Items.Add(WidgetTypes.VARIABLE, "Variable");
            Type.Items.Add(WidgetTypes.RAND_INT, "Random integer");
            Type.Items.Add(WidgetTypes.RAND_STRING, "Random string");
            Type.Items.Add(WidgetTypes.RAND_FLOAT, "Random float");
            Type.Items.Add(WidgetTypes.SEQUENCE, "Sequence");

            HBox HorizontalOption = new HBox();
            HorizontalOption.PackStart(Type, expand: true);

            Button RemoveBtn = new Button(Image.FromResource(DirectorImages.CROSS_ICON))
            {
                MarginRight = 5,
                HorizontalPlacement = WidgetPlacement.Center,
                VerticalPlacement = WidgetPlacement.Center,
                ExpandHorizontal = false,
                ExpandVertical = false,
                MarginTop = 5
            };
            HorizontalOption.PackStart(RemoveBtn, expand: false, fill: false);
            RemoveBtn.Clicked += RemoveBtn_Clicked;
            PackStart(HorizontalOption, expand: true);

            // Prepare contents
            ComponentContent = new VBox()
            {
                MarginBottom = (BackgroundColor == Colors.White) ? 10 : 5
            };
            PackStart(ComponentContent, expand: true);

            // Bind handler
            Type.SelectionChanged += Type_SelectionChanged;

            // Select text default
            Type.SelectedIndex = 0;

            // Prepare occurences
            var type = Occruence.type;
            var fct = Occruence.name;

            if (type == "text")
            {
                Type.SelectedItem = WidgetTypes.TEXT;
            }
            else if (type == "variable")
            {
                Type.SelectedItem = WidgetTypes.VARIABLE;
            }
            else
            {
                if (fct == "randInt")
                {
                    Type.SelectedItem = WidgetTypes.RAND_INT;
                }
                else if (fct == "randString")
                {
                    Type.SelectedItem = WidgetTypes.RAND_STRING;
                }
                else if (fct == "randFloat")
                {
                    Type.SelectedItem = WidgetTypes.RAND_FLOAT;
                }
                else
                {
                    Type.SelectedItem = WidgetTypes.SEQUENCE;
                }
            }

            // Set data
            ((IVariable)ActiveComponent).SetData(Occruence.name, Occruence.arguments);
        }
        private void _initializeComponents()
        {
            // Parent Vbox
            VBox ParentContent = new VBox();

            // Request URL in frame
            Frame RequestUrl = new Frame()
            {
                Label = Director.Properties.Resources.RequestInfoBox,
                Padding = 10
            };
            VBox RequestUrlContent = new VBox();
            RequestUrlContent.PackStart(new Label(Director.Properties.Resources.RequestUrl));
            TextEntry RequestUrlField = new TextEntry()
            {
                Text = ActiveRequest.Url
            };
            RequestUrlContent.PackStart(RequestUrlField, expand: true, fill: true);
            RequestUrlContent.PackStart(InvalidRequestUrl, vpos: WidgetPlacement.End);

            // Method
            RequestUrlContent.PackStart(new Label(Director.Properties.Resources.RequestMethod));
            RequestHttpMethod = new ComboBox();
            RequestHttpMethod.Items.Add(1, "GET");
            RequestHttpMethod.Items.Add(2, "HEAD");
            RequestHttpMethod.Items.Add(3, "POST");
            RequestHttpMethod.Items.Add(4, "PUT");
            RequestHttpMethod.Items.Add(5, "PATCH");
            RequestHttpMethod.Items.Add(6, "DELETE");
            RequestHttpMethod.Items.Add(7, "OPTIONS");
            try
            {
                RequestHttpMethod.SelectedText = ActiveRequest.HTTP_METHOD;
            }
            catch
            {
                RequestHttpMethod.SelectedText = ActiveRequest.HTTP_METHOD = "GET";
            }
            RequestUrlContent.PackStart(RequestHttpMethod);
            RequestHttpMethod.SelectionChanged += delegate
            {
                ActiveRequest.HTTP_METHOD = RequestHttpMethod.SelectedText;
                if (RequestSettings.CurrentTab.Child is OverviewWidget)
                    ((OverviewWidget) RequestSettings.CurrentTab.Child).RefreshOverview();
            };

            // Wait in seconds
            RequestUrlContent.PackStart(new Label(Director.Properties.Resources.WaitPreviousRequest));
            TextEntry WaitTime = new TextEntry()
            {
                Text = ActiveRequest.WaitAfterPreviousRequest + ""
            };
            RequestUrlContent.PackStart(WaitTime, expand: true, fill: true);
            RequestUrlContent.PackStart(InvalidTime, vpos: WidgetPlacement.End);
            WaitTime.Changed += delegate
            {
                try
                {
                    ActiveRequest.WaitAfterPreviousRequest = int.Parse(WaitTime.Text);

                    if (ActiveRequest.WaitAfterPreviousRequest < 0)
                    {
                        ActiveRequest.WaitAfterPreviousRequest = 0;
                        WaitTime.Text = "0";
                        throw new InvalidCastException();
                    }

                    InvalidTime.Visible = false;
                }
                catch
                {
                    InvalidTime.Visible = true;
                }
            };

            // Repeat count
            RequestUrlContent.PackStart(new Label(Director.Properties.Resources.NumberOfCallRepeats));
            TextEntry RepeatCounter = new TextEntry()
            {
                Text = ActiveRequest.RepeatsCounter + ""
            };
            RequestUrlContent.PackStart(RepeatCounter, expand: true, fill: true);
            RequestUrlContent.PackStart(InvalidRepeatCount, vpos: WidgetPlacement.End);
            RepeatCounter.Changed += delegate
            {
                try
                {
                    ActiveRequest.RepeatsCounter = int.Parse(RepeatCounter.Text);

                    if (ActiveRequest.RepeatsCounter < 0)
                    {
                        ActiveRequest.RepeatsCounter = 0;
                        RepeatCounter.Text = "0";
                        throw new InvalidCastException();
                    }

                    InvalidRepeatCount.Visible = false;
                }
                catch
                {
                    InvalidRepeatCount.Visible = true;
                }
            };

            // Time between repeaters
            RequestUrlContent.PackStart(new Label(Director.Properties.Resources.TimeBetweenRequests));
            TextEntry RequestTimeouts = new TextEntry()
            {
                Text = ActiveRequest.RepeatsTimeout + ""
            };
            RequestUrlContent.PackStart(RequestTimeouts, expand: true, fill: true);
            RequestUrlContent.PackStart(InvalidBetweenRepeatTime, vpos: WidgetPlacement.End);
            RequestTimeouts.Changed += delegate
            {
                try
                {
                    ActiveRequest.RepeatsTimeout = int.Parse(RequestTimeouts.Text);

                    if (ActiveRequest.RepeatsTimeout < 0)
                    {
                        ActiveRequest.RepeatsTimeout = 0;
                        RequestTimeouts.Text = "0";
                        throw new InvalidCastException();
                    }

                    InvalidBetweenRepeatTime.Visible = false;
                }
                catch
                {
                    InvalidBetweenRepeatTime.Visible = true;
                }
            };

            // Set content
            RequestUrl.Content = RequestUrlContent;
            ParentContent.PackStart(RequestUrl, expand: false, fill: true);

            // Change request URL field
            RequestUrlField.Changed += delegate
            {
                try
                {
                    ActiveRequest.SetUrl(RequestUrlField.Text);
                    InvalidRequestUrl.Hide();
                }
                catch
                {
                    InvalidRequestUrl.Show();
                }
                if (RequestSettings.CurrentTab.Child is OverviewWidget)
                    ((OverviewWidget)RequestSettings.CurrentTab.Child).RefreshOverview();
            };

            // Create Notebook
            RequestSettings = new Notebook()
            {
                ExpandHorizontal = true,
                ExpandVertical = true,
                TabOrientation = NotebookTabOrientation.Top
            };
            _initializeTabs();
            RequestSettings.CurrentTabChanged += delegate
            {
                if (RequestSettings.CurrentTab.Child is OverviewWidget)
                    ((OverviewWidget) RequestSettings.CurrentTab.Child).RefreshOverview();
            };
            ParentContent.PackStart(RequestSettings, true, true);

            // Close btn
            Button ConfirmButton = new Button(Image.FromResource(DirectorImages.OK_ICON),
                Director.Properties.Resources.Confirm)
            {
                WidthRequest = 150,
                ExpandHorizontal = false,
                ExpandVertical = false
            };
            ConfirmButton.Clicked += delegate { Close(); };
            ParentContent.PackStart(ConfirmButton, expand: false, hpos: WidgetPlacement.End);

            // Set content
            Content = ParentContent;
        }
Exemple #18
0
        public OptionView(LauncherWindow window)
        {
            _texturePacks = new List<TexturePack>();
            _lastTexturePack = null;

            Window = window;
            this.MinWidth = 250;

            OptionLabel = new Label("Options")
            {
                Font = Font.WithSize(16),
                TextAlignment = Alignment.Center
            };

            ResolutionLabel = new Label("Select a resolution...");
            ResolutionComboBox = new ComboBox();

            int resolutionIndex = -1;
            for (int i = 0; i < WindowResolution.Defaults.Length; i++)
            {
                ResolutionComboBox.Items.Add(WindowResolution.Defaults[i].ToString());

                if (resolutionIndex == -1)
                {
                    resolutionIndex =
                        ((WindowResolution.Defaults[i].Width == UserSettings.Local.WindowResolution.Width) &&
                        (WindowResolution.Defaults[i].Height == UserSettings.Local.WindowResolution.Height)) ? i : -1;
                }
            }

            if (resolutionIndex == -1)
            {
                ResolutionComboBox.Items.Add(UserSettings.Local.WindowResolution.ToString());
                resolutionIndex = ResolutionComboBox.Items.Count - 1;
            }

            ResolutionComboBox.SelectedIndex = resolutionIndex;
            FullscreenCheckBox = new CheckBox()
            {
                Label = "Fullscreen mode",
                State = (UserSettings.Local.IsFullscreen) ? CheckBoxState.On : CheckBoxState.Off
            };

            TexturePackLabel = new Label("Select a texture pack...");
            TexturePackImageField = new DataField<Image>();
            TexturePackTextField = new DataField<string>();
            TexturePackStore = new ListStore(TexturePackImageField, TexturePackTextField);
            TexturePackListView = new ListView
            {
                MinHeight = 200,
                SelectionMode = SelectionMode.Single,
                DataSource = TexturePackStore,
                HeadersVisible = false
            };
            OpenFolderButton = new Button("Open texture pack folder");
            BackButton = new Button("Back");

            TexturePackListView.Columns.Add("Image", TexturePackImageField);
            TexturePackListView.Columns.Add("Text", TexturePackTextField);

            ResolutionComboBox.SelectionChanged += (sender, e) =>
            {
                UserSettings.Local.WindowResolution =
                    WindowResolution.FromString(ResolutionComboBox.SelectedText);
                UserSettings.Local.Save();
            };

            FullscreenCheckBox.Clicked += (sender, e) =>
            {
                UserSettings.Local.IsFullscreen = !UserSettings.Local.IsFullscreen;
                UserSettings.Local.Save();
            };

            TexturePackListView.SelectionChanged += (sender, e) =>
            {
                var texturePack = _texturePacks[TexturePackListView.SelectedRow];
                if (_lastTexturePack != texturePack)
                {
                    UserSettings.Local.SelectedTexturePack = texturePack.Name;
                    UserSettings.Local.Save();
                }
            };

            OpenFolderButton.Clicked += (sender, e) =>
            {
                var dir = new DirectoryInfo(TexturePack.TexturePackPath);
                Process.Start(dir.FullName);
            };

            BackButton.Clicked += (sender, e) =>
            {
                Window.MainContainer.Remove(this);
                Window.MainContainer.PackEnd(Window.MainMenuView);
            };

            OfficialAssetsButton = new Button("Download Minecraft assets") { Visible = false };
            OfficialAssetsButton.Clicked += OfficialAssetsButton_Clicked;
            OfficialAssetsProgress = new ProgressBar() { Visible = false, Indeterminate = true };

            LoadTexturePacks();

            this.PackStart(OptionLabel);
            this.PackStart(ResolutionLabel);
            this.PackStart(ResolutionComboBox);
            this.PackStart(FullscreenCheckBox);
            this.PackStart(TexturePackLabel);
            this.PackStart(TexturePackListView);
            this.PackStart(OfficialAssetsProgress);
            this.PackStart(OfficialAssetsButton);
            this.PackStart(OpenFolderButton);
            this.PackEnd(BackButton);
        }
		public DotNetRunConfigurationEditorWidget ()
		{
			VBox mainBox = new VBox ();

			mainBox.Margin = 12;
			mainBox.PackStart (new Label { Markup = GettextCatalog.GetString ("Start Action") });
			var table = new Table ();
			
			table.Add (radioStartProject = new RadioButton (GettextCatalog.GetString ("Start project")), 0, 0);
			table.Add (radioStartApp = new RadioButton (GettextCatalog.GetString ("Start external program:")), 0, 1);
			table.Add (appEntry = new Xwt.FileSelector (), 1, 1, hexpand: true);
			table.Add (appEntryInfoIcon = new InformationPopoverWidget (), 2, 1);
			appEntryInfoIcon.Hide ();
			radioStartProject.Group = radioStartApp.Group;
			table.MarginLeft = 12;
			mainBox.PackStart (table);

			mainBox.PackStart (new HSeparator () { MarginTop = 8, MarginBottom = 8 });
			table = new Table ();

			table.Add (new Label (GettextCatalog.GetString ("Arguments:")), 0, 0);
			table.Add (argumentsEntry = new TextEntry (), 1, 0, hexpand:true);

			table.Add (new Label (GettextCatalog.GetString ("Run in directory:")), 0, 1);
			table.Add (workingDir = new FolderSelector (), 1, 1, hexpand: true);
		
			mainBox.PackStart (table);

			mainBox.PackStart (new HSeparator () { MarginTop = 8, MarginBottom = 8 });

			mainBox.PackStart (new Label (GettextCatalog.GetString ("Environment Variables")));
			envVars = new EnvironmentVariableCollectionEditor ();

			mainBox.PackStart (envVars, true);

			mainBox.PackStart (new HSeparator () { MarginTop = 8, MarginBottom = 8 });

			HBox cbox = new HBox ();
			cbox.PackStart (externalConsole = new CheckBox (GettextCatalog.GetString ("Run on external console")));
			cbox.PackStart (pauseConsole = new CheckBox (GettextCatalog.GetString ("Pause console output")));
			mainBox.PackStart (cbox);

			Add (mainBox, GettextCatalog.GetString ("General"));

			var adBox = new VBox ();
			adBox.Margin = 12;

			table = new Table ();
			table.Add (new Label (GettextCatalog.GetString ("Execute in .NET Runtime:")), 0, 0);
			table.Add (runtimesCombo = new ComboBox (), 1, 0, hexpand:true);

			table.Add (new Label (GettextCatalog.GetString ("Mono runtime settings:")), 0, 1);

			var box = new HBox ();
			Button monoSettingsButton = new Button (GettextCatalog.GetString ("..."));
			box.PackStart (monoSettingsEntry = new TextEntry { PlaceholderText = GettextCatalog.GetString ("Default settings")}, true);
			box.PackStart (monoSettingsButton);
			monoSettingsEntry.ReadOnly = true;
			table.Add (box, 1, 1, hexpand: true);
			adBox.PackStart (table);

			Add (adBox, GettextCatalog.GetString ("Advanced"));

			monoSettingsButton.Clicked += EditRuntimeClicked;
			radioStartProject.ActiveChanged += (sender, e) => UpdateStatus ();
			externalConsole.Toggled += (sender, e) => UpdateStatus ();

			LoadRuntimes ();

			appEntry.FileChanged += (sender, e) => NotifyChanged ();
			argumentsEntry.Changed += (sender, e) => NotifyChanged ();
			workingDir.FolderChanged += (sender, e) => NotifyChanged ();
			envVars.Changed += (sender, e) => NotifyChanged ();
			externalConsole.Toggled += (sender, e) => NotifyChanged ();
			pauseConsole.Toggled += (sender, e) => NotifyChanged ();
			runtimesCombo.SelectionChanged += (sender, e) => NotifyChanged ();
			monoSettingsEntry.Changed += (sender, e) => NotifyChanged ();

		}
Exemple #20
0
        public override Widget ToWidget()
        {
            ComboBox combo = new ComboBox();
            foreach (var v in values) {
                combo.Items.Add(v);
            }

            if (string.IsNullOrEmpty(val)) {
                combo.SelectedIndex = 0;
            } else {
                try {
                    combo.SelectedItem = val;
                } catch (Exception e) {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
                }
            }

            return combo;
        }
        /// <summary>
        /// Init.
        /// </summary>
        void _initializeComponents()
        {
            // Create content box
            VBox ContentBox = new VBox ();

            // Create Item count
            ItemCount = new RadioButton (Director.Properties.Resources.CompareItemCount);
            ContentBox.PackStart (ItemCount);

            // Create All item template
            AllItemsTemplate = new RadioButton (Director.Properties.Resources.CompareAllArrayItem);
            ContentBox.PackStart (AllItemsTemplate);

            // Set group
            ItemCount.Group = AllItemsTemplate.Group;
            ItemCount.Group.ActiveRadioButtonChanged += CompareTypeChanged_Event;

            // Type
            ContentBox.PackStart (new Label (Director.Properties.Resources.FormatType) { Font = Font.SystemFont.WithWeight (FontWeight.Bold) }, true, false);

            // Combo box
            FormatTypeSelect = new ComboBox ();

            // Add items
            FormatTypeSelect.Items.Add ("string", "String");
            FormatTypeSelect.Items.Add ("integer", "Integer");
            FormatTypeSelect.Items.Add ("real", "Real");
            FormatTypeSelect.Items.Add ("boolean", "Boolean");
            FormatTypeSelect.SelectionChanged += FormatTypeSelectionChanged;
            ContentBox.PackStart (FormatTypeSelect, true, false);

            // Operations
            ContentBox.PackStart (new Label (Director.Properties.Resources.Operation) { Font = Font.SystemFont.WithWeight (FontWeight.Bold) }, true, false);
            FormatOperationsSelect = new ComboBox ();
            FormatOperationsSelect.Items.Add("ip_", Director.Properties.Resources.PresentsTest);
            FormatOperationsSelect.Items.Add("eq", Director.Properties.Resources.OperationEquals);
            FormatOperationsSelect.Items.Add("ne", Director.Properties.Resources.OperationNotEquals);
            FormatOperationsSelect.Items.Add("lte", Director.Properties.Resources.OperationLessThanOrEquals);
            FormatOperationsSelect.Items.Add("gt", Director.Properties.Resources.OperationGreatherThan);
            FormatOperationsSelect.Items.Add("gte", Director.Properties.Resources.OperationGreatherThanOrEqual);
            FormatOperationsSelect.Items.Add("mp", Director.Properties.Resources.OperationMatchingRegex);
            FormatOperationsSelect.SelectedIndex = 0;

            // Select - fill combo box
            FormatTypeSelect.SelectedIndex = 0;

            // Add
            ContentBox.PackStart (FormatOperationsSelect, true, false);

            // Create items
            UseVariable = new CheckBox (Director.Properties.Resources.VariableInsteadConditionValue);
            ContentBox.PackStart (UseVariable, true, false);

            // Evaluate this if present
            EvalIfPresent = new CheckBox (Director.Properties.Resources.EvaluateConditionIfParameterIsPresent);
            ContentBox.PackStart (EvalIfPresent, true, false);

            // Value
            ContentBox.PackStart (new Label (Director.Properties.Resources.ConditionValue) { Font = Font.SystemFont.WithWeight (FontWeight.Bold) }, true, false);
            ConditionValue = new TextEntry ();
            ContentBox.PackStart (ConditionValue, true, false);

            // Save to variable
            ContentBox.PackStart (new Label (Director.Properties.Resources.SaveToVariable) { Font = Font.SystemFont.WithWeight (FontWeight.Bold) }, true, false);
            SaveToVariable = new TextEntry ();
            ContentBox.PackStart (SaveToVariable, true, false);

            // Set active
            ItemCount.Active = true;

            // Set content
            Content = ContentBox;
        }
		ComboBox MakeSelector (IGroupingProvider selectedProvider)
		{
			var combo = new ComboBox ();
			combo.Items.Add (typeof(NullGroupingProvider), "Nothing");
			combo.Items.Add (ItemSeparator.Instance);
			foreach (var providerType in availableProviders) {
				var metadata = (GroupingDescriptionAttribute)providerType.GetCustomAttributes (false).FirstOrDefault (attr => attr is GroupingDescriptionAttribute);
				if (metadata == null) {
					LoggingService.LogWarning ("Grouping provider '{0}' does not have a metadata attribute, ignoring provider.", providerType.FullName);
					continue;
				}
				combo.Items.Add (providerType, metadata.Title);
			}
			if (selectedProvider != null) {
				combo.SelectedItem = selectedProvider.GetType ();
			} else {
				combo.SelectedItem = typeof(NullGroupingProvider);
			}
			return combo;
		}
Exemple #23
0
        public ComboBoxes()
        {
            HBox box = new HBox ();
            ComboBox c = new ComboBox ();
            c.Items.Add ("One");
            c.Items.Add ("Two");
            c.Items.Add ("Three");
            c.SelectedIndex = 1;
            box.PackStart (c);
            Label la = new Label ();
            box.PackStart (la);
            c.SelectionChanged += delegate {
                la.Text = "Selected: " + (string)c.SelectedItem;
            };
            PackStart (box);

            box = new HBox ();
            ComboBox c2 = new ComboBox ();
            box.PackStart (c2);
            Button b = new Button ("Fill combo (should grow)");
            box.PackStart (b);
            b.Clicked += delegate {
                for (int n=0; n<10; n++) {
                    c2.Items.Add ("Item " + new string ('#', n));
                }
            };
            PackStart (box);

            // Combo with custom labels

            box = new HBox ();
            ComboBox c3 = new ComboBox ();
            c3.Items.Add (0, "Combo with custom labels");
            c3.Items.Add (1, "One");
            c3.Items.Add (2, "Two");
            c3.Items.Add (3, "Three");
            c3.Items.Add (ItemSeparator.Instance);
            c3.Items.Add (4, "Maybe more");
            var la3 = new Label ();
            box.PackStart (c3);
            box.PackStart (la3);
            c3.SelectionChanged += delegate {
                la3.Text = string.Format ("Selected item: {0} with label {1}",
                                          c3.SelectedItem,
                                          c3.SelectedText);
            };
            PackStart (box);

            box = new HBox ();
            var c4 = new ComboBoxEntry ();
            var la4 = new Label ();
            box.PackStart (c4);
            box.PackStart (la4);

            c4.Items.Add (1, "One");
            c4.Items.Add (2, "Two");
            c4.Items.Add (3, "Three");
            c4.TextEntry.PlaceholderText = "This is an entry";
            c4.TextEntry.Changed += delegate {
                la4.Text = "Selected text: " + c4.TextEntry.Text;
            };
            PackStart (box);

            // A complex combobox

            // Three data fields
            var imgField = new DataField<Image> ();
            var textField = new DataField<string> ();
            var descField = new DataField<string> ();

            ComboBox cbox = new ComboBox ();
            ListStore store = new ListStore (textField, imgField, descField);

            cbox.ItemsSource = store;
            var r = store.AddRow ();
            store.SetValue (r, textField, "Information");
            store.SetValue (r, descField, "Icons are duplicated on purpose");
            store.SetValue (r, imgField, Image.FromIcon (StockIcons.Information, IconSize.Small));
            r = store.AddRow ();
            store.SetValue (r, textField, "Error");
            store.SetValue (r, descField, "Another item");
            store.SetValue (r, imgField, Image.FromIcon (StockIcons.Error, IconSize.Small));
            r = store.AddRow ();
            store.SetValue (r, textField, "Warning");
            store.SetValue (r, descField, "A third item");
            store.SetValue (r, imgField, Image.FromIcon (StockIcons.Warning, IconSize.Small));

            // Four views to show three data fields
            cbox.Views.Add (new ImageCellView (imgField));
            cbox.Views.Add (new TextCellView (textField));
            cbox.Views.Add (new ImageCellView (imgField));
            cbox.Views.Add (new TextCellView (descField));

            cbox.SelectedIndex = 0;

            PackStart (cbox);
        }
		void Build ()
		{
			Title = Catalog.GetString ("Add Packages");
			Width = 820;
			Height = 520;
			Padding = new WidgetSpacing ();

			// Top part of dialog:
			// Package sources and search.
			var topHBox = new HBox ();
			topHBox.Margin = new WidgetSpacing (8, 5, 6, 5);

			packageSourceComboBox = new ComboBox ();
			packageSourceComboBox.MinWidth = 200;
			topHBox.PackStart (packageSourceComboBox);

			packageSearchEntry = new SearchTextEntry ();
			packageSearchEntry.WidthRequest = 187;
			topHBox.PackEnd (packageSearchEntry);

			this.HeaderContent = topHBox;

			// Middle of dialog:
			// Packages and package information.
			var mainVBox = new VBox ();
			Content = mainVBox;

			var middleHBox = new HBox ();
			middleHBox.Spacing = 0;
			var middleFrame = new FrameBox ();
			middleFrame.Content = middleHBox;
			middleFrame.BorderWidth = new WidgetSpacing (0, 0, 0, 1);
			middleFrame.BorderColor = lineBorderColor;
			mainVBox.PackStart (middleFrame, true, true);

			// Error information.
			var packagesListVBox = new VBox ();
			packagesListVBox.Spacing = 0;
			errorMessageHBox = new HBox ();
			errorMessageHBox.Margin = new WidgetSpacing ();
			errorMessageHBox.BackgroundColor = Colors.Orange;
			errorMessageHBox.Visible = false;
			var errorImage = new ImageView ();
			errorImage.Margin = new WidgetSpacing (10, 0, 0, 0);
			errorImage.Image = ImageService.GetIcon (Stock.Warning, Gtk.IconSize.Menu);
			errorImage.HorizontalPlacement = WidgetPlacement.End;
			errorMessageHBox.PackStart (errorImage);
			errorMessageLabel = new Label ();
			errorMessageLabel.TextColor = Colors.White;
			errorMessageLabel.Margin = new WidgetSpacing (5, 5, 5, 5);
			errorMessageLabel.Wrap = WrapMode.Word;
			errorMessageHBox.PackStart (errorMessageLabel, true);
			packagesListVBox.PackStart (errorMessageHBox);

			// Packages list.
			middleHBox.PackStart (packagesListVBox, true, true);
			packagesListView = new ListView ();
			packagesListView.BorderVisible = false;
			packagesListView.HeadersVisible = false;
			packagesListVBox.PackStart (packagesListView, true, true);

			// Loading spinner.
			var loadingSpinnerHBox = new HBox ();
			loadingSpinnerHBox.HorizontalPlacement = WidgetPlacement.Center;
			var loadingSpinner = new Spinner ();
			loadingSpinner.Animate = true;
			loadingSpinner.MinWidth = 20;
			loadingSpinnerHBox.PackStart (loadingSpinner);

			loadingSpinnerLabel = new Label ();
			loadingSpinnerLabel.Text = Catalog.GetString ("Loading package list...");
			loadingSpinnerHBox.PackEnd (loadingSpinnerLabel);

			loadingSpinnerFrame = new FrameBox ();
			loadingSpinnerFrame.Visible = false;
			loadingSpinnerFrame.BackgroundColor = Colors.White;
			loadingSpinnerFrame.Content = loadingSpinnerHBox;
			loadingSpinnerFrame.BorderWidth = new WidgetSpacing ();
			packagesListVBox.PackStart (loadingSpinnerFrame, true, true);

			// No packages found label.
			var noPackagesFoundHBox = new HBox ();
			noPackagesFoundHBox.HorizontalPlacement = WidgetPlacement.Center;

			var noPackagesFoundLabel = new Label ();
			noPackagesFoundLabel.Text = Catalog.GetString ("No matching packages found.");
			noPackagesFoundHBox.PackEnd (noPackagesFoundLabel);

			noPackagesFoundFrame = new FrameBox ();
			noPackagesFoundFrame.Visible = false;
			noPackagesFoundFrame.BackgroundColor = Colors.White;
			noPackagesFoundFrame.Content = noPackagesFoundHBox;
			noPackagesFoundFrame.BorderWidth = new WidgetSpacing ();
			packagesListVBox.PackStart (noPackagesFoundFrame, true, true);

			// Package information
			packageInfoVBox = new VBox ();
			var packageInfoFrame = new FrameBox ();
			packageInfoFrame.BackgroundColor = packageInfoBackgroundColor;
			packageInfoFrame.BorderWidth = new WidgetSpacing ();
			packageInfoFrame.Content = packageInfoVBox;
			packageInfoVBox.Margin = new WidgetSpacing (15, 12, 15, 12);
			var packageInfoContainerVBox = new VBox ();
			packageInfoContainerVBox.WidthRequest = 240;
			packageInfoContainerVBox.PackStart (packageInfoFrame, true, true);

			var packageInfoScrollView = new ScrollView ();
			packageInfoScrollView.BorderVisible = false;
			packageInfoScrollView.HorizontalScrollPolicy = ScrollPolicy.Never;
			packageInfoScrollView.Content = packageInfoContainerVBox;
			packageInfoScrollView.BackgroundColor = packageInfoBackgroundColor;
			var packageInfoScrollViewFrame = new FrameBox ();
			packageInfoScrollViewFrame.BackgroundColor = packageInfoBackgroundColor;
			packageInfoScrollViewFrame.BorderWidth = new WidgetSpacing (1, 0, 0, 0);
			packageInfoScrollViewFrame.BorderColor = lineBorderColor;
			packageInfoScrollViewFrame.Content = packageInfoScrollView;
			middleHBox.PackEnd (packageInfoScrollViewFrame);

			// Package name and version.
			var packageNameHBox = new HBox ();
			packageInfoVBox.PackStart (packageNameHBox);

			packageNameLabel = new Label ();
			packageNameLabel.Ellipsize = EllipsizeMode.End;
			Font packageInfoSmallFont = packageNameLabel.Font.WithScaledSize (0.8);
			packageNameHBox.PackStart (packageNameLabel, true);

			packageVersionLabel = new Label ();
			packageVersionLabel.TextAlignment = Alignment.End;
			packageNameHBox.PackEnd (packageVersionLabel);

			// Package description.
			packageDescription = new Label ();
			packageDescription.Wrap = WrapMode.Word;
			packageDescription.Font = packageNameLabel.Font.WithScaledSize (0.9);
			packageDescription.BackgroundColor = packageInfoBackgroundColor;
			packageInfoVBox.PackStart (packageDescription);

			// Package id.
			var packageIdHBox = new HBox ();
			packageIdHBox.MarginTop = 7;
			packageInfoVBox.PackStart (packageIdHBox);

			var packageIdLabel = new Label ();
			packageIdLabel.Font = packageInfoSmallFont;
			packageIdLabel.Markup = Catalog.GetString ("<b>Id</b>");
			packageIdHBox.PackStart (packageIdLabel);

			packageId = new Label ();
			packageId.Ellipsize = EllipsizeMode.End;
			packageId.TextAlignment = Alignment.End;
			packageId.Font = packageInfoSmallFont;
			packageIdLink = new LinkLabel ();
			packageIdLink.Ellipsize = EllipsizeMode.End;
			packageIdLink.TextAlignment = Alignment.End;
			packageIdLink.Font = packageInfoSmallFont;
			packageIdHBox.PackEnd (packageIdLink, true);
			packageIdHBox.PackEnd (packageId, true);

			// Package author
			var packageAuthorHBox = new HBox ();
			packageInfoVBox.PackStart (packageAuthorHBox);

			var packageAuthorLabel = new Label ();
			packageAuthorLabel.Markup = Catalog.GetString ("<b>Author</b>");
			packageAuthorLabel.Font = packageInfoSmallFont;
			packageAuthorHBox.PackStart (packageAuthorLabel);

			packageAuthor = new Label ();
			packageAuthor.TextAlignment = Alignment.End;
			packageAuthor.Ellipsize = EllipsizeMode.End;
			packageAuthor.Font = packageInfoSmallFont;
			packageAuthorHBox.PackEnd (packageAuthor, true);

			// Package published
			var packagePublishedHBox = new HBox ();
			packageInfoVBox.PackStart (packagePublishedHBox);

			var packagePublishedLabel = new Label ();
			packagePublishedLabel.Markup = Catalog.GetString ("<b>Published</b>");
			packagePublishedLabel.Font = packageInfoSmallFont;
			packagePublishedHBox.PackStart (packagePublishedLabel);

			packagePublishedDate = new Label ();
			packagePublishedDate.Font = packageInfoSmallFont;
			packagePublishedHBox.PackEnd (packagePublishedDate);

			// Package downloads
			var packageDownloadsHBox = new HBox ();
			packageInfoVBox.PackStart (packageDownloadsHBox);

			var packageDownloadsLabel = new Label ();
			packageDownloadsLabel.Markup = Catalog.GetString ("<b>Downloads</b>");
			packageDownloadsLabel.Font = packageInfoSmallFont;
			packageDownloadsHBox.PackStart (packageDownloadsLabel);

			packageDownloads = new Label ();
			packageDownloads.Font = packageInfoSmallFont;
			packageDownloadsHBox.PackEnd (packageDownloads);

			// Package license.
			var packageLicenseHBox = new HBox ();
			packageInfoVBox.PackStart (packageLicenseHBox);

			var packageLicenseLabel = new Label ();
			packageLicenseLabel.Markup = Catalog.GetString ("<b>License</b>");
			packageLicenseLabel.Font = packageInfoSmallFont;
			packageLicenseHBox.PackStart (packageLicenseLabel);

			packageLicenseLink = new LinkLabel ();
			packageLicenseLink.Text = Catalog.GetString ("View License");
			packageLicenseLink.Font = packageInfoSmallFont;
			packageLicenseHBox.PackEnd (packageLicenseLink);

			// Package project page.
			var packageProjectPageHBox = new HBox ();
			packageInfoVBox.PackStart (packageProjectPageHBox);

			var packageProjectPageLabel = new Label ();
			packageProjectPageLabel.Markup = Catalog.GetString ("<b>Project Page</b>");
			packageProjectPageLabel.Font = packageInfoSmallFont;
			packageProjectPageHBox.PackStart (packageProjectPageLabel);

			packageProjectPageLink = new LinkLabel ();
			packageProjectPageLink.Text = Catalog.GetString ("Visit Page");
			packageProjectPageLink.Font = packageInfoSmallFont;
			packageProjectPageHBox.PackEnd (packageProjectPageLink);

			// Package dependencies
			var packageDependenciesHBox = new HBox ();
			packageInfoVBox.PackStart (packageDependenciesHBox);

			var packageDependenciesLabel = new Label ();
			packageDependenciesLabel.Markup = Catalog.GetString ("<b>Dependencies</b>");
			packageDependenciesLabel.Font = packageInfoSmallFont;
			packageDependenciesHBox.PackStart (packageDependenciesLabel);

			packageDependenciesNoneLabel = new Label ();
			packageDependenciesNoneLabel.Text = Catalog.GetString ("None");
			packageDependenciesNoneLabel.Font = packageInfoSmallFont;
			packageDependenciesHBox.PackEnd (packageDependenciesNoneLabel);

			// Package dependencies list.
			packageDependenciesListHBox = new HBox ();
			packageDependenciesListHBox.Visible = false;
			packageInfoVBox.PackStart (packageDependenciesListHBox);

			packageDependenciesList = new Label ();
			packageDependenciesList.Wrap = WrapMode.WordAndCharacter;
			packageDependenciesList.Margin = new WidgetSpacing (5);
			packageDependenciesList.Font = packageInfoSmallFont;
			packageDependenciesListHBox.PackStart (packageDependenciesList, true);

			// Bottom part of dialog:
			// Show pre-release packages and Close/Add to Project buttons.
			var bottomHBox = new HBox ();
			bottomHBox.Margin = new WidgetSpacing (8, 5, 14, 10);
			bottomHBox.Spacing = 5;
			mainVBox.PackStart (bottomHBox);

			showPrereleaseCheckBox = new CheckBox ();
			showPrereleaseCheckBox.Label = Catalog.GetString ("Show pre-release packages");
			bottomHBox.PackStart (showPrereleaseCheckBox);

			addPackagesButton = new Button ();
			addPackagesButton.MinWidth = 120;
			addPackagesButton.MinHeight = 25;
			addPackagesButton.Label = Catalog.GetString ("Add Package");
			bottomHBox.PackEnd (addPackagesButton);

			var closeButton = new Button ();
			closeButton.MinWidth = 120;
			closeButton.MinHeight = 25;
			closeButton.Label = Catalog.GetString ("Close");
			closeButton.Clicked += (sender, e) => Close ();
			bottomHBox.PackEnd (closeButton);

			packageSearchEntry.SetFocus ();
			packageInfoVBox.Visible = false;
		}
        /// <summary>
        /// Init components.
        /// </summary>
        private void _initializeComponents()
        {
            VBox ContentBox = new VBox();

            // First value
            Value = new RadioButton(Director.Properties.Resources.JsonValue);
            ContentBox.PackStart(Value);

            // Horizontal
            HBox ValueBox = new HBox();

            // Options
            ValueType = new ComboBox()
            {
                WidthRequest = 80
            };
            ValueType.Items.Add(DataType.TYPE_STRING, "String");
            ValueType.Items.Add(DataType.TYPE_INT, "Integer");
            ValueType.Items.Add(DataType.TYPE_DOUBLE, "Double");
            ValueType.Items.Add(DataType.TYPE_NULL, "Null");
            ValueType.Items.Add(DataType.TYPE_BOOL, "Boolean");
            ValueType.SelectedIndex = 0;
            ValueBox.PackStart(ValueType, false, false);

            // Value
            ValueText = new TextEntry();
            ValueBox.PackStart(ValueText, true, true);
            ContentBox.PackStart(ValueBox);

            // Guide
            Format = new RadioButton(Director.Properties.Resources.FormatGuide);
            ContentBox.PackStart(Format);
            Value.Group = Format.Group;
            Value.Active = true;
            Value.Group.ActiveRadioButtonChanged += GroupChanged_Event;

            // Type
            ContentBox.PackStart (new Label (Director.Properties.Resources.FormatType) { Font = Font.SystemFont.WithWeight (FontWeight.Bold) }, true, false);

            // Combo box
            FormatTypeSelect = new ComboBox ();

            // Add items
            FormatTypeSelect.Items.Add ("string", "String");
            FormatTypeSelect.Items.Add ("integer", "Integer");
            FormatTypeSelect.Items.Add ("real", "Real");
            FormatTypeSelect.Items.Add ("boolean", "Boolean");
            FormatTypeSelect.SelectionChanged += delegate {
                var selectedItem = FormatOperationsSelect.SelectedItem;

                FormatOperationsSelect.Items.Clear();

                // Always
                FormatOperationsSelect.Items.Add("ip_", Director.Properties.Resources.PresentsTest);
                FormatOperationsSelect.Items.Add("eq", Director.Properties.Resources.OperationEquals);
                FormatOperationsSelect.Items.Add("ne", Director.Properties.Resources.OperationNotEquals);

                if (((String)FormatTypeSelect.SelectedItem) != "boolean") {
                    FormatOperationsSelect.Items.Add ("lt", Director.Properties.Resources.OperationLessThan);
                    FormatOperationsSelect.Items.Add("lte", Director.Properties.Resources.OperationLessThanOrEquals);
                    FormatOperationsSelect.Items.Add("gt", Director.Properties.Resources.OperationGreatherThan);
                    FormatOperationsSelect.Items.Add("gte", Director.Properties.Resources.OperationGreatherThanOrEqual);

                    if (((String)FormatTypeSelect.SelectedItem) == "string")
                        FormatOperationsSelect.Items.Add ("mp", Director.Properties.Resources.OperationMatchingRegex);
                }

                FormatOperationsSelect.SelectedItem = selectedItem;
                if (FormatOperationsSelect.SelectedIndex == -1)
                    FormatOperationsSelect.SelectedIndex = 0;
            };
            ContentBox.PackStart (FormatTypeSelect, true, false);

            // Operations
            ContentBox.PackStart (new Label (Director.Properties.Resources.Operation) { Font = Font.SystemFont.WithWeight (FontWeight.Bold) }, true, false);
            FormatOperationsSelect = new ComboBox ();
            FormatOperationsSelect.Items.Add("ip_", Director.Properties.Resources.PresentsTest);
            FormatOperationsSelect.Items.Add("eq", Director.Properties.Resources.OperationEquals);
            FormatOperationsSelect.Items.Add("ne", Director.Properties.Resources.OperationNotEquals);
            FormatOperationsSelect.Items.Add("lt", Director.Properties.Resources.OperationLessThan);
            FormatOperationsSelect.Items.Add("lte", Director.Properties.Resources.OperationLessThanOrEquals);
            FormatOperationsSelect.Items.Add("gt", Director.Properties.Resources.OperationGreatherThan);
            FormatOperationsSelect.Items.Add("gte", Director.Properties.Resources.OperationGreatherThanOrEqual);
            FormatOperationsSelect.Items.Add("mp", Director.Properties.Resources.OperationMatchingRegex);
            FormatOperationsSelect.SelectedIndex = 0;

            // Select - fill combo box
            FormatTypeSelect.SelectedIndex = 0;

            // Add
            ContentBox.PackStart (FormatOperationsSelect, true, false);

            // Use variable instead of value
            UseVariable = new CheckBox(Director.Properties.Resources.UseVarInsteadOfValue);
            ContentBox.PackStart (UseVariable, true, false);

            // Evaluate this if present
            EvalIfPresent = new CheckBox(Director.Properties.Resources.EvalCondIfParIsPresent);
            ContentBox.PackStart (EvalIfPresent, true, false);

            // Value
            ContentBox.PackStart(new Label(Director.Properties.Resources.ConditionValue) { Font = Font.SystemFont.WithWeight(FontWeight.Bold) }, true, false);
            ConditionValue = new TextEntry ();
            ContentBox.PackStart (ConditionValue, true, false);

            // Save to variable
            ContentBox.PackStart(new Label(Director.Properties.Resources.SaveToVariable) { Font = Font.SystemFont.WithWeight(FontWeight.Bold) }, true, false);
            SaveToVariable = new TextEntry ();
            ContentBox.PackStart (SaveToVariable, true, false);

            // Change selection
            FormatOperationsSelect.SelectionChanged += delegate
            {
                string item = (String)FormatOperationsSelect.SelectedItem;

                if (item == "ip_")
                {
                    UseVariable.Sensitive = false;
                    ConditionValue.Sensitive = false;
                    EvalIfPresent.Sensitive = false;
                }
                else
                {
                    UseVariable.Sensitive = true;
                    ConditionValue.Sensitive = true;
                    EvalIfPresent.Sensitive = true;
                }
            };

            // Content
            Content = ContentBox;
        }
Exemple #26
0
		public ComboBoxes ()
		{
			HBox box = new HBox ();
			ComboBox c = new ComboBox ();
			c.Items.Add ("One");
			c.Items.Add ("Two");
			c.Items.Add ("Three");
			c.SelectedIndex = 1;
			box.PackStart (c);
			Label la = new Label ();
			box.PackStart (la);
			c.SelectionChanged += delegate {
				la.Text = "Selected: " + (string)c.SelectedItem;
			};
			PackStart (box);
			
			box = new HBox ();
			ComboBox c2 = new ComboBox ();
			box.PackStart (c2);
			Button b = new Button ("Fill combo (should grow)");
			box.PackStart (b);
			b.Clicked += delegate {
				for (int n=0; n<10; n++) {
					c2.Items.Add ("Item " + new string ('#', n));
				}
			};
			PackStart (box);
			
			// Combo with custom labels
			
			box = new HBox ();
			ComboBox c3 = new ComboBox ();
			c3.Items.Add (0, "Combo with custom labels");
			c3.Items.Add (1, "One");
			c3.Items.Add (2, "Two");
			c3.Items.Add (3, "Three");
			c3.Items.Add (ItemSeparator.Instance);
			c3.Items.Add (4, "Maybe more");
			var la3 = new Label ();
			box.PackStart (c3);
			box.PackStart (la3);
			c3.SelectionChanged += delegate {
				la3.Text = string.Format ("Selected item: {0} with label {1}",
				                          c3.SelectedItem,
				                          c3.SelectedText);
			};
			PackStart (box);
			
			box = new HBox ();
			var c4 = new ComboBoxEntry ();
			var la4 = new Label ();
			box.PackStart (c4);
			box.PackStart (la4);
			
			c4.Items.Add (1, "One");
			c4.Items.Add (2, "Two");
			c4.Items.Add (3, "Three");
			c4.TextEntry.PlaceholderText = "This is an entry";
			c4.TextEntry.Changed += delegate {
				la4.Text = "Selected text: " + c4.TextEntry.Text;
			};
			PackStart (box);

			HBox selBox = new HBox ();
			Label las = new Label ("Selection:");
			selBox.PackStart (las);
			Button selReplace = new Button ("Replace");
			selReplace.Clicked += delegate {
				c4.TextEntry.SelectedText = "[TEST]";
			};
			selBox.PackEnd (selReplace);
			Button selAll = new Button ("Select all");
			selAll.Clicked += delegate {
				c4.TextEntry.SelectionStart = 0;
				c4.TextEntry.SelectionLength = c4.TextEntry.Text.Length;
			};
			selBox.PackEnd (selAll);
			Button selPlus = new Button ("+");
			selPlus.Clicked += delegate {
				c4.TextEntry.SelectionLength++;
			};
			selBox.PackEnd (selPlus);
			Button selRight = new Button (">");
			selRight.Clicked += delegate {
				c4.TextEntry.SelectionStart++;
			};
			selBox.PackEnd (selRight);
			PackStart (selBox);

			c4.TextEntry.SelectionChanged += delegate {
				las.Text = "Selection: (" + c4.TextEntry.CursorPosition + " <-> " + c4.TextEntry.SelectionStart + " + " + c4.TextEntry.SelectionLength + ") " + c4.TextEntry.SelectedText;
			};


			var c5 = new ComboBoxEntry ();
			c5.TextEntry.TextAlignment = Alignment.Center;
			c5.TextEntry.Text = "centered text with red background";
			c5.BackgroundColor = Colors.Red;
			c5.Items.Add (1, "One");
			c5.Items.Add (2, "Two");
			c5.Items.Add (3, "Three");
			PackStart (c5);

			// A complex combobox
			
			// Three data fields
			var imgField = new DataField<Image> ();
			var textField = new DataField<string> ();
			var descField = new DataField<string> ();
			
			ComboBox cbox = new ComboBox ();
			ListStore store = new ListStore (textField, imgField, descField);
			
			cbox.ItemsSource = store;
			var r = store.AddRow ();
			store.SetValue (r, textField, "Information");
			store.SetValue (r, descField, "Icons are duplicated on purpose");
			store.SetValue (r, imgField, StockIcons.Information);
			r = store.AddRow ();
			store.SetValue (r, textField, "Error");
			store.SetValue (r, descField, "Another item");
			store.SetValue (r, imgField, StockIcons.Error);
			r = store.AddRow ();
			store.SetValue (r, textField, "Warning");
			store.SetValue (r, descField, "A third item");
			store.SetValue (r, imgField, StockIcons.Warning);
			
			// Four views to show three data fields
			cbox.Views.Add (new ImageCellView (imgField));
			cbox.Views.Add (new TextCellView (textField));
			cbox.Views.Add (new ImageCellView (imgField));
			cbox.Views.Add (new TextCellView (descField));
			
			cbox.SelectedIndex = 0;
			
			PackStart (cbox);
		}
Exemple #27
0
		public MessageDialogs ()
		{
			Table table = new Table ();

			TextEntry txtPrimay = new TextEntry ();
			TextEntry txtSecondary = new TextEntry ();
			txtSecondary.MultiLine = true;
			ComboBox cmbType = new ComboBox ();
			cmbType.Items.Add ("Message");
			cmbType.Items.Add ("Question");
			cmbType.Items.Add ("Confirmation");
			cmbType.Items.Add ("Warning");
			cmbType.Items.Add ("Error");
			cmbType.SelectedIndex = 0;

			Button btnShowMessage = new Button ("Show Message");

			Label lblResult = new Label ();

			table.Add (new Label ("Primary Text:"), 0, 0);
			table.Add (txtPrimay, 1, 0, hexpand: true);
			table.Add (new Label ("Secondary Text:"), 0, 1);
			table.Add (txtSecondary, 1, 1, hexpand: true);
			table.Add (new Label ("Message Type:"), 0, 2);
			table.Add (cmbType, 1, 2, hexpand: true);

			table.Add (btnShowMessage, 1, 3, hexpand: true);
			table.Add (lblResult, 1, 4, hexpand: true);

			btnShowMessage.Clicked += (sender, e) => {

				switch (cmbType.SelectedText) {
					case "Message":
						MessageDialog.ShowMessage (this.ParentWindow, txtPrimay.Text, txtSecondary.Text);
						lblResult.Text = "Result: dialog closed";
						break;
					case "Question":
						var question = new QuestionMessage(txtPrimay.Text, txtSecondary.Text);
						question.Buttons.Add(new Command("Answer 1"));
						question.Buttons.Add(new Command("Answer 2"));
						question.DefaultButton = 1;
						question.AddOption ("option1", "Option 1", false);
						question.AddOption ("option2", "Option 2", true);
						var result = MessageDialog.AskQuestion (question);
						lblResult.Text = "Result: " + result.Id;
						if (question.GetOptionValue ("option1"))
							lblResult.Text += " + Option 1";
						if (question.GetOptionValue ("option2"))
							lblResult.Text += " + Option 2";
						break;
					case "Confirmation":
						var confirmation = new ConfirmationMessage (txtPrimay.Text, txtSecondary.Text, Command.Apply);
						confirmation.AddOption ("option1", "Option 1", false);
						confirmation.AddOption ("option2", "Option 2", true);
						confirmation.AllowApplyToAll = true;

						var success = MessageDialog.Confirm (confirmation);
						lblResult.Text = "Result: " + success;
						if (confirmation.GetOptionValue ("option1"))
							lblResult.Text += " + Option 1";
						if (confirmation.GetOptionValue ("option2"))
							lblResult.Text += " + Option 2";

						lblResult.Text += " + All: " + confirmation.AllowApplyToAll;
						break;
					case "Warning":
						MessageDialog.ShowWarning (this.ParentWindow, txtPrimay.Text, txtSecondary.Text);
						lblResult.Text = "Result: dialog closed";
						break;
					case "Error":
						MessageDialog.ShowError (this.ParentWindow, txtPrimay.Text, txtSecondary.Text);
						lblResult.Text = "Result: dialog closed";
						break;
				}
			};

			PackStart (table, true);
		}
        /// <summary>
        /// Initialize components.
        /// </summary>
        public override void _initializeComponents()
        {
            Frame f = new Frame()
            {
                Label = Director.Properties.Resources.ScenarioLabel,
                Padding = 10
            };
            VBox ScenarioSettings = new VBox();

            // Create scenario name
            ScenarioName = new TextEntry();
            ScenarioName.Changed += ScenarioName_Changed;
            ScenarioSettings.PackStart(new Label(Director.Properties.Resources.ScenarioName));
            ScenarioSettings.PackStart(ScenarioName);
            ScenarioSettings.PackStart(InvalidScenarioName);
            f.Content = ScenarioSettings;
            PackStart(f);

            Frame h = new Frame()
            {
                Label = Director.Properties.Resources.RunningOptionsLabel,
                Padding = 10
            };
            VBox RunningOptionsSettings = new VBox();

            // Select scenario run
            PeriodicityRunning = new RadioButton(Director.Properties.Resources.FrequencyLabel);
            TimeDelayRunning = new RadioButton(Director.Properties.Resources.TimeDelayLabel);
            PeriodicityRunning.Group = TimeDelayRunning.Group;
            RunningOptionsSettings.PackStart(PeriodicityRunning);
            RunningOptionsSettings.PackStart(TimeDelayRunning);
            PeriodicityRunning.Group.ActiveRadioButtonChanged += ChangeFrequencyOption;

            // Frequency settings
            RunningOptionsSettings.PackStart(new Label()
            {
                Text = Director.Properties.Resources.RunningPeriodicity
            });
            FrequencyRunning = new ComboBox();
            FrequencyHelper.FillComboBox(FrequencyRunning);
            RunningOptionsSettings.PackStart(FrequencyRunning);
            FrequencyRunning.SelectedIndex = 0;
            FrequencyRunning.SelectionChanged += FrequencyRunning_SelectionChanged;

            // Time delay settings
            RunningOptionsSettings.PackStart(new Label()
            {
                Text = Director.Properties.Resources.TimeDelayInSeconds
            });
            TimeDelay = new TextEntry()
            {
                Text = "0"
            };
            TimeDelay.Changed += delegate
            {
                try
                {
                    ActiveScenario.TimeAfterPrevious = int.Parse(TimeDelay.Text);

                    InvalidTimeDelay.Visible = false;
                }
                catch
                {
                    InvalidTimeDelay.Visible = true;
                }
            };
            RunningOptionsSettings.PackStart(TimeDelay);
            RunningOptionsSettings.PackStart(InvalidTimeDelay);

            // Add to form
            h.Content = RunningOptionsSettings;
            PackStart(h);

            // Scenario information
            ScenarioInformation = new VBox();
            ScrollView ScenarioInformationScrollView = new ScrollView()
            {
                VerticalScrollPolicy = ScrollPolicy.Automatic,
                Content = ScenarioInformation
            };

            Frame si = new Frame()
            {
                Label = Director.Properties.Resources.ScenarioOverview,
                Padding = 10,
                Content = ScenarioInformationScrollView
            };
            PackStart(si, true, true);
        }
        /// <summary>
        /// Init components.
        /// </summary>
        private void _initializeComponents()
        {
            VBox ContentBox = new VBox();

            // First value
            Value = new RadioButton(Director.Properties.Resources.JsonValue);
            ContentBox.PackStart(Value);

            // Horizontal
            HBox ValueBox = new HBox();

            // Options
            ValueType = new ComboBox()
            {
                WidthRequest = 80
            };
            ValueType.Items.Add(DataType.TYPE_STRING, "String");
            ValueType.Items.Add(DataType.TYPE_INT, "Integer");
            ValueType.Items.Add(DataType.TYPE_DOUBLE, "Double");
            ValueType.Items.Add(DataType.TYPE_NULL, "Null");
            ValueType.Items.Add(DataType.TYPE_BOOL, "Boolean");
            ValueType.SelectedIndex = 0;
            ValueBox.PackStart(ValueType, false, false);

            // Value
            ValueText = new TextEntry();
            ValueBox.PackStart(ValueText, true, true);
            ContentBox.PackStart(ValueBox);

            // Guide
            FormatGuide = new RadioButton(Director.Properties.Resources.FormatGuide);
            ContentBox.PackStart(FormatGuide);
            Value.Group = FormatGuide.Group;
            Value.Active = true;
            Value.Group.ActiveRadioButtonChanged += Group_ActiveRadioButtonChanged;

            // First line
            HBox FirstLine = new HBox();

            // Value option
            Label Variable = new Label(Director.Properties.Resources.VariableType)
            {
                HorizontalPlacement = WidgetPlacement.Center,
                ExpandHorizontal = true,
                ExpandVertical = false,
                MarginLeft = 10
            };
            Label VariableValue = new Label(Director.Properties.Resources.VariableValue) {
                ExpandHorizontal = true,
                ExpandVertical = false,
                HorizontalPlacement = WidgetPlacement.Center
            };
            NewFormat = new Button(Image.FromResource(DirectorImages.ADD_ICON))
            {
                MinWidth = 30,
                WidthRequest = 30,
                MarginRight = 30
            };
            FirstLine.PackStart(Variable, true, true);
            FirstLine.PackStart(VariableValue, true, true);
            FirstLine.PackStart(NewFormat, false, false);
            ContentBox.PackStart(FirstLine);
            NewFormat.Clicked += NewFormat_Clicked;

            // Variables
            FormatWrapper = new VBox();
            ScrollView FormatWrapperSV = new ScrollView()
            {
                HorizontalScrollPolicy = ScrollPolicy.Never,
                VerticalScrollPolicy = ScrollPolicy.Always,
                Content = FormatWrapper,
                BackgroundColor = Colors.LightGray
            };
            ContentBox.PackStart(FormatWrapperSV, true, true);

            // Example output
            ExampleOutput = new Label()
            {
                ExpandHorizontal = true
            };
            ContentBox.PackStart(ExampleOutput, false, true);

            Content = ContentBox;
        }