/// <summary> /// Constructs a ScrollPanelDemo for the specified program. /// </summary> /// <param name="program"></param> public ScrollPanelDemo(MySimpleWPFApplication program) : base(program) { // Create a stack panel for the title and scroll view. StackPanel panel = new StackPanel(Orientation.Vertical); // Create the text scroll view and set all of its properties. _viewer = new TextScrollViewer(Resources.GetString( Resources.StringResources.ScrollableText), MySimpleWPFApplication.NinaBFont, Color.Black); _viewer.Width = this.Width; // Make room for the title bar. _viewer.Height = this.Height - 25; _viewer.HScrollHeight = 10; _viewer.VScrollWidth = 10; _viewer.HorizontalAlignment = HorizontalAlignment.Left; _viewer.VerticalAlignment = VerticalAlignment.Top; // Create the title text Text title = new Text(MySimpleWPFApplication.NinaBFont, Resources.GetString(Resources.StringResources.ScrollableTextTitle)); title.ForeColor = Color.White; // Add the elements to the stack panel. panel.Children.Add(title); panel.Children.Add(_viewer); // Add the stack panel to this window. this.Child = panel; // Set the background color. this.Background = new SolidColorBrush(ColorUtility.ColorFromRGB(64, 64, 255)); }
/// <summary> /// Constructs a MainMenuWindow for the specified program. /// </summary> /// <param name="program"></param> public MainMenuWindow(MySimpleWPFApplication program) : base(program) { // Create some colors for the text items. Color instructionTextColor = ColorUtility.ColorFromRGB(255, 255, 255); Color backgroundColor = ColorUtility.ColorFromRGB(0, 0, 0); Color upperBackgroundColor = ColorUtility.ColorFromRGB(69, 69, 69); Color unselectedItemColor = ColorUtility.ColorFromRGB(192, 192, 192); Color selectedItemColor = ColorUtility.ColorFromRGB(128, 128, 128); // The Main window contains a veritcal StackPanel. StackPanel panel = new StackPanel(Orientation.Vertical); this.Child = panel; // The top child contains a horizontal StackPanel. m_MenuItemPanel = new MenuItemPanel(this.Width, this.Height); // The top child contains the menu items. We pass in the small bitmap, // large bitmap a description and then a large bitmap to use as a common // sized bitmap for calculating the width and height of a MenuItem. MenuItem menuItem1 = new MenuItem( Resources.BitmapResources.Vertical_Stack_Panel_Icon_Small, Resources.BitmapResources.Vertical_Stack_Panel_Icon, "Vertical Stack Panel", Resources.BitmapResources.Canvas_Panel_Icon); MenuItem menuItem2 = new MenuItem( Resources.BitmapResources.Horizontal_Stack_Panel_Icon_Small, Resources.BitmapResources.Horizontal_Stack_Panel_Icon, "Horizontal Stack Panel", Resources.BitmapResources.Canvas_Panel_Icon); MenuItem menuItem3 = new MenuItem( Resources.BitmapResources.Canvas_Panel_Icon_Small, Resources.BitmapResources.Canvas_Panel_Icon, "Canvas Panel", Resources.BitmapResources.Canvas_Panel_Icon); MenuItem menuItem4 = new MenuItem( Resources.BitmapResources.Scrollable_Panel_Icon_Small, Resources.BitmapResources.Scrollable_Panel_Icon, "Scrollable Panel", Resources.BitmapResources.Canvas_Panel_Icon); MenuItem menuItem5 = new MenuItem( Resources.BitmapResources.Free_Drawing_Panel_Icon_Small, Resources.BitmapResources.Free_Drawing_Panel_Icon, "Free Drawing Panel", Resources.BitmapResources.Canvas_Panel_Icon); // Add each of the menu items to the menu item panel m_MenuItemPanel.AddMenuItem(menuItem1); m_MenuItemPanel.AddMenuItem(menuItem2); m_MenuItemPanel.AddMenuItem(menuItem3); m_MenuItemPanel.AddMenuItem(menuItem4); m_MenuItemPanel.AddMenuItem(menuItem5); // Add the menu item panel to the main window panel panel.Children.Add(m_MenuItemPanel); }
/// <summary> /// Constructs a FreeDrawingDemo, using the specified program. /// </summary> /// <param name="program">The program to construct a demo for.</param> public FreeDrawingDemo(MySimpleWPFApplication program) : base(program) { #if MF_FRAMEWORK_VERSION_V3_0 Microsoft.SPOT.Math.Randomize(); #else _random = new Random(); #endif }
/// <summary> /// Constructs a PresentationWindow for the specified program. /// </summary> /// <param name="program"></param> protected PresentationWindow(MySimpleWPFApplication program) { _program = program; // Make the window visible and the size of the LCD this.Visibility = Visibility.Visible; this.Width = SystemMetrics.ScreenWidth; this.Height = SystemMetrics.ScreenHeight; Buttons.Focus(this); // Set focus to this window }
/// <summary> /// The executable entry point. /// </summary> public static void Main() { MySimpleWPFApplication myApplication = new MySimpleWPFApplication(); mainWindow = new MainMenuWindow(myApplication); // Create the object that configures the GPIO pins to buttons. GPIOButtonInputProvider inputProvider = new GPIOButtonInputProvider(null); // Load the fonts. NinaBFont = Resources.GetFont(Resources.FontResources.NinaBFont); SmallFont = Resources.GetFont(Resources.FontResources.SmallFont); // Start the application. myApplication.Run(mainWindow); }
/// <summary> /// Constructs a StackPanelDemo for the specified program and orientation. /// </summary> /// <param name="program">The program for which to construct a demo.</param> /// <param name="orientation">The orientation of the graphical layout. /// </param> public StackPanelDemo(MySimpleWPFApplication program, Orientation orientation) : base(program) { StackPanel panel = new StackPanel(orientation); this.Child = panel; panel.Visibility = Visibility.Visible; // This is an array of different shapes to be drawn. Shape[] shapes = new Shape[] { new Ellipse(0, 0), new Line(), // A square. new Polygon(new Int32[] { 0, 0, 50, 0, 50, 50, 0, 50 }), new Rectangle(), // A custom shape. new Cross() }; // Set up the needed member values for each shape. for (Int32 x = 0; x < shapes.Length; x++) { Shape s = shapes[x]; s.Fill = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 255, 0)); s.Stroke = new Pen(Color.Black, 2); s.Visibility = Visibility.Visible; s.HorizontalAlignment = HorizontalAlignment.Center; s.VerticalAlignment = VerticalAlignment.Center; s.Height = Height - 1; s.Width = Width - 1; if (panel.Orientation == Orientation.Horizontal) { s.Width /= shapes.Length; } else { s.Height /= shapes.Length; } panel.Children.Add(s); } }
/// <summary> /// Constructs a CanvasPanelDemo for the given program. /// </summary> /// <param name="program"></param> public CanvasPanelDemo(MySimpleWPFApplication program) : base(program) { Canvas canvas = new Canvas(); this.Child = canvas; this.Background = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 255, 255)); for (Int32 x = 0; x < Width; x += Width / 4) { for (Int32 y = 0; y < Height; y += Height / 4) { Text text = new Text(MySimpleWPFApplication.SmallFont, " (" + x + "," + y + ")"); Canvas.SetLeft(text, x); Canvas.SetTop(text, y); canvas.Children.Add(text); } } }
/// <summary> /// Constructs a StackPanelDemo for the specified program and orientation. /// </summary> /// <param name="program">The program for which to construct a demo.</param> /// <param name="orientation">The orientation of the graphical layout. /// </param> public StackPanelDemo(MySimpleWPFApplication program, Orientation orientation) : base(program) { StackPanel panel = new StackPanel(orientation); this.Child = panel; panel.Visibility = Visibility.Visible; // This is an array of different shapes to be drawn. Shape[] shapes = new Shape[] { new Ellipse(0, 0), new Line(), // A square. new Polygon(new Int32[] { 0, 0, 50, 0, 50, 50, 0, 50 }), new Rectangle(), // A custom shape. new Cross() }; // Set up the needed member values for each shape. for (Int32 x = 0; x < shapes.Length; x++) { Shape s = shapes[x]; s.Fill = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 255, 0)); s.Stroke = new Pen(Color.Black, 2); s.Visibility = Visibility.Visible; s.HorizontalAlignment = HorizontalAlignment.Center; s.VerticalAlignment = VerticalAlignment.Center; s.Height = Height - 1; s.Width = Width - 1; if (panel.Orientation == Orientation.Horizontal) s.Width /= shapes.Length; else s.Height /= shapes.Length; panel.Children.Add(s); } }