Example #1
0
		public MainWindow ()
		{
			WidthRequest = 997;
			HeightRequest = 679;
			Title = "fkalc";

			var quitButton = new Button () { Content = new TextBlock() { Text = "Quit" }, BorderThickness = 0 };
			quitButton.Click += (sender, e) => Application.Current.Shutdown ();

			var fileMenuItem = new MenuItem ()
			{
				Header = new TextBlock()
				{
					Text = "File"
				},
				ItemsSource = new ObservableCollection<UIElement>()
				{ 
					new TextBlock() { Text = "New", HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 50, 5) },
					new TextBlock() { Text = "Open", HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 50, 5)}, 
					new TextBlock() { Text = "Close", HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 50, 5)},
					new MenuItem() { Header = quitButton, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(20, 0, 50, 5)},
				},
				Margin = new Thickness(5),
			};

			var menuItems = new ObservableCollection<MenuItem> () { fileMenuItem };

			var menu = new Menu ()
			{
				HorizontalAlignment = HorizontalAlignment.Stretch,
				VerticalAlignment = VerticalAlignment.Stretch,
				ItemsSource = menuItems,
			};

			var tabControl = new TabControl ();
			tabControl.ItemTemplate = new DataTemplate (DocumentTemplate);

			BindingOperations.SetBinding (this, "DataContext.Documents", tabControl.GetProperty ("ItemsSource"));

			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 ());

			grid.Children.Add (menu);
			grid.Children.Add (tabControl);		

			grid.SetRow (0, menu);
			grid.SetColumn (0, menu);

			grid.SetRow (1, tabControl);
			grid.SetColumn (0, tabControl);

			Content = grid;
		}
Example #2
0
		public DocumentView ()
		{	
			HorizontalAlignment = HorizontalAlignment.Stretch;
			VerticalAlignment = VerticalAlignment.Stretch;

			newRegionCommand = BuildProperty<ICommand> ("NewRegionCommand");

			Focusable = true;

			itemsControl.ItemsPanel = canvas;
			itemsControl.ItemTemplate = new DataTemplate (Factory);
			
			var adornerDecorator = new AdornerDecorator () { Child = itemsControl };
			
			var grid = new Grid () {HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch};
			grid.RowDefinitions.Add (new RowDefinition ());
			grid.RowDefinitions.Add (new RowDefinition () {Height = GridLength.Auto});
			grid.ColumnDefinitions.Add (new ColumnDefinition ());
			grid.ColumnDefinitions.Add (new ColumnDefinition () {Width = GridLength.Auto});			
			
			var textBlock = new TextBlock (){Text ="+"};
						
			var button = new Button () { Content = textBlock};			
			
			grid.Children.Add (adornerDecorator);
			grid.Children.Add (button);
			
			grid.SetRow (1, button);			
			
			Content = grid;

			PreviewKeyPressEvent += HandlePreviewKeyPressEvent;
			ButtonPressEvent += HandleButtonPressEvent;

			AdornerLayer.GetAdornerLayer (itemsControl).Add (documentCursor);
			
			Background = Brushes.White;

			Keyboard.Focus (this);

			BindingOperations.SetBinding (this, "DataContext.DocumentCursor", documentCursor.GetProperty ("DataContext"));
			BindingOperations.SetBinding (this, "DataContext.Regions", itemsControl.GetProperty ("ItemsSource"));
			BindingOperations.SetBinding (this, "DataContext.NewRegionCommand", GetProperty ("NewRegionCommand"));
		}		
		private static Button CloseButton ()
		{
			var figure1 = new PathFigure ();
			figure1.StartPoint = new Point (0, 0);
			figure1.Segments.Add (new LineSegment () { Point = new Point(7,7)});
			
			var figure2 = new PathFigure ();
			figure2.StartPoint = new Point (7, 0);
			figure2.Segments.Add (new LineSegment () { Point = new Point(0,7)});
			
			var pathGeomentry = new PathGeometry ();
			pathGeomentry.Figures.Add (figure1);
			pathGeomentry.Figures.Add (figure2);
			
			var path = new Path ();
			path.WidthRequest = 7;
			path.HeightRequest = 7;
			path.Stroke = Colors.White;
			path.StrokeThickness = 2;
			path.Data = pathGeomentry;
			
			var button = new Button () { Content = path };
			button.Padding = new Thickness (4);
			button.BorderColor = new Color (0x1f, 0x42, 0x6f); 
			button.BorderThickness = 1;
			button.Background = GetTitleBrush ();
			return button;
		}