public Window CreateWindow() { // Create a window object and set its size to the // size of the display. mainWindow = new Window(); mainWindow.Height = SystemMetrics.ScreenHeight; mainWindow.Width = SystemMetrics.ScreenWidth; // Create Ink Canvas InkCanvas inkCanvas = new InkCanvas(0, 0, mainWindow.Width, mainWindow.Height); // Set line color to green DrawingAttributes attr = new DrawingAttributes(); attr.Color = Colors.Green; inkCanvas.DefaultDrawingAttributes = attr; // Add the text control to the window. mainWindow.Child = inkCanvas; // Set the window visibility to visible. mainWindow.Visibility = Visibility.Visible; return mainWindow; }
/// <summary> /// The default constructor. /// </summary> public MyWindow() { int screenWidth; int screenHeight; int bitsPerPixel; int orientation; HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight, out bitsPerPixel, out orientation); // Create the puzzle board. Default to square, because all of // the images fit in a square. puzzleBoard = new PuzzleBoard(240, 240); #if !MF_FRAMEWORK_VERSION_V3_0 puzzleBoard.TouchGestureChanged += new TouchGestureEventHandler(puzzleBoard_Gesture); #endif // Create the Reset button. button = new Button("Reset", Resources.GetFont(Resources.FontResources.small)); button.HorizontalAlignment = HorizontalAlignment.Right; button.VerticalAlignment = VerticalAlignment.Top; button.Click += new EventHandler(button_Click); // Create the Solve button. button2 = new Button("Solve", Resources.GetFont(Resources.FontResources.small)); button2.HorizontalAlignment = HorizontalAlignment.Right; button2.VerticalAlignment = VerticalAlignment.Center; button2.Click += new EventHandler(button2_Click); if (screenWidth < screenHeight) { button.HorizontalAlignment = HorizontalAlignment.Left; button.VerticalAlignment = VerticalAlignment.Bottom; button2.HorizontalAlignment = HorizontalAlignment.Center; button2.VerticalAlignment = VerticalAlignment.Bottom; } // Create a text element to display the action the user just // performed. text = new Text(); text.Font = Resources.GetFont(Resources.FontResources.small); text.TextContent = " "; text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Right; text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Bottom; // Add a panel to hold the other controls. this.Child = panel; // Add the puzzle, buttons and text controls to the panel. panel.Children.Add(puzzleBoard); panel.Children.Add(button); panel.Children.Add(button2); panel.Children.Add(text); // Set the drawing attributes to a default set. DrawingAttributes da = new DrawingAttributes(); puzzleBoard.DefaultDrawingAttributes = da; }
/// <summary> /// The default constructor. /// </summary> public MyWindow() { // Create the canvas to draw on. int screenWidth; int screenHeight; int bitsPerPixel; int orientation; HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight, out bitsPerPixel, out orientation); inkCanvas = new MyCanvas(screenWidth - 60, screenHeight - 30); // Create the Clear button. button = new Button("Clear", Resources.GetFont(Resources.FontResources.small)); button.Click += new EventHandler(button_Click); // Create the palette for selecting colors. colorPalette = new MyColorPalette(8, 2, 54, 204); colorPalette.HorizontalAlignment = HorizontalAlignment.Right; colorPalette.VerticalAlignment = VerticalAlignment.Top; colorPalette.ItemClick += new PaletteControlEventHandler(colorPalette_ItemClick); // Add a panel to hold the other controls. this.Child = panel; // Add the canvas, clear button and palette to the panel. panel.Children.Add(inkCanvas); panel.Children.Add(button); panel.Children.Add(colorPalette); // Set the drawing attributes to a default set. DrawingAttributes da = new DrawingAttributes(); inkCanvas.DefaultDrawingAttributes = da; }
/// <summary> /// Constructs a MyCanvas with the specified settings. /// </summary> /// <param name="width"></param> /// <param name="height"></param> public MyCanvas(int width, int height) : base(0, 0, width, height) { #if MF_FRAMEWORK_VERSION_V3_0 _drawingAttribs = new DrawingAttributes(); _drawingAttribs.Color = ColorUtility.ColorFromRGB(0, 0, 255); #endif }