Esempio n. 1
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;
            mainWindow.Background = new SolidColorBrush(Color.Black);

            imageView = new Image();
            imageView.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
            imageView.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center;
            mainWindow.Child = imageView;

            mainWindow.AddHandler(Buttons.ButtonDownEvent, new ButtonEventHandler(OnButtonDown), false);

            mainWindow.Visibility = Visibility.Visible;
            Buttons.Focus(mainWindow);

            // Create camera
            camera = new C328R(new SerialPort.Configuration(SerialPort.Serial.COM2, SerialPort.BaudRate.Baud115200, false));
            InitCamera();

            return mainWindow;
        }
Esempio n. 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;

            // Create a single text control.
            Text text = new Text();

            text.Font = Resources.GetFont(Resources.FontResources.small);
            text.TextContent = Resources.GetString(Resources.StringResources.String1);
            text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
            text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center;

            // Add the text control to the window.
            mainWindow.Child = text;

            // Connect the button handler to all of the buttons.
            mainWindow.AddHandler(Buttons.ButtonUpEvent, new RoutedEventHandler(OnButtonUp), false);

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

            // Attach the button focus to the window.
            Buttons.Focus(mainWindow);

            return mainWindow;
        }
Esempio n. 3
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 single text control.
            Text text = new Text();

            text.Font = Resources.GetFont(Resources.FontResources.small);
            text.TextContent = "Displaying a text is one of the most common tasks you need to do with your display. So it is worth looking at the Text and TextFlow classes.";
            //text.Height = 100;
            //text.Width = 50;
            text.TextWrap = true;
            text.Trimming = Microsoft.SPOT.Presentation.Media.TextTrimming.WordEllipsis;
            text.TextAlignment = Microsoft.SPOT.Presentation.Media.TextAlignment.Right;
            text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Right;
            text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center;

            // Add the text control to the window.
            mainWindow.Child = text;

            // Connect the button handler to all of the buttons.
            mainWindow.AddHandler(Buttons.ButtonUpEvent, new ButtonEventHandler(OnButtonUp), false);

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

            // Attach the button focus to the window.
            Buttons.Focus(mainWindow);

            return mainWindow;
        }
Esempio n. 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;

            Text help = new Text();
            help.Font = Resources.GetFont(Resources.FontResources.nina14);
            help.TextContent = "Buttons: UP resets, SEL Syncs, DOWN schedules";
            help.HorizontalAlignment = HorizontalAlignment.Center;
            help.VerticalAlignment = VerticalAlignment.Top;

            time.Font = Resources.GetFont(Resources.FontResources.small);
            time.TextContent = "Initializing...";
            time.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
            time.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center;

            // Add the text controls to the window.
            Panel panel = new Panel();
            panel.Children.Add(help);
            panel.Children.Add(time);
            mainWindow.Child = panel;

            // Connect the button handler to all of the buttons.
            mainWindow.AddHandler(Buttons.ButtonUpEvent, new RoutedEventHandler(OnButtonUp), false);

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

            clockTimer = new DispatcherTimer(mainWindow.Dispatcher);
            clockTimer.Interval = new TimeSpan(0, 0, 0, 1, 0);
            clockTimer.Tick += new EventHandler(ClockTimer_Tick);

            // Attach the button focus to the window.
            Buttons.Focus(mainWindow);

            TimeService.SystemTimeChanged += new SystemTimeChangedEventHandler(TimeService_SystemTimeChanged);
            TimeService.TimeSyncFailed += new TimeSyncFailedEventHandler(TimeService_TimeSyncFailed);

            clockTimer.Start();

            return mainWindow;
        }
Esempio n. 5
0
        /// <summary>
        /// Creates the main window.
        /// </summary>
        /// <returns>The main window.</returns>
        public Window CreateWindow()
        {
            // Create a window object and set its size to the size of the 
            // display.
            mainWindow = new Window();
            mainWindow.Width = SystemMetrics.ScreenWidth;
            mainWindow.Height = SystemMetrics.ScreenHeight;

            // Detect landscape or portrait so the program can adjust its 
            // layout.
            bool portrait =
                SystemMetrics.ScreenWidth < SystemMetrics.ScreenHeight;

            // Create the main stack panel.
            StackPanel stack = new StackPanel(portrait ?
                Orientation.Vertical : Orientation.Horizontal);

            // Create stack panels for the current temperature and target 
            // temperature.
            StackPanel stack1 = new StackPanel(Orientation.Vertical);
            StackPanel stack2 = new StackPanel(Orientation.Vertical);

            // Create border panels for the current temperature and target 
            // temperature.
            BorderPanel panel1;
            BorderPanel panel2;

            // Detect portrait or landscape orientation.
            if (portrait)
            {

                // If in portrait mode, set the width to the screen width and 
                // height to 1/4 and 3/4.
                panel1 = new BorderPanel(SystemMetrics.ScreenWidth,
                    (int)(SystemMetrics.ScreenHeight * .25));
                panel2 = new BorderPanel(SystemMetrics.ScreenWidth,
                    (int)(SystemMetrics.ScreenHeight * .75));
            }
            else
            {
                // Otherwise, set the width and height to 1/2 and 1/2, 
                // respectively.
                panel1 = new BorderPanel(SystemMetrics.ScreenWidth / 2,
                    SystemMetrics.ScreenHeight);
                panel2 = new BorderPanel(SystemMetrics.ScreenWidth / 2,
                    SystemMetrics.ScreenHeight);
            }

            // Add the border panels to the panels containing the current 
            // temperature and target temperature.
            panel1.Children.Add(stack1);
            panel2.Children.Add(stack2);

            // Add the stack panels to the border panels.
            stack.Children.Add(panel1);
            stack.Children.Add(panel2);

            // Create text controls for the current temperature.
            _textCurrentTemp = new Text();
            _textCurrentTemp.Font =
                Resources.GetFont(Resources.FontResources.nina48);
            _textCurrentTemp.TextContent =
                Resources.GetString(Resources.StringResources.InitialTemp);
            _textCurrentTemp.HorizontalAlignment =
                Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
            _textCurrentTemp.VerticalAlignment =
                Microsoft.SPOT.Presentation.VerticalAlignment.Center;

            Text currentLabel = new Text();
            currentLabel.Font =
                Resources.GetFont(Resources.FontResources.nina14);
            currentLabel.TextContent =
                Resources.GetString(Resources.StringResources.CurrentTemp);
            currentLabel.HorizontalAlignment =
                Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
            currentLabel.VerticalAlignment =
                Microsoft.SPOT.Presentation.VerticalAlignment.Center;

            // Add the text controls to the current temperature stack panel.
            stack1.Children.Add(currentLabel);
            stack1.Children.Add(_textCurrentTemp);

            // Create controls for the target temperature.
            _textTargetTemp = new Text();
            _textTargetTemp.Font =
                Resources.GetFont(Resources.FontResources.nina48);
            _textTargetTemp.TextContent =
                Resources.GetString(Resources.StringResources.InitialTemp);
            _textTargetTemp.HorizontalAlignment =
                HorizontalAlignment.Center;
            _textTargetTemp.VerticalAlignment =
                VerticalAlignment.Center;

            Text targetLabel = new Text();
            targetLabel.Font =
                Resources.GetFont(Resources.FontResources.nina14);
            targetLabel.TextContent =
                Resources.GetString(Resources.StringResources.TargetTemp);
            targetLabel.HorizontalAlignment = HorizontalAlignment.Center;
            targetLabel.VerticalAlignment = VerticalAlignment.Center;

            // Create the air conditioner or heater status indicator.
            _statusIndicator = new StatusIndicator();

            // Add the controls to the target temperature stack panel.
            stack2.Children.Add(targetLabel);
            stack2.Children.Add(_textTargetTemp);
            stack2.Children.Add(_statusIndicator);

            // Add instructions to the target temperature stack panel.
            TextFlow instructions = new TextFlow();
            instructions.HorizontalAlignment = HorizontalAlignment.Center;
            instructions.VerticalAlignment = VerticalAlignment.Center;
            instructions.TextAlignment = TextAlignment.Center;
            instructions.TextRuns.Add(new TextRun("Up Button to Increase",
                Resources.GetFont(Resources.FontResources.nina14), Color.Black));
            instructions.TextRuns.Add(TextRun.EndOfLine);
            instructions.TextRuns.Add(new TextRun("Down Button to Decrease",
                Resources.GetFont(Resources.FontResources.nina14), Color.Black));
            instructions.TextRuns.Add(TextRun.EndOfLine);
            instructions.TextRuns.Add(new TextRun(
                "Select Button to Toggle Celsius / Fahrenheit",
                Resources.GetFont(Resources.FontResources.nina14), Color.Black));
            stack2.Children.Add(instructions);

            // Set the main window child to the main horizontal stack panel.
            mainWindow.Child = stack;

            // Connect the button handler to all of the buttons.
            mainWindow.AddHandler(Buttons.ButtonUpEvent,
                new RoutedEventHandler(OnButtonUp), false);

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

            // Attach the button focus to the window.
            Buttons.Focus(mainWindow);

            // Create the timer that will check the current temperature.
            _timer = new DispatcherTimer(mainWindow.Dispatcher);
            _timer.Interval = new TimeSpan(0, 0, 0, 0, 50);
            _timer.Tick += new EventHandler(OnTimer);
            _timer.Start();

            return mainWindow;
        }
Esempio n. 6
0
        public Window CreateUI()
        {

            Window      window       = new Window();
            StackPanel  panel        = new StackPanel();
            panel.Orientation        = Orientation.Vertical;

            Text   text         = new Text();
            text.Font           = Resources.GetFont(Resources.FontResources.FONT);
            text.TextContent    = "Hello";
            text.ForeColor      = Colors.Red;
            text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Left;
            text.VerticalAlignment   = Microsoft.SPOT.Presentation.VerticalAlignment.Stretch;

            panel.Children.Add(text);

            text                = new Text();
            text.Font           = Resources.GetFont(Resources.FontResources.FONT);
            text.TextContent    = "comma";
            text.ForeColor      = Colors.Green;
            text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
            text.VerticalAlignment   = Microsoft.SPOT.Presentation.VerticalAlignment.Stretch;

            panel.Children.Add(text);

            text                = new Text();
            text.Font           = Resources.GetFont(Resources.FontResources.FONT);
            text.TextContent    = "World!";
            text.ForeColor      = Colors.Blue;
            text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Right;
            text.VerticalAlignment   = Microsoft.SPOT.Presentation.VerticalAlignment.Stretch;

            panel.Children.Add(text);            

            TextFlow textFlow = new TextFlow();
            textFlow.Height = 60;            
            textFlow.TextRuns.Add("[BEGIN] ", Resources.GetFont(Resources.FontResources.FONT), Colors.Green);
            textFlow.TextRuns.Add("Call me Ishmael. ", Resources.GetFont(Resources.FontResources.FONT), Colors.Gray);
            textFlow.TextRuns.Add("Some years ago - never mind how long precisely - having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. ", Resources.GetFont(Resources.FontResources.FONT), Colors.Gray);
            textFlow.TextRuns.Add("It is a way I have of driving off the spleen, and regulating the circulation. ", Resources.GetFont(Resources.FontResources.FONT), Colors.Gray);
            textFlow.TextRuns.Add("A_very_long_sentence_with_no_whitespace_that_should_trigger_an_emergency_break. ", Resources.GetFont(Resources.FontResources.FONT), Colors.Blue);
            textFlow.TextRuns.Add("[END] ", Resources.GetFont(Resources.FontResources.FONT), Colors.Green);

            panel.Children.Add(textFlow);

            text = new Text();
            text.Font = Resources.GetFont(Resources.FontResources.FONT);
            text.TextContent = "";
            text.ForeColor = Colors.Gray;
            text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
            text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Stretch;

            panel.Children.Add(text);

            _buttonText = text;

            text = new Text();
            text.Font = Resources.GetFont(Resources.FontResources.FONT);
            text.TextContent = "";
            text.ForeColor = Colors.Gray;
            text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
            text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Stretch;

            panel.Children.Add(text);

            _timeText = text;            

            window.Child        = panel;

            window.AddHandler(Buttons.ButtonDownEvent, new RoutedEventHandler(OnButtonDown), false);
            window.AddHandler(Buttons.GotFocusEvent, new RoutedEventHandler(OnGotFocus), false);

            window.Width = SystemMetrics.ScreenWidth;
            window.Height = SystemMetrics.ScreenHeight;
            window.Visibility = Visibility.Visible;

            // Buttons.Focus(window);

            Buttons.Focus(textFlow);

            return window;
        }