Ejemplo n.º 1
0
		public ExponentiationArea ()
		{
			Base = new ContentControl () 
			{
				Content = new TextArea(),
				Margin = new Thickness (0, 3, 3, 0)
			};

			Power = new ContentControl () 
			{
				Content = new TextArea(),
				RenderTransform = new ScaleTransform(0.75, 0.75),
				LayoutTransform = new ScaleTransform(0.75, 0.75),
				//BorderColor = Colors.Blue
			};

			var grid = new Grid ();

			grid.Children.Add (Base);
			grid.Children.Add (Power);

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

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

			BindingOperations.SetBinding (this, "DataContext.Base", Base.GetProperty ("Content"), new TokenAreaConverter ());
			BindingOperations.SetBinding (this, "DataContext.Power", Power.GetProperty ("Content"), new TokenAreaConverter ());

			Content = grid;
		}
Ejemplo n.º 2
0
		public MainWindow ()
		{
			WidthRequest = 997;
			HeightRequest = 679;
			Title = "fkalc";

			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)}
				},
				//Template = new ControlTemplate(MenuItemTemplate),
				Margin = new Thickness(5),
			};

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

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

			var document = new DocumentView ()
			{
				DataContext = new DocumentViewModel ()
			};

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

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

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

			Content = grid;
		}
Ejemplo n.º 3
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"));
		}		
Ejemplo n.º 4
0
		public AssignmentArea ()
		{
			var grid = new Grid ();

			var ellipse1 = new Ellipse ()
			{
				WidthRequest = 3,
				HeightRequest = 3,
				StrokeThickness = 1,
				Fill = Brushes.Black,
				Margin = new Thickness(1)
			};

			var ellipse2 = new Ellipse ()
			{
				WidthRequest = 3,
				HeightRequest = 3,
				StrokeThickness = 1,
				Fill = Brushes.Black,
				Margin = new Thickness(1)
			};

			var line1 = new Line ()
			{
				WidthRequest = 12,
				HeightRequest = 2,
				StrokeThickness = 2,
				Stroke = Colors.Black,
				SnapsToDevicePixels = true,
				Margin = new Thickness (0,2,0,0)
			};

			var line2 = new Line ()
			{
				WidthRequest = 12,
				HeightRequest = 2,
				StrokeThickness = 2,
				Stroke = Colors.Black,
				SnapsToDevicePixels = true,
				Margin = new Thickness (0,2,0,0)
			};
						
			grid.Children.Add (ellipse1);
			grid.Children.Add (ellipse2);
			grid.Children.Add (line1);
			grid.Children.Add (line2);

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

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


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

			grid.SetRow (1, line2);
			grid.SetColumn (1, line2);
						
			Content = grid;
		}
		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;
		}
		private static UIElement WindowTemplate (Window 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 titleGrid = new Grid () {HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch};
			titleGrid.RowDefinitions.Add (new RowDefinition ());
			titleGrid.ColumnDefinitions.Add (new ColumnDefinition ());
			titleGrid.ColumnDefinitions.Add (new ColumnDefinition () { Width = GridLength.Auto });
			
			var title = new TextBlock ();		
			title.Foreground = Colors.White;
			title.HorizontalAlignment = HorizontalAlignment.Center;
			BindingOperations.SetBinding (element.GetProperty ("Title"), title.GetProperty ("Text"));
			
			var closeButton = CloseButton ();			
			closeButton.Click += (sender, e) => element.Close ();
			
			titleGrid.Children.Add (title);			
			titleGrid.Children.Add (closeButton);
			
			titleGrid.SetColumn (0, title);
			titleGrid.SetColumn (1, closeButton);
			
			var titleThumb = new Thumb () 
			{
				HorizontalAlignment = HorizontalAlignment.Stretch, 
				VerticalAlignment = VerticalAlignment.Stretch,
				Template = new ControlTemplate(t => titleGrid)
			};
			
			titleThumb.DragDelta += (sender, e) => 
			{
				element.Left += e.HorizontalChange;
				element.Top += e.VerticalChange;
			};
			
			var titleBorder = new Border ();
			titleBorder.Background = GetTitleBrush ();
			titleBorder.Child = titleThumb;
			titleBorder.Padding = new Thickness (3);
			
			grid.Children.Add (titleBorder);
			grid.SetRow (0, titleBorder);
			
			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 ("Content"), border.GetProperty ("Child"));
			
			grid.Children.Add (border);
			grid.SetRow (1, border);
			
			return grid;		
		}
Ejemplo n.º 7
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;
		}