コード例 #1
0
        /// <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(Resource.GetString(Resource.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, Resource.GetString(Resource.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));
        }
コード例 #2
0
        /// <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
        }
コード例 #3
0
        /// <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);
                }
            }
        }
コード例 #4
0
        /// <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(),

                                           new Cross()  // A custom shape.
            };

            // 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);
            }
        }
コード例 #5
0
        /// <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(Resource.BitmapResources.Vertical_Stack_Panel_Icon_Small, Resource.BitmapResources.Vertical_Stack_Panel_Icon, "Vertical Stack Panel", Resource.BitmapResources.Canvas_Panel_Icon);
            MenuItem menuItem2 = new MenuItem(Resource.BitmapResources.Horizontal_Stack_Panel_Icon_Small, Resource.BitmapResources.Horizontal_Stack_Panel_Icon, "Horizontal Stack Panel", Resource.BitmapResources.Canvas_Panel_Icon);
            MenuItem menuItem3 = new MenuItem(Resource.BitmapResources.Canvas_Panel_Icon_Small, Resource.BitmapResources.Canvas_Panel_Icon, "Canvas Panel", Resource.BitmapResources.Canvas_Panel_Icon);
            MenuItem menuItem4 = new MenuItem(Resource.BitmapResources.Scrollable_Panel_Icon_Small, Resource.BitmapResources.Scrollable_Panel_Icon, "Scrollable Panel", Resource.BitmapResources.Canvas_Panel_Icon);
            MenuItem menuItem5 = new MenuItem(Resource.BitmapResources.Free_Drawing_Panel_Icon_Small, Resource.BitmapResources.Free_Drawing_Panel_Icon, "Free Drawing Panel", Resource.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);
        }
コード例 #6
0
 /// <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)
 {
     _random = new Random();
 }