Example #1
0
        void setupUI()
        {
            touchScreen = display_T35.WPFWindow;
            //setup layout
            Canvas layout = new Canvas();
            Border background = new Border();
            background.Background = new SolidColorBrush(Colors.Black);
            background.Height = 240;
            background.Width = 320;
            layout.Children.Add(background);
            Canvas.SetLeft(background, 0);
            Canvas.SetTop(background, 0);

            //add label
            console = new Text("Hello World!");
            console.Height = 100;
            console.Width = 320;
            console.ForeColor = Colors.Green;
            console.Font = Resources.GetFont(Resources.FontResources.NinaB);
            console.TextAlignment = TextAlignment.Left;

            layout.Children.Add(console);
            Canvas.SetLeft(console, 0);
            Canvas.SetTop(console, 10);

            touchScreen.Child = layout;
        }
Example #2
0
        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;

            Canvas canvas = new Canvas();

            // Create aborder for the text
            Border textBorder = new Border();
            textBorder.SetBorderThickness(1, 5, 1, 5);
            textBorder.BorderBrush = new SolidColorBrush(Colors.Blue);
            Canvas.SetLeft(textBorder, 20);
            Canvas.SetTop(textBorder, 150);

            // Create a single text control and add it to the canvas
            Font font = Resources.GetFont(Resources.FontResources.NinaB);
            Text text = new Text(font, "Text with a border");
            textBorder.Child = text; // Add the text to the border

            // Add the border to the canvas
            canvas.Children.Add(textBorder);

            // Add the canvas to the window.
            mainWindow.Child = canvas;

            // Set the window visibility to visible.
            mainWindow.Visibility = Visibility.Visible;

            return mainWindow;
        }
Example #3
0
        /// <summary>This method is run when the mainboard is powered up or reset</summary>
        public void ProgramStarted()
        {
            Debug.Print("Program Started");

            this.canvas = new Canvas();
            this.text = new Text(Resources.GetFont(Resources.FontResources.NinaB), "Starting...");
            this.canvas.Children.Add(this.text);
            
            this.window = this.oledDisplay.WPFWindow;
            this.window.Child = this.canvas;

            this.temperatureHumidity.MeasurementComplete += new TemperatureHumidity.MeasurementCompleteEventHandler(this.TemperatureHumidityMeasurementComplete);
            this.temperatureHumidity.StartContinuousMeasurements();
        }
Example #4
0
        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 a scrollviewer
            ScrollViewer scrollViewer = new ScrollViewer();
            scrollViewer.Background = new SolidColorBrush(Colors.Gray);
            // scroll line by line with 10 pixels per line
            scrollViewer.ScrollingStyle = ScrollingStyle.LineByLine;
            scrollViewer.LineWidth = 10;
            scrollViewer.LineHeight = 10;

            // Create a canvas and add ellipse shapes
            Canvas canvas = new Canvas();
            for (int x = 0; x <= 20; ++x)
            {
                for (int y = 0; y <= 20; ++y)
                {
                    Ellipse ellipse = new Ellipse(10, 10);
                    ellipse.Stroke = new Pen(Colors.White);
                    canvas.Children.Add(ellipse);
                    Canvas.SetLeft(ellipse, x * 30);
                    Canvas.SetTop(ellipse, y * 30);
                }
            }
            //we need to set the size of a canvas explicitly
            //because it doesn´t calculate the desired size from its content
            canvas.Width = 20 * 30 + 10 * 2;
            canvas.Height = 20 * 30 + 10 * 2;
            scrollViewer.Child = canvas;

            // Add the scroll viewer to the window.
            mainWindow.Child = scrollViewer;

            // Set the window visibility to visible.
            mainWindow.Visibility = Visibility.Visible;

            // Attach the button focus to the scroll viewer
            // to be able to scroll with the up down right and left buttons
            Buttons.Focus(scrollViewer);

            return mainWindow;
        }
Example #5
0
        /// <summary>This method is run when the mainboard is powered up or reset</summary>
        public void ProgramStarted()
        {
            Debug.Print("Program Started");

            this.canvas = new Canvas();
            
            this.window = this.oledDisplay.WPFWindow;
            this.window.Child = this.canvas;

            Timer timer = new Timer(34);
            timer.Tick += new Timer.TickEventHandler(TimerTick);
            timer.Start();

            game = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
            scoreFont = Resources.GetFont(Resources.FontResources.NinaB);

            joystick.JoystickReleased += new Joystick.JoystickEventHandler(Player1JoystickReleased);

            InitBall();
        }
Example #6
0
        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;

            Canvas canvas = new Canvas();

            // Create a single text control and add it to the canvas
            Font font = Resources.GetFont(Resources.FontResources.small);
            Text text = new Text(font, "I am a racer.");
            Canvas.SetLeft(text, 50);
            Canvas.SetTop(text, 200);
            canvas.Children.Add(text);

            // Create an image and add it to the canvas
            Bitmap racer = Resources.GetBitmap(Resources.BitmapResources.Racer);
            Image image = new Image(racer);
            Canvas.SetLeft(image, 10);
            Canvas.SetTop(image, 10);
            canvas.Children.Add(image);

            // Create a rectangle shape and add it to the canvas
            Rectangle rect = new Rectangle();
            rect.Fill = new SolidColorBrush(Colors.Blue);
            rect.Width = 100;
            rect.Height = 50;
            Canvas.SetLeft(rect, 200);
            Canvas.SetTop(rect, 50);
            canvas.Children.Add(rect);

            // Add the canvas to the window.
            mainWindow.Child = canvas;

            // Set the window visibility to visible.
            mainWindow.Visibility = Visibility.Visible;

            return mainWindow;
        }
Example #7
0
        void SetupUI()
        {
            mainWindow = display.WPFWindow;

            // setup the layout and background
            Canvas layout = new Canvas();
            Border background = new Border();
            background.Background = new SolidColorBrush(Colors.Black);
            background.Height = 240;
            background.Width = 320;
            layout.Children.Add(background);
            Canvas.SetLeft(background, 0);
            Canvas.SetTop(background, 0);

            // add the image display
            imageDisplay = new Border();
            imageDisplay.Height = 240;
            imageDisplay.Width = 320;
            layout.Children.Add(imageDisplay);
            Canvas.SetLeft(imageDisplay, 0);
            Canvas.SetTop(imageDisplay, 0);

            // add the text label
            label = new Text("");
            label.Height = 50;
            label.Width = 320;
            label.ForeColor = Colors.White;
            label.Font = Resources.GetFont(Resources.FontResources.NinaB);
            label.TextAlignment = TextAlignment.Center;
            label.Visibility = Visibility.Collapsed;
            layout.Children.Add(label);
            Canvas.SetLeft(label, 0);
            Canvas.SetTop(label, 0);

            mainWindow.Child = layout;
        }
Example #8
0
        void setupUI()
        {
            mainWindow = screen.WPFWindow;

            layout = new Canvas();
            mainWindow.Child = layout;

            Border background = new Border();
            background.Background = new SolidColorBrush(Colors.Black);
            background.Height = 240;
            background.Width = 320;
            layout.Children.Add(background);
            Canvas.SetLeft(background, 0);
            Canvas.SetTop(background, 0);

            ipText = new Text(Resources.GetFont(Resources.FontResources.NinaB), "IP: " + myIP);
            ipText.ForeColor = Color.White;
            layout.Children.Add(ipText);
            Canvas.SetLeft(ipText, 10);
            Canvas.SetTop(ipText, 10);

            Text message = new Text(Resources.GetFont(Resources.FontResources.NinaB), "Message:");
            message.ForeColor = Color.White;
            layout.Children.Add(message);
            Canvas.SetLeft(message, 10);
            Canvas.SetTop(message, 50);

            messageText = new Text(Resources.GetFont(Resources.FontResources.NinaB), "message");
            messageText.ForeColor = Color.White;
            // layout.Children.Add(messageText);
            Canvas.SetLeft(messageText, 10);
            Canvas.SetTop(messageText, 70);
        }
        public void DrawCanvas()
        {
            Canvas canvas = new Canvas();

            Text OkText = new Text("OK");
            OkText.Font = Resources.GetFont(Resources.FontResources.NinaB);
            OkText.ForeColor = Colors.DarkGray;
            SimpleButton OkButton = new SimpleButton(OkText, 100, 50);
            OkButton.NormalBackgroundColor = Colors.Green;
            OkButton.Click += new EventHandler(Ok_Click);

            Text CancelText = new Text("Cancel");
            CancelText.Font = Resources.GetFont(Resources.FontResources.NinaB);
            CancelText.ForeColor = Colors.DarkGray;
            SimpleButton CancelButton = new SimpleButton(CancelText, 100, 50);
            CancelButton.NormalBackgroundColor = Colors.Red;
            CancelButton.Click += new EventHandler(Cancel_Click);

            SimpleButton[] digits = new SimpleButton[10];
            for (int i = 0; i < digits.Length; i++)
            {
                Text t = new Text(i.ToString());
                t.Font = Resources.GetFont(Resources.FontResources.NinaB);
                t.ForeColor = Colors.DarkGray;
                digits[i] = new SimpleButton(t, 50, 50);
                digits[i].Click += new EventHandler(Value_Click);
            }

            Rectangle TextBox = new Rectangle(130, 50);
            TextBox.Stroke = new Pen(Colors.Gray);

            Value = new Text("");
            Value.Font = Resources.GetFont(Resources.FontResources.NinaB);
            Value.ForeColor = Colors.DarkGray;

            Canvas.SetLeft(OkButton, 160);
            Canvas.SetTop(CancelButton, 50);
            Canvas.SetLeft(CancelButton, 160);

            Canvas.SetTop(TextBox, 25);
            Canvas.SetLeft(TextBox, 10);
            Canvas.SetTop(Value, 45);
            Canvas.SetLeft(Value, 20);

            Canvas.SetTop(digits[1], 100);
            Canvas.SetLeft(digits[1], 10);
            Canvas.SetTop(digits[2], 100);
            Canvas.SetLeft(digits[2], 60);
            Canvas.SetTop(digits[3], 100);
            Canvas.SetLeft(digits[3], 110);
            Canvas.SetTop(digits[4], 100);
            Canvas.SetLeft(digits[4], 160);
            Canvas.SetTop(digits[5], 100);
            Canvas.SetLeft(digits[5], 210);
            Canvas.SetTop(digits[6], 150);
            Canvas.SetLeft(digits[6], 10);
            Canvas.SetTop(digits[7], 150);
            Canvas.SetLeft(digits[7], 60);
            Canvas.SetTop(digits[8], 150);
            Canvas.SetLeft(digits[8], 110);
            Canvas.SetTop(digits[9], 150);
            Canvas.SetLeft(digits[9], 160);
            Canvas.SetTop(digits[0], 150);
            Canvas.SetLeft(digits[0], 210);

            canvas.Children.Add(TextBox);
            canvas.Children.Add(Value);
            canvas.Children.Add(OkButton);
            canvas.Children.Add(CancelButton);
            foreach (SimpleButton s in digits)
                canvas.Children.Add(s);

            canvas.SetMargin(20, 20, 20, 20);
            spWindow.Child = canvas;
            spWindow.Visibility = Visibility.Visible;
        }
Example #10
0
        private void SetupUi()
        {
            _mainWindow = Screen.WPFWindow;

            var layout = new Canvas();

            _imageDisplay = new Border { Height = 240, Width = 320 };
            layout.Children.Add(_imageDisplay);
            Canvas.SetLeft(_imageDisplay, 0);
            Canvas.SetTop(_imageDisplay, 0);

            _message = new Text()
            {
                Height = 240,
                Width = 320,
                ForeColor = Colors.Black,
                Font = Resources.GetFont(Resources.FontResources.NinaB),
                TextAlignment = TextAlignment.Center,
                Visibility = Visibility.Visible
            };
            layout.Children.Add(_message);
            Canvas.SetLeft(_message, 0);
            Canvas.SetTop(_message, 0);

            _mainWindow.Child = layout;

            var assembly = System.Reflection.Assembly.GetExecutingAssembly().GetName();
            DisplayMessage(assembly.Name + " " + assembly.Version);
        }
        private void SetupWindow()
        {
            var window = display.WPFWindow;
            var baseFont = Resources.GetFont(Resources.FontResources.NinaB);

            Canvas canvas = new Canvas();
            window.Child = canvas;

            txtAddress = new Text(baseFont, "Loading, please wait...");
            canvas.Children.Add(txtAddress);
            Canvas.SetTop(txtAddress, 50);
            Canvas.SetLeft(txtAddress, 30);

            txtReceivedMessage = new Text(baseFont, string.Empty);
            txtReceivedMessage.Width = 300;
            txtReceivedMessage.TextWrap = true;
            canvas.Children.Add(txtReceivedMessage);
            Canvas.SetTop(txtReceivedMessage, 100);
            Canvas.SetLeft(txtReceivedMessage, 10);
        }
Example #12
0
        void SetupUI()
        {
            Border whiteButton;
            Border yellowButton;
            Border redButton;
            Border greenButton;
            Border blueButton;
            Border blackButton;
            Text clearButton;
            // initialize window
            mainWindow = display.WPFWindow;

            // setup the layout
            layout = new Canvas();
            background = new Image();
            background.Bitmap = new Bitmap(320 - sideBarWidth, 240);
            background.Height = 240;
            background.Width = 320 - sideBarWidth;

            layout.Children.Add(background);
            Canvas.SetLeft(background, sideBarWidth);
            Canvas.SetTop(background, 0);

            whiteButton = new Border();
            SetupButton(whiteButton, Colors.White, 0);
            whiteButton.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(whiteButton_TouchUp);

            yellowButton = new Border();
            SetupButton(yellowButton, Colors.Yellow, 1);
            yellowButton.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(yellowButton_TouchUp);

            redButton = new Border();
            SetupButton(redButton, Colors.Red, 2);
            redButton.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(redButton_TouchUp);

            greenButton = new Border();
            SetupButton(greenButton, Colors.Green, 3);
            greenButton.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(greenButton_TouchUp);

            blueButton = new Border();
            SetupButton(blueButton, Colors.Blue, 4);
            blueButton.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(blueButton_TouchUp);

            blackButton = new Border();
            SetupButton(blackButton, Colors.Black, 5);
            blackButton.TouchUp += new Microsoft.SPOT.Input.TouchEventHandler(blackButton_TouchUp);

            clearButton = SetupClearButton();

            mainWindow.Child = layout;
        }
Example #13
0
        object Canvas_AllSet(object obj)
        {
            _canvas = new Canvas();

            Rectangle _rect1 = new Rectangle();
            _rect1.Width = _rectW;
            _rect1.Height = _rectH;
            _rect1.Fill = new SolidColorBrush(c1);
            Canvas.SetLeft(_rect1, hLength);
            Canvas.SetTop(_rect1, vLength);

            Rectangle _rect2 = new Rectangle();
            _rect2.Width = _rectW;
            _rect2.Height = _rectH;
            _rect2.Fill = new SolidColorBrush(c2);
            Canvas.SetRight(_rect2, hLength);
            Canvas.SetTop(_rect2, vLength);

            Rectangle _rect3 = new Rectangle();
            _rect3.Width = _rectW;
            _rect3.Height = _rectH;
            _rect3.Fill = new SolidColorBrush(c3);
            Canvas.SetLeft(_rect3, hLength);
            Canvas.SetBottom(_rect3, vLength);

            Rectangle _rect4 = new Rectangle();
            _rect4.Width = _rectW;
            _rect4.Height = _rectH;
            _rect4.Fill = new SolidColorBrush(c4);
            Canvas.SetRight(_rect4, hLength);
            Canvas.SetBottom(_rect4, vLength);

            _canvas.Children.Add(_rect1);
            _canvas.Children.Add(_rect2);
            _canvas.Children.Add(_rect3);
            _canvas.Children.Add(_rect4);

            mainWindow.Child = _canvas;
            return null;
        }
Example #14
0
        object Canvas_UpdateWindow(object obj)
        {
            _canvas = new Canvas();
            //Setting the Width & Height of the Canvas
            //by default the Canvas is at the center both from Horizontal and Vertical
            _canvas.Width = _cWidth;
            _canvas.Height = _cHeight;
            if (!_null)
            {
                _rect1 = new Rectangle();
                _rect1.Width = _rectW;
                _rect1.Height = _rectH;
                _rect1.Fill = new SolidColorBrush(_fillColor);
            }
            if (_left)
            {
                try
                {
                    Canvas.SetLeft(_rect1, _lt);
                    gLeft = Canvas.GetLeft(_rect1);
                }
                catch (Exception ex)
                {
                    Log.Comment("Caught " + ex.Message + " when Canvas.SetLeft(UIElemnt, " + _lt + ")");
                    _argumentException = true;
                }
            }
            else if (_top)
            {
                try
                {
                    Canvas.SetTop(_rect1, _tp);
                    gTop = Canvas.GetTop(_rect1);
                }
                catch (Exception ex)
                {
                    Log.Comment("Caught " + ex.Message + " when Canvas.SetTop(UIElemnt, " + _tp + ")");
                    _argumentException = true;
                }
            }
            else if (_right)
            {
                try
                {
                    Canvas.SetRight(_rect1, _rt);
                    gRight = Canvas.GetRight(_rect1);
                }
                catch (Exception ex)
                {
                    Log.Comment("Caught " + ex.Message + " when Canvas.SetRight(UIElemnt, " + _rt + ")");
                    _argumentException = true;
                }

            }
            else if (_bottom)
            {
                try
                {
                    Canvas.SetBottom(_rect1, _bt);
                    gBottom = Canvas.GetBottom(_rect1);
                }
                catch (Exception ex)
                {
                    Log.Comment("Caught " + ex.Message + " when Canvas.SetBottom(UIElemnt, " + _bt + ")");
                    _argumentException = true;
                }
            }
            if (_rect1 != null)
            {
                _canvas.Children.Add(_rect1);
            }
            mainWindow.Child = _canvas;
            return null;
        }
Example #15
0
 protected override void Reset()
 {
     //variables to store Canvas.GetXxxx(UIElement)
     gLeft = 0;
     gTop = 0;
     gRight = 0;
     gBottom = 0;
     //Rectangle Width & Height
     _lt = 0;
     _tp = 0;
     _rt = 0;
     _bt = 0;
     _left = false;
     _top = false;
     _right = false;
     _bottom = false;
     _null = false;
     _canvas = null;
     _rect1 = null;
     _fillColor = Colors.Green;
 }
Example #16
0
 private void DrawSlider(Canvas canvas)
 {
     Line horizontal = new Line(50, 0);
     circle = new Ellipse(7, 7);
     horizontal.Stroke = new Pen(Colors.Black);
     circle.Stroke = new Pen(Colors.DarkGray);
     circle.Fill = new SolidColorBrush(Colors.Blue);
     circle.TouchDown+=new TouchEventHandler(slider_TouchDown);
     Canvas.SetTop(circle, 180);
     Canvas.SetLeft(circle, 80);
     Canvas.SetTop(horizontal, 187);
     Canvas.SetLeft(horizontal, 75);
     canvas.Children.Add(horizontal);
     canvas.Children.Add(circle);
 }
Example #17
0
        public void SetupWindow()
        {
            int BtnWidth = 90;
            int BtnHeight = 50;

            GT.Color selectedFronColor = GT.Color.White;

            Font font = Resources.GetFont(Resources.FontResources.NinaB);
            unselectedBackgroundBrush = new SolidColorBrush(GT.Color.FromRGB(89, 192, 255));
            selectedONAndLoadedBackgroundBrush = new SolidColorBrush(GT.Color.FromRGB(43, 255, 121));
            selectedOFFBackgroundBrush = new SolidColorBrush(GT.Color.FromRGB(240, 28, 126));
            window = display.WPFWindow;
            canvas = new Canvas();
            window.Child = canvas;

            StackPanel stack = new StackPanel(Orientation.Horizontal);

            // ON button
            onBtnBorder = new Border();
            onBtnBorder.SetBorderThickness(0);
            onBtnBorder.Width = BtnWidth;
            onBtnBorder.Height = BtnHeight;
            onBtnBorder.Background = unselectedBackgroundBrush;

            onBtnBorder.SetMargin(12, 10, 0, 0);
            onBtnBorder.TouchDown += new Microsoft.SPOT.Input.TouchEventHandler((s, e) =>
            {
                coffeeMachineOn();
            });

            tempText = new Text(font, "ON");
            tempText.Width = BtnWidth;
            tempText.ForeColor = selectedFronColor;
            tempText.TextAlignment = TextAlignment.Center;
            tempText.SetMargin(0, 15, 0, 0);

            onBtnBorder.Child = tempText;
            stack.Children.Add(onBtnBorder);

            // OFF button
            offBtnBorder = new Border();
            offBtnBorder.SetBorderThickness(0);
            offBtnBorder.Width = BtnWidth;
            offBtnBorder.Height = BtnHeight;

            offBtnBorder.Background = selectedOFFBackgroundBrush;

            offBtnBorder.SetMargin(12, 10, 0, 0);
            offBtnBorder.TouchDown += new Microsoft.SPOT.Input.TouchEventHandler((s, e) =>
            {
                coffeeMachineOff();
            });

            tempText = new Text(font, "OFF");
            tempText.Width = BtnWidth;
            tempText.ForeColor = selectedFronColor;
            tempText.TextAlignment = TextAlignment.Center;
            tempText.SetMargin(0, 15, 0, 0);

            offBtnBorder.Child = tempText;
            stack.Children.Add(offBtnBorder);

            // LOADED button
            loadedBtnBorder = new Border();
            loadedBtnBorder.SetBorderThickness(0);
            loadedBtnBorder.Width = BtnWidth;
            loadedBtnBorder.Height = BtnHeight;

            loadedBtnBorder.Background = unselectedBackgroundBrush;

            loadedBtnBorder.SetMargin(12, 10, 0, 0);
            loadedBtnBorder.TouchDown += new Microsoft.SPOT.Input.TouchEventHandler((s, e) =>
            {
                coffeeMachineLoaded();
            });

            tempText = new Text(font, "LOADED");
            tempText.Width = BtnWidth;
            tempText.ForeColor = selectedFronColor;
            tempText.TextAlignment = TextAlignment.Center;
            tempText.SetMargin(0, 15, 0, 0);

            loadedBtnBorder.Child = tempText;
            stack.Children.Add(loadedBtnBorder);

            StackPanel verticalStack = new StackPanel(Orientation.Vertical);
            verticalStack.Children.Add(stack);

            Font ff = Resources.GetFont(Resources.FontResources.moireFonts);

            timerText = new Text(ff, "off");
            timerText.Width = 320;
            timerText.ForeColor = GT.Color.FromRGB(89, 192, 255);
            timerText.TextAlignment = TextAlignment.Center;
            timerText.SetMargin(0, 35, 0, 0);
            verticalStack.Children.Add(timerText);

            canvas.Children.Add(verticalStack);
        }
        public void DrawCanvas()
        {
            Canvas canvas = new Canvas();

            Text title = new Text();
            title.Font = Resources.GetFont(Resources.FontResources.NinaB);
            title.ForeColor = Colors.DarkGray;
            title.TextContent = "Settings";
            title.SetMargin(5);

            Text backtext = new Text();
            backtext.Font = Resources.GetFont(Resources.FontResources.NinaB);
            backtext.ForeColor = Colors.DarkGray;
            backtext.TextContent = "Back";
            backtext.SetMargin(5);
            SimpleButton back = new SimpleButton(backtext, 60, 25);
            back.Click += new EventHandler(back_Click);

            Text updateTimeInfo = new Text("Update Time");
            updateTimeInfo.Font = Resources.GetFont(Resources.FontResources.NinaB);
            updateTimeInfo.ForeColor = Colors.DarkGray;

            Text plustext = new Text("+");
            plustext.Font = Resources.GetFont(Resources.FontResources.NinaB);
            plustext.ForeColor = Colors.DarkGray;
            SimpleButton plusButton = new SimpleButton(plustext, 60, 25);
            plusButton.Width = plusButton.Height;
            plusButton.Click += new EventHandler(plus_Click);

            Text minustext = new Text("-");
            minustext.Font = Resources.GetFont(Resources.FontResources.NinaB);
            minustext.ForeColor = Colors.DarkGray;
            SimpleButton minusButton = new SimpleButton(minustext, 60, 25);
            minusButton.Width = plusButton.Height;
            minusButton.Click += new EventHandler(minus_Click);

            Text metricInfo = new Text("Measurement");
            metricInfo.Font = Resources.GetFont(Resources.FontResources.NinaB);
            metricInfo.ForeColor = Colors.DarkGray;

            Text metricC = new Text("Celsius");
            metricC.Font = Resources.GetFont(Resources.FontResources.NinaB);
            metricC.ForeColor = Colors.DarkGray;
            CButton = new SimpleButton(metricC, 60, 25);
            if (!HwDevices.fahrenheit)
                CButton.NormalBackgroundColor = Colors.Blue;
            CButton.Click += new EventHandler(C_Click);

            Text metricF = new Text("Fahrenheit");
            metricF.Font = Resources.GetFont(Resources.FontResources.NinaB);
            metricF.ForeColor = Colors.DarkGray;
            FButton = new SimpleButton(metricF, 80, 25);
            if(HwDevices.fahrenheit)
                FButton.NormalBackgroundColor=Colors.Blue;
            FButton.Click += new EventHandler(F_Click);

            Text LocationIdInfo = new Text("Location ID:" + HwDevices.WOEID);
            LocationIdInfo.Font = Resources.GetFont(Resources.FontResources.NinaB);
            LocationIdInfo.ForeColor = Colors.DarkGray;

            Text ChangeLocationText = new Text("Change");
            ChangeLocationText.Font = Resources.GetFont(Resources.FontResources.NinaB);
            ChangeLocationText.ForeColor = Colors.DarkGray;
            SimpleButton ChangeLocationButton = new SimpleButton(ChangeLocationText, 60, 25);
            ChangeLocationButton.Click += new EventHandler(Location_Click);

            Rectangle valueRectangle = new Rectangle(2 * minusButton.Height, minusButton.Height);
            valueRectangle.Stroke = new Pen(Colors.Gray);

            updatetext = new Text(""+HwDevices.getUpdateTime());
            updatetext.Font = Resources.GetFont(Resources.FontResources.NinaB);
            updatetext.ForeColor = Colors.DarkGray;

            Canvas.SetTop(updatetext, 83);
            Canvas.SetLeft(updatetext, 150);
            Canvas.SetTop(valueRectangle, 80);
            Canvas.SetLeft(valueRectangle, 130);
            Canvas.SetTop(plusButton, 80);
            Canvas.SetLeft(plusButton, 187);
            Canvas.SetTop(minusButton, 80);
            Canvas.SetLeft(minusButton, 100);
            Canvas.SetTop(updateTimeInfo, 80);
            Canvas.SetTop(back, 175);
            Canvas.SetLeft(back, 220);
            Canvas.SetTop(CButton, 110);
            Canvas.SetLeft(CButton, 100);
            Canvas.SetTop(FButton, 110);
            Canvas.SetLeft(FButton, 170);
            Canvas.SetTop(metricInfo, 110);
            Canvas.SetTop(LocationIdInfo, 140);
            Canvas.SetTop(ChangeLocationButton, 140);
            Canvas.SetLeft(ChangeLocationButton, 170);

            canvas.Children.Add(title);
            canvas.Children.Add(back);
            canvas.Children.Add(updateTimeInfo);
            canvas.Children.Add(plusButton);
            canvas.Children.Add(minusButton);
            canvas.Children.Add(valueRectangle);
            canvas.Children.Add(updatetext);
            canvas.Children.Add(metricInfo);
            canvas.Children.Add(CButton);
            canvas.Children.Add(FButton);
            canvas.Children.Add(LocationIdInfo);
            canvas.Children.Add(ChangeLocationButton);

            canvas.SetMargin(20, 20, 20, 20);
            spWindow.Child = canvas;
            spWindow.Visibility = Visibility.Visible;
        }
Example #19
0
        public Stats(Window mw, Data h)
        {
            spWindow = new Window();
            spWindow.Height = SystemMetrics.ScreenHeight;
            spWindow.Width = SystemMetrics.ScreenWidth;

            HwDevices = h;

            canvas = new Canvas();

            weatherData = new DayData [30];

            weatherData=get_Data("http://picktheoutfit.com/api/measurements/last/30", weatherData);

            Text title = new Text();
            title.Font = Resources.GetFont(Resources.FontResources.NinaB);
            title.ForeColor = Colors.DarkGray;
            title.TextContent = "Statistics (Last 30 days)";
            title.SetMargin(5);

            Text backtext = new Text();
            backtext.Font = Resources.GetFont(Resources.FontResources.NinaB);
            backtext.ForeColor = Colors.DarkGray;
            backtext.TextContent = "Back";
            backtext.SetMargin(5);
            SimpleButton back = new SimpleButton(backtext, 60, 25);
            back.Click += new EventHandler(back_Click);

            temptext = new Text();
            temptext.Font = Resources.GetFont(Resources.FontResources.small);
            temptext.ForeColor = Colors.DarkGray;
            temptext.TextContent = "Temperature";
            temptext.TouchDown += new TouchEventHandler(TempTextClick);
            temptext.SetMargin(5);

            humtext = new Text();
            humtext.Font = Resources.GetFont(Resources.FontResources.small);
            humtext.ForeColor = Colors.DarkGray;
            humtext.TextContent = "Humidity";
            humtext.TouchDown += new TouchEventHandler(HumTextClick);
            humtext.SetMargin(5);

            canvas.Children.Add(title);

            Canvas.SetTop(back, 175);
            Canvas.SetLeft(back, 220);

            Canvas.SetTop(temptext, 175);

            Canvas.SetTop(humtext, 175);
            Canvas.SetLeft(humtext, 125);

            canvas.Children.Add(temptext);
            canvas.Children.Add(humtext);
            canvas.Children.Add(back);

            graph = new Canvas();

            graph.Width = 275;
            graph.Height = 150;
            Canvas.SetTop(graph, 25);
            canvas.Children.Add(graph);

            DrawSlider(canvas);

            DrawGraph(graph);

            canvas.SetMargin(20, 20, 20, 20);
            spWindow.Child = canvas;
            spWindow.Visibility = Visibility.Visible;
        }
        /// <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);
                }
            }
        }
        object ScrollViewer_UpdateWindow(object obj)
        {
            scv = new ScrollViewer();
            scv.Width = _scvWidth;
            scv.Height = _scvHeight;
            scv.Background = new SolidColorBrush(_scvBground);
            scv.LineHeight = _lineHeight;
            scv.LineWidth = _lineWidth;
            scv.HorizontalOffset = _hOffset;
            scv.VerticalOffset = _vOffset;
            scv.ScrollingStyle = _style;
            scv.VerticalAlignment = VerticalAlignment.Center;
            scv.HorizontalAlignment = HorizontalAlignment.Center;

            Canvas _canvas = new Canvas();
            _canvas.Width = _canWidth;
            _canvas.Height = _canHeight;
            _canvas.VerticalAlignment = VerticalAlignment.Top;
            _canvas.HorizontalAlignment = HorizontalAlignment.Left;

            //Adding child elt to Canvas           
            _rect = new Rectangle();
            _rect.Width = _rectW;
            _rect.Height = _rectH;
            _rect.Fill = new SolidColorBrush(_color);
            _canvas.Children.Add(_rect);
            Canvas.SetTop(_rect, cTop);
            Canvas.SetLeft(_rect, cLeft);

            //Adding the StackPanel to ScrollViewer
            scv.Child = _canvas;
            if (_lineDown)
            {
                for (int i = 0; i < scrollCount; i++)
                {
                    scv.LineDown();
                }
            }
            if (_lineUp)
            {
                for (int i = 0; i < scrollCount; i++)
                {
                    scv.LineUp();
                }
            }
            if (_lineRight)
            {
                for (int i = 0; i < scrollCount; i++)
                {
                    scv.LineRight();
                }
            }
            if (_lineLeft)
            {
                for (int i = 0; i < scrollCount; i++)
                {
                    scv.LineLeft();
                }
            }

            //Adding the ScrollViewer to the Window           
            mainWindow.Child = scv;

            _getHOffset = scv.HorizontalOffset;
            _getVOffset = scv.VerticalOffset;
            _getLineHeight = scv.LineHeight;
            _getLineWidth = scv.LineWidth;

            return null;
        }
Example #22
0
        void SetupUI()
        {
            // initialize window
            mainWindow = display.WPFWindow;

            // setup the layout
            layout = new Canvas();
            Border background = new Border();
            background.Background = new SolidColorBrush(Colors.Black);
            background.Height = 240;
            background.Width = 320;

            layout.Children.Add(background);
            Canvas.SetLeft(background, 0);
            Canvas.SetTop(background, 0);

            //add the tongue
            tongue = new Rectangle(tongueWidth, 40);
            tongue.Fill = new SolidColorBrush(Colors.Red);
            layout.Children.Add(tongue);

            //add the snowflake
            snowflake = new Rectangle(10, 10);
            snowflake.Fill = new SolidColorBrush(Colors.White);
            layout.Children.Add(snowflake);

            // add the text area
            label = new Text();
            label.Height = 240;
            label.Width = 320;
            label.ForeColor = Colors.White;
            label.Font = Resources.GetFont(Resources.FontResources.NinaB);

            layout.Children.Add(label);
            Canvas.SetLeft(label, 0);
            Canvas.SetTop(label, 0);

            mainWindow.Child = layout;
        }
        public MainMenu(Window mw, Data h)
        {
            spWindow = new Window();
            spWindow.Height = SystemMetrics.ScreenHeight;
            spWindow.Width = SystemMetrics.ScreenWidth;

            HwDevices = h;

            Get xml = new Get("http://weather.yahooapis.com/forecastrss?w=" + HwDevices.WOEID + "&u=c.xml");
            HwDevices = xml.AnalyseXMLResults(HwDevices);

            Bitmap aux = Resources.GetBitmap(Resources.BitmapResources.Title);
            Image logo = new Image(aux);
            logo.Width = 250;
            logo.Height = 75;

            TemperatureData = new Text();
            HumidityData = new Text();

            TemperatureData.Font = Resources.GetFont(Resources.FontResources.NinaB);
            TemperatureData.ForeColor = Colors.DarkGray;
            TemperatureData.TextContent = "Temperature: " + HwDevices.ReadValue();
            if (HwDevices.fahrenheit)
                TemperatureData.TextContent += "F";
            else
                TemperatureData.TextContent += "C";

            HumidityData.Font = Resources.GetFont(Resources.FontResources.NinaB);
            HumidityData.ForeColor = Colors.DarkGray;
            HumidityData.TextContent = "Humidity: " + HwDevices.humidity+"%";
            aux = null;

            switch (HwDevices.getWeatherType())
            {
                case 0:
                    aux = Resources.GetBitmap(Resources.BitmapResources.warning);
                    break;
                case 1:
                    aux = Resources.GetBitmap(Resources.BitmapResources.sun);
                    break;
                case 2:
                    aux = Resources.GetBitmap(Resources.BitmapResources.cloudy);
                    break;
                case 3:
                    aux = Resources.GetBitmap(Resources.BitmapResources.moon);
                    break;
                case 4:
                    aux = Resources.GetBitmap(Resources.BitmapResources.cloud);
                    break;
                case 5:
                    aux = Resources.GetBitmap(Resources.BitmapResources.lightning__1_);
                    break;
                case 6:
                    aux = Resources.GetBitmap(Resources.BitmapResources.rainy);
                    break;
                case 7:
                    aux = Resources.GetBitmap(Resources.BitmapResources.rainy__1_);
                    break;
                case 8:
                    aux = Resources.GetBitmap(Resources.BitmapResources.snowy);
                    break;
                case 9:
                    aux = Resources.GetBitmap(Resources.BitmapResources.cloud__1_);
                    break;
                case 10:
                    aux = Resources.GetBitmap(Resources.BitmapResources.snowy__1_);
                    break;
            }
            Image weather = new Image(aux);
            weather.Width = weather.Height = 50;

            Text LocationText = new Text("Location: "+HwDevices.location);
            LocationText.Font = Resources.GetFont(Resources.FontResources.NinaB);
            LocationText.ForeColor = Colors.DarkGray;

            Text text2 = new Text();
            text2.Font = Resources.GetFont(Resources.FontResources.NinaB);
            text2.ForeColor = Colors.DarkGray;
            text2.TextContent = "Stats";
            text2.SetMargin(5);
            SimpleButton sb2 = new SimpleButton(text2, 130, 30);
            sb2.Click += new EventHandler(sb2_Click);

            Text text3 = new Text();
            text3.Font = Resources.GetFont(Resources.FontResources.NinaB);
            text3.ForeColor = Colors.DarkGray;
            text3.TextContent = "Settings";
            text3.SetMargin(5);
            SimpleButton sb3 = new SimpleButton(text3, 130, 30);
            sb3.Click += new EventHandler(sb3_Click);

            ImageButton refresh = new ImageButton(new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.refresh)),30,30);
            refresh.Click += new EventHandler(refresh_Click);

            Canvas canvas = new Canvas();

            Canvas.SetTop(LocationText, 70);
            canvas.Children.Add(LocationText);

            Canvas.SetTop(TemperatureData, 100);
            canvas.Children.Add(TemperatureData);

            Canvas.SetTop(HumidityData, 130);
            canvas.Children.Add(HumidityData);
            Canvas.SetTop(sb2, 170);
            canvas.Children.Add(sb2);
            Canvas.SetTop(sb3, 170);
            Canvas.SetLeft(sb3, 150);
            canvas.Children.Add(sb3);
            Canvas.SetTop(weather, 100);
            Canvas.SetLeft(weather, 150);
            Canvas.SetTop(refresh, 130);
            Canvas.SetLeft(refresh, 250);

            canvas.Children.Add(weather);
            canvas.Children.Add(logo);
            canvas.Children.Add(refresh);

            spWindow.Child = canvas;
            canvas.SetMargin(20, 20, 20, 20);
            spWindow.Visibility = Visibility.Visible;
            //dispatcher = spWindow.Dispatcher;

            //Thread t0 = new Thread(new ThreadStart(run));
            //t0.Start();
        }
Example #24
0
        void SetupUI()
        {
            // 1) init window
            mainWindow = display.WPFWindow;
            mainWindow.TouchDown += new Microsoft.SPOT.Input.TouchEventHandler(mainWindow_TouchDown);

            // 2) setup the layout
            Canvas layout = new Canvas();
            Border background = new Border();
            background.Background = new SolidColorBrush(Colors.Black);
            background.Height = 240;
            background.Width = 320;

            layout.Children.Add(background);
            Canvas.SetLeft(background, 0);
            Canvas.SetTop(background, 0);

            // 3) add the image display
            imageDisplay = new Border();
            imageDisplay.Height = 240;
            imageDisplay.Width = 320;

            layout.Children.Add(imageDisplay);
            Canvas.SetLeft(imageDisplay, 0);
            Canvas.SetTop(imageDisplay, 0);

            // 4) add the text label
            label = new Text("testing");
            label.Height = 240;
            label.Width = 320;
            label.ForeColor = Colors.White;
            label.Font = Resources.GetFont(Resources.FontResources.NinaB);
            label.TextAlignment = TextAlignment.Center;
            label.Visibility = Visibility.Collapsed;

            layout.Children.Add(label);
            Canvas.SetLeft(label, 0);
            Canvas.SetTop(label, 0);

            mainWindow.Child = layout;
        }
Example #25
0
        private void DrawGraph(Canvas canvas)
        {
            canvas.Children.Clear();
            if (tempMode) //Temperature mode
            {
                //Determine the maximum and minimum registered values
                int min=666, max=-666;
                if(weatherData[0]!=null)
                    for (int i = 0; i < weatherData.Length; i++)
                    {
                        if (weatherData[i].temperature != -666 && weatherData[i].temperature < min)
                            min = (int)weatherData[i].temperature;
                        if (weatherData[i].temperature != -666 && weatherData[i].temperature >max)
                            max = (int)weatherData[i].temperature;
                    }

                if (HwDevices.fahrenheit)
                {
                    min = (int)(min * 1.8 + 32);
                    max = (int)(max * 1.8 + 32);
                }

                minText = new Text("" + min);
                minText.Font=Resources.GetFont(Resources.FontResources.small);
                maxText = new Text("" + max);
                maxText.Font=Resources.GetFont(Resources.FontResources.small);

                Line horizontal = new Line(0, canvas.Height-10);
                horizontal.Stroke = new Pen(Colors.Black);

                Canvas.SetTop(maxText, 5);
                Canvas.SetTop(minText, 130);
                Canvas.SetTop(horizontal, 5);
                Canvas.SetLeft(horizontal, 20);

                int px = 20;
                int py = 135;
                int x = 25;
                if (weatherData[0] != null)
                    for (int i = 0; i < 30; i++)
                    {
                        if (weatherData[i].temperature != -666)
                        {
                            int t;
                            if (HwDevices.fahrenheit)
                                t = (int)(weatherData[i].temperature * 1.8 + 32);
                            else
                                t = (int)(weatherData[i].temperature);
                            int y = (int)(t * 135);
                            y = 135-(y / max-min ) +5;
                            Ellipse auxCircle = new Ellipse(3, 3);
                            auxCircle.Stroke = new Pen(Colors.Orange);
                            auxCircle.Fill = new SolidColorBrush(Colors.Red);
                            Canvas.SetTop(auxCircle, y);
                            Canvas.SetLeft(auxCircle, x);
                            graph.Children.Add(auxCircle);
                            px = x;
                            py = y;
                        }
                        x += 6;
                    }

                canvas.Children.Add(minText);
                canvas.Children.Add(maxText);
                canvas.Children.Add(horizontal);
            }
            else //Humidity mode
            {
                //Determine the maximum and minimum registered values
                int min = 666, max = -666;
                for (int i = 0; i < weatherData.Length; i++)
                {
                    if (weatherData[i].humidity != -666 && weatherData[i].humidity < min)
                        min = (int)weatherData[i].humidity;
                    if (weatherData[i].humidity != -666 && weatherData[i].humidity > max)
                        max = (int)weatherData[i].humidity;
                }

                minText = new Text("" + min);
                minText.Font = Resources.GetFont(Resources.FontResources.small);
                maxText = new Text("" + max);
                maxText.Font = Resources.GetFont(Resources.FontResources.small);

                Line horizontal = new Line(0, canvas.Height - 10);
                horizontal.Stroke = new Pen(Colors.Black);

                Canvas.SetTop(maxText, 5);
                Canvas.SetTop(minText, 130);
                Canvas.SetTop(horizontal, 5);
                Canvas.SetLeft(horizontal, 20);

                int px = 20;
                int py = 135;
                int x = 25;
                for (int i = 0; i < 30; i++)
                {
                    if (weatherData[i].humidity != -666)
                    {
                        int y = (int)(weatherData[i].humidity * 135);
                        y = 135 - (y / max) + 5;
                        Ellipse auxCircle = new Ellipse(3, 3);
                        auxCircle.Stroke = new Pen(Colors.Blue);
                        auxCircle.Fill = new SolidColorBrush(Colors.Cyan);
                        Canvas.SetTop(auxCircle, y);
                        Canvas.SetLeft(auxCircle, x);
                        graph.Children.Add(auxCircle);

                        px = x;
                        py = y;
                    }
                    x += 6;
                }

                canvas.Children.Add(minText);
                canvas.Children.Add(maxText);
                canvas.Children.Add(horizontal);

            }
        }