Ejemplo n.º 1
0
        public FileBrowserItem(string label, Font font)
        {
            this.font = font;
            Width = SystemMetrics.ScreenWidth;
            Height = 30;

            iconOffset = (Height - iconSize) / 2;
            selectedBrush = new SolidColorBrush(Colors.Blue);

            fileName = label;
            fileType = String.Empty;
            filePath = String.Empty;

            Text text = new Text(font, label);
            text.ForeColor = Color.White;
            text.Height = font.Height;
            text.Width = Width;
            text.VerticalAlignment = VerticalAlignment.Top;
            int top = (Height - font.Height) / 2;
            text.SetMargin(Height + iconOffset, top, 0, 0);

            Child = text;

            UpdateIcon();
        }
Ejemplo n.º 2
0
        public CalibrationWindow(Font font, string txt)
        {
            Height = SystemMetrics.ScreenHeight;
            Width = SystemMetrics.ScreenWidth;
            Visibility = Visibility.Visible;
            //Buttons.Focus(this);

            pen = new Pen(ColorUtility.ColorFromRGB(255, 0, 0), 1);

            Text text = new Text();
            text.Font = font;
            text.ForeColor = Colors.Blue;
            text.TextContent = txt;
            text.TextWrap = true;
            text.SetMargin(0, 0, 0, SystemMetrics.ScreenHeight / 2);
            text.TextAlignment = TextAlignment.Center;
            text.HorizontalAlignment = HorizontalAlignment.Center;
            text.VerticalAlignment = VerticalAlignment.Center;
            Child = text;

            CalibrationManager.PrepareCalibrationPoints();
            CalibrationManager.StartCalibration();
            idx = 0;

            Invalidate();
        }
 public void set_text(string text, Font font, Color font_colour, int margin=5)
 {
     Text text_element = new Text(font, text);
     text_element.Width = Width;
     text_element.ForeColor = font_colour;
     text_element.SetMargin(margin);
     this.Child = text_element;
 }
Ejemplo n.º 4
0
        public RadioButton(Font font, string txt, bool isChecked)
        {
            Orientation = Orientation.Horizontal;

            this.isChecked = isChecked;

            image = new Image();
            image.VerticalAlignment = VerticalAlignment.Center;
            SetImage();
            Children.Add(image);

            text = new Text(font, txt);
            text.ForeColor = Color.White;
            text.VerticalAlignment = VerticalAlignment.Center;
            text.TextWrap = false;
            text.SetMargin(textMargin, 0, 0, 0);
            Children.Add(text);
        }
Ejemplo n.º 5
0
        public MessageBox(Font font, int width, string message, MessageBoxButton buttonsSet, Bitmap buttonBackground, Color buttonTextColor, Color textColor)
        {
            Background = new SolidColorBrush(Colors.Black);
            Width = width;
            Visibility = Visibility.Hidden;
            SizeToContent = SizeToContent.Height;

            this.buttonsSet = buttonsSet;

            main = Application.Current.MainWindow;
            modalBlock = new DispatcherFrame();

            StackPanel pnl = new StackPanel(Orientation.Vertical);
            Child = pnl;

            txtMessage = new Text(font, message);
            txtMessage.ForeColor = textColor;
            txtMessage.HorizontalAlignment = HorizontalAlignment.Center;
            txtMessage.TextAlignment = TextAlignment.Center;
            txtMessage.TextWrap = true;
            txtMessage.SetMargin(3);
            pnl.Children.Add(txtMessage);

            StackPanel pnlButtons = new StackPanel(Orientation.Horizontal);
            pnlButtons.HorizontalAlignment = HorizontalAlignment.Center;
            pnlButtons.VerticalAlignment = VerticalAlignment.Bottom;
            pnl.Children.Add(pnlButtons);

            btn1 = new Button(font, "", null, buttonTextColor);
            btn1.Background = buttonBackground;
            btn1.ImageSize = 16;
            btn1.HorizontalAlignment = HorizontalAlignment.Center;
            btn1.SetMargin(3);
            btn1.Clicked += new EventHandler(btn1_Clicked);
            pnlButtons.Children.Add(btn1);

            btn2 = new Button(font, "", null, buttonTextColor);
            btn2.Background = buttonBackground;
            btn2.ImageSize = 16;
            btn2.HorizontalAlignment = HorizontalAlignment.Center;
            btn2.SetMargin(3);
            btn2.Clicked += new EventHandler(btn2_Clicked);
            pnlButtons.Children.Add(btn2);

            btn3 = new Button(font, "", null, buttonTextColor);
            btn3.Background = buttonBackground;
            btn3.ImageSize = 16;
            btn3.HorizontalAlignment = HorizontalAlignment.Center;
            btn3.SetMargin(3);
            btn3.Clicked += new EventHandler(btn3_Clicked);
            pnlButtons.Children.Add(btn3);

            switch (buttonsSet)
            {
                case MessageBoxButton.OK:
                    btn1.Text = "OK";
                    btn2.Visibility = btn3.Visibility = Visibility.Collapsed;
                    break;
                case MessageBoxButton.OKCancel:
                    btn1.Text = "OK";
                    btn2.Text = "Отмена";
                    btn3.Visibility = Visibility.Collapsed;
                    break;
                case MessageBoxButton.YesNo:
                    btn1.Text = "Да";
                    btn2.Text = "Нет";
                    btn3.Visibility = Visibility.Collapsed;
                    break;
                case MessageBoxButton.YesNoCancel:
                    btn1.Text = "Да";
                    btn2.Text = "Нет";
                    btn3.Text = "Отмена";
                    break;
            }

            //Top = (SystemMetrics.ScreenHeight - Height) / 2;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates all WPF controls of the window
        /// </summary>
        private void InitializeComponents()
        {
            this.Width = SystemMetrics.ScreenWidth;
            this.Height = SystemMetrics.ScreenHeight;
            this.Background = new SolidColorBrush(Colors.Black);

            #region Caption
            Text caption = new Text(Resources.GetString(Resources.StringResources.HighScore));
            caption.Font = Resources.GetFont(Resources.FontResources.Consolas23);
            caption.ForeColor = Colors.Red;
            caption.SetMargin(0, 10, 0, 15);
            caption.TextAlignment = TextAlignment.Center;
            #endregion

            #region Score ListBox
            scoreListBox = new ListBox();
            scoreListBox.Background = this.Background;
            scoreListBox.HorizontalAlignment = HorizontalAlignment.Center;

            foreach (ScoreRecord scoreRecord in parentApp.HighScore.Table)
            {
                ScoreItem scoreItem = new ScoreItem(scoreRecord.Name, scoreRecord.Score);
                scoreItem.Background = scoreListBox.Background;
                scoreListBox.Items.Add(scoreItem);
            }
            #endregion

            #region HintLabel
            hintTextFlow = new TextFlow();
            hintTextFlow.SetMargin(0, 15, 0, 0);
            hintTextFlow.TextAlignment = TextAlignment.Center;
            UpdateHint();
            #endregion

            StackPanel mainStack = new StackPanel(Orientation.Vertical);
            mainStack.HorizontalAlignment = HorizontalAlignment.Center;
            mainStack.Children.Add(caption);
            mainStack.Children.Add(scoreListBox);
            mainStack.Children.Add(hintTextFlow);

            this.Child = mainStack;

            this.Visibility = Visibility.Visible;
            Buttons.Focus(this);
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
        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;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates all WPF controls of the window
        /// </summary>
        private void InitializeComponents()
        {
            this.Width = SystemMetrics.ScreenWidth;
            this.Height = SystemMetrics.ScreenHeight;
            this.Background = new SolidColorBrush(Colors.Black);

            Image logoImage = new Image(Resources.GetBitmap(Resources.BitmapResources.Logo));

            #region ListBox event handler
            Color selectedItemColor = Colors.White;
            Color unselectedItemColor = ColorUtility.ColorFromRGB(206, 206, 206);
            Brush selectedBackground = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 148, 255));

            menuListBox = new ListBox();
            menuListBox.Background = this.Background;
            menuListBox.HorizontalAlignment = HorizontalAlignment.Center;

            // Event handler for menu items
            menuListBox.SelectionChanged += delegate(object sender, SelectionChangedEventArgs e)
            {
                int previousSelectedIndex = e.PreviousSelectedIndex;
                if (previousSelectedIndex != -1)
                {
                    // Change previously-selected listbox item color to unselected color
                    ((Text)menuListBox.Items[previousSelectedIndex].Child).ForeColor = unselectedItemColor;
                    menuListBox.Items[previousSelectedIndex].Background = menuListBox.Background;
                }

                // Change newly-selected listbox item color to selected color and background
                ((Text)menuListBox.Items[e.SelectedIndex].Child).ForeColor = selectedItemColor;
                menuListBox.Items[e.SelectedIndex].Background = selectedBackground;
            };
            #endregion

            #region Menu Items
            // Menu items from resources
            string[] menuItems = new string[4] { Resources.GetString(Resources.StringResources.RookieLevel),
                                                 Resources.GetString(Resources.StringResources.AdvancedLevel),
                                                 Resources.GetString(Resources.StringResources.ExtremeLevel),
                                                 Resources.GetString(Resources.StringResources.ViewHighScore)};
            // Add items into listbox
            foreach(string item in menuItems)
            {
                Text itemText = new Text(Resources.GetFont(Resources.FontResources.NinaB), item);
                itemText.Width = this.Width - 40;
                itemText.ForeColor = unselectedItemColor;
                itemText.TextAlignment = TextAlignment.Center;
                itemText.SetMargin(5);

                ListBoxItem listBoxItem = new ListBoxItem();
                listBoxItem.Background = menuListBox.Background;
                listBoxItem.Child = itemText;

                menuListBox.Items.Add(listBoxItem);
            }

            menuListBox.SelectedIndex = 0;
            #endregion

            // Add all controls to stack panel
            StackPanel mainStackPanel = new StackPanel(Orientation.Vertical);
            mainStackPanel.Children.Add(logoImage);
            mainStackPanel.Children.Add(menuListBox);

            this.Child = mainStackPanel;

            this.Visibility = Visibility.Visible;
            Buttons.Focus(menuListBox);
        }
Ejemplo n.º 10
0
        public Border AddTitleBar(string title, Font font, GT.Color foreColor, Brush backgroundBrush)
        {
            Border titleBar = new Border();
            titleBar.Width = displayWidth;
            titleBar.Height = titlebarHeight;
            titleBar.Background = backgroundBrush;

            Text text = new Text(font, title);
            text.Width = displayWidth;
            text.ForeColor = foreColor;
            text.SetMargin(marginSize);
            text.TextAlignment = TextAlignment.Left;

            titleBar.Child = text;
            AddChild(titleBar);

            return titleBar;
        }
Ejemplo n.º 11
0
        ///// <summary>
        ///// Assigns the provided TouchEventHander to the settings button
        ///// </summary>
        ///// <param name="handler"></param>
        //public void AttachButtonTouchHandler(TouchEventHandler handler)
        //{
        //    settingsButton.TouchDown += handler;
        //}
        /// <summary>
        /// Creates the UI elements
        /// </summary>
        public void SetupUI()
        {
            #region Title Bar
            AddTitleBar(Resources.GetString(Resources.StringResources.appTitle), Resources.GetFont(Resources.FontResources.NinaB), GT.Color.White, GT.Color.Blue, GT.Color.Black);
            #endregion // Title Bar

            #region Main Display Window
            StackPanel dashboardPanel = new StackPanel(Orientation.Vertical);
            // Current Temp Label
            currentTempLabel = new Text()
            {
                ForeColor = GT.Color.Black,
                Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold),
                TextContent = Resources.GetString(Resources.StringResources.currentTempLabel) + theModel.AverageTemperature.ToString() + theModel.TemperatureDegreeSymbol,
                TextAlignment = TextAlignment.Left,
                VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center
            };
            currentTempLabel.SetMargin(0, 8, 0, 8);
            dashboardPanel.Children.Add(currentTempLabel);

            // Set Point Label
            setPointLabel = new Text()
            {
                ForeColor = GT.Color.Black,
                Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold),
                TextContent = Resources.GetString(Resources.StringResources.setpointLabel) + theModel.AverageTemperature.ToString() + theModel.TemperatureDegreeSymbol,
                TextAlignment = TextAlignment.Left,
                VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center
            };
            setPointLabel.SetMargin(0, 8, 0, 8);
            dashboardPanel.Children.Add(setPointLabel);

            // State Label
            stateLabel = new Text()
            {
                ForeColor = GT.Color.Black,
                Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold),
                TextContent = Resources.GetString(Resources.StringResources.statusLabel) + theModel.CurrentStateStringTable[(int)theModel.CurrentState],
                TextAlignment = TextAlignment.Left,
                VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center
            };
            stateLabel.SetMargin(0, 8, 0, 8);
            dashboardPanel.Children.Add(stateLabel);

            // Mode Label
            modeLabel = new Text()
            {
                ForeColor = GT.Color.Black,
                Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold),
                TextContent = Resources.GetString(Resources.StringResources.currentModeLabel) + theModel.ControllerModeStringTable[(int)theModel.ControllerMode],
                TextAlignment = TextAlignment.Left,
                VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center
            };
            modeLabel.SetMargin(0, 8, 0, 8);
            dashboardPanel.Children.Add(modeLabel);

            this.AddChild(dashboardPanel, 10);

            #region Settings Button
            settingsButton = new Image(Resources.GetBitmap(Resources.BitmapResources.BlueGlassSettingsSmall));
            settingsButton.SetMargin(5, 3, 0, 0);

            this.AddChild(settingsButton, displayHeight - 45, 0);
            #endregion // Settings Button
            #endregion // Main Display Window
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates the UI elements
        /// </summary>
        public void SetupUI()
        {
            #region Title Bar
            AddTitleBar(Resources.GetString(Resources.StringResources.errorTitle), Resources.GetFont(Resources.FontResources.NinaB), GT.Color.White, GT.Color.Blue, GT.Color.Black);
            #endregion // Title Bar

            #region Main Display Window
            StackPanel mainPanel = new StackPanel(Orientation.Horizontal);
            mainPanel.SetMargin(4);

            // Error Message Label
            errorMessageText = new Text()
            {
                ForeColor = GT.Color.Red,
                Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold),
                TextContent = "",
                TextAlignment = TextAlignment.Center,
                VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center
            };
            errorMessageText.SetMargin(8, 8, 8, 8);
            mainPanel.Children.Add(errorMessageText);

            this.AddChild(mainPanel, 0);
            #endregion // Main Display Window
        }
        public void SetupUI()
        {
            #region Title Bar
            AddTitleBar(theModel.AppTitle, Resources.GetFont(Resources.FontResources.NinaB), GT.Color.White, GT.Color.Blue, GT.Color.Black);
            #endregion // Title Bar

            #region Main Display Window
            StackPanel dashboardPanel = new StackPanel(Orientation.Vertical);
            // Current Temp Label
            currentTempLabel = new Text()
            {
                ForeColor = GT.Color.Black,
                Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold),
                TextContent = "Current Temperature: " + theModel.CurrentTemperature.ToString() + theModel.TemperatureDegreeSymbol,
                TextAlignment = TextAlignment.Left,
                VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center
            };
            currentTempLabel.SetMargin(0, 8, 0, 8);
            dashboardPanel.Children.Add(currentTempLabel);

            // Set Point Label
            setPointLabel = new Text()
            {
                ForeColor = GT.Color.Black,
                Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold),
                TextContent = "Set Point: " + theModel.DesiredTemperature.ToString() + theModel.TemperatureDegreeSymbol,
                TextAlignment = TextAlignment.Left,
                VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center
            };
            setPointLabel.SetMargin(0, 8, 0, 8);
            dashboardPanel.Children.Add(setPointLabel);

            // State Label
            stateLabel = new Text()
            {
                ForeColor = GT.Color.Black,
                Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold),
                TextContent = "Status: " + theModel.CurrentStateString,
                TextAlignment = TextAlignment.Left,
                VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center
            };
            stateLabel.SetMargin(0, 8, 0, 8);
            dashboardPanel.Children.Add(stateLabel);

            modeLabel = new Text()
            {
                ForeColor = GT.Color.Black,
                Font = Resources.GetFont(Resources.FontResources.Arial_16_Bold),
                TextContent = "Mode: " + theModel.ControllerModeString,
                TextAlignment = TextAlignment.Left,
                VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center
            };
            modeLabel.SetMargin(0, 8, 0, 8);
            dashboardPanel.Children.Add(modeLabel);

            this.AddChild(dashboardPanel, 10);

            #region Back Button
            Image image = new Image(Resources.GetBitmap(Resources.BitmapResources.BlueGlassSettingsSmall));
            image.TouchDown += new TouchEventHandler(controller.settingsButton_Click);
            image.SetMargin(5, 3, 0, 0);

            this.AddChild(image, displayHeight - 45, 0);
            #endregion

            #endregion
        }
Ejemplo n.º 14
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;
            // Add a gradient color background to the window
            mainWindow.Background = new LinearGradientBrush(Colors.White, Colors.Red,
                                                            0, 0,
                                                            mainWindow.Width, mainWindow.Height);

            Font normalFont = Resources.GetFont(Resources.FontResources.NinaB);
            Font smallFont = Resources.GetFont(Resources.FontResources.small);

            // Create a list box control and add text items
            ListBox listBox = new ListBox();
            // set the width so that it fills the entire screen
            listBox.Child.Width = mainWindow.Width;
            // make the list box transparent
            listBox.Background = null;
            // make the enclosed scroll viewer transparent also
            // we get the scroll viewer via the child property but
            // need to cast it to Control in order to clear the background
            ((Control)listBox.Child).Background = null;

            // Add simple text items
            for (int i = 0; i < 2; ++i)
            {
                string str = "Simple text item";
                Text text = new Text(normalFont, str);
                text.SetMargin(2);
                ListBoxItem item = new HighlightableListBoxItem(text);
                listBox.Items.Add(item);
            }

            // Add a separator
            listBox.Items.Add(new SeparatorListBoxItem());

            // Add a text item with icon
            {
                // Create the stack panel to align the elements
                StackPanel stackPanel = new StackPanel(Orientation.Horizontal);

                // Icon
                Bitmap bmp = Resources.GetBitmap(Resources.BitmapResources.Clock);
                // Make the bitmap transparent using
                // the color of the top left corner pixel.
                // Therefore the image should not be in the Bitmap and Jpeg format
                // because that requires to create a copy in order to make it
                // transparent. Use Gif instead.
                bmp.MakeTransparent(bmp.GetPixel(0, 0));
                Image image = new Image(bmp);
                image.SetMargin(2); // set a margin to separate the image
                // vertically center the icon within the item
                image.VerticalAlignment = VerticalAlignment.Center;
                stackPanel.Children.Add(image);

                // Text
                Text text = new Text(normalFont, "Item with a icon and text");
                text.SetMargin(2); // set margin to separate the text
                // vertically center the icon within the item
                text.VerticalAlignment = VerticalAlignment.Center;
                stackPanel.Children.Add(text);

                // Create a highlightable list box item
                ListBoxItem item = new HighlightableListBoxItem(stackPanel);
                listBox.Items.Add(item);
            }

            // Add a separator
            listBox.Items.Add(new SeparatorListBoxItem());

            // Add two items with multiple columns
            // use i to add a right aligned number to the first column
            for (int i = 0; i <= 100; i += 50)
            {
                //create the stack panel to align the elements
                StackPanel stackPanel = new StackPanel(Orientation.Horizontal);

                // Add right aligned text
                Text text1 = new Text(normalFont, i.ToString());
                text1.Width = 30;
                text1.SetMargin(2); // set margin to separate the text
                text1.TextAlignment = TextAlignment.Right;
                // vertically center the icon within the item
                text1.VerticalAlignment = VerticalAlignment.Center;
                stackPanel.Children.Add(text1);

                // Icon
                Bitmap bmp = Resources.GetBitmap(Resources.BitmapResources.Audio);
                // Make the bitmap transparent using
                // the color of the top left corner pixel.
                // Therefore the image should not be in the Bitmap and Jpeg format
                // because that requires to create a copy in order to make it
                // transparent. Use Gif instead.
                bmp.MakeTransparent(bmp.GetPixel(0, 0));
                Image image = new Image(bmp);
                image.SetMargin(2); // set a margin to separate the image
                // vertically center the icon within the item
                image.VerticalAlignment = VerticalAlignment.Center;
                stackPanel.Children.Add(image);

                // Text
                Text text = new Text(normalFont, "Item with multiple columns");
                text.SetMargin(2); // set margin to separate the text
                // vertically center the icon within the item
                text.VerticalAlignment = VerticalAlignment.Center;
                stackPanel.Children.Add(text);

                // Create a highlightable list box item
                ListBoxItem item = new HighlightableListBoxItem(stackPanel);
                listBox.Items.Add(item);
            }

            // Add a separator
            listBox.Items.Add(new SeparatorListBoxItem());

            // Add two multi line text item
            for (int i = 0; i < 2; ++i)
            {
                TextFlow textFlow = new TextFlow();
                textFlow.TextRuns.Add("This is the first line.", normalFont, Colors.Black);
                textFlow.TextRuns.Add(TextRun.EndOfLine);
                textFlow.TextRuns.Add("Second line.", normalFont, Colors.Green);
                textFlow.TextRuns.Add(TextRun.EndOfLine);
                textFlow.TextRuns.Add("Third line.", smallFont, Colors.Red);
                textFlow.SetMargin(2);

                ListBoxItem item = new HighlightableListBoxItem(textFlow);
                listBox.Items.Add(item);
            }

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

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

            // Let the user select items with the up and down buttons.
            Buttons.Focus(listBox);
            // Get notified when the selected item was changed.
            listBox.SelectionChanged += new SelectionChangedEventHandler(listBox_SelectionChanged);
            // Get notified when a selected item was pressed
            // using the select button.
            listBox.AddHandler(Buttons.ButtonDownEvent, new ButtonEventHandler(listBox_ButtonDown), false);

            return mainWindow;
        }
Ejemplo n.º 15
0
        private void InitializeComponents()
        {
            this.Height = SystemMetrics.ScreenHeight;
            this.Width = SystemMetrics.ScreenWidth;

            Text textChannel = new Text();
            textChannel.Font = Resources.GetFont(Resources.FontResources.Consolas24);
            textChannel.TextContent = Resources.GetString(Resources.StringResources.Channel);
            textChannel.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
            textChannel.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Top;

            Text textVolume = new Text();
            textVolume.Font = Resources.GetFont(Resources.FontResources.Consolas24);
            textVolume.TextContent = Resources.GetString(Resources.StringResources.Volume);
            textVolume.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
            textVolume.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Bottom;
            textVolume.SetMargin(0, 50, 0, 0);

            channelLabel = new Text();
            channelLabel.Font = Resources.GetFont(Resources.FontResources.Consolas48);
            channelLabel.TextContent = channel.ToString();
            channelLabel.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
            channelLabel.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Top;

            volumeBar = new VolumeBar();
            volumeBar.HorizontalAlignment = HorizontalAlignment.Center;
            volumeBar.VerticalAlignment = VerticalAlignment.Bottom;
            volumeBar.Value = 10;

            StackPanel panel = new StackPanel(Orientation.Vertical);
            panel.HorizontalAlignment = HorizontalAlignment.Center;
            panel.VerticalAlignment = VerticalAlignment.Stretch;
            panel.Children.Add(textChannel);
            panel.Children.Add(channelLabel);
            panel.Children.Add(textVolume);
            panel.Children.Add(volumeBar);

            // Add the text control to the window.
            this.Child = panel;

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

            // Attach the button focus to the window.
            Buttons.Focus(this);
        }
Ejemplo n.º 16
0
        public QuaziMessageBox(Font font, int width, string message, MessageBoxButton buttons, Bitmap buttonBackground, Color buttonTextColor, Color textColor, EventHandler Closed)
        {
            Width = width;
            Visibility = Visibility.Hidden;

            this.buttons = buttons;
            onClose = Closed;

            Orientation = Orientation.Vertical;
            HorizontalAlignment = HorizontalAlignment.Center;
            VerticalAlignment = VerticalAlignment.Center;

            txtMessage = new Text(font, message);
            txtMessage.ForeColor = Color.Black;
            txtMessage.HorizontalAlignment = HorizontalAlignment.Center;
            txtMessage.TextAlignment = TextAlignment.Center;
            txtMessage.TextWrap = true;
            txtMessage.SetMargin(3);
            Children.Add(txtMessage);

            StackPanel pnlButtons = new StackPanel(Orientation.Horizontal);
            pnlButtons.HorizontalAlignment = HorizontalAlignment.Center;
            pnlButtons.VerticalAlignment = VerticalAlignment.Bottom;
            Children.Add(pnlButtons);

            btn1 = new Button(font, "", null, buttonTextColor);
            btn1.Background = buttonBackground;
            btn1.ImageSize = 16;
            btn1.HorizontalAlignment = HorizontalAlignment.Center;
            btn1.SetMargin(3);
            btn1.Clicked += new EventHandler(btn1_Clicked);
            pnlButtons.Children.Add(btn1);

            btn2 = new Button(font, "", null, buttonTextColor);
            btn2.Background = buttonBackground;
            btn2.ImageSize = 16;
            btn2.HorizontalAlignment = HorizontalAlignment.Center;
            btn2.SetMargin(3);
            btn2.Clicked += new EventHandler(btn2_Clicked);
            pnlButtons.Children.Add(btn2);

            btn3 = new Button(font, "", null, buttonTextColor);
            btn3.Background = buttonBackground;
            btn3.ImageSize = 16;
            btn3.HorizontalAlignment = HorizontalAlignment.Center;
            btn3.SetMargin(3);
            btn3.Clicked += new EventHandler(btn3_Clicked);
            pnlButtons.Children.Add(btn3);

            switch (buttons)
            {
                case MessageBoxButton.OK:
                    btn1.Text = "OK";
                    btn2.Visibility = btn3.Visibility = Visibility.Collapsed;
                    break;
                case MessageBoxButton.OKCancel:
                    btn1.Text = "OK";
                    btn2.Text = "Отмена";
                    btn3.Visibility = Visibility.Collapsed;
                    break;
                case MessageBoxButton.YesNo:
                    btn1.Text = "Да";
                    btn2.Text = "Нет";
                    btn3.Visibility = Visibility.Collapsed;
                    break;
                case MessageBoxButton.YesNoCancel:
                    btn1.Text = "Да";
                    btn2.Text = "Нет";
                    btn3.Text = "Отмена";
                    break;
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 18
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;
        }