Beispiel #1
0
		public PixelOffsetTransforms()
		{
			HorizontalContentAlignment = HorizontalAlignment.Stretch;
			Spacing = 5;

			var canvas = new TestCanvas();

			var offsetMode = new EnumDropDown<PixelOffsetMode>();
			offsetMode.SelectedValueBinding.Bind(canvas, c => c.PixelOffsetMode);

			var testDropDown = new DropDown();
			testDropDown.ItemTextBinding = Binding.Property((TestInfo t) => t.Name);
			testDropDown.SelectedValueBinding.Cast<TestInfo>().Bind(canvas, c => c.Test);
			testDropDown.DataStore = tests;
			testDropDown.SelectedIndex = 0;

			var options = new StackLayout
			{
				Orientation = Orientation.Horizontal,
				VerticalContentAlignment = VerticalAlignment.Center,
				Spacing = 5,
				Padding = new Padding(10),
				Items =
				{
					"PixelOffsetMode",
					offsetMode,
					"Test",
					testDropDown
				}
			};

			Items.Add(options);
			Items.Add(new StackLayoutItem(canvas, true));
		}
Beispiel #2
0
		Control ClearButton(DropDown list)
		{
			var control = new Button { Text = "Clear" };
			control.Click += delegate
			{
				list.Items.Clear();
			};
			return control;
		}
Beispiel #3
0
		Control ClearSelected(DropDown list)
		{
			var control = new Button { Text = "Clear Selected" };
			control.Click += delegate
			{
				list.SelectedIndex = -1;
			};
			return control;
		}
Beispiel #4
0
		Control AddRowsButton(DropDown 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 #5
0
		Control RemoveRowsButton(DropDown list)
		{
			var control = new Button { Text = "Remove Rows" };
			control.Click += delegate
			{
				if (list.SelectedIndex >= 0)
					list.Items.RemoveAt(list.SelectedIndex);
			};
			return control;
		}
Beispiel #6
0
		Control SetSelected(DropDown list)
		{
			var control = new Button { Text = "Set Selected" };
			control.Click += delegate
			{
				if (list.Items.Count > 0)
					list.SelectedIndex = new Random().Next(list.Items.Count - 1);
			};
			return control;
		}
Beispiel #7
0
		public DynamicMenuBar()
		{
			var count = 0;
			var menu = Application.Instance.MainForm.Menu;
			ISubmenu editMenu = menu.Items.GetSubmenu("Edit");

			// selection of which menu to add/remove
			var menuToEdit = new DropDown
			{
				DataStore = menu.Items.OfType<ISubmenu>().Union(new ISubmenu[] { menu }).ToList(),
				ItemTextBinding = Binding.Delegate((MenuItem item) => item.Text, defaultGetValue: "Main Menu")
			};
			menuToEdit.SelectedValueBinding.Bind(() => editMenu, v => editMenu = v as ISubmenu);

			// tag to identify items that we've added
			var dynamicTag = new object();

			// button to add a new item
			var addToEditMenu = new Button { Text = "Add MenuItem" };
			addToEditMenu.Click += (sender, e) =>
			{
				var itemNumber = ++count;
				var item = new ButtonMenuItem { Text = "Dynamic Menu Item " + itemNumber, Tag = dynamicTag };
				item.Click += (s, ee) => Log.Write(item, "Clicked " + itemNumber);
				editMenu.Items.Add(item);
			};

			// button to remove the item
			var removeFromEditMenu = new Button { Text = "Remove MenuItem" };
			removeFromEditMenu.Click += (sender, e) =>
			{
				var item = editMenu.Items.LastOrDefault(r => Equals(r.Tag, dynamicTag));
				if (item != null)
				{
					editMenu.Items.Remove(item);
				}
			};

			// layout of the form
			Content = new StackLayout
			{
				Spacing = 5,
				HorizontalContentAlignment = HorizontalAlignment.Center,
				Items =
				{
					null,
					new StackLayout { Orientation = Orientation.Horizontal, Spacing = 5, Items = { new Label { Text = "Submenu to add to", VerticalAlignment = VerticalAlignment.Center }, menuToEdit } },
					new StackLayout { Orientation = Orientation.Horizontal, Spacing = 5, Items = { addToEditMenu, removeFromEditMenu } },
					null
				}
			};
		}
Beispiel #8
0
		Control Default()
		{
			var control = new DropDown();
			LogEvents(control);
			
			var layout = new DynamicLayout();
			layout.Add(TableLayout.AutoSized(control));
			layout.BeginVertical();
			layout.AddRow(null, AddRowsButton(control), RemoveRowsButton(control), ClearButton(control), SetSelected(control), ClearSelected(control), null);
			layout.EndVertical();
			
			return layout;
		}
Beispiel #9
0
		Control DashStyleControl()
		{
			var control = new DropDown();
			control.Items.Add(new DashStyleItem { Text = "Solid", Style = DashStyles.Solid });
			control.Items.Add(new DashStyleItem { Text = "Dash", Style = DashStyles.Dash });
			control.Items.Add(new DashStyleItem { Text = "Dot", Style = DashStyles.Dot });
			control.Items.Add(new DashStyleItem { Text = "Dash Dot", Style = DashStyles.DashDot });
			control.Items.Add(new DashStyleItem { Text = "Dash Dot Dot", Style = DashStyles.DashDotDot });
			control.SelectedIndex = 0;
			control.SelectedIndexChanged += (sender, e) =>
			{
				if (control.SelectedValue != null)
					DashStyle = ((DashStyleItem)control.SelectedValue).Style;
				Refresh(sender, e);
			};
			return control;
		}
Beispiel #10
0
        /// <summary>
        /// Creates the content control for the cell.
        /// </summary>
        /// <remarks>
        /// The control returned may be reused for other cells, so it is ideal to use MVVM data binding using
        /// BindDataContext()
        /// methods of your controls.
        /// This should return the same control for each row, otherwise the incorrect control may be shown on certain cells.
        /// </remarks>
        /// <param name="args">Cell arguments.</param>
        public override Control OnCreate(CellEventArgs args)
        {
            if (ItemBinding == null)
            {
                return(null);
            }
            var dropDown = new DropDown();

            dropDown.ShowBorder      = false;
            dropDown.ItemTextBinding = ItemTextBinding;
            dropDown.ItemKeyBinding  = ItemKeyBinding;
            if (ItemsBinding != null)
            {
                dropDown.BindDataContext(c => c.DataStore, ItemsBinding);
            }
            dropDown.SelectedValueBinding.BindDataContext(ItemBinding);
            return(dropDown);
        }
Beispiel #11
0
		void Init()
		{
			_textAreaInput = new TextArea();
			_textAreaInput.Font = new Font(FontFamilies.Monospace, 10);

		    _dropDownServices = new DropDown {Width = 200};
			_dropDownServices.SelectedIndexChanged += DropDownServicesSelectedIndexChanged;

			_radioButtonEncode = new RadioButton {Text = "Encode"};
			_radioButtonEncode.CheckedChanged += _radioButtonEncode_CheckedChanged;
			_radioButtonDecode = new RadioButton(_radioButtonEncode) {Text = "Decode"};

			_buttonRun = new Button { Text = "Run" };
			_buttonRun.Click += _buttonRun_Click;

			_textAreaOutput = new TextArea();
			_textAreaOutput.Font = new Font(FontFamilies.Monospace, 10);

			var inputLayout = new DynamicLayout {Padding = new Padding(5, 5, 5, 0), Spacing = new Size(5, 5)};
			inputLayout.AddSeparateRow(_textAreaInput);

			var outputLayout = new DynamicLayout {Padding = new Padding(5, 5), Spacing = new Size(5, 5)};
			outputLayout.BeginVertical();
			outputLayout.BeginHorizontal();
			outputLayout.AddCentered(_radioButtonEncode, horizontalCenter: false);
			outputLayout.AddCentered(_radioButtonDecode, horizontalCenter: false);
			outputLayout.Add(null);
			outputLayout.AddCentered(_dropDownServices, horizontalCenter: false);
			outputLayout.AddCentered(_buttonRun, horizontalCenter: false);
			outputLayout.EndHorizontal();
			outputLayout.EndVertical();
			outputLayout.AddSeparateRow(_textAreaOutput);

			var layout = new Splitter
			{
				Panel1 = inputLayout,
				Panel2 = outputLayout,
				Orientation = SplitterOrientation.Vertical,
				Position = 130
			};

			Content = layout;
		}
		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
				);
		}
		void Init()
		{
		    _dropDownLang = new DropDown {Width = 200};
			var lanList = new List<IListItem>
			{
				new ListItem {Text = "EN",Key="EN"},
				new ListItem {Text = "CN",Key="CN"}
			};
			_dropDownLang.Items.AddRange(lanList);

			_checkBoxIsShowDisclaimer = new CheckBox { Text = AltStrRes.IsShowDisclaimer };
			_checkBoxIsOpenIPythonSupport = new CheckBox {Text = AltStrRes.IsOpenIPythonSupport};

			var layout = new DynamicLayout {Padding = new Padding(20, 20), Spacing = new Size(10, 10)};
			layout.AddSeparateRow(
				new Label {Text = AltStrRes.Language, VerticalAlign = VerticalAlign.Middle},
				_dropDownLang, null);
			layout.AddRow(_checkBoxIsShowDisclaimer, null);
			layout.AddRow(_checkBoxIsOpenIPythonSupport, null);
			layout.Add(null);

			Content = layout;
		}
		void InitUi()
		{
			// input
            _textBoxName = new TextBox { PlaceholderText = "*Name", Width = 200};
		    _comboBoxLevel = new ComboBox {Width = 100};
		    _dropDownScritpType = new DropDown {Width = 120};
		    _textBoxShellPath = new TextBox {PlaceholderText = "*Shell Url", Width = 300};
			_textBoxShellPass = new TextBox { PlaceholderText = "*Pass" };
			_textBoxRemark = new TextBox { PlaceholderText = "Remark" };

			// _buttonAdd
			_buttonAdd = new Button { Text = StrRes.GetString("StrAdd", "Add") };
			_buttonAdd.Click += buttonAdd_Click;

			// _buttonAlter
			_buttonAlter = new Button { Text = StrRes.GetString("StrAlter", "Alter") };
			_buttonAlter.Click += _buttonAlter_Click;

			// _buttonAdvanced
			_buttonAdvanced = new Button { Text = StrRes.GetString("StrAdvanced","Advanced") };
			_buttonAdvanced.Click += _buttonAdvanced_Click;

			var codeList = new List<IListItem>
			{
				new ListItem {Text = "UTF-8"},
				new ListItem {Text = "GB2312"}
			};
			_dropDownServerCoding = new DropDown();
			_dropDownServerCoding.Items.AddRange(codeList);
			_dropDownServerCoding.SelectedIndex = 0;
			_dropDownWebCoding = new DropDown();
			_dropDownWebCoding.Items.AddRange(codeList);
			_dropDownWebCoding.SelectedIndex = 0;

			// _buttonDefault
			_buttonDefault = new Button { Text = "Default" };
			_buttonDefault.Click += _buttonDefault_Click;

			// _richTextBoxSetting
			_richTextBoxSetting = new TextArea {Wrap = false};

			// _panelAdvanced
			_panelAdvanced = new DynamicLayout { Padding = new Padding(5, 5), Spacing = new Size(5, 5) };
			_panelAdvanced.BeginVertical();
			_panelAdvanced.BeginHorizontal();
			_panelAdvanced.AddAutoSized(new Label
			{
				Text = StrRes.GetString("StrServerCoding", "ServerCoding"),
				VerticalAlign = VerticalAlign.Middle
			}, centered: true);
			_panelAdvanced.AddAutoSized(_dropDownServerCoding, centered: true);
			_panelAdvanced.AddAutoSized(new Label
			{
				Text = StrRes.GetString("StrWebCoding", "WebCoding"),
				VerticalAlign = VerticalAlign.Middle
			}, centered: true);
			_panelAdvanced.AddAutoSized(_dropDownWebCoding, centered: true);
			_panelAdvanced.Add(null);
			_panelAdvanced.AddAutoSized(_buttonDefault, centered: true);
			_panelAdvanced.EndHorizontal();
			_panelAdvanced.EndVertical();
			//_panelAdvanced.AddSeparateRow(new Label { Text = StrRes.GetString("StrServerCoding", "ServerCoding"), VerticalAlign = VerticalAlign.Middle }, _dropDownServerCoding);
			//_panelAdvanced.AddSeparateRow(new Label { Text = StrRes.GetString("StrWebCoding", "WebCoding"), VerticalAlign = VerticalAlign.Middle }, _dropDownWebCoding);
			_panelAdvanced.AddSeparateRow(_richTextBoxSetting);

			var panel1 = new DynamicLayout { Padding = new Padding(5, 5), Spacing = new Size(5, 5) };
			//line 1
			panel1.BeginVertical();
			panel1.BeginHorizontal();
			panel1.Add(_textBoxName, xscale: true);
			panel1.Add(_comboBoxLevel);
			panel1.Add(_dropDownScritpType);
			panel1.EndHorizontal();
			panel1.EndVertical();
			//line 2
			panel1.BeginVertical();
			panel1.BeginHorizontal();
			panel1.Add(_textBoxShellPath, true);
			panel1.Add(_textBoxShellPass);
			panel1.EndHorizontal();
			panel1.EndVertical();
			//line 3
			panel1.AddRow(_textBoxRemark);
			//line 4
			panel1.BeginVertical();
			panel1.BeginHorizontal();
			panel1.Add(_buttonAdvanced);
			panel1.Add(null, true);
			panel1.Add(_buttonAdd);
			panel1.Add(_buttonAlter);
			panel1.EndHorizontal();
			panel1.EndVertical();
			//line 5
			panel1.Add(_panelAdvanced, false, true);
			_panelAdvanced.Visible = false;

			//_p12 = new Splitter
			//{
			//	Panel1 = panel1,
			//	Panel2 = _panelAdvanced,
			//	Orientation = SplitterOrientation.Vertical,
			//	Position = 130,
			//};
			//_p12.FixedPanel = SplitterFixedPanel.Panel1;
			//_p12.Panel2.Visible = false;

			Content = panel1;
			ClientSize = new Size(500, 130);
			Title = "Edit Shell";
			Icon = Application.Instance.MainForm.Icon;
		}
Beispiel #15
0
		DropDown Items()
		{
			var control = new DropDown();
			LogEvents(control);
			for (int i = 0; i < 20; i++)
			{
				control.Items.Add(new ListItem { Text = "Item " + i });
			}
			return control;
		}
Beispiel #16
0
		public RichTextAreaSection()
		{
			var richText = new RichTextArea();
			richText.Size = new Size(-1, 300);
			richText.Text = LoremText;

			var range = new Range<int>(6, 10);
			var buffer = richText.Buffer;
			buffer.SetFont(range, Fonts.Cursive(20, FontStyle.Bold, FontDecoration.Underline));
			buffer.SetForeground(range, Colors.Blue);
			buffer.SetBackground(range, Colors.Yellow);

			buffer.SetBold(new Range<int>(11, 16), true);
			buffer.SetItalic(new Range<int>(18, 20), true);
			buffer.SetUnderline(new Range<int>(22, 25), true);
			buffer.SetStrikethrough(new Range<int>(28, 38), true);

			richText.CaretIndex = LoremText.Length - 1;

			richText.SelectionChanged += (sender, e) =>
			{
				UpdateBindings(BindingUpdateMode.Destination);
				Log.Write(sender, "SelectionChanged: {0}", richText.Selection);
			};

			var boldButton = new CheckBox { Text = "Bold" };
			boldButton.CheckedBinding.Bind(richText, r => r.SelectionBold);
			boldButton.CheckedChanged += (sender, e) =>
			{
				richText.Focus();
				UpdateBindings(BindingUpdateMode.Destination);
			};

			var italicButton = new CheckBox { Text = "Italic" };
			italicButton.CheckedBinding.Bind(richText, r => r.SelectionItalic);
			italicButton.CheckedChanged += (sender, e) =>
			{
				richText.Focus();
				UpdateBindings(BindingUpdateMode.Destination);
			};

			var underlineButton = new CheckBox { Text = "Underline" };
			underlineButton.CheckedBinding.Bind(richText, r => r.SelectionUnderline);
			underlineButton.CheckedChanged += (sender, e) => richText.Focus();

			var strikethroughButton = new CheckBox { Text = "Strikethrough" };
			strikethroughButton.CheckedBinding.Bind(richText, r => r.SelectionStrikethrough);
			strikethroughButton.CheckedChanged += (sender, e) => richText.Focus();

			var backgroundButton = new ColorPicker { };
			backgroundButton.ValueBinding.Bind(() => richText.SelectionBackground, val => richText.SelectionBackground = val, h => Binding.AddPropertyEvent(richText, r => r.SelectionBackground, h), h => Binding.RemovePropertyEvent(richText, h));
			backgroundButton.ValueChanged += (sender, e) => richText.Focus();

			var foregroundButton = new ColorPicker { };
			foregroundButton.ValueBinding.Bind(richText, r => r.SelectionForeground);
			foregroundButton.ValueChanged += (sender, e) => richText.Focus();

			var fontButton = new Button();
			fontButton.Bind(c => c.Text, new DelegateBinding<string>(() =>
			{
				var font = richText.SelectionFont;
				if (font == null)
					return "<No Font>";
				return string.Format("{0}, {1}, {2:0.00}pt", font.FamilyName, font.Typeface.Name, font.Size);
			}));
			var fd = new FontDialog();
			fontButton.Click += (sender, e) =>
			{
				fd.Font = richText.SelectionFont;
				fd.FontChanged += (s, ee) =>
				{
					richText.SelectionFont = fd.Font;
					UpdateBindings(BindingUpdateMode.Destination);
				};
				if (fd.ShowDialog(this) == DialogResult.Ok)
					richText.Focus();
			};

			var familyDropDown = new DropDown();
			familyDropDown.DataStore = Fonts.AvailableFontFamilies.OrderBy(r => r.Name);
			familyDropDown.SelectedValueBinding.Bind(richText, r => r.SelectionFamily);
			familyDropDown.SelectedValueChanged += (sender, e) =>
			{
				richText.Focus();
				UpdateBindings(BindingUpdateMode.Destination);
			};

			var formatEnum = new EnumDropDown<RichTextAreaFormat>();
			formatEnum.SelectedValue = RichTextAreaFormat.Rtf;

			var loadButton = new Button { Text = "Load" };
			loadButton.Enabled = buffer.SupportedFormats.Contains(formatEnum.SelectedValue);
			loadButton.Click += (sender, e) => buffer.Load(new MemoryStream(Encoding.UTF8.GetBytes(formatEnum.SelectedValue == RichTextAreaFormat.Rtf ? RtfString : LoremText)), formatEnum.SelectedValue);

			var saveButton = new Button { Text = "Save" };
			saveButton.Enabled = buffer.SupportedFormats.Contains(formatEnum.SelectedValue);
			saveButton.Click += (sender, e) =>
			{
				var stream = new MemoryStream();
				buffer.Save(stream, formatEnum.SelectedValue);
				stream.Position = 0;
				Log.Write(richText, "Saved {0}:\n{1}", formatEnum.SelectedValue, new StreamReader(stream).ReadToEnd());
			};

			formatEnum.SelectedValueChanged += (sender, e) => saveButton.Enabled = loadButton.Enabled = buffer.SupportedFormats.Contains(formatEnum.SelectedValue);

			var clearButton = new Button { Text = "Clear" };
			clearButton.Click += (sender, e) => buffer.Clear();

			var formatting1 = new StackLayout
			{
				Orientation = Orientation.Horizontal,
				Spacing = 5,
				Items =
				{
				    null,
				    boldButton,
				    italicButton,
				    underlineButton,
				    strikethroughButton,
				    null
				}
			};

			var formatting2 = new StackLayout
			{
				Orientation = Orientation.Horizontal,
				Spacing = 5,
				Items =
				{
					null,
					new Label { Text = "Foreground", VerticalAlignment = VerticalAlignment.Center },
					TableLayout.AutoSized(foregroundButton, centered: true),
					new Label { Text = "Background", VerticalAlignment = VerticalAlignment.Center },
					TableLayout.AutoSized(backgroundButton, centered: true),
					null
				}
			};
			var formatting3 = new StackLayout
			{
				Orientation = Orientation.Horizontal,
				Spacing = 5,
				Items =
				{
				    null,
				    fontButton,
				    familyDropDown,
				    null
				}
			};

			var buttons = new StackLayout
			{
				Orientation = Orientation.Horizontal,
				Spacing = 5,
				Items =
				{
				    null,
				    formatEnum,
				    loadButton,
				    saveButton,
				    clearButton,
				    null
				}
			};

			Content = new StackLayout
			{
				Padding = new Padding(10),
				Spacing = 5,
				HorizontalContentAlignment = HorizontalAlignment.Stretch,
				Items =
				{
					buttons,
					TextAreaSection.TextAreaOptions(richText),
					TextAreaSection.TextAreaOptions2(richText),
					TextAreaSection.TextAreaOptions3(richText),
					formatting1,
					formatting2,
					formatting3,
					new StackLayoutItem(richText, expand: true)
				}
			};
		}
Beispiel #17
0
		Control BrushControl()
		{
			var control = new DropDown();
			control.Items.Add(new BrushItem { Text = "Solid", Brush = solidBrush });
			control.Items.Add(new BrushItem { Text = "Texture", Brush = textureBrush, SupportsMatrix = true });
			control.Items.Add(new BrushItem { Text = "Gradient", Brush = gradientBrush, SupportsMatrix = true, SupportsGradient = true });
			control.SelectedValue = control.Items.OfType<BrushItem>().First(r => r.Brush == brush);
			control.SelectedValueChanged += (sender, e) =>
			{
				var item = (BrushItem)control.SelectedValue;
				if (item != null)
					SetItem(item);
			};
			LoadComplete += (sender, e) => SetItem(control.SelectedValue as BrushItem);
			control.SelectedValueChanged += (sender, e) => Refresh();
			return control;
		}
Beispiel #18
0
		static DropDown ComboWithItems()
		{
			var combo = new DropDown();
			combo.Items.Add("hello");
			combo.Items.Add("there");
			return combo;
		}
Beispiel #19
0
		void LogEvents(DropDown control)
		{
			control.SelectedIndexChanged += delegate
			{
				Log.Write(control, "SelectedIndexChanged, Value: {0}", control.SelectedIndex);
			};
		}
Beispiel #20
0
        void Init()
        {
            //_buttonConnect
            _buttonConnect = new Button { Text = StrRes.GetString("StrConnect","Connect"), Image = Icons.ConnectIcon };
            _buttonConnect.Click += ButtonConnect_Click;

            //_buttonDisconnect
            _buttonDisconnect = new Button { Text = StrRes.GetString("StrDisconnect","Disconnect"), Image = Icons.DisconnectIcon };
            _buttonDisconnect.Click += _buttonDisconnect_Click;

            //_dropDownDbs
            _dropDownDbs = new DropDown {Width = 200};

            //_buttonRunScript
            _buttonRunScript = new Button {Text = StrRes.GetString("StrExecute","Execute"), Image = Icons.RunScripIcon};
            _buttonRunScript.Click += _buttonRunScript_Click;

            //_itemSaveAsCsv
            _itemSaveAsCsv = new ButtonMenuItem { Text = StrRes.GetString("StrSaveAsCsv","SaveAs .Csv") };
            _itemSaveAsCsv.Click += _itemSaveAsCsv_Click;

            //_itemViewTable
            _itemViewTable = new ButtonMenuItem { Text = StrRes.GetString("StrViewTable","ViewTable") };
            _itemViewTable.Click += _itemViewTable_Click;
            _itemViewTable.Enabled = false;

            //_itemCopyName
            _itemCopyName = new ButtonMenuItem { Text = StrRes.GetString("StrCopyName","CopyName") };
            _itemCopyName.Click += _itemCopyName_Click;

            //_menuDbView
            _menuDbView = new ContextMenu();
            _menuDbView.Items.Add(_itemCopyName);
            _menuDbView.Items.Add(_itemViewTable);

            //_menuResultView
            _menuResultView = new ContextMenu();
            _menuResultView.Items.Add(_itemSaveAsCsv);

            //_treeViewDbs
            _treeViewDbs = new TreeView();
            _treeViewDbs.ContextMenu = _menuDbView;
            _treeViewDbs.SelectionChanged += _treeViewDbs_SelectionChanged;
            _treeViewDbs.Activated += _treeViewDbs_Activated;
            _treeViewDbs.MouseUp += (sender, e) =>
            {
                if (e.Buttons == MouseButtons.Alternate)
                {
                    _treeViewDbs.ContextMenu.Show(_treeViewDbs);
                }
            };

            //_textAreaSql
            _textAreaSql = new TextArea {Font = new Font(FontFamilies.Sans, 12, FontStyle.Bold | FontStyle.Italic)};

            //_gridViewResult
            _gridViewResult = new GridView();
            _gridViewResult.ContextMenu = _menuResultView;
            _gridViewResult.Style = "GridViewResult";
            _gridViewResult.MouseUp += (sender, e) =>
            {
                if (e.Buttons == MouseButtons.Alternate)
                {
                    _gridViewResult.ContextMenu.Show(_treeViewDbs);
                }
            };

            //topLayout
            var topLayout = new DynamicLayout();
            topLayout.BeginHorizontal();
            topLayout.AddCentered(_buttonConnect, horizontalCenter: false);
            topLayout.AddCentered(_buttonDisconnect, horizontalCenter: false);
            topLayout.AddCentered(_dropDownDbs, horizontalCenter: false);
            topLayout.AddCentered(_buttonRunScript, horizontalCenter: false);
            topLayout.Add(null);
            topLayout.EndVertical();

            //rightPanel
            var rightPanel = new Splitter
            {
                Panel1 = _textAreaSql,
                Panel2 = _gridViewResult,
                Orientation = SplitterOrientation.Vertical,
                Position = 100
            };

            //mainLayout
            var mainLayout = new Splitter
            {
                Panel1 = _treeViewDbs,
                Panel2 = rightPanel,
                Orientation = SplitterOrientation.Horizontal,
                Position = 200
            };

            //layout
            var layout = new DynamicLayout { Padding = new Padding(0, 0), Spacing = new Size(5, 5) };
            layout.AddRow(topLayout);
            layout.AddRow(mainLayout);
            Content = layout;
        }
Beispiel #21
0
		public ScrollableSection()
		{
			var scrollable = CreateScrollable();

			var borderType = new EnumDropDown<BorderType>();
			borderType.SelectedValueBinding.Bind(scrollable, r => r.Border);

			var expandWidth = new CheckBox { Text = "Width" };
			expandWidth.CheckedBinding.Bind(scrollable, r => r.ExpandContentWidth);

			var expandHeight = new CheckBox { Text = "Height" };
			expandHeight.CheckedBinding.Bind(scrollable, r => r.ExpandContentHeight);

			var sizeMode = new DropDown
			{
				Items = { "Auto", "800x800", "30x30", "1x1" },
				SelectedIndex = 0
			};
			sizeMode.SelectedIndexChanged += (sender, e) => 
			{
				switch (sizeMode.SelectedIndex) {
                    case 0:
                        scrollable.Content.Size = new Size(-1, -1);
                        break;
                    case 1:
						scrollable.Content.Size = new Size(800, 800);
						break;
                    case 2:
                        scrollable.Content.Size = new Size(30, 30);
                        break;
                    case 3:
                        scrollable.Content.Size = new Size(1, 1);
                        break;

                }
            };

			var options = new StackLayout
			{
				Orientation = Orientation.Horizontal,
				VerticalContentAlignment = VerticalAlignment.Center,
				Spacing = 5,
				Items = { 
					"Border:",
					borderType,
					"Expand:",
					expandWidth,
					expandHeight,
					"Content Size:",
					sizeMode
				}
			};

			Content = new StackLayout
			{
				Padding = 10,
				Spacing = 5,
				HorizontalContentAlignment = HorizontalAlignment.Stretch,
				Items =
				{ 
					new StackLayoutItem(options, HorizontalAlignment.Center), 
					new StackLayoutItem(scrollable, true)
				}
			};
		}
Beispiel #22
0
 /// <summary>
 /// Raises the <see cref="DropDownClosed"/> event
 /// </summary>
 /// <param name="widget">Widget to raise the event</param>
 /// <param name="e">Event arguments</param>
 public void OnDropDownClosed(DropDown widget, EventArgs e)
 {
     using (widget.Platform.Context)
         widget.OnDropDownClosed(e);
 }
Beispiel #23
0
		Control BrushControl()
		{
			var control = new DropDown();
			control.Items.Add(new BrushItem { Text = "Solid", CreateBrush = () => new SolidBrush(Colors.LightSkyBlue) });
			control.Items.Add(new BrushItem
			{
				Text = "Texture",
				SupportsMatrix = true,
				CreateBrush = () => new TextureBrush(image, 0.5f) { Transform = GetTransform() }
			});
			control.Items.Add(new BrushItem
			{
				Text = "Linear Gradient",
				SupportsMatrix = true,
				SupportsGradient = true,
				SupportsLinear = true,
				CreateBrush = () => new LinearGradientBrush(Colors.AliceBlue, Colors.Black, StartPoint, EndPoint)
				{
					Wrap = GradientWrap,
					Transform = GetTransform()
				}
			});
			control.Items.Add(new BrushItem
			{
				Text = "Radial Gradient",
				SupportsMatrix = true,
				SupportsGradient = true,
				SupportsRadial = true,
				CreateBrush = () => new RadialGradientBrush(Colors.AliceBlue, Colors.Black, Center, GradientOrigin, Radius)
				{
					Wrap = GradientWrap,
					Transform = GetTransform()
				}
			});
			control.SelectedValue = control.Items.OfType<BrushItem>().First(); //r => r.Text == "Linear Gradient");
			control.SelectedValueChanged += (sender, e) => SetItem(control.SelectedValue as BrushItem);
			Load += (sender, e) => SetItem(control.SelectedValue as BrushItem);
			control.SelectedValueChanged += (sender, e) => Refresh();
			return control;
		}
Beispiel #24
0
		Control DropDownControl()
		{
			var control = new DropDown();
			control.Items.Add(new ListItem { Text = "Item 1" });
			control.Items.Add(new ListItem { Text = "Item 2" });
			control.Items.Add(new ListItem { Text = "Item 3" });
			control.SelectedKey = "Item 1";
			LogEvents(control);
			return control;
		}