Inheritance: Eto.Forms.TextControl
        /// <summary>
        /// Creates a new menu form.
        /// </summary>
        /// <param name="title">Window title.</param>
        /// <param name="itemNames">Item names.</param>
        /// <param name="actions">Actions.</param>
        public MenuForm(string title, string[] itemNames, Action[] actions)
        {
            Title = title;
            SelectedIndex = -1;

            if (itemNames == null || actions == null)
                return;
            if (itemNames.Length != actions.Length)
                return;

            var stackLayout = new StackLayout {Orientation = Orientation.Vertical, HorizontalContentAlignment = HorizontalAlignment.Stretch };

            for (int i = 0; i < itemNames.Length; i++)
            {
                var idx = i;

                var button = new Button { Text = itemNames[idx], Size = new Size(240, 60) }; 
                button.Click += (s, e) =>
                {
                    actions[idx]();
                    SelectedIndex = idx;
                    this.Close();
                };

                stackLayout.Items.Add(new StackLayoutItem(button, true));
            }

            Content = stackLayout;
            Size = new Size(-1, -1);
        }
Exemple #2
0
		Control TestProperties()
		{
			var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5) };
			DateTimePicker min, max, current, setValue;
			Button setButton;

			layout.AddRow("Min Value", min = new DateTimePicker());
			layout.AddRow("Max Value", max = new DateTimePicker());
			layout.BeginHorizontal();
			layout.Add("Set to value");
			layout.BeginVertical(Padding.Empty);
			layout.BeginHorizontal();
			layout.AddAutoSized(setValue = new DateTimePicker());
			layout.Add(setButton = new Button { Text = "Set" });
			layout.EndHorizontal();
			layout.EndVertical();
			layout.EndHorizontal();
			layout.AddRow("Value", current = new DateTimePicker());

			min.ValueChanged += (sender, e) => current.MinDate = min.Value ?? DateTime.MinValue;
			max.ValueChanged += (sender, e) => current.MaxDate = max.Value ?? DateTime.MaxValue;
			setButton.Click += (sender, e) => current.Value = setValue.Value;
			LogEvents(current);

			return layout;
		}
		Control TestProperties()
		{
			var layout = new DynamicLayout();
			DateTimePicker min, max, current, setValue;
			Button setButton;

			layout.AddRow(new Label { Text = "Min Value" }, min = new DateTimePicker());
			layout.AddRow(new Label { Text = "Max Value" }, max = new DateTimePicker());
			layout.BeginHorizontal();
			layout.Add(new Label { Text = "Set to value" });
			layout.BeginVertical();
			layout.BeginHorizontal();
			layout.AddAutoSized(setValue = new DateTimePicker());
			layout.Add(setButton = new Button { Text = "Set" });
			layout.EndHorizontal();
			layout.EndVertical();
			layout.EndHorizontal();
			layout.AddRow(new Label { Text = "Value" }, current = new DateTimePicker());

			min.ValueChanged += (sender, e) => current.MinDate = min.Value ?? DateTime.MinValue;
			max.ValueChanged += (sender, e) => current.MaxDate = max.Value ?? DateTime.MaxValue;
			setButton.Click += (sender, e) => current.Value = setValue.Value;
			LogEvents(current);

			return layout;
		}
Exemple #4
0
		public ServerDialog (Server server, bool isNew, bool allowConnect)
		{
			this.isNew = isNew;
			this.allowConnect = allowConnect && !isNew;
			this.Server = server;
			this.Title = "Add Server";
			this.MinimumSize = new Size (300, 0);
			this.DataContext = server;
			
			var layout = new DynamicLayout (this);
			
			layout.BeginVertical ();
			
			layout.AddRow (new Label { Text = "Server Name"}, ServerName ());
			
			// generate server-specific edit controls
			server.GenerateEditControls (layout, isNew);
			
			layout.AddRow (null, AutoConnectButton());
			
			layout.EndBeginVertical ();

			layout.AddRow (Connect (), Disconnect (), null, cancelButton = this.CancelButton (), this.OkButton ("Save", () => SaveData()));
			
			layout.EndVertical ();
			
			SetVisibility ();
		}
        void Init()
        {
            //_textBoxUrl
            _textBoxUrl = new TextBox();

            //_buttonReadFile
            _buttonReadFile = new Button { Text = StrRes.GetString("StrLoad", "Load") };
            _buttonReadFile.Click += _buttonReadFile_Click;

            //_buttonSaveFile
            _buttonSaveFile = new Button {Text = StrRes.GetString("StrSave","Save")};
            _buttonSaveFile.Click += _buttonSaveFile_Click;

            //_textAreaBody
            _textAreaBody = new TextArea();

            var layout = new DynamicLayout { Padding = new Padding(5, 5), Spacing = new Size(5, 5) };
            layout.BeginVertical();
            layout.BeginHorizontal();
            layout.AddCentered(_textBoxUrl, xscale: true, horizontalCenter: false);
            layout.AddCentered(_buttonReadFile, horizontalCenter: false);
            layout.AddCentered(_buttonSaveFile, horizontalCenter: false);
            layout.EndBeginHorizontal();
            layout.EndVertical();

            layout.AddRow(_textAreaBody);

            Content = layout;
        }
Exemple #6
0
		Control ToggleButton ()
		{
			var control = new Button {
				Text = "Add Columns To Table"
			};

			control.Click += delegate {
				toggle = !toggle;
				this.SuspendLayout ();
				if (toggle) {
					mainTable.Add (VerticalSection (), 0, 0);
					rightSection.AddDockedControl (VerticalSection ());
					middleTable.Add (HorizontalSection (), 0, 2);
					topSection.AddDockedControl (HorizontalSection ());
					control.Text = "Remove Columns";
				}
				else {
					mainTable.Add (null, 0, 0);
					rightSection.AddDockedControl (null);
					middleTable.Add (null, 0, 2);
					topSection.AddDockedControl (null);
					control.Text = "Add Columns To Table";
				}
				this.ResumeLayout ();
			};

			return control;
		}
Exemple #7
0
		Control StartStopButton(ProgressBar bar)
		{
			var control = new Button { Text = "Start Timer" };
			control.Click += delegate
			{
				if (timer == null)
				{
					timer = new UITimer { Interval = 0.5 };
					timer.Elapsed += delegate
					{
						if (bar.Value < bar.MaxValue)
							bar.Value += 50;
						else
							bar.Value = bar.MinValue;
					};
					timer.Start();
					control.Text = "Stop Timer";
				}
				else
				{
					timer.Stop();
					timer.Dispose();
					timer = null;
					control.Text = "Start Timer";
				}
			};
			return control;
		}
Exemple #8
0
        void Init()
        {
	        _tbxShellData = new TextArea {Size = new Size(-1, 200)};
            _tbxMsg = new TextBox();
	        _btnShowMsgInStatus = new Button {Text = "Show Msg In Status", Width = 150};
            _btnShowMsgInStatus.Click+=btn_showMsgInStatus_Click;
			_btnShowMessageBox = new Button { Text = "Show Msg In Message", Width = 150 };
            _btnShowMessageBox.Click+=btn_showMessageBox_Click;
			_btnCreateNewTabPage = new Button { Text = "Create New TabPage", Width = 150 };
            _btnCreateNewTabPage.Click+=btn_createNewTabPage_Click;

			// Test
	        var btnTest = new Button {Text = "Test", Width = 150};
			btnTest.Click += btnTest_Click;

	        var layout = new DynamicLayout {Padding = new Padding(10, 10), Size = new Size(10, 10)};
            layout.AddRow(new Label() { Text = "ShellData"});
			layout.AddRow(_tbxShellData);
			layout.AddSeparateRow(new Label() { Text = "Msg", VerticalAlign = VerticalAlign.Middle }, _tbxMsg, null);
	        layout.AddAutoSized(_btnShowMsgInStatus);
	        layout.AddAutoSized(_btnShowMessageBox);
	        layout.AddAutoSized(_btnCreateNewTabPage);
			layout.AddAutoSized(btnTest);
			layout.Add(null);

            this.Content = layout;
        }
Exemple #9
0
		Control ClearButton (ListBox list)
		{
			var control = new Button{ Text = "Clear" };
			control.Click += delegate {
				list.Items.Clear ();
			};
			return control;
		}
Exemple #10
0
		Control ShowSelectedText (TextArea text)
		{
			var control = new Button { Text = "Show selected text" };
			control.Click += (sender, e) => {
				MessageBox.Show (this, string.Format ("Selected Text: {0}", text.SelectedText));
			};
			return control;
		}
Exemple #11
0
        protected virtual void LogEvents(Button control)
        {
            control.Click += delegate {
                Log.Write (control, "Click");
            };

            LogEvents ((Control)control);
        }
		protected override Forms.Window GetWindow()
		{
			// Add splitters like this:
			// |---------------------------
			// |        |      |          |
			// |  P0    |  P2  |   P4     |
			// | -------|      |          |  <== These are on MainPanel
			// |  P1    |------|          |
			// |        |  P3  |          |
			// |---------------------------
			// |         status0..4,      |  <== These are on StatusPanel
			// ----------------------------

			Label[] status = new Label[] { new Label(), new Label(), new Label(), new Label(), new Label() };

			// Status bar
			var statusPanel = new Panel { };
			var statusLayout = new DynamicLayout(Padding.Empty, Size.Empty);
			statusLayout.BeginHorizontal();
			for (var i = 0; i < status.Length; ++i)
				statusLayout.Add(status[i], xscale: true);
			statusLayout.EndHorizontal();
			statusPanel.Content = statusLayout;

			// Splitter windows
			Panel[] p = new Panel[] { new Panel(), new Panel(), new Panel(), new Panel(), new Panel() };
			var colors = new Color[] { Colors.PaleTurquoise, Colors.Olive, Colors.NavajoWhite, Colors.Purple, Colors.Orange };
			var count = 0;
			for (var i = 0; i < p.Length; ++i)
			{
				var temp = i;
				//p[i].BackgroundColor = colors[i];
				var button = new Button { Text = "Click to update status " + i.ToString(), BackgroundColor = colors[i] };
				button.Click += (s, e) => status[temp].Text = "New count: " + (count++).ToString();
				p[i].Content = button;
			}

			var p0_1 = new Splitter { Panel1 = p[0], Panel2 = p[1], Orientation = SplitterOrientation.Vertical, Position = 200 };
			var p2_3 = new Splitter { Panel1 = p[2], Panel2 = p[3], Orientation = SplitterOrientation.Vertical, Position = 200 };
			var p01_23 = new Splitter { Panel1 = p0_1, Panel2 = p2_3, Orientation = SplitterOrientation.Horizontal, Position = 200};
			var p0123_4 = new Splitter { Panel1 = p01_23, Panel2 = p[4], Orientation = SplitterOrientation.Horizontal, Position = 400 };

			// Main panel
			var mainPanel = new Panel();
			mainPanel.Content = p0123_4;

			// Form's content
			var layout = new DynamicLayout();
			layout.Add(mainPanel, yscale: true);
			layout.Add(statusPanel);
			layout.Generate();
			var form = new Form 
			{ 
				Size = new Size(800, 600),
				Content = layout
			};
			return form;
		}
Exemple #13
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;
		}
Exemple #14
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;
		}
Exemple #15
0
		Control CloseButton()
		{
			var control = new Button{ Text = "Close" };
			control.Click += delegate {
				Close ();
			};
			this.DefaultButton = this.AbortButton = control;
			return control;
		}
Exemple #16
0
		Control TestProperties()
		{
			var min = new DateTimePicker();
			var max = new DateTimePicker();
			var setValue = new DateTimePicker();
			var toValue = new DateTimePicker();
			var modeSelect = new EnumRadioButtonList<CalendarMode>();
			var current = new Calendar();
			var setButton = new Button { Text = "Set" };
			var toValueSection = new StackLayout
			{
				Orientation = Orientation.Horizontal,
				Visible = false,
				Spacing = 5,
				Items = { " to ", toValue }
			};

			var layout = new TableLayout
			{
				Spacing = new Size(5, 5),
				Padding = new Padding(10),
				Rows = 
				{
					new TableRow("Min Value", min),
					new TableRow("Max Value", max),
					new TableRow("Mode", modeSelect),
					new TableRow("Set to value",
						new StackLayout
						{
							Orientation = Orientation.Horizontal,
							Spacing = 5,
							Items = { setValue, toValueSection, setButton }
						}
					),
					new TableRow("Value", TableLayout.AutoSized(current), null),
					null
				}
			};

			modeSelect.SelectedValueBinding.Bind(() => current.Mode, v =>
			{
				toValueSection.Visible = v == CalendarMode.Range;
				current.Mode = v;
			});
			min.ValueChanged += (sender, e) => current.MinDate = min.Value ?? DateTime.MinValue;
			max.ValueChanged += (sender, e) => current.MaxDate = max.Value ?? DateTime.MaxValue;
			setButton.Click += (sender, e) =>
			{
				if (current.Mode == CalendarMode.Range)
					current.SelectedRange = (setValue.Value != null && toValue.Value != null) ? new Range<DateTime>(setValue.Value.Value, toValue.Value.Value) : current.SelectedRange;
				else
					current.SelectedDate = setValue.Value ?? current.SelectedDate;
			};
			LogEvents(current);

			return layout;
		}
Exemple #17
0
		Control ReplaceSelected(TextArea textArea)
		{
			var control = new Button { Text = "Replace selected text" };
			control.Click += (sender, e) => {
				textArea.SelectedText = "Some inserted text!";
				textArea.Focus();
			};
			return control;
		}
Exemple #18
0
		Control ClearSelected(DropDown list)
		{
			var control = new Button { Text = "Clear Selected" };
			control.Click += delegate
			{
				list.SelectedIndex = -1;
			};
			return control;
		}
Exemple #19
0
		Control SelectAll(TextArea text)
		{
			var control = new Button { Text = "Select All" };
			control.Click += (sender, e) => {
				text.SelectAll();
				text.Focus();
			};
			return control;
		}
Exemple #20
0
		Control SetCaret(TextArea textArea)
		{
			var control = new Button { Text = "Set Caret" };
			control.Click += (sender, e) => {
				textArea.CaretIndex = textArea.Text.Length / 2;
				textArea.Focus();
			};
			return control;
		}
Exemple #21
0
 Control BackButton()
 {
     var control = goBack = new Button{
         Text = "Back"
     };
     control.Click += delegate {
         webView.GoBack ();
     };
     return control;
 }
Exemple #22
0
 Control ForwardButton()
 {
     var control = goForward = new Button{
         Text = "Forward"
     };
     control.Click += delegate {
         webView.GoForward ();
     };
     return control;
 }
Exemple #23
0
 Control ExecuteScriptButton()
 {
     var control = new Button{
         Text = "Execute Script"
     };
     control.Click += delegate {
         webView.ExecuteScript("alert('this is called from code');");
     };
     return control;
 }
Exemple #24
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;
		}
Exemple #25
0
		Control StartStopButton(Spinner spinner)
		{
			var control = new Button { Text = spinner.Enabled ? "Stop" : "Start" };
			control.Click += delegate
			{
				spinner.Enabled = !spinner.Enabled;
				control.Text = spinner.Enabled ? "Stop" : "Start";
			};
			return control;
		}
        public HiSumDisplay()
        {
            // sets the client (inner) size of the window for your content
            ClientSize = new Eto.Drawing.Size(600, 400);

            Title = "HiSum";
            TreeGridView view = new TreeGridView(){Height = 500};

            view.Columns.Add(new GridColumn() { HeaderText = "Summary", DataCell = new TextBoxCell(0), AutoSize = true, Resizable = true, Editable = false });
            var textbox = new TextBox() {Width = 1000};
            var button = new Button(){Text = "Go", Width = 15};
            var label = new Label() {Width = 100};
            var tbResult = new TextArea() {Width = 1000};

            button.Click += (sender, e) =>
            {
                Reader reader = new Reader();
                List<int> top100 = reader.GetTop100();
                List<FullStory> fullStories = new List<FullStory>();
                foreach (int storyID in top100.Take(30))
                {
                    FullStory fullStory = reader.GetStoryFull(storyID);
                    fullStories.Add(fullStory);
                }
                TreeGridItemCollection data = GetTree(fullStories);
                view.DataStore = data;
            };
            Content = new TableLayout
            {
                Spacing = new Size(5, 5), // space between each cell
                Padding = new Padding(10, 10, 10, 10), // space around the table's sides
                Rows = {
                    new TableRow(
                        new Label{Text = "Input URL from Hacker News: ",Width=200},
                        textbox,
                        button,
                        label
                    ),
                    new TableRow(
                        null,
                        tbResult,
                        null,
                        null
                        ),
                    new TableRow(
                        new Label(),
                        view
                    ),

                    // by default, the last row & column will get scaled. This adds a row at the end to take the extra space of the form.
                    // otherwise, the above row will get scaled and stretch the TextBox/ComboBox/CheckBox to fill the remaining height.
                    new TableRow { ScaleHeight = true }
                }
            };
        }
Exemple #27
0
		public UnitTestSection()
		{
			var layout = new DynamicLayout();
			var button = new Button { Text = "Start Tests" };
			layout.Add(null);
			layout.Add(button);
			layout.Add(null);

			Content = layout;

			button.Click += (s, e) =>
			{
				button.Enabled = false;
				var thread = new Thread(() =>
				{
					using (Generator.ThreadStart())
					{
						var oldOut = Console.Out;
						var oldErr = Console.Error;
						var output = new EventStringWriter();
						output.Flushed += val => Application.Instance.Invoke(() =>
						{
							foreach (var line in val.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
								Log.Write(null, line);
							output.Clear();
						});
						Console.SetOut(output);
						Console.SetError(output);
						try
						{
							var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
							#if DESKTOP
							var consoleRunner = NUnit.ConsoleRunner.Runner.Main(new[]
							{
								"-noshadow",
								"-nothread",
								"-nologo",
								"-nodots",
								"-domain=None",
								"-work=" + dir,
								typeof(Eto.Test.UnitTests.Startup).Assembly.Location
							});
							#endif
						}
						finally
						{
							Console.SetOut(oldOut);
							Console.SetError(oldErr);
							Application.Instance.Invoke(() => button.Enabled = true);
						}
					}
				});
				thread.Start();
			};
		}
Exemple #28
0
		Control DefaultSizeButton()
		{
			var control = new Button { Text = "B", Size = new Size(50, 50) };
			LogEvents(control);
			var control2 = new Button { Text = "Button With Text", Size = new Size(-1, 50) };
			LogEvents(control2);

			var layout = new DynamicLayout { Spacing = new Size(5, 5) };
			layout.AddRow(new Label { Text = "With Default Size of 50x50:", VerticalAlignment = VerticalAlignment.Center }, control, control2);
			return layout;
		}
 public static Button CancelButton(this Dialog dialog, string text = null, Func<bool> clicked = null)
 {
     var control = new Button { Text = text ?? "Cancel" };
     dialog.AbortButton = control;
     control.Click += (sender, e) => {
         if (clicked != null && !clicked())
             return;
         dialog.Close(DialogResult.Cancel);
     };
     return control;
 }
Exemple #30
0
		Control SetSelectedText(TextArea textArea)
		{
			var control = new Button { Text = "Set selected text" };
			control.Click += (sender, e) => {
				var text = textArea.Text;
				// select the last half of the text
				textArea.Selection = new Range(text.Length / 2, text.Length / 2 + 1);
				textArea.Focus();
			};
			return control;
		}
Exemple #31
0
        public StepperRenderer()
        {
            Control = new Panel();
            var table      = new TableLayout();
            var plusButton = new Eto.Forms.Button()
            {
                Text = "+"
            };
            var minusButton = new Eto.Forms.Button()
            {
                Text = "-"
            };

            table.Rows.Add(new TableRow(
                               new TableCell(plusButton, true),
                               new TableCell(minusButton, true)
                               ));
            plusButton.Click  += PlusButtonClick;
            minusButton.Click += MinusButtonClick;
        }
Exemple #32
0
        /// <summary>
        /// Show a general settings dialog.
        /// </summary>
        private static void ShowSettings(object sender, object e)
        {
            // Options dialog.
            Eto.Forms.Form dialog = new Eto.Forms.Form();
            dialog.Size = new Eto.Drawing.Size(300, 300);

            StackLayout buttonStack = new StackLayout();

            Eto.Forms.Button b0 = new Eto.Forms.Button();
            buttonStack.Items.Add(b0);

            // Set the main content and options.
            dialog.Content = buttonStack;

            dialog.BackgroundColor = Colors.SlateGray;
            dialog.Maximizable     = false;
            dialog.Minimizable     = false;
            dialog.Topmost         = true;

            dialog.Show();
        }
Exemple #33
0
        public Dialog_SaveColorSet(System.Collections.Generic.List <HoneybeeSchema.Color> colors)
        {
            this.Title = "Save as a preset";
            this.Width = 300;
            this.Icon  = DialogHelper.HoneybeeIcon;

            var layout = new DynamicLayout();

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

            var name = new TextBox()
            {
                PlaceholderText = "Input a name for this preset"
            };

            layout.AddSeparateRow("Name:", name);

            var OkBtn = new Eto.Forms.Button()
            {
                Text = "OK"
            };

            OkBtn.Click += (s, e) => {
                var n = name.Text;
                if (LegendColorSet.SaveUserColorSet(n, colors))
                {
                    this.Close();
                }
            };
            this.AbortButton = new Eto.Forms.Button()
            {
                Text = "Cancel"
            };
            this.AbortButton.Click += (s, e) => { this.Close(); };

            layout.AddSeparateRow(null, OkBtn, this.AbortButton, null);
            layout.AddSeparateRow(null);
            this.Content = layout;
        }
Exemple #34
0
        public MyForm()
        {
            if (File.Exists("Config.json"))
            {
                Settings = JsonSettings.Load <MySettings>("Config.json");
            }
            else
            {
                Settings = JsonSettings.Construct <MySettings>("Config.json");
            }

            // sets the client (inner) size of the window for your content
            //this.ClientSize = new Eto.Drawing.Size(600, 400);
            this.ClientSize   = Settings.windowSize;
            this.SizeChanged += (sender, args) =>
            {
                Settings.windowSize = this.ClientSize;
                Settings.Save();
            };
            this.Title = "KruBot3";
            var Twitch  = new WebView();
            var Pretzel = new WebView();

            Twitch.OpenNewWindow  += TwitchOnOpenNewWindow;
            Pretzel.OpenNewWindow += TwitchOnOpenNewWindow; //Nothing special is needed.
            Twitch.Url             = new Uri("https://www.twitch.tv/popout/" + Settings.Username + "/chat?popout=");
            WebClient wb     = new WebClient();
            string    Script = wb.DownloadString("https://cdn.frankerfacez.com/static/ffz_injector.user.js");

            Twitch.DocumentLoaded += (sender, args) =>
                                     // Twitch.ExecuteScript(""););
                                     Pretzel.Url = new Uri("https://app.pretzel.rocks/player");
            var browserLayout = new Splitter();

            browserLayout.Panel1           = Twitch;
            browserLayout.Panel2           = Pretzel;
            browserLayout.Orientation      = Orientation.Horizontal;
            browserLayout.RelativePosition = 0.75;
            browserLayout.FixedPanel       = SplitterFixedPanel.None;
            browserLayout.PositionChanged += (sender, args) =>
            {
                Console.WriteLine(browserLayout.RelativePosition);
                Settings.splitPosition = browserLayout.RelativePosition;
                Settings.Save();
            };
            browserLayout.RelativePosition = Settings.splitPosition;

            var Tabs     = new TabControl();
            var TabPage1 = new TabPage();

            TabPage1.Text    = "Main Chat";
            TabPage1.Content = browserLayout;
            Tabs.Pages.Add(TabPage1);

            var TabPage2 = new TabPage();

            TabPage2.Text = "Settings";

            var t2Contents = new StackLayout();

            t2Contents.Padding = 50;
            Label Info = new Label();

            Info.Text = "This page lets you configure the bot to be able to listen to your chat.";
            t2Contents.Items.Add(Info);
            Label Info2 = new Label();

            Info2.Text = "Please enter your Username Below:";
            t2Contents.Items.Add(Info2);
            TextBox userName = new TextBox();

            userName.Size = new Size(400, userName.Height);
            if (Settings.Username == "Twitch")
            {
                userName.PlaceholderText = "Username";
            }
            else
            {
                userName.Text = Settings.Username;
            }

            t2Contents.Items.Add(userName);

            Label Info3 = new Label();

            Info3.Text = "And now we need an OAuth Code from that account:";
            t2Contents.Items.Add(Info3);

            Button openOAuth = new Button();

            openOAuth.Click += OpenOAuthOnClick;
            openOAuth.Text   = "Open Website";
            t2Contents.Items.Add(openOAuth);

            PasswordBox oAuth = new PasswordBox();

            if (string.IsNullOrEmpty(Settings.oAuthToken))
            {
            }
            else
            {
                oAuth.Text = Settings.oAuthToken;
            }

            oAuth.Size = new Size(400, oAuth.Height);
            t2Contents.Items.Add(oAuth);

            Label SaveNow = new Label();

            SaveNow.Text = "Once you're done, click this button to save your settings!";
            t2Contents.Items.Add(SaveNow);

            Button Save = new Button();

            Save.Text   = "Save!";
            Save.Click += (sender, args) =>
            {
                Settings.Username   = userName.Text.ToLower();
                Settings.oAuthToken = oAuth.Text;
                Settings.Save();
                MessageBox.Show("Saved!");
                Twitch.Url = new Uri("https://www.twitch.tv/popout/" + Settings.Username + "/chat?popout=");
                initBot();
            };
            t2Contents.Items.Add(Save);
            TabPage2.Content = t2Contents;
            Tabs.Pages.Add(TabPage2);
            this.Content = Tabs;


            #region Bringing up the bot

            if (string.IsNullOrEmpty(Settings.oAuthToken))
            {
                Tabs.SelectedIndex = 1;
            }
            else
            {
                initBot();
            }

            #endregion
        }
Exemple #35
0
        private Dialog_Error(HoneybeeSchema.ValidationReport report)
        {
            this.Title = $"Validation Report - {DialogHelper.PluginName}";
            this.Width = 800;
            this.Icon  = DialogHelper.HoneybeeIcon;

            _vm = new ErrorViewModel(report, this);

            _grid = GenGridView();
            var nextBtn = new Button()
            {
                Text = ">>"
            };
            var currentErrorIndex = new Label();
            var preBtn            = new Button()
            {
                Text = "<<"
            };
            var showBtn = new Button()
            {
                Text = "Show"
            };
            var showParentBtn = new Button()
            {
                Text = "Show Parent"
            };
            var moreInfoBtn = new Button()
            {
                Text = "More Info"
            };

            var message = new TextArea()
            {
                Height = 84
            };


            message.TextBinding.Bind(_vm, _ => _.CurrentErrorMessage);
            currentErrorIndex.TextBinding.Bind(_vm, _ => _.CurrentErrorIndex);
            nextBtn.Bind(_ => _.Enabled, _vm, _ => _.NextBtnEnabled);
            preBtn.Bind(_ => _.Enabled, _vm, _ => _.PreBtnEnabled);
            moreInfoBtn.Bind(_ => _.Enabled, _vm, _ => _.MoreBtnEnabled);

            showBtn.Bind(_ => _.Enabled, _vm, _ => _.ShowBtnEnabled);
            showParentBtn.Bind(_ => _.Enabled, _vm, _ => _.ShowParentBtnEnabled);

            nextBtn.Command       = _vm.NextBtnCommand;
            preBtn.Command        = _vm.PreBtnCommand;
            moreInfoBtn.Command   = _vm.ErrorLinkCommand;
            showBtn.Command       = _vm.ShowCommand;
            showParentBtn.Command = _vm.ShowParentCommand;
            //errorLink.Command = _vm.ErrorLinkCommand;


            var group = new GroupBox();

            group.Bind(_ => _.Text, _vm, _ => _.TotalErrorMessage);

            group.Size = new Eto.Drawing.Size(-1, -1);
            var groupLayout = new DynamicLayout();

            groupLayout.DefaultSpacing = new Eto.Drawing.Size(5, 5);
            groupLayout.DefaultPadding = new Eto.Drawing.Padding(5);
            groupLayout.AddSeparateRow(_grid);
            groupLayout.AddSeparateRow(preBtn, currentErrorIndex, nextBtn, null, showBtn, showParentBtn, moreInfoBtn);
            groupLayout.AddSeparateRow(message);
            group.Content = groupLayout;

            var validateBtn = new Eto.Forms.Button()
            {
                Text = "Re-Validate"
            };

            validateBtn.Bind(_ => _.Visible, _vm, _ => _.ValidateBtnEnabled);
            validateBtn.Command = _vm.ValidateCommand;

            var abortButton = new Eto.Forms.Button()
            {
                Text = "Close", Height = 24
            };

            abortButton.Click += (s, e) => { this.Close(); };

            var layout = new Eto.Forms.DynamicLayout();

            layout.DefaultSpacing = new Eto.Drawing.Size(5, 2);
            layout.DefaultPadding = new Eto.Drawing.Padding(4);
            layout.AddSeparateRow(controls: new[] { group }, xscale: true, yscale: true);
            layout.AddSeparateRow(null, validateBtn, abortButton);
            this.Content = layout;

            _vm.UILoaded();
        }
Exemple #36
0
        public Dialog_Legend(LegendParameter parameter, Action <LegendParameter> previewAction = default)
        {
            this.Title = $"Legend Parameters - {DialogHelper.PluginName}";
            this.Width = 400;
            this.Icon  = DialogHelper.HoneybeeIcon;

            _vm = new LegendViewModel(parameter, this);

            var title = new TextBox();
            var x     = new Eto.Forms.NumericStepper()
            {
                MinValue = 0
            };
            var y = new Eto.Forms.NumericStepper()
            {
                MinValue = 0
            };
            var w = new Eto.Forms.NumericStepper()
            {
                MinValue = 1
            };
            var h = new Eto.Forms.NumericStepper()
            {
                MinValue = 1
            };
            var fontH = new Eto.Forms.NumericStepper()
            {
                MinValue = 1
            };
            var fontColor     = new Button();
            var decimalPlaces = new Eto.Forms.NumericStepper()
            {
                DecimalPlaces = 0, MinValue = 0
            };


            title.TextBinding.Bind(_vm, _ => _.Title);
            x.ValueBinding.Bind(_vm, _ => _.X);
            y.ValueBinding.Bind(_vm, _ => _.Y);
            w.ValueBinding.Bind(_vm, _ => _.W);
            h.ValueBinding.Bind(_vm, _ => _.H);
            fontH.ValueBinding.Bind(_vm, _ => _.FontHeight);
            fontColor.Bind(_ => _.BackgroundColor, _vm, _ => _.FontColor);
            fontColor.Command = _vm.FontColorCommand;
            decimalPlaces.ValueBinding.Bind(_vm, _ => _.DecimalPlaces);

            var minNum = new Eto.Forms.NumericStepper()
            {
                MaximumDecimalPlaces = 5
            };
            var maxNum = new Eto.Forms.NumericStepper()
            {
                MaximumDecimalPlaces = 5
            };
            var numSeg = new Eto.Forms.NumericStepper()
            {
                DecimalPlaces = 0, MinValue = 1
            };
            var continuous = new CheckBox();
            var horizontal = new CheckBox();

            minNum.ValueBinding.Bind(_vm, _ => _.Min);
            maxNum.ValueBinding.Bind(_vm, _ => _.Max);
            numSeg.ValueBinding.Bind(_vm, _ => _.NumSeg);
            continuous.CheckedBinding.Bind(_vm, _ => _.Continuous);
            horizontal.CheckedBinding.Bind(_vm, _ => _.IsHorizontal);
            minNum.Bind(_ => _.Enabled, _vm, _ => _.IsNumberValues);
            maxNum.Bind(_ => _.Enabled, _vm, _ => _.IsNumberValues);
            numSeg.Bind(_ => _.Enabled, _vm, _ => _.IsNumberValues);
            continuous.Bind(_ => _.Enabled, _vm, _ => _.IsNumberValues);


            var colorPanel = GenColorControl();
            var tb         = new TabControl();

            tb.Pages.Add(new TabPage(colorPanel)
            {
                Text = "Colors"
            });

            var general = new DynamicLayout();

            general.Height         = 280;
            general.DefaultSpacing = new Eto.Drawing.Size(5, 5);
            general.DefaultPadding = new Eto.Drawing.Padding(5);
            general.AddRow("Font height:", fontH);
            general.AddRow("Font color:", fontColor);
            general.AddRow("Location X:", x);
            general.AddRow("Location Y:", y);
            general.AddRow("Width:", w);
            general.AddRow("Height:", h);
            general.AddRow("Decimal places", decimalPlaces);
            general.AddRow(null, null);
            tb.Pages.Add(new TabPage(general)
            {
                Text = "Settings"
            });

            var OkBtn = new Eto.Forms.Button()
            {
                Text = "OK"
            };

            OkBtn.Click += (s, e) => {
                if (_vm.Validate())
                {
                    var lg = _vm.GetLegend();
                    this.Close(lg);
                }
            };
            this.AbortButton = new Eto.Forms.Button()
            {
                Text = "Cancel"
            };
            this.AbortButton.Click += (s, e) => { this.Close(); };

            var preview = new Button()
            {
                Text = "Preview", Visible = previewAction != default
            };

            preview.Click += (s, e) =>
            {
                if (_vm.Validate())
                {
                    var lg = _vm.GetLegend();
                    previewAction?.Invoke(lg);
                }
            };

            var layout = new Eto.Forms.DynamicLayout();

            layout.DefaultSpacing = new Eto.Drawing.Size(5, 2);
            layout.DefaultPadding = new Eto.Drawing.Padding(4);
            layout.AddSeparateRow("Legend title:", title);
            layout.AddSeparateRow("Maximum:", maxNum);
            layout.AddSeparateRow("Minimum:", minNum);
            layout.AddSeparateRow("Number of segment:", numSeg);
            layout.AddSeparateRow("Continuous colors:", continuous);
            layout.AddSeparateRow("Horizontal:", horizontal);

            layout.AddSeparateRow(tb);

            //layout.AddSeparateRow("Font height:", fontH, null, "Font color:", fontColor);
            //layout.AddSeparateRow("X:", x, "Y:", y, "W", w, "H", h);
            layout.AddSeparateRow(null, OkBtn, this.AbortButton, null, preview);
            layout.AddRow(null);
            this.Content = layout;
        }