Inheritance: Eto.Forms.BindableWidget, IMouseInputSource, IKeyboardInputSource, ICallbackSource
Ejemplo n.º 1
0
		public AnchorSection()
		{
			Content = PixelLayout = new PixelLayout();

			Buttons = CreateButtons();
			HandleEvent(SizeChangedEvent);
		}
Ejemplo n.º 2
0
		public static void SetLocation(Control control, Point value)
		{
			control.Properties[LocationProperty] = value;
			var layout = control.Parent as PixelLayout;
			if (layout != null)
				layout.Move(control, value);
		}
Ejemplo n.º 3
0
		public override void Remove(Control child)
		{
			if (ReferenceEquals(Content, child))
			{
				Content = null;
			}
		}
Ejemplo n.º 4
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;
		}
Ejemplo n.º 5
0
		public static Container AddDockedControl (this Panel container, Control control, Padding? padding = null)
		{
			container.Content = control;
			if (padding != null)
				container.Padding = padding.Value;
			return container;
		}
Ejemplo n.º 6
0
		public static void SetLocation (Control control, Point value)
		{
			control.Properties.Set (LocationProperty, value);
			var layout = control.ParentLayout as TableLayout;
			if (layout != null)
				layout.Move (control, value);
		}
Ejemplo n.º 7
0
		public void RemoveItemsIndividuallyShouldClearParent()
		{
			TestUtils.Invoke(() =>
			{
				var stackLayout = new StackLayout();

				var items = new Control[] { new Label(), new Button(), new TextBox() };

				foreach (var item in items)
					stackLayout.Items.Add(item);

				CollectionAssert.AreEqual(items, stackLayout.Children, "#1. Items do not match");

				foreach (var item in items)
					Assert.AreEqual(stackLayout, item.Parent, "#2. Items should have parent set to stack layout");

				stackLayout.Items.RemoveAt(0);
				Assert.IsNull(items[0].Parent, "#3. Item should have parent cleared when removed from stack layout");

				stackLayout.Items[0] = new Button();
				Assert.IsNull(items[1].Parent, "#4. Item should have parent cleared when replaced with another item in the stack layout");

				Assert.AreEqual(stackLayout, items[2].Parent, "#5. Item should not have changed parent as it is still in the stack layout");
			});
		}
Ejemplo n.º 8
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;
		}
Ejemplo n.º 9
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;
		}
Ejemplo n.º 10
0
		public void ControlEventsShouldBeHandled(Control control)
		{
			TestBase.Invoke(() =>
			{
				try
				{
					control.SizeChanged += Control_EventHandler;
					control.EnabledChanged += Control_EventHandler;
					control.GotFocus += Control_EventHandler;
					control.LostFocus += Control_EventHandler;
					control.KeyDown += Control_EventHandler;
					control.KeyUp += Control_EventHandler;
					control.MouseUp += Control_EventHandler;
					control.MouseDown += Control_EventHandler;
					control.MouseEnter += Control_EventHandler;
					control.MouseLeave += Control_EventHandler;
					control.MouseDoubleClick += Control_EventHandler;
					control.MouseWheel += Control_EventHandler;
					//control.Shown += Control_EventHandler;
					//control.TextInput += Control_EventHandler;
				}
				catch (Exception ex)
				{
					throw new InvalidOperationException($"Control {control.GetType().Name}:", ex);
				}
			});
		}
Ejemplo n.º 11
0
        async Task ShowModalAsync(Eto.Forms.Control parent, bool opening)
        {
            closedcs = new TaskCompletionSource <bool>();
            inNav    = false;
            if (parent != null && (DisplayMode.HasFlag(DialogDisplayMode.Navigation) || DisplayMode == DialogDisplayMode.Default))
            {
                var iosView = parent.Handler as IIosViewControllerSource;
                if (iosView != null && iosView.Controller != null)
                {
                    var nav = iosView.Controller.NavigationController;
                    if (nav != null)
                    {
                        nav.PushViewController(Controller, true);
                        inNav = true;
                    }
                }
            }
            if (!inNav)
            {
                Controller.ModalPresentationStyle = WindowState == WindowState.Maximized ? UIModalPresentationStyle.FullScreen : UIModalPresentationStyle.FormSheet;

                var top = UIApplication.SharedApplication.KeyWindow.TopMostController();
                opencs = new TaskCompletionSource <bool>();
                top.PresentViewController(Controller, animated: true, completionHandler: () => opencs.SetResult(true));
                await opencs.Task;
                opencs = null;
            }
            if (opening)
            {
                await closedcs.Task;
            }
        }
Ejemplo n.º 12
0
		protected override void LogEvents(Control control)
		{
			base.LogEvents(control);

			control.MouseDoubleClick += delegate(object sender, MouseEventArgs e)
			{
				LogMouseEvent(control, "MouseDoubleClick", e);
			};
			control.MouseWheel += delegate(object sender, MouseEventArgs e)
			{
				LogMouseEvent(control, "MouseWheel", e);
			};
			control.MouseMove += delegate(object sender, MouseEventArgs e)
			{
				LogMouseEvent(control, "MouseMove", e);
			};
			control.MouseUp += delegate(object sender, MouseEventArgs e)
			{
				LogMouseEvent(control, "MouseUp", e);
			};
			control.MouseDown += delegate(object sender, MouseEventArgs e)
			{
				LogMouseEvent(control, "MouseDown", e);
			};
			control.MouseEnter += delegate(object sender, MouseEventArgs e)
			{
				LogMouseEvent(control, "MouseEnter", e);
			};
			control.MouseLeave += delegate(object sender, MouseEventArgs e)
			{
				LogMouseEvent(control, "MouseLeave", e);
			};
		}
Ejemplo n.º 13
0
		public static Control AutoSized (Control control, Padding? padding = null)
		{
			var layout = new TableLayout(new Panel(), 2, 2);
			layout.Padding = padding ?? Padding.Empty;
			layout.Spacing = Size.Empty;
			layout.Add (control, 0, 0);
			return layout.Container;
		}
Ejemplo n.º 14
0
		protected override void LogEvents (Control control)
		{
			base.LogEvents (control);
			
			control.KeyDown += delegate(object sender, KeyPressEventArgs e) {
				Log.Write (control, "KeyDown, Key: {0}, Char: {1}", e.KeyData, e.KeyChar);
			};
		}
Ejemplo n.º 15
0
		public static DialogResult Show (Generator g, Control parent, string text, string caption, MessageBoxButtons buttons, MessageBoxType type = MessageBoxType.Information)
		{
			var mb = g.CreateControl<IMessageBox> ();
			mb.Text = text;
			mb.Caption = caption;
			mb.Type = type;
			return mb.ShowDialog (parent, buttons);
		}
Ejemplo n.º 16
0
		protected override void LogEvents(Control control)
		{
			base.LogEvents(control);

			control.KeyDown += control_KeyDown;

			control.KeyUp += control_KeyUp;
		}
Ejemplo n.º 17
0
		/// <summary>
		/// Show the context menu relative to the specified control
		/// </summary>
		/// <param name="relativeTo">Control to show the menu relative to</param>
		public void Show(Control relativeTo)
		{
			if (Trim)
				Items.Trim();
			OnPreLoad(EventArgs.Empty);
			OnLoad(EventArgs.Empty);
			Handler.Show(relativeTo);
		}
Ejemplo n.º 18
0
		public void Add(Control control, int x, int y)
		{
			control.Properties[LocationProperty] = new Point(x, y);
			controls.Add(control);
			var load = SetParent(control);
			Handler.Add(control, x, y);
			if (load)
				control.OnLoadComplete(EventArgs.Empty);
		}
Ejemplo n.º 19
0
		public DialogResult ShowDialog (Control parent, PrintDocument document)
		{
			this.PrintSettings.MaximumPageRange = new Range (1, document.PageCount);
			this.PrintSettings = document.PrintSettings;
			var result = this.ShowDialog (parent);
			if (result == DialogResult.Ok) {
				document.Print ();
			}
			return result;
		}
Ejemplo n.º 20
0
		public static bool KeyUp(Control control, NSEvent theEvent)
		{
			if (control != null)
			{
				var kpea = theEvent.ToEtoKeyEventArgs();
				control.OnKeyUp(kpea);
				return kpea.Handled;
			}
			return false;
		}
Ejemplo n.º 21
0
		public static Container AddDockedControl (this Container container, Control control, Padding? padding = null)
		{
			var layout = container.Layout as DockLayout;
			if (layout == null)
				layout = new DockLayout (container);
			if (padding != null)
				layout.Padding = padding.Value;
			layout.Content = control;
			return container;
		}
Ejemplo n.º 22
0
		protected override void LogEvents (Control control)
		{
			base.LogEvents (control);
			
			control.GotFocus += delegate {
				Log.Write (control, "GotFocus");
			};
			control.LostFocus += delegate {
				Log.Write (control, "LostFocus");
			};
		}
Ejemplo n.º 23
0
		public static void AddLabelledSection (this DynamicLayout layout, string text, Control control)
		{
			var label = new Label { Text = text, VerticalAlign = VerticalAlign.Middle };
#if DESKTOP
			layout.AddRow (Label, control);
#elif MOBILE
			layout.BeginVertical ();
			layout.Add (label);
			layout.Add (control);
			layout.EndVertical ();
#endif
		}
Ejemplo n.º 24
0
		/// <summary>
		/// Shows the print dialog for the specified <paramref name="document"/>, printing after closed if the user selects to print.
		/// </summary>
		/// <returns>The result.</returns>
		/// <param name="parent">Parent of the dialog to make modal.</param>
		/// <param name="document">Document to print.</param>
		public DialogResult ShowDialog(Control parent, PrintDocument document)
		{
			PrintSettings = document.PrintSettings;
			PrintSettings.MaximumPageRange = new Range<int>(1, document.PageCount);
			Handler.Document = document;
			var result = ShowDialog(parent);
			if (result == DialogResult.Ok)
			{
				document.Print();
			}
			return result;
		}
Ejemplo n.º 25
0
 public DialogResult ShowDialog(Control parent, MessageBoxButtons buttons)
 {
     var element = parent == null ? null: parent.ControlObject as System.Windows.FrameworkElement;
     var window = element == null ? null: element.GetParent<System.Windows.Window>();
     System.Windows.MessageBoxResult result;
     var wpfbuttons = Convert(buttons);
     var icon = Convert(Type);
     var caption = Caption ?? ((parent != null && parent.ParentWindow != null) ? parent.ParentWindow.Text : null);
     if (window != null) result = System.Windows.MessageBox.Show(window, Text, caption, wpfbuttons, icon);
     else result = System.Windows.MessageBox.Show(Text, caption, wpfbuttons, icon);
     return Convert (result);
 }
Ejemplo n.º 26
0
		public void Add (Control control, int x, int y)
		{
			controls.Add (control);
			control.SetParentLayout (this);
			var load = Loaded && !control.Loaded;
			if (load) {
				control.OnPreLoad (EventArgs.Empty);
				control.OnLoad (EventArgs.Empty);
			}
			inner.Add (control, x, y);
			if (load)
				control.OnLoadComplete (EventArgs.Empty);
		}
Ejemplo n.º 27
0
        public void ShowModal(Eto.Forms.Control owner, System.Action <T> returnFunc)
        {
            _returnFunc = returnFunc;
            if (!this.Loaded)
            {
                var c = owner.Bounds.Center;
                c.X           = c.X - this.Width / 2;
                c.Y           = c.Y - 200;
                this.Location = c;
            }

            this.Show();
        }
Ejemplo n.º 28
0
		protected override void LogEvents (Control control)
		{
			base.LogEvents (control);

			var cc = control as CommonControl;
			if (cc != null) {
				cc.Font = new Font (FontFamily.Serif, 20, FontStyle.Italic);
			}
			var gb = control as GroupBox;
			if (gb != null) {
				gb.Font = new Font (FontFamily.Serif, 20, FontStyle.Italic);
			}
		}
Ejemplo n.º 29
0
 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();
 }
Ejemplo n.º 30
0
		protected override void LogEvents(Control control)
		{
			base.LogEvents(control);
			
			control.KeyDown += (sender, e) => {
				Log.Write(control, "KeyDown, Key: {0}, Char: {1}", e.KeyData, e.IsChar ? e.KeyChar.ToString() : "no char");
				if (handleEvents.Checked == true)
					e.Handled = true;
			};

			control.KeyUp += (sender, e) => {
				Log.Write(control, "KeyUp, Key: {0}, Char: {1}", e.KeyData, e.IsChar ? e.KeyChar.ToString() : "no char");
			};
		}
Ejemplo n.º 31
0
		public DialogResult ShowDialog(Control parent)
		{
			Gtk.Widget c = (parent == null) ? null : (Gtk.Widget)parent.ControlObject;
			while (!(c is Gtk.Window) && c != null)
			{
				c = c.Parent;
			}
			control = new Gtk.MessageDialog((Gtk.Window)c, Gtk.DialogFlags.Modal, Convert (Type), Gtk.ButtonsType.Ok, false, Text);
			control.TypeHint = Gdk.WindowTypeHint.Dialog;
            var caption = Caption ?? ((parent != null && parent.ParentWindow != null) ? parent.ParentWindow.Title : null);
            if (!string.IsNullOrEmpty(caption)) control.Title = caption;
			int ret = control.Run();
			control.Destroy();
			return Generator.Convert((Gtk.ResponseType)ret);
		}
Ejemplo n.º 32
0
		public void Add(Control control, int x, int y)
		{
			RemoveParent(control, false);
			control.Properties[LocationProperty] = new Point(x, y);
			controls.Add(control);
			var load = Loaded && !control.Loaded;
			if (load)
			{
				control.OnPreLoad(EventArgs.Empty);
				control.OnLoad(EventArgs.Empty);
			}
			SetParent(control);
			Handler.Add(control, x, y);
			if (load)
				control.OnLoadComplete(EventArgs.Empty);
		}
Ejemplo n.º 33
0
 public static Point GetLocation(Control control)
 {
     return(control.Properties.Get <Point>(LocationProperty, Point.Empty));
 }
Ejemplo n.º 34
0
 public static void SetColumnScale(Control control, bool value)
 {
     control.Properties[ColumnScaleProperty] = value;
 }
Ejemplo n.º 35
0
 public static bool GetRowScale(Control control)
 {
     return(control.Properties.Get <bool>(RowScaleProperty, false));
 }
Ejemplo n.º 36
0
 public static void SetRowScale(Control control, bool value)
 {
     control.Properties[RowScaleProperty] = value;
 }
Ejemplo n.º 37
0
 public void Add(Control child, Point p)
 {
     Add(child, p.X, p.Y);
 }
Ejemplo n.º 38
0
 public void Move(Control child, Point p)
 {
     Move(child, p.X, p.Y);
 }