public GtkSurface (UIElement owner, double left, double top, double width, double height, Gtk.WindowType windowType): base (windowType)
		{
			Owner = owner;

			Move ((int)left, (int)top);

			Width = width;
			Height = height;

			DefaultWidth = (int)Width;
			DefaultHeight = (int)Height;
			Decorated = false;
			Events = Gdk.EventMask.ExposureMask
				| Gdk.EventMask.ButtonPressMask
				| Gdk.EventMask.ButtonReleaseMask
				| Gdk.EventMask.PointerMotionMask
				| Gdk.EventMask.KeyPressMask
				| Gdk.EventMask.KeyReleaseMask;  
						
			ExposeEvent += OnExposeEvent;			

			Keyboard.Device.RegisterKeyboardInputProvider (new WidgetKeyboardInputProvider (this));
			Mouse.Device.RegistedMouseInputProvider (new WidgetMouseInputProvider (this, owner));

			Application.Current.RegisterRoot (this);
		}
		public void SetTop (double top, UIElement element)
		{
			var child = children.FirstOrDefault (c => c.Content == element);
			
			if (child == null)
				return;
			
			child.Y = top;
		}
		public void SetRow (uint row, UIElement element)
		{
			var child = children.FirstOrDefault (c => c.Content == element);
			
			if (child == null)
				return;
			
			child.Row = row;
		}
		public CanvasChild (UIElement child)
		{
			x = BuildVisualProperty<double> ("X");
			y = BuildVisualProperty<double> ("Y");

			Content = child;

			BindingOperations.SetBinding (child.GetProperty ("Visibility"), GetProperty ("Visibility"));
		}
		public double GetTop (UIElement element)
		{
			var child = children.FirstOrDefault (c => c.Content == element);
			
			if (child == null)
				return 0;
			
			return child.Y;
		}
		public void SetColumn (uint column, UIElement element)
		{
			var child = children.FirstOrDefault (c => c.Content == element);
			
			if (child == null)
				return;
			
			child.Column = column;
		}
		public void SetLeft (double left, UIElement element)
		{
			var child = children.FirstOrDefault (c => c.Content == element);
			
			if (child == null)
				return;
			
			child.X = left;
		}
		public GridChild (UIElement child)
		{
			Content = child;

			BindingOperations.SetBinding (child.GetProperty ("Visibility"), GetProperty ("Visibility"));
			
			HorizontalAlignment = HorizontalAlignment.Stretch;
			VerticalAlignment = VerticalAlignment.Stretch;
		}	
		private void HandleTemplateChanged (object sender, DPropertyValueChangedEventArgs<ControlTemplate> e)
		{
			if (templateControl != null)				
				RemoveVisualChild (templateControl);
			
			templateControl = e.NewValue != null ? e.NewValue.LoadContent (this) : null;
			
			if (templateControl != null)
				AddVisualChild (templateControl);
		}
		public StackPanelChild (UIElement child)
		{
			Content = child;
			
			HorizontalAlignment = HorizontalAlignment.Center;

			BindingOperations.SetBinding (child.GetProperty ("Margin"), GetProperty ("Margin"));
			BindingOperations.SetBinding (child.GetProperty ("HorizontalAlignment"), GetProperty ("HorizontalAlignment"));
			BindingOperations.SetBinding (child.GetProperty ("VerticalAlignment"), GetProperty ("VerticalAlignment"));
			BindingOperations.SetBinding (child.GetProperty ("Visibility"), GetProperty ("Visibility"));
		}
		private void HandleItemsChanged (object sender, NotifyCollectionChangedEventArgs e)
		{
			switch (e.Action) {
			case NotifyCollectionChangedAction.Add:
				if (SelectedItem == null)
					SelectedItem = e.NewItems.Cast<ItemView> ().First ().Visual;
				break;
			default:
				break;
			}
		}
		private static UIElement ItemsControlTemplate (UIElement element)
		{
			var border = new Border ();
			
			BindingOperations.SetBinding (element.GetProperty ("Padding"), border.GetProperty ("Padding"));
			BindingOperations.SetBinding (element.GetProperty ("Background"), border.GetProperty ("Background"));
			BindingOperations.SetBinding (element.GetProperty ("BorderThickness"), border.GetProperty ("BorderThickness"));
			BindingOperations.SetBinding (element.GetProperty ("BorderColor"), border.GetProperty ("BorderColor"));
			
			BindingOperations.SetBinding (element.GetProperty ("ItemsPanel"), border.GetProperty ("Child"));
			
			return border;		
		}
		private static UIElement ButtonTemplate (UIElement element)
		{
			var border = new Border ();
			border.CornerRadius = new CornerRadius (3);
			
			BindingOperations.SetBinding (element.GetProperty ("Padding"), border.GetProperty ("Padding"));
			BindingOperations.SetBinding (element.GetProperty ("Background"), border.GetProperty ("Background"));
			BindingOperations.SetBinding (element.GetProperty ("BorderThickness"), border.GetProperty ("BorderThickness"));
			BindingOperations.SetBinding (element.GetProperty ("BorderColor"), border.GetProperty ("BorderColor"));
			
			BindingOperations.SetBinding (element.GetProperty ("Content"), border.GetProperty ("Child"));
			
			return border;		
		}
Example #14
0
		public static Area GetArea (UIElement uielement)
		{
			if (uielement == null)
				return null;

			if (uielement is Area)
				return uielement as Area;

			for (int i = 0; i < uielement.VisualChildrenCount; i++) {
				var child = GetArea (uielement.GetVisualChild (i) as UIElement);

				if (child != null)
					return child;
			}

			return null;
		}
Example #15
0
			private Area GetArea (UIElement uielement)
			{
				return AreaHelper.GetArea (uielement);
			}
Example #16
0
		private static UIElement MenuItemTemplate (UIElement element)
		{
			var header = new ContentControl ();
			BindingOperations.SetBinding (element.GetProperty ("Header"), header.GetProperty ("Content"));

			var popup = new Popup ()
			{
				PlacementTarget = element,
				VerticalOffset = 6,
				HorizontalOffset = -5,
			};

			BindingOperations.SetBinding (element.GetProperty ("ItemsPanel"), popup.GetProperty ("Child"));
			BindingOperations.SetBinding (element.GetProperty ("IsSubmenuOpen"), popup.GetProperty ("IsOpen"));

			return header;
		}
		private static UIElement TabControlTemplate (UIElement element)
		{
			var grid = new Grid ()
			{
				HorizontalAlignment = HorizontalAlignment.Stretch,
				VerticalAlignment = VerticalAlignment.Stretch
			};
			
			grid.RowDefinitions.Add (new RowDefinition () { Height = GridLength.Auto });
			grid.RowDefinitions.Add (new RowDefinition ());
			grid.ColumnDefinitions.Add (new ColumnDefinition ());
									
			var selectedTabContent = new ContentControl ()
			{
				HorizontalAlignment = HorizontalAlignment.Stretch,
				VerticalAlignment = VerticalAlignment.Stretch
			};
			BindingOperations.SetBinding (element, "SelectedItem.Content", selectedTabContent.GetProperty ("Content"));

			var headerPanel = new ItemsControl ()
			{
				ItemsPanel = new StackPanel() { Orientation = Orientation.Horizontal },
				ItemTemplate = new DataTemplate(TabHeaderTemplate),
			};
			BindingOperations.SetBinding (element.GetProperty ("Items"), headerPanel.GetProperty ("ItemsSource"));

			grid.Children.Add (headerPanel);
			grid.Children.Add (selectedTabContent);
			
			grid.SetRow (0, headerPanel);
			grid.SetColumn (0, headerPanel);
			
			grid.SetRow (1, selectedTabContent);
			grid.SetColumn (0, selectedTabContent);
			
			var border = new Border ()
			{
				Child = grid,
			};

			BindingOperations.SetBinding (element.GetProperty ("Padding"), border.GetProperty ("Padding"));
			BindingOperations.SetBinding (element.GetProperty ("Background"), border.GetProperty ("Background"));
			BindingOperations.SetBinding (element.GetProperty ("BorderThickness"), border.GetProperty ("BorderThickness"));
			BindingOperations.SetBinding (element.GetProperty ("BorderColor"), border.GetProperty ("BorderColor"));
			
			return border;
		}
Example #18
0
		private Area GetArea (Token token, UIElement uielement)
		{
			if (uielement == null)
				return null;

			if (uielement is FrameworkElement && (uielement as FrameworkElement).DataContext == token)
				return uielement as Area;

			
			for (int i = 0; i < uielement.VisualChildrenCount; i++) {
				var child = GetArea (token, uielement.GetVisualChild (i) as UIElement);

				if (child != null)
					return child;
			}

			return null;
		}
		public UIElement LoadContent (UIElement element)
		{
			return factory (element);
		}