Exemple #1
0
		public static Control GetContent(Control content)
		{
			var window = content as Window;
			if (window != null)
			{
				var size = window.ClientSize;
				// some platforms report 0,0 even though it probably should be -1, -1 initially.
				if (size.Width == 0)
					size.Width = -1;
				if (size.Height == 0)
					size.Height = -1;
				// swap out window for a panel so we can add it as a child
				content = new Panel
				{
					BackgroundColor = SystemColors.Control,
					Padding = window.Padding,
					Size = size,
					Content = window.Content
				};
			}
			else
			{
				content = new Panel
				{
					BackgroundColor = SystemColors.Control,
					Content = content
				};
			}
			return content;
		}
Exemple #2
0
        public void DataContextInNativeControlShouldBeSet()
        {
			int dataContextChanged = 0;
			Shown(form =>
			{
				var c = new Panel();
				c.DataContextChanged += (sender, e) => dataContextChanged++;
				var expander = new CustomExpander { Content = c };

				var content = new Panel { Content = expander };

				Assert.AreEqual(0, dataContextChanged);

				// embed the expander natively, so it is 'disconnected' from eto
				var holder = new Panel();
				var holderWpf = holder.ToNative() as System.Windows.Controls.Decorator;
				holderWpf.Child = content.ToNative(true);

				form.Content = holder;
				content.DataContext = new MyViewModel();

				Assert.AreEqual(1, dataContextChanged);
			}, () =>
			{
				Assert.AreEqual(1, dataContextChanged);
			});
		}
Exemple #3
0
		void FinishProcessing(Control child, Exception error)
		{
			errorPanel.Visible = error != null;
			if (error != null)
				errorPanel.Content = new Label { Text = error.Message, ToolTip = error.ToString() };
			if (child != null)
			{
				var window = child as Eto.Forms.Window;
				if (window != null)
				{
					// swap out window for a panel so we can add it as a child
					var content = window.Content;
					window.Content = null;
					child = new Panel { Content = content, Padding = window.Padding };
				}
				previewPanel.Content = child;
			}

			if (processingCount > 1)
			{
				// process was requested while we were processing the last one, so redo
				processingCount = 1;
				timer.Start();
			}
			else
				processingCount = 0;
		}
Exemple #4
0
		public PreviewEditorView(Control editor, Func<string> getCode)
		{
			Editor = editor;
			this.getCode = getCode;

			Orientation = Orientation.Vertical;
			FixedPanel = SplitterFixedPanel.None;
			RelativePosition = 0.4;

			previewPanel = new Panel();
			errorPanel = new Panel { Padding = new Padding(5), Visible = false, BackgroundColor = new Color(Colors.Red, .4f) };

			Panel1 = new StackLayout
			{
				HorizontalContentAlignment = HorizontalAlignment.Stretch,
				Items =
				{
					new StackLayoutItem(previewPanel, expand: true),
					errorPanel
				}
			};
			Panel2 = editor;

			timer = new UITimer { Interval = RefreshTime };
			timer.Elapsed += Timer_Elapsed;
		}
Exemple #5
0
		Control MainContent()
		{
			contentContainer = new Panel();

			// set focus when the form is shown
			Shown += delegate
			{
				SectionList.Focus();
			};
			SectionList.SelectedItemChanged += (sender, e) =>
			{
				try
				{
					var item = SectionList.SelectedItem;
					Control content = item != null ? item.CreateContent() : null;

					if (navigation != null)
					{
						if (content != null)
							navigation.Push(content, item != null ? item.Text : null);
					}
					else
					{
						contentContainer.Content = content;
					}
				}
				catch (Exception ex)
				{
					Log.Write(this, "Error loading section: {0}", ex.GetBaseException());
					contentContainer.Content = null;
				}

				#if DEBUG
				GC.Collect();
				GC.WaitForPendingFinalizers();
				#endif
			};

			if (Splitter.IsSupported)
			{
				var splitter = new Splitter
				{
					Position = 200,
					FixedPanel = SplitterFixedPanel.Panel1,
					Panel1 = SectionList.Control,
					// for now, don't show log in mobile
					Panel2 = Platform.IsMobile ? contentContainer : RightPane()
				};

				return splitter;
			}
			if (Navigation.IsSupported)
			{
				navigation = new Navigation(SectionList.Control, "Eto.Test");
				return navigation;
			}
			throw new EtoException("Platform must support splitter or navigation");

		}
Exemple #6
0
		Control TabTwo ()
		{
			var control = new Panel ();
			
			control.AddDockedControl (new TextAreaSection());
			
			return control;
		}
Exemple #7
0
		Control TabOne ()
		{
			var control = new Panel ();
			
			control.AddDockedControl (new LabelSection());
			
			return control;
		}
		Control Default()
		{
			var layout = new Panel();
			layout.BackgroundColor = Colors.Blue; // should not see the blue
			layout.Content = new Label { BackgroundColor = Colors.Red, Text = "Expanded Width/Height (default)" };
			defaultScrollable.Content = layout;
			return defaultScrollable;
		}
		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 #10
0
		Control MiddleSection()
		{
			middleTable = new TableLayout(1, 3);

			middleTable.Add(new Label { Text = "Content", BackgroundColor = Colors.LightGrey, HorizontalAlign = HorizontalAlign.Center, VerticalAlign = VerticalAlign.Middle }, 0, 1, true, true);
			middleTable.Add(topSection = new Panel(), 0, 0);

			return middleTable;
		}
Exemple #11
0
		Control MainTable()
		{
			mainTable = new TableLayout(3, 1);

			mainTable.Add(MiddleSection(), 1, 0, true, true);
			mainTable.Add(rightSection = new Panel(), 2, 0);

			return mainTable;
		}
Exemple #12
0
 public FrameRenderer()
 {
     Control = layout = new PixelLayout();
     content = new Panel();
     //drawable = new Drawable();
     top    = new Panel();
     bottom = new Panel();
     left   = new Panel();
     right  = new Panel();
 }
Exemple #13
0
		void FillTable (TableLayout layout)
		{
			for (int y = 0; y < layout.Size.Height - 1; y++)
				for (int x = 0; x < layout.Size.Width; x++) {
					var panel = new Panel { 
						Size = SquareSize, 
						BackgroundColor = (x+y*layout.Size.Width) % 2 == 0 ? Colors.Lime : Colors.Red 
					};
					layout.Add (panel, x, y);
				}
		}
Exemple #14
0
		Control MiddleSection()
		{
			middleTable = new TableLayout(1, 3);
			middleTable.Padding = new Padding(10);
			middleTable.Spacing = new Size(5, 5);

			middleTable.Add(new Label { Text = "Content", BackgroundColor = Colors.LightGrey, TextAlignment = TextAlignment.Center, VerticalAlignment = VerticalAlignment.Center }, 0, 1, true, true);
			middleTable.Add(topSection = new Panel(), 0, 0);

			return middleTable;
		}
Exemple #15
0
		Control MainTable()
		{
			mainTable = new TableLayout(3, 1);
			mainTable.Padding = new Padding(10);
			mainTable.Spacing = new Size(5, 5);

			mainTable.Add(MiddleSection(), 1, 0, true, true);
			mainTable.Add(rightSection = new Panel(), 2, 0);

			return mainTable;
		}
Exemple #16
0
		public SystemColorSection()
		{
			var layout = new StackLayout
			{
				Spacing = 10,
				HorizontalContentAlignment = HorizontalAlignment.Stretch
			};

			var type = typeof(SystemColors);

			var properties = type.GetRuntimeProperties();

			var skip = new List<PropertyInfo>();
			var colorProperties = properties.Where(r => r.PropertyType == typeof(Color)).OrderBy(r => r.Name).ToList();
			foreach (var property in colorProperties)
			{
				if (skip.Contains(property))
					continue;
				var color = (Color)property.GetValue(null);
				var label = new Label { Text = property.Name };
				var panel = new Panel
				{ 
					Content = label,
					Padding = new Padding(10),
				};

				bool isTextColor = property.Name.EndsWith("Text");

				if (isTextColor)
					label.TextColor = color;
				else
				{
					panel.BackgroundColor = color;
					var textProp = colorProperties.FirstOrDefault(r => r.Name == property.Name + "Text");
					if (textProp != null)
					{
						label.TextColor = (Color)textProp.GetValue(null);
						label.Text += " && " + textProp.Name;
						skip.Add(textProp);
					}
					else if (color.ToHSB().B < 0.5)
						label.TextColor = Colors.White;
				}

				layout.Items.Add(panel);
			}

			Content = new Scrollable { Content = TableLayout.AutoSized(layout, centered: true) };

		}
 public JabbRServerEdit(JabbRServer server, DynamicLayout layout)
 {
     this.server = server;
     layout.AddRow(new Label { Text = "Address" }, EditAddress());
     layout.EndBeginVertical(yscale: true);
     layout.AddRow(UseSocialLogin());
     layout.Add(authSection = new Panel {  }, yscale: true);
     layout.EndBeginVertical();
     loginSection = LoginSection();
     socialSection = SocialSection();
     
     authSection.DataContextChanged += (sender, e) => SetVisibility();
     SetVisibility();
 }
Exemple #18
0
			protected override void Initialize()
			{
				base.Initialize();

				content = new Panel();
				Control.DataContextChanged += (sender, e) => dataContextChanged++;
				content.DataContextChanged += (sender, e) => contentDataContextChanged++;

				base.Content = content;
				Assert.AreEqual(0, dataContextChanged);
				Assert.AreEqual(0, contentDataContextChanged);
				Control.DataContext = new MyViewModel2(); // this shouldn't fire data context changes for logical children
				Assert.AreEqual(1, dataContextChanged);
				Assert.AreEqual(1, contentDataContextChanged);
			}
Exemple #19
0
		public DrawLoopSection()
		{
			drawable = new Drawable
			{
				Style = "direct",
				BackgroundColor = Colors.Black
			};
			drawable.Paint += (sender, e) => renderer.DrawFrame(e.Graphics, drawable.Size);
			renderer = new DirectDrawingRenderer();

			var layout = new DynamicLayout(new Padding(10));
			layout.AddSeparateRow(null, UseTexturesAndGradients(), UseCreateGraphics(), null);
			layout.Add(content = new Panel { Content = drawable });
			this.Content = layout;
		}
Exemple #20
0
        public SessionCreator()
        {
            _session = new Session();
            _session.Processes.Add(new PortManagerProcess());
            _session.Processes.Add(new RouterProcess());
            _session.Processes.Add(new HostProcess());
            _session.Processes.Add(new DeviceFinderProcess ());
            _session.Processes.Add(new NetworkDatabaseProcess());

            var left = new TableLayout(1, 3);

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

            left.Add(_processesList, 0, 0);

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

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

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

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

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

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

            this.BeginVertical(padding:null, xscale: true, yscale: false);
            this.AddRow(null, _createSessionButton);
            this.EndVertical();
        }
Exemple #21
0
		public PreviewEditorView(Control editor, string mainAssembly, IEnumerable<string> references, Func<string> getCode)
		{
			//Size = new Size (200, 200);
			Editor = editor;
			MainAssemblyPath = mainAssembly;
			this.getCode = getCode;

			if (EnableAppDomains)
				designPanel = new AppDomainDesignHost();
			else
				designPanel = new InProcessDesignPanel();

			designPanel.MainAssembly = mainAssembly;
			designPanel.References = references;

			designPanel.ControlCreated = () => FinishProcessing(null);
			designPanel.Error = FinishProcessing;

			designPanelHolder = new Panel();
			designPanelHolder.Content = designPanel.GetContainer();

			designPanel.ContainerChanged = () => designPanelHolder.Content = designPanel.GetContainer();

			Orientation = Orientation.Vertical;
			FixedPanel = SplitterFixedPanel.None;
			RelativePosition = lastPosition;

			errorPanel = new Panel { Padding = new Padding(5), Visible = false, BackgroundColor = new Color(Colors.Red, .4f) };

			Panel1 = new StackLayout
			{
				HorizontalContentAlignment = HorizontalAlignment.Stretch,
				Items =
				{
					new StackLayoutItem(designPanelHolder, expand: true),
					errorPanel
				}
			};
			Panel2 = editor;

			timer = new UITimer { Interval = RefreshTime };
			timer.Elapsed += Timer_Elapsed;

			errorTimer = new UITimer { Interval = ErrorDisplayTime };
			errorTimer.Elapsed += ErrorTimer_Elapsed;
		}
Exemple #22
0
		public DynamicFocusSection()
		{
			var content = new Panel();
			var focusControlCheckBox = new CheckBox { Text = "Focus Control", Checked = true };

			var addContentButton = new Button { Text = "Add Control" };
			var controls = new List<Func<Control>>
			{
				() => new TextBox(),
				() => new TextArea(),
				() => new CheckBox { Text = "A Check Box" },
				() => new RadioButton { Text = "A Radio Button" },
				() => new DropDown { Items = { "Item 1", "Item 2", "Item 3" } },
				() => new DateTimePicker(),
				() => new ColorPicker(),
				() => new PasswordBox(),
				() => new ListBox { Items = { "Item 1", "Item 2", "Item 3" } },
				() => new NumericUpDown(),
			};

			var count = 0;
			addContentButton.Click += (sender, e) =>
			{
				Control control = controls[(count++) % controls.Count]();
				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
			{
				Spacing = new Size(5, 5),
				Padding = new Padding(10),
				Rows = {
					new StackLayout { Orientation = Orientation.Horizontal, Spacing = 5, Items = { addContentButton, focusControlCheckBox } },
					content
				}
			};
		}
		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
				);
		}
Exemple #24
0
		public void LogicalParentShouldChangeWhenAddedOrRemoved()
		{
			Invoke(() =>
			{
				var child = new Panel();
				var table = new TableLayout();

				// adding/removing rows
				table.Rows.Add(child);
				Assert.AreSame(table, child.Parent);
				table.Rows.Clear();
				Assert.IsNull(child.Parent);
				table.Rows.Add(child);
				Assert.AreSame(table, child.Parent);
				table.Rows.RemoveAt(0);
				Assert.IsNull(child.Parent);
				table.Rows.Insert(0, child);
				Assert.AreSame(table, child.Parent);
				table.Rows[0] = new TableRow();
				Assert.IsNull(child.Parent);

				var row = new TableRow();
				row.Cells.Add(child);
				Assert.IsNull(child.Parent);
				table.Rows.Add(row);
				Assert.AreSame(table, child.Parent);
				row.Cells.Clear();
				Assert.IsNull(child.Parent);
				row.Cells.Add(child);
				Assert.AreSame(table, child.Parent);
				row.Cells.RemoveAt(0);
				Assert.IsNull(child.Parent);
				row.Cells.Insert(0, child);
				Assert.AreSame(table, child.Parent);
				row.Cells[0] = new TableCell();
				Assert.IsNull(child.Parent);
			});
		}
Exemple #25
0
		static Form Test1(bool setSize, Action<Label[], Panel> layoutContent)
		{
			// Status bar
			Label[] status = { new Label(), new Label(), new Label(), new Label(), new Label() };
			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();

			// Main panel
			var mainPanel = new Panel();
			layoutContent(status, mainPanel);

			// Form's content
			var layout = new DynamicLayout();
			layout.Add(mainPanel, yscale: true);
			layout.Add(statusLayout);
			layout.Generate();
			var form = new Form { Content = layout };
			if (setSize)
				form.ClientSize = new Size(800, 600);
			return form;
		}
Exemple #26
0
		public void LogicalParentOfChildrenShouldBeStackLayout()
		{
			StackLayout stack = null;
			Panel child = null;
			Shown(form =>
			{
				child = new Panel();
				stack = new StackLayout
				{
					Items = { child }
				};
				Assert.AreSame(stack, child.Parent);
				Assert.IsNull(child.VisualParent);
				form.Content = stack;
			}, () =>
			{
				Assert.AreSame(stack, child?.Parent);
				Assert.IsNotNull(child.VisualParent); 
				// StackLayout uses TableLayout internally to align controls
				// this will be changed when StackLayout does not depend on TableLayout
				Assert.AreNotSame(stack, child.VisualParent);
				Assert.IsInstanceOf<TableLayout>(child.VisualParent); 
			});
		}
Exemple #27
0
 public BoxViewRenderer()
 {
     Control = new Eto.Forms.Panel();
 }
Exemple #28
0
        public static void SetView(this Panel panel, View view)
        {
            var handler = Renderer.Render(view);

            panel.Content = handler.Result;
        }
Exemple #29
0
        public override Control Generate(DynamicLayout layout)
        {
            if (rows.Count == 0)
                return null;
            int cols = rows.Max (r => r.Items.Count);

            if (Container == null) {
                Container = new Panel ();
                this.Layout = new TableLayout (Container, cols, rows.Count);
            }
            else {
                this.Layout = new TableLayout (null, cols, rows.Count);
                Container.SetInnerLayout ();
            }
            var tableLayout = this.Layout;
            var padding = this.Padding ?? layout.DefaultPadding;
            if (padding != null)
                tableLayout.Padding = padding.Value;

            var spacing = this.Spacing ?? layout.DefaultSpacing;
            if (spacing != null)
                tableLayout.Spacing = spacing.Value;

            for (int cy = 0; cy < rows.Count; cy++) {
                var row = rows[cy];
                for (int cx = 0; cx < row.Items.Count; cx++) {
                    var item = row.Items[cx];
                    item.Generate (layout, tableLayout, cx, cy);
                }
            }
            return Container;
        }
Exemple #30
0
 public static Panel CreatePanel(Control control, Padding? padding = null)
 {
     var panel = new Panel ();
     panel.AddDockedControl (control, padding);
     return panel;
 }
Exemple #31
0
		public DynamicLayout(Panel container, Size? spacing)
			: this(container, null, spacing)
		{
		}
Exemple #32
0
		public DynamicLayout(Panel container, Padding? padding = null, Size? spacing = null)
			: this(padding, spacing, container == null ? null : container.Generator)
		{
			if (container != null)
				container.Content = this;
		}
Exemple #33
0
		public void DataContextChangedShouldNotFireWhenNoContext()
		{
			int dataContextChanged = 0;
			Shown(form =>
			{
				form.DataContextChanged += (sender, e) => dataContextChanged++;
				var c = new Panel();
				c.DataContextChanged += (sender, e) => dataContextChanged++;
				form.Content = c;
				Assert.AreEqual(0, dataContextChanged);
				Assert.IsNull(form.DataContext);
				Assert.IsNull(c.DataContext);
			}, () =>
			{
				Assert.AreEqual(0, dataContextChanged);
			});
		}