예제 #1
0
        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;
        }
예제 #2
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;
        }
예제 #3
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();
        }
예제 #4
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;
        }