Example #1
1
        /// <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);
        }
Example #2
1
        /// <summary>
        /// Creates new image display form.
        /// </summary>
        /// <param name="title">Window title.</param>
        public ImageForm(string title = "")
        {
            Title = title;
            ClientSize = new Size(640, 480);

            imageView = new ImageView { Image = bmp };

            Content = new Scrollable
            {
                Content = imageView
            };
        }
Example #3
0
		/// <summary>
		/// Sets attributes on the specified <paramref name="element"/> with width and height attributes of the specified value
		/// </summary>
		/// <remarks>
		/// This will write attributes with suffixes "-width" and "-height" prefixed by <paramref name="baseName"/>.
		/// For example, if you specify "myProperty" as the base name, then it will write attributes "myProperty-width" and "myProperty-height".
		/// 
		/// Passing null as the size will not write either attribute value.
		/// </remarks>
		/// <param name="element">Element to write the width and height attributes on</param>
		/// <param name="baseName">Base attribute name prefix</param>
		/// <param name="value">Value to set the width and height attributes, if not null</param>
		public static void SetSizeAttributes (this XmlElement element, string baseName, Size? value)
		{
			if (value != null) {
				element.SetAttribute (baseName + "-width", value.Value.Width);
				element.SetAttribute (baseName + "-height", value.Value.Height);
			}
		}
Example #4
0
		public MainForm(IEnumerable<Section> topNodes = null)
		{
			Title = string.Format("Test Application [{0}, {1} {2}, {3}]",
				Platform.ID,
				EtoEnvironment.Is64BitProcess ? "64bit" : "32bit",
				EtoEnvironment.Platform.IsMono ? "Mono" : ".NET",
				EtoEnvironment.Platform.IsWindows ? EtoEnvironment.Platform.IsWinRT
				? "WinRT" : "Windows" : EtoEnvironment.Platform.IsMac
				? "Mac" : EtoEnvironment.Platform.IsLinux
				? "Linux" : EtoEnvironment.Platform.IsUnix
				? "Unix" : "Unknown");
			Style = "main";
			MinimumSize = new Size(400, 400);
			topNodes = topNodes ?? TestSections.Get(TestApplication.DefaultTestAssemblies());
			//SectionList = new SectionListGridView(topNodes);
			//SectionList = new SectionListTreeView(topNodes);
			if (Platform.IsAndroid)
				SectionList = new SectionListGridView(topNodes);
			else
				SectionList = new SectionListTreeGridView(topNodes);

			this.Icon = TestIcons.TestIcon;

			if (Platform.IsDesktop)
				ClientSize = new Size(900, 650);
			//Opacity = 0.5;

			Content = MainContent();

			CreateMenuToolBar();
		}
Example #5
0
        /// <summary>
        /// Sets the specified image.
        /// </summary>
        /// <param name="image">Image to display.</param>
        public void SetImage(Bgr<byte>[,] image)
        {
            if (bmp == null || bmp.Width != image.Width() || bmp.Height != image.Height())
            {
                bmp = new Bitmap(image.Width(), image.Height(), PixelFormat.Format24bppRgb);
            }

            BitmapData bmpData = bmp.Lock();
            if (bmpData.BytesPerPixel != image.ColorInfo().Size)
            {
                bmpData.Dispose();
                bmpData = null;
                bmp = new Bitmap(image.Width(), image.Height(), PixelFormat.Format24bppRgb);
            }

            bmpData = bmpData ?? bmp.Lock();
            using (var uIm = image.Lock())
            {
                Copy.UnsafeCopy2D(uIm.ImageData, bmpData.Data, uIm.Stride, bmpData.ScanWidth, uIm.Height);
            }

            bmpData.Dispose();

            imageView.Image = bmp;

            if (ScaleForm)
                ClientSize = new Size(image.Width(), image.Height());
        }
Example #6
0
		/// <summary>
		/// Test paint operations on a drawable
		/// </summary>
		/// <param name="paint">Delegate to execute during the paint event</param>
		/// <param name="size">Size of the drawable, or null for 200x200</param>
		/// <param name="timeout">Timeout to wait for the operation to complete</param>
		public static void Paint(Action<Drawable, PaintEventArgs> paint, Size? size = null, int timeout = DefaultTimeout)
		{
			Exception exception = null;
			Form(form =>
			{
				var drawable = new Drawable { Size = size ?? new Size(200, 200) };
				drawable.Paint += (sender, e) =>
				{
					try
					{
						paint(drawable, e);
					}
					catch (Exception ex)
					{
						exception = ex;
					}
					finally
					{
						Application.Instance.AsyncInvoke(form.Close);
					}
				};
				form.Content = drawable;
			}, timeout);
			if (exception != null)
				throw new Exception("Paint event caused exception", exception);
		}
Example #7
0
		void Init()
		{
			_comboBoxServices = new ComboBox();
			_comboBoxServices.SelectedIndexChanged += _comboBoxServices_SelectedIndexChanged;

			_textAreaInfo = new TextArea{Size=new Size(-1,200)};
			_textAreaInfo.Enabled = false;
			_textAreaResult = new TextArea();
			_textAreaResult.Text = "If you wanna call one service, you can do like this:\n" +
									"dynamic ToBase64 = PluginServiceProvider.GetService(\"ToBase64\");\n" +
									"var result = ToBase64(new PluginParameter(\"str\", \"Test\"));\n" +
									"//result=\"VGVzdA==\"";
			_textAreaResult.Enabled = false;

			var layout = new DynamicLayout {Padding = new Padding(10, 10)};

			layout.AddSeparateRow(
				new Label {Text = "The Registered Services", VerticalAlign = VerticalAlign.Middle},
				_comboBoxServices);
			layout.AddSeparateRow(_textAreaInfo);
			layout.AddSeparateRow(_textAreaResult);

			Content = layout;
			Title = "Developer Tool";
			Size = new Size(400, 400);
		}
Example #8
0
File: Main.cs Project: mhusen/Eto
		public MyForm()
		{
			ClientSize = new Size(600, 400);
			Title = "Table Layout";


			Content = new TableLayout(
				new TableRow(new Label { Text = "DataContext Binding" }, DataContextBinding()),
				new TableRow(new Label { Text = "Object Binding" }, ObjectBinding()),
				new TableRow(new Label { Text = "Direct Binding" }, DirectBinding()),
				null // same as creating a row with ScaleHeight = true
			) { Spacing = new Size(5, 5), Padding = new Padding(10) };

			// Set data context so it propegates to all child controls
			DataContext = new MyObject { TextProperty = "Initial value 1" };

			Menu = new MenuBar
			{
				QuitItem = new Command((sender, e) => Application.Instance.Quit())
				{ 
					MenuText = "Quit",
					Shortcut = Application.Instance.CommonModifier | Keys.Q
				}
			};
		}
Example #9
0
		public Rectangle(Size size)
		{
			this.x = 0;
			this.y = 0;
			this.width = size.Width;
			this.height = size.Height;
		}
Example #10
0
        public CSyclesForm(string path)
        {
            ClientSize = new Eto.Drawing.Size(500, 500);
            Title = "CSycles Tester";
            Path = path;

            Image = new ef.ImageView();
            var layout = new ef.TableLayout();
            layout.Rows.Add(
                new ef.TableRow(
                    Image
                    )
                );

            var scenes = Directory.EnumerateFiles(path, "scene*.xml");
            Menu = new ef.MenuBar();
            var scenesmenu = Menu.Items.GetSubmenu("scenes");
            foreach(var sf in scenes)
            {
                scenesmenu.Items.Add(new RenderModalCommand(this, sf));
            }

            Content = layout;

            var m = new RendererModel();
            DataContext = m;
        }
Example #11
0
		void SetButtonsPosition()
		{
			// remove the buttons 
			if (PixelLayout.Children.Contains(Buttons))
				PixelLayout.Remove(Buttons);

			var size = new Size(200, 200);
			var location = Point.Empty;
			var containerSize = PixelLayout.Size;

			// X
			if (Anchor.HasFlag(Anchor.Right) && !Anchor.HasFlag(Anchor.Left))
				location.X = containerSize.Width - size.Width;

			// Y
			if (Anchor.HasFlag(Anchor.Bottom) && !Anchor.HasFlag(Anchor.Top))
				location.Y = containerSize.Height - size.Height;

			// Width
			if (Anchor.HasFlag(Anchor.Left) && Anchor.HasFlag(Anchor.Right))
				size.Width = containerSize.Width;

			// Height
			if (Anchor.HasFlag(Anchor.Top) && Anchor.HasFlag(Anchor.Bottom))
				size.Height = containerSize.Height;

			// At this point size and location are where
			// Buttons should be displayed.
			Buttons.Size = size;
			PixelLayout.Add(Buttons, location);
		}
Example #12
0
		public Rectangle(Point point, Size size)
		{
			this.x = point.X;
			this.y = point.Y;
			this.width = size.Width;
			this.height = size.Height;
		}
Example #13
0
        public MainForm()
        {
            _mainView = ServiceLocator.Current.Get <MainView>();
            _mainVm   = ServiceLocator.Current.Get <MainViewModel>();

            Title      = CoreApp.AssemblyProduct;
            ClientSize = new Eto.Drawing.Size(720, 480);
            Style      = EtoStyles.FormMain;

            if (!Platform.IsGtk)
            {
                Icon = DesktopAppResources.DevAppIcon;
            }

            Menu    = BuildMenu();
            Content = _mainView;

            MainApplication.TrayIndicator = CreateTrayIndicator();
            MainApplication.TrayIndicator.Show();

            ConfigureDataBinding();

            this.DataContext = _mainVm;
            _menuItemAlwaysOnTop.DataContext = _mainVm;
            _menuItemNew.DataContext         = _mainVm;
            _menuItemOpen.DataContext        = _mainVm;
            _menuItemSave.DataContext        = _mainVm;
            _menuItemSaveAs.DataContext      = _mainVm;
            _menuItemExit.DataContext        = _mainVm;
        }
Example #14
0
        public CSyclesForm(string path)
        {
            ClientSize = new Eto.Drawing.Size(500, 500);
            Title      = "CSycles Tester";
            Path       = path;

            Image = new ef.ImageView();
            var layout = new ef.TableLayout();

            layout.Rows.Add(
                new ef.TableRow(
                    Image
                    )
                );

            var scenes = Directory.EnumerateFiles(path, "scene*.xml");

            Menu = new ef.MenuBar();
            var scenesmenu = Menu.Items.GetSubmenu("scenes");

            foreach (var sf in scenes)
            {
                scenesmenu.Items.Add(new RenderModalCommand(this, sf));
            }

            Content = layout;

            var m = new RendererModel();

            DataContext = m;
        }
Example #15
0
File: Main.cs Project: mhusen/Eto
		public MyForm()
		{
			ClientSize = new Size(600, 400);
			Title = "Table Layout";

			// The main layout mechanism for Eto.Forms is a TableLayout.
			// This is recommended to allow controls to keep their natural platform-specific size.
			// You can layout your controls declaratively using rows and columns as below, or add to the TableLayout.Rows and TableRow.Cell directly.

			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 TableCell(new Label { Text = "First Column" }, true), 
						new TableCell(new Label { Text = "Second Column" }, true),
						new Label { Text = "Third Column" }
					),
					new TableRow(
						new TextBox { Text = "Some text" },
						new DropDown { Items = { "Item 1", "Item 2", "Item 3" } },
						new CheckBox { Text = "A checkbox" }
					),
					// 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 }
				}
			};

			// This creates the following layout:
			//  --------------------------------
			// |First     |Second    |Third     |
			//  --------------------------------
			// |<TextBox> |<ComboBox>|<CheckBox>|
			//  --------------------------------
			// |          |          |          |
			// |          |          |          |
			//  --------------------------------
			//
			// Some notes:
			//  1. When scaling the width of a cell, it applies to all cells in the same column.
			//  2. When scaling the height of a row, it applies to the entire row.
			//  3. Scaling a row/column makes it share all remaining space with other scaled rows/columns.
			//  4. If a row/column is not scaled, it will be the size of the largest control in that row/column.
			//  5. A Control can be implicitly converted to a TableCell or TableRow to make the layout more concise.

			Menu = new MenuBar
			{
				QuitItem = new Command((sender, e) => Application.Instance.Quit())
				{
					MenuText = "Quit",
					Shortcut = Application.Instance.CommonModifier | Keys.Q
				}
			};
		}
Example #16
0
        public MainForm()
        {
            Title = "MachoMap";
            Size = new Size(1280, 800);

            Menu = new MenuBar();
            ButtonMenuItem fileMenu = Menu.Items.GetSubmenu("&File");
            fileMenu.Items.AddRange(new Command[] { new NewWindowCommand(), new OpenFileCommand(this) });
        }
Example #17
0
        public MainForm()
        {
            Title = "Notedown";
            Icon = Icon.FromResource("Icon.ico");
            ClientSize = new Size(800, 600);
            Style = "MainWindow";

            Update();
        }
Example #18
0
			public void ReadXml (XmlElement element)
			{
				var width = element.GetIntAttribute ("width");
				var height = element.GetIntAttribute ("height");
				var size = Size;
				if (width != null) size.Width = width.Value;
				if (height != null) size.Height = height.Value;
				Size = size;
			}
Example #19
0
 public TableLayout(Container container, Size size)
     : base(container != null ? container.Generator : Generator.Current, container, typeof(ITableLayout), false)
 {
     inner = (ITableLayout)Handler;
     this.Size = size;
     Initialize ();
     if (this.Container != null)
         this.Container.Layout = this;
 }
Example #20
0
		public void ClipBoundsShouldMatchClientSize()
		{
			var size = new Size(200, 200);
			TestUtils.Paint((drawable, e) =>
			{
				var graphics = e.Graphics;
				Assert.AreEqual(size, drawable.ClientSize, "Drawable client size should be 200x200");
				Assert.AreEqual(Size.Round(drawable.ClientSize), Size.Round(graphics.ClipBounds.Size), "Clip bounds should match drawable client size");
			}, size);
		}
Example #21
0
        /// <summary>
        /// Creates new image display form.
        /// </summary>
        /// <param name="title">Window title.</param>
        public ImageForm(string title = "")
        {
            Title = title;
            ClientSize = new Size(640, 480);

            PictureBox = new PictureBox { Image = bmp, AutoScale = true };
            Content = PictureBox;

            this.Shown += (s, e) => PictureBox.Image = bmp;
        }
Example #22
0
		public DynamicLayout(Padding? padding, Size? spacing = null, Generator generator = null)
			: base(generator)
		{
			topTable = new DynamicTable
			{ 
				Padding = padding, 
				Spacing = spacing
			};
			currentItem = topTable;
		}
        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 }
                }
            };
        }
			public Box (Size canvasSize, bool useTexturesAndGradients)
			{
				var size = new SizeF(random.Next (50) + 50, random.Next (50) + 50);
				var location = new PointF(random.Next (canvasSize.Width - (int)size.Width), random.Next (canvasSize.Height - (int)size.Height));
				position = new RectangleF(location, size);
				increment = new SizeF (random.Next (3) + 1, random.Next (3) + 1);
				if (random.Next (2) == 1)
					increment.Width = -increment.Width;
				if (random.Next (2) == 1)
					increment.Height = -increment.Height;

				angle = random.Next (360);
				rotation = (random.Next (20) - 10f) / 4f;

				var rect = new RectangleF (size);
				color = GetRandomColor (random);
				switch (random.Next (useTexturesAndGradients ? 4 : 2)) {
				case 0:
					draw = (g) => g.DrawRectangle (color, rect);
					erase = (g) => g.DrawRectangle (Colors.Black, rect);
					break;
				case 1:
					draw = (g) => g.DrawEllipse (color, rect);
					erase = (g) => g.DrawEllipse (Colors.Black, rect);
					break;
				case 2:
					switch (random.Next (2)) {
					case 0:
						fillBrush = new LinearGradientBrush (GetRandomColor (random), GetRandomColor (random), PointF.Empty, new PointF(size.Width, size.Height));
						break;
					case 1:
						fillBrush = new TextureBrush(texture) {
							Transform = Matrix.FromScale (size / 80)
						};
						break;
					}
					draw = (g) => g.FillEllipse (fillBrush, rect);
					erase = (g) => g.FillEllipse (Colors.Black, rect);
					break;
				case 3:
					switch (random.Next (2)) {
					case 0:
						fillBrush = new LinearGradientBrush (GetRandomColor (random), GetRandomColor (random), PointF.Empty, new PointF(size.Width, size.Height));
						break;
					case 1:
						fillBrush = new TextureBrush(texture) {
							Transform = Matrix.FromScale (size / 80)
						};
						break;
					}
					draw = (g) => g.FillRectangle (fillBrush, rect);
					erase = (g) => g.FillRectangle (Colors.Black, rect);
					break;
				}
			}
Example #25
0
File: Main.cs Project: mhusen/Eto
		public MyForm()
		{
			// Set ClientSize instead of Size, as each platform has different window border sizes
			ClientSize = new Size(600, 400);

			// Title to show in the title bar
			Title = "Hello, Eto.Forms";

			// Content of the form
			Content = new Label { Text = "Some content", VerticalAlign = VerticalAlign.Middle, HorizontalAlign = HorizontalAlign.Center };
		}
Example #26
0
        void Init()
        {
            //_textAreaWelcome
	        _textAreaWelcome = new TextArea() {Size = new Size(418, 277), Text = AltStrRes.Disclaimer};
	        _textAreaWelcome.Wrap = true;
	        _textAreaWelcome.Enabled = false;

            //_checkBoxNoDisplay
			_checkBoxNoDisplay = new CheckBox() { Text = AltStrRes.DontDisplayAgain};

            //_buttonNo
			_buttonNo = new Button() { Text = AltStrRes.No};
            _buttonNo.Click += delegate
            {
                if (_checkBoxNoDisplay.Checked == true)
                {
                    _setting.IsShowDisclaimer = false;

                    //保存Setting到xml
					InitWorker.SaveSettingToXml(AppEnvironment.AppPath, _setting);
                    //重新初始化GlobalSetting
					InitWorker.InitGlobalSetting(AppEnvironment.AppPath);
                }
				//Application.Instance.Quit();
				Environment.Exit(0);
            };

            //_buttonYes
	        _buttonYes = new Button() {Text = AltStrRes.Yes};
            _buttonYes.Click += delegate
            {
                if (_checkBoxNoDisplay.Checked == true)
                {
                    _setting.IsShowDisclaimer = false;
                    //保存Setting到xml
					InitWorker.SaveSettingToXml(AppEnvironment.AppPath, _setting);
                    //重新初始化GlobalSetting
					InitWorker.InitGlobalSetting(AppEnvironment.AppPath);
                }
                Close();
            };

            var layout = new DynamicLayout();
            layout.AddRow(_textAreaWelcome);
            layout.AddSeparateRow(_checkBoxNoDisplay,null, _buttonNo, _buttonYes);
            layout.AddRow(null);

            Content = layout;
            Size = new Size(460,370);
			Icon = Icons.AltmanIcon;
			ShowInTaskbar = true;
            Title = AltStrRes.Welcome;
        }
Example #27
0
		private void Construct()
		{
			Title = "My Eto Form";
			ClientSize = new Size(400, 350);

            lblContent = new Label { Text = "Hello World!" };
            prgBar = new ProgressBar();

			// scrollable region as the main content
			Content = new Scrollable
			{
				// table with three rows
				Content = new TableLayout(
					null,
					// row with three columns
					new TableRow(null, lblContent, null),
                    new TableRow(null, prgBar, null)
				)
			};

			// create a few commands that can be used for the menu and toolbar
            cmdButton = new Command { MenuText = "Click Me!", ToolBarText = "Click Me!" };

			var quitCommand = new Command { MenuText = "Quit", Shortcut = Application.Instance.CommonModifier | Keys.Q };
			quitCommand.Executed += (sender, e) => Application.Instance.Quit();

			var aboutCommand = new Command { MenuText = "About..." };
			aboutCommand.Executed += (sender, e) => MessageBox.Show(this, "About my app...");

			// create menu
			Menu = new MenuBar
			{
				Items =
				{
					// File submenu
					new ButtonMenuItem { Text = "&File", Items = { cmdButton } },
					// new ButtonMenuItem { Text = "&Edit", Items = { /* commands/items */ } },
					// new ButtonMenuItem { Text = "&View", Items = { /* commands/items */ } },
				},
				ApplicationItems =
				{
					// application (OS X) or file menu (others)
					new ButtonMenuItem { Text = "&Preferences..." },
				},
				QuitItem = quitCommand,
				AboutItem = aboutCommand
			};

			// create toolbar			
            ToolBar = new ToolBar { Items = { cmdButton } };
		}
Example #28
0
		void SetContentSize()
		{
			if (Content != null)
			{
				var handler = Content.Handler as IControlHandler;
				if (handler != null)
				{
					if (AutoSize)
						ClientSize = handler.GetPreferredSize();
					else
						handler.SetBounds(new Rectangle(ClientSize));
				}
			}
		}
Example #29
0
		public ScalingSection()
		{
			TableLayout tableLayout;

			var layout = new DynamicLayout();
			var size = new Size(-1, 100);

			tableLayout = new TableLayout(1, 1) { BackgroundColor = Colors.Blue, Size = size };
			tableLayout.Add(new Label { Text = "1x1, should scale to fill entire region with 5px padding around border", BackgroundColor = Colors.Red }, 0, 0, false, false);
			layout.Add(tableLayout, yscale: true);

			tableLayout = new TableLayout(2, 2) { BackgroundColor = Colors.Blue, Size = size };
			tableLayout.Add(new Label { Text = "2x2, should scale with extra space on top & left", BackgroundColor = Colors.Red }, 1, 1, false, false);
			layout.Add(tableLayout, yscale: true);

			tableLayout = new TableLayout(2, 2) { BackgroundColor = Colors.Blue, Size = size };
			tableLayout.Add(new Label { Text = "2x2, should scale with extra space on bottom & right", BackgroundColor = Colors.Red }, 0, 0, true, true);
			layout.Add(tableLayout, yscale: true);

			tableLayout = new TableLayout(3, 3) { BackgroundColor = Colors.Blue, Size = size };
			tableLayout.Add(new Label { Text = "3x3, should scale with extra space all around (10px)", BackgroundColor = Colors.Red }, 1, 1, true, true);
			layout.Add(tableLayout, yscale: true);

			tableLayout = new TableLayout(2, 2) { BackgroundColor = Colors.Blue, Size = size };
			tableLayout.Add(new Label { Text = "2x2, should not scale and be top left", BackgroundColor = Colors.Red }, 0, 0, false, false);
			layout.Add(tableLayout, yscale: true);

			tableLayout = new TableLayout(2, 2) { BackgroundColor = Colors.Blue, Size = size };
			tableLayout.SetColumnScale(0);
			tableLayout.SetRowScale(0);
			tableLayout.Add(new Label { Text = "2x2, should not scale and be bottom-right", BackgroundColor = Colors.Red }, 1, 1);
			layout.Add(tableLayout, yscale: true);

			tableLayout = new TableLayout(3, 3) { BackgroundColor = Colors.Blue, Size = size };
			tableLayout.SetColumnScale(0);
			tableLayout.SetRowScale(0);
			tableLayout.Add(new Label { Text = "3x3, should not scale and be bottom-right", BackgroundColor = Colors.Red }, 1, 1);
			layout.Add(tableLayout, yscale: true);

			tableLayout = new TableLayout(3, 3) { BackgroundColor = Colors.Blue, Size = size };
			tableLayout.SetColumnScale(0);
			tableLayout.SetColumnScale(2);
			tableLayout.SetRowScale(0);
			tableLayout.SetRowScale(2);
			tableLayout.Add(new Label { Text = "2x2, should not scale and be centered", BackgroundColor = Colors.Red }, 1, 1);
			layout.Add(tableLayout, yscale: true);

			Content = layout;
		}
Example #30
0
        public static void SetWindowProperties(this Dialog dialog, string title, Size minimumSize = default(Size))
        {
            dialog.Icon = Utilities.ApplicationIcon;

            dialog.Title = title;

            if (Utilities.EnvironmentPlatform.IsGtk) {
                if (minimumSize.Width == 0) minimumSize.Width = -1;
                if (minimumSize.Height == 0) minimumSize.Height = -1;
            }
            dialog.MinimumSize = minimumSize;

            if (Utilities.EnvironmentPlatform.IsWpf) {
                dialog.BackgroundColor = Colors.White;
            }
        }
Example #31
0
		Control Default(Size? size = null)
		{
			var control = new Spinner();
			if (size != null)
				control.Size = size.Value;

			var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5) };

			layout.AddCentered(control);

			layout.BeginVertical();
			layout.AddRow(null, StartStopButton(control), null);
			layout.EndVertical();

			return layout;
		}
Example #32
0
        void CreateControls()
        {
            Title      = "Nintendo CTR Layout (BCLYT) Viewer ~~ by pleonex";
            ClientSize = new Eto.Drawing.Size(600, 600);

            StackLayout mainPanel = new StackLayout();

            Content = mainPanel;

            drawable = new Drawable();
            drawable.BackgroundColor = Colors.White;
            drawable.Paint          += Draw;

            Scrollable  drawScrollable = new Scrollable();
            TableLayout drawPanel      = new TableLayout();

            drawPanel.BackgroundColor = Colors.Gray;
            drawPanel.Rows.Add(null);
            drawPanel.Rows.Add(new TableRow(null, new TableCell(drawable), null));
            drawPanel.Rows.Add(null);
            drawScrollable.Content = drawPanel;

            TableLayout sidePanel = new TableLayout();

            sidePanel.ClientSize = new Eto.Drawing.Size(200, 30);

            Button openBtn = new Button();

            openBtn.Text   = "Open";
            openBtn.Click += OnOpenClicked;
            sidePanel.Rows.Add(null);
            sidePanel.Rows.Add(new TableRow(openBtn, null));

            mainPanel.Orientation = Orientation.Horizontal;
            mainPanel.Items.Add(new StackLayoutItem(sidePanel, VerticalAlignment.Stretch, false));
            mainPanel.Items.Add(new StackLayoutItem(drawScrollable, VerticalAlignment.Stretch, true));
        }
Example #33
0
 public static IntSize2 ToClarity(this ed.Size eSize) =>
 new IntSize2(eSize.Width, eSize.Height);
Example #34
0
        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
                    }
                }
            };
        }
        /// <summary>
        /// Creates the content of the dialog
        /// </summary>
        private RhinoDialogTableLayout CreateTableLayout()
        {
            // Create controls and define behaviors

            var ns_threshold = new NumericUpDownWithUnitParsing
            {
                ValueUpdateMode = NumericUpDownWithUnitParsingUpdateMode.WhenDoneChanging,
                MinValue        = 0.0,
                MaxValue        = 100.0,
                DecimalPlaces   = 0,
                Increment       = 1.0,
                ToolTip         = "Weighted RGB color evaluation threshold.",
                Value           = (int)(Potrace.Treshold * 100.0), Width = 45
            };

            var sld_threshold = new Slider
            {
                MinValue      = 0,
                MaxValue      = 100,
                TickFrequency = 25,
                Value         = (int)(Potrace.Treshold * 100.0),
                Width         = 220
            };

            ns_threshold.ValueChanged += (sender, args) =>
            {
                if (m_allow_update_and_redraw)
                {
                    m_allow_update_and_redraw = false;
                    Potrace.Treshold          = ns_threshold.Value / 100.0;
                    sld_threshold.Value       = (int)(Potrace.Treshold * 100.0);
                    m_allow_update_and_redraw = true;
                    UpdateAndRedraw();
                }
            };

            sld_threshold.ValueChanged += (sender, args) =>
            {
                if (m_allow_update_and_redraw)
                {
                    m_allow_update_and_redraw = false;
                    Potrace.Treshold          = sld_threshold.Value / 100.0;
                    ns_threshold.Value        = (int)(Potrace.Treshold * 100.0);
                    m_allow_update_and_redraw = true;
                    UpdateAndRedraw();
                }
            };

            var dd_turnpolicy = new DropDown
            {
                ToolTip = "Algorithm used to resolve ambiguities in path decomposition."
            };

            foreach (var str in Enum.GetNames(typeof(TurnPolicy)))
            {
                dd_turnpolicy.Items.Add(str);
            }
            dd_turnpolicy.SelectedIndex         = (int)Potrace.turnpolicy;
            dd_turnpolicy.SelectedIndexChanged += (sender, args) =>
            {
                if (dd_turnpolicy.SelectedIndex != 0)
                {
                    Potrace.turnpolicy = (TurnPolicy)dd_turnpolicy.SelectedIndex;
                    UpdateAndRedraw();
                }
            };

            var ns_turdsize = new NumericUpDownWithUnitParsing
            {
                ValueUpdateMode = NumericUpDownWithUnitParsingUpdateMode.WhenDoneChanging,
                MinValue        = 1.0,
                MaxValue        = 100.0,
                DecimalPlaces   = 0,
                Increment       = 1.0,
                ToolTip         = "Filter speckles of up to this size in pixels.",
                Value           = Potrace.turdsize
            };

            ns_turdsize.ValueChanged += (sender, args) =>
            {
                Potrace.turdsize = (int)ns_turdsize.Value;
                UpdateAndRedraw();
            };

            var ns_alphamax = new NumericUpDownWithUnitParsing
            {
                ValueUpdateMode = NumericUpDownWithUnitParsingUpdateMode.WhenDoneChanging,
                MinValue        = 0.0,
                MaxValue        = 100.0,
                DecimalPlaces   = 0,
                Increment       = 1.0,
                ToolTip         = "Corner rounding threshold.",
                Value           = Potrace.alphamax
            };

            ns_alphamax.ValueChanged += (sender, args) =>
            {
                Potrace.alphamax = ns_alphamax.Value;
                UpdateAndRedraw();
            };

            var chk_curveoptimizing = new CheckBox
            {
                ThreeState = false,
                ToolTip    = "Optimize of Bézier segments by a single segment when possible.",
                Checked    = Potrace.curveoptimizing
            };

            var ns_opttolerance = new NumericUpDownWithUnitParsing
            {
                ValueUpdateMode = NumericUpDownWithUnitParsingUpdateMode.WhenDoneChanging,
                MinValue        = 0.1,
                MaxValue        = 1.0,
                DecimalPlaces   = 1,
                Increment       = 0.1,
                Enabled         = Potrace.curveoptimizing,
                ToolTip         = "Tolerance used to optimize Bézier segments.",
                Value           = Potrace.opttolerance
            };

            chk_curveoptimizing.CheckedChanged += (sender, args) =>
            {
                Potrace.curveoptimizing = chk_curveoptimizing.Checked.Value;
                ns_opttolerance.Enabled = Potrace.curveoptimizing;
                UpdateAndRedraw();
            };

            ns_opttolerance.ValueChanged += (sender, args) =>
            {
                Potrace.opttolerance = ns_opttolerance.Value;
                UpdateAndRedraw();
            };

            var btn_reset = new Button
            {
                Text = "Restore Defaults"
            };

            btn_reset.Click += (sender, args) =>
            {
                m_allow_update_and_redraw = false;
                Potrace.RestoreDefaults();
                sld_threshold.Value         = (int)(Potrace.Treshold * 100.0);
                ns_threshold.Value          = sld_threshold.Value;
                dd_turnpolicy.SelectedIndex = (int)Potrace.turnpolicy;
                ns_turdsize.Value           = Potrace.turdsize;
                ns_alphamax.Value           = Potrace.alphamax;
                chk_curveoptimizing.Checked = Potrace.curveoptimizing;
                ns_opttolerance.Value       = Potrace.opttolerance;
                m_allow_update_and_redraw   = true;
                UpdateAndRedraw();
            };

            // Layout the controls

            var minimum_size = new Eto.Drawing.Size(150, 0);

            var layout = new RhinoDialogTableLayout(false)
            {
                Spacing = new Eto.Drawing.Size(10, 8)
            };

            layout.Rows.Add(new TableRow(new TableCell(new LabelSeparator {
                Text = "Vectorization options"
            }, true)));

            var panel0 = new Panel {
                MinimumSize = minimum_size, Content = new Label()
                {
                    Text = "Threshold"
                }
            };
            var table0 = new TableLayout {
                Padding = new Eto.Drawing.Padding(8, 0, 0, 0)
            };

            table0.Rows.Add(new TableRow(new TableCell(panel0), new TableCell(sld_threshold, true), new TableCell(ns_threshold)));
            layout.Rows.Add(table0);

            var panel1 = new Panel {
                MinimumSize = minimum_size, Content = new Label()
                {
                    Text = "Turn policy"
                }
            };
            var table1 = new TableLayout {
                Padding = new Eto.Drawing.Padding(8, 0, 0, 0), Spacing = new Size(10, 8)
            };

            table1.Rows.Add(new TableRow(new TableCell(panel1), new TableCell(dd_turnpolicy)));
            table1.Rows.Add(new TableRow(new TableCell(new Label()
            {
                Text = "Filter size"
            }), new TableCell(ns_turdsize)));
            table1.Rows.Add(new TableRow(new TableCell(new Label()
            {
                Text = "Corner rounding"
            }), new TableCell(ns_alphamax)));
            layout.Rows.Add(table1);

            layout.Rows.Add(new TableRow(new TableCell(new LabelSeparator {
                Text = "Curve optimization"
            }, true)));

            var panel2 = new Panel {
                MinimumSize = minimum_size, Content = new Label()
                {
                    Text = "Optimizing"
                }
            };
            var table2 = new TableLayout {
                Padding = new Eto.Drawing.Padding(8, 0, 0, 0), Spacing = new Size(10, 8)
            };

            table2.Rows.Add(new TableRow(new TableCell(panel2), new TableCell(chk_curveoptimizing)));
            table2.Rows.Add(new TableRow(new TableCell(new Label()
            {
                Text = "Tolerance"
            }), new TableCell(ns_opttolerance)));
            table2.Rows.Add(null);
            table2.Rows.Add(new TableRow(new TableCell(new Label()
            {
                Text = ""
            }), new TableCell(btn_reset)));
            layout.Rows.Add(table2);

            return(layout);
        }
Example #36
0
        public Form()
        {
            ClientSize  = new Eto.Drawing.Size(300, 150);
            Padding     = new Padding(5);
            Resizable   = false;
            Result      = DialogResult.Cancel;
            Title       = "MECAHOPPER";
            WindowStyle = WindowStyle.Default;

            DefaultButton = new Button {
                Text = "OK"
            };
            DefaultButton.Click += (sender, e) => Close(DialogResult.Ok);

            AbortButton = new Button {
                Text = "Cancel"
            };
            AbortButton.Click += (sender, e) => Close(DialogResult.Cancel);

            var linearLabel = new Label {
                Text = "Linear Elements:"
            };


            var defaults_layout = new TableLayout
            {
                Padding = new Padding(5, 10, 5, 5),
                Spacing = new Size(5, 5),
                Rows    = { new TableRow(null, DefaultButton, AbortButton) }
            };

            var layout = new TableLayout()
            {
                Padding = new Padding(5),
                Spacing = new Size(5, 5)
            };

            linQty = new TextBox()
            {
                PlaceholderText = "0"
            };
            rotQty = new TextBox()
            {
                PlaceholderText = "0"
            };

            layout.Rows.Add(new TableRow(
                                new Label {
                Text = "Linear Nodes"
            },
                                linQty
                                ));
            layout.Rows.Add(new TableRow(
                                new Label {
                Text = "Rotate Nodes"
            },
                                rotQty
                                ));
            layout.Rows.Add(defaults_layout);

            Content = layout;
        }
Example #37
-1
        void InitializeComponent()
        {
            Title = "My Eto Form";
            ClientSize = new Size(400, 350);

            Content = new StackLayout
            {
                Padding = 10,
                Items =
                {
                    "Hello World!",
                    // add more controls here
                }
            };

            // create a few commands that can be used for the menu and toolbar
            var clickMe = new Command { MenuText = "Click Me!", ToolBarText = "Click Me!" };
            clickMe.Executed += (sender, e) => MessageBox.Show(this, "I was clicked!");

            var quitCommand = new Command { MenuText = "Quit", Shortcut = Application.Instance.CommonModifier | Keys.Q };
            quitCommand.Executed += (sender, e) => Application.Instance.Quit();

            var aboutCommand = new Command { MenuText = "About..." };
            aboutCommand.Executed += (sender, e) => MessageBox.Show(this, "About my app...");

            // create menu
            Menu = new MenuBar
            {
                Items =
                    {
					    // File submenu
					    new ButtonMenuItem { Text = "&File", Items = { clickMe } },
					    // new ButtonMenuItem { Text = "&Edit", Items = { /* commands/items */ } },
					    // new ButtonMenuItem { Text = "&View", Items = { /* commands/items */ } },
				    },
                ApplicationItems =
                    {
					    // application (OS X) or file menu (others)
					    new ButtonMenuItem { Text = "&Preferences..." },
                    },
                QuitItem = quitCommand,
                AboutItem = aboutCommand
            };

            // create toolbar			
            ToolBar = new ToolBar { Items = { clickMe } };
        }