Beispiel #1
0
		Control ClearButton (ListBox list)
		{
			var control = new Button{ Text = "Clear" };
			control.Click += delegate {
				list.Items.Clear ();
			};
			return control;
		}
Beispiel #2
0
		void SetContent ()
		{
			var list = new ListBox ();
			list.SelectedIndexChanged += HandleListItemSelected;
			for (int i = 0; i<1000; i++) {
				list.Items.Add ("Item " + i);
			}
			nav.Push (list, "Test");
		}
Beispiel #3
0
		Control AddRowsButton (ListBox list)
		{
			var control = new Button{ Text = "Add Rows" };
			control.Click += delegate {
				for (int i = 0; i < 10; i++)
					list.Items.Add (new ListItem { Text = "Item " + list.Items.Count});
			};
			return control;
		}
Beispiel #4
0
		Control RemoveRowsButton (ListBox list)
		{
			var control = new Button{ Text = "Remove Rows" };
			control.Click += delegate {
				if (list.SelectedIndex >= 0)
					list.Items.RemoveAt (list.SelectedIndex);
			};
			return control;
		}
Beispiel #5
0
 void LogEvents(ListBox control)
 {
     control.SelectedIndexChanged += delegate {
         Log.Write (control, "SelectedIndexChanged, Index: {0}", control.SelectedIndex);
     };
     control.Activated += delegate {
         Log.Write (control, "Activated, Index: {0}", control.SelectedIndex);
     };
 }
Beispiel #6
0
        public SessionCreator()
        {
            _session = new Session();
            _session.Processes.Add(new PortManagerProcess());
            _session.Processes.Add(new RouterProcess());
            _session.Processes.Add(new HostProcess());
            _session.Processes.Add(new DeviceFinderProcess ());
            _session.Processes.Add(new NetworkDatabaseProcess());

            var left = new TableLayout(1, 3);

            _processesList = new ListBox();
            _processesList.Size = new Size(250, -1);
            _processesList.DataStore = _session.Processes;
            _processesList.SelectedValueChanged += _selectedProcessChanged;

            left.Add(_processesList, 0, 0);

            _portTypesCombo = new ComboBox();
            foreach (var portType in PortType.All())
            {
                _portTypesCombo.Items.Add(portType);
            }

            _addPortButton = new Button();
            _addPortButton.Text = Constants.AddPortButtonText;
            _addPortButton.Click += _addPortButtonClicked;

            var newPortLayout = new DynamicLayout();
            newPortLayout.Padding = Eto.Drawing.Padding.Empty;
            newPortLayout.AddRow(_portTypesCombo, _addPortButton);
            left.Add(newPortLayout, 0, 1);

            _contentPanel = new Panel();
            _contentPanel.Content = new SessionSettings(_session);

            _createSessionButton = new Button();
            _createSessionButton.Text = Constants.CreateSessionButtonText;
            _createSessionButton.Click += _createSessionButtonClicked;

            this.BeginVertical(padding:null, xscale: true, yscale: true);
            this.AddRow(left, _contentPanel);
            this.EndVertical();

            this.BeginVertical(padding:null, xscale: true, yscale: false);
            this.AddRow(null, _createSessionButton);
            this.EndVertical();
        }
Beispiel #7
0
        public SessionPicker()
        {
            _sessions = SessionsStore.Instance.GetSessions();
            _sessionList = new ListBox();
            _sessionList.DataStore = _sessions;
            _sessionList.TextBinding = new PropertyBinding<string>("Name");

            _pickButton = new Button();
            _pickButton.Text = Constants.PickSessionButtonText;
            _pickButton.Click += _pickButtonClicked;

            this.BeginVertical(padding: null, xscale: true, yscale: true);
            this.AddRow(_sessionList);
            this.EndVertical();
            this.BeginVertical(padding: null,  xscale: false, yscale: false);
            this.AddRow(null, _pickButton);
            this.EndVertical();
        }
Beispiel #8
0
		Control Default ()
		{
			var control = new ListBox {
				Size = new Size (100, 150)
			};
			LogEvents (control);

			for (int i = 0; i < 10; i++) {
				control.Items.Add (new ListItem{ Text = "Item " + i });
			}
			
			var layout = new DynamicLayout (new Panel());
			layout.Add (control);
			layout.BeginVertical ();
			layout.AddRow (null, AddRowsButton (control), RemoveRowsButton (control), ClearButton (control), null);
			layout.EndVertical ();
			
			return layout.Container;
		}
		public DynamicFocusSection()
		{
			var content = new Panel();
			var focusControlCheckBox = new CheckBox { Text = "Focus Control", Checked = true };

			var addContentButton = new Button { Text = "Add Control" };

			var count = 0;
			addContentButton.Click += (sender, e) =>
			{
				Control control;
				switch((count++) % 9)
				{
					case 0: control = new TextBox(); break;
					case 1: control = new TextArea(); break;
					case 2: control = new CheckBox { Text = "A Check Box" }; break;
					case 3: control = new RadioButton { Text = "A Radio Button" }; break;
					case 4: control = new DropDown { Items = { "Item 1", "Item 2", "Item 3" } }; break;
					case 5: control = new DateTimePicker(); break;
					case 6: control = new ColorPicker(); break;
					case 7: control = new PasswordBox(); break;
					case 8: control = new ListBox { Items = { "Item 1", "Item 2", "Item 3" } }; break;
					case 9: control = new PasswordBox(); break;
					default: throw new InvalidOperationException();
				}
				if (focusControlCheckBox.Checked ?? false)
					control.Focus();
				content.Content = new TableLayout(
					null,
					new Label { Text = string.Format("Control: {0}", control.GetType().Name) },
					new TableRow(control),
					null
				);
			};

			Content = new TableLayout(
				new TableLayout(new TableRow(null, addContentButton, focusControlCheckBox, null)),
				content
				);
		}
Beispiel #10
0
        public NoteView(string dir)
        {
            directory = dir;
            notes = new List<Note>();

            ListBox = new ListBox { Style = "ListNative" };
            TextArea = new TextArea { Style = "TextConsole" };

            var updatingNote = false;

            TextArea.TextChanged += delegate
            {
                if (ListBox.SelectedIndex < 0)
                    return;
                var note = notes[ListBox.SelectedIndex];
                bool changed = note.Changed;
                note.Content = TextArea.Text;
                if (changed != note.Changed)
                    ListBox.Invalidate();
            };

            TextArea.SelectionChanged += delegate
            {
                if (ListBox.SelectedIndex < 0 || updatingNote)
                    return;
                notes[ListBox.SelectedIndex].Selection = TextArea.Selection;
            };

            ListBox.SelectedIndexChanged += delegate
            {
                if (ListBox.SelectedIndex < 0)
                    return;
                var note = notes[ListBox.SelectedIndex];
                updatingNote = true;
                TextArea.Text = note.Content;
                TextArea.Selection = note.Selection;
                TextArea.Focus();
                updatingNote = false;
            };
        }
Beispiel #11
0
		Control FontSizes()
		{
			fontSizes = new ListBox { Size = new Size(60, 100) };
			for (int i = 6; i < 72; i++)
			{
				fontSizes.Items.Add(i.ToString(), i.ToString());
			}
			fontSizes.SelectedIndexChanged += (sender, e) =>
			{
				if (updating)
					return;
				float size;
				if (float.TryParse(fontSizes.SelectedKey, out size))
				{
					UpdatePreview(new Font(selectedFont.Typeface, size, selectedFont.FontDecoration));
				}
			};
			return fontSizes;
		}
Beispiel #12
0
		Control FontStyles()
		{
			fontStyles = new ListBox { Size = new Size(150, 100) };
			fontStyles.SelectedIndexChanged += (sender, e) =>
			{
				if (updating)
					return;
				var face = selectedFont.Family.Typefaces.FirstOrDefault(r => r.Name == fontStyles.SelectedKey);
				if (face != null)
				{
					UpdatePreview(new Font(face, selectedFont.Size, selectedFont.FontDecoration));
				}
			};
			return fontStyles;
		}
Beispiel #13
0
		Control FontList()
		{
			fontList = new ListBox { Size = new Size(300, 180) };
			var lookup = Fonts.AvailableFontFamilies.ToDictionary(r => r.Name);
			fontList.Items.AddRange(lookup.Values.OrderBy(r => r.Name).Select(r => new ListItem { Text = r.Name, Key = r.Name }).OfType<IListItem>());
			fontList.SelectedIndexChanged += (sender, e) =>
			{
				if (updating || fontList.SelectedKey == null)
					return;
				var family = lookup[fontList.SelectedKey];
				UpdatePreview(new Font(family.Typefaces.First(), selectedFont.Size, selectedFont.FontDecoration));
			};

			return fontList;
		}
Beispiel #14
0
 /// <summary>
 /// Raises the activated event.
 /// </summary>
 public void OnActivated(ListBox widget, EventArgs e)
 {
     using (widget.Platform.Context)
         widget.OnActivated(e);
 }
Beispiel #15
0
		Control WithIcons ()
		{
			var control = new ListBox {
				Size = new Size (100, 150)
			};
			LogEvents (control);
			
			control.DataStore = new VirtualList ();
			return control;
		}
Beispiel #16
0
		Control WithContextMenu ()
		{
			var control = new ListBox {
				Size = new Size (100, 150)
			};
			LogEvents (control);

			for (int i = 0; i < 10; i++) {
				control.Items.Add (new ListItem{ Text = "Item " + i });
			}
			
			var menu = new ContextMenu ();
			var item = new ImageMenuItem{ Text = "Click Me!"};
			item.Click += delegate {
				if (control.SelectedValue != null)
					Log.Write (item, "Click, Item: {0}", control.SelectedValue.Text);
				else
					Log.Write (item, "Click, no item selected");
			};
			menu.MenuItems.Add (item);
			
			control.ContextMenu = menu;
			return control;
		}
Beispiel #17
0
		Control ListBoxControl()
		{
			var control = new ListBox();
			control.Items.Add(new ListItem { Text = "Item 1" });
			control.Items.Add(new ListItem { Text = "Item 2" });
			control.Items.Add(new ListItem { Text = "Item 3" });
			LogEvents(control);
			return control;
		}
Beispiel #18
0
		Control FontList()
		{
			fontList = new ListBox { Size = new Size(300, 180) };
			var lookup = Fonts.AvailableFontFamilies.ToDictionary(r => r.Name);
			Func<FontFamily, string> getName = (FontFamily ff) =>
			{
				var name = ff.Name;
				if (ff.LocalizedName != name)
					name += $" ({ff.LocalizedName})";
				return name;
			};

			fontList.Items.AddRange(lookup.Values.OrderBy(r => r.Name).Select(r => new ListItem { Text = getName(r), Key = r.Name }).OfType<IListItem>());
			fontList.SelectedIndexChanged += (sender, e) =>
			{
				if (updating || fontList.SelectedKey == null)
					return;
				var family = lookup[fontList.SelectedKey];
				UpdatePreview(new Font(family.Typefaces.First(), selectedFont.Size, selectedFont.FontDecoration));
			};

			return fontList;
		}