예제 #1
0
        private void InitMaps()
        {
            if (!GMapControl.IsDesignerHosted)
            {
                try
                {
                    gmap.Manager.Mode = AccessMode.ServerAndCache;

                    if (!MiscStuff.CheckForInternetConnection())
                    {
                        gmap.Manager.Mode = AccessMode.CacheOnly;
                        MessageBox.Show("No internet connection available, going to CacheOnly mode.", "Server Only", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    gmap.MapProvider = GMapProviders.OpenStreetMap;

                    CenterOnPosition(addressChosen);

                    gmap.MinZoom = 10;
                    gmap.MaxZoom = 17;
                    gmap.Zoom = 12;

                    gmap.Overlays.Add(objects);
                    gmap.Overlays.Add(top);

                    currentMarker = new GMarkerGoogle(gmap.Position, GMarkerGoogleType.arrow);
                    currentMarker.IsHitTestVisible = false;
                    top.Markers.Add(currentMarker);

                    gmap.ShowCenter = false;

                    if (objects.Markers.Count > 0)
                    {
                        gmap.ZoomAndCenterMarkers(null);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(MiscStuff.GetAllMessages(ex));
                }
            }
        }
예제 #2
0
        private void wizardPage1_PageInit(object sender, EventArgs e)
        {
            if (wizardPage1Valid())
            {
                wizardControl1.SelectedPage.AllowNext = true;
            }
            else
            {
                wizardControl1.SelectedPage.AllowNext = false;
            }

            if (!MiscStuff.CheckForInternetConnection())
            {
                buttonMap.Enabled = false;
            }
            else
            {
                buttonMap.Enabled = true;
            }
        }
예제 #3
0
        private void FormCountryOfOrigin_Load(object sender, EventArgs e)
        {
            if (MiscStuff.CheckForInternetConnection())
            {
                bingMapDataProvider.BingKey = yourBingKey;

                geocodeProvider = new BingGeocodeDataProvider
                {
                    BingKey = yourBingKey,
                    MaxVisibleResultCount = 1
                };
                geocodeProvider.LocationInformationReceived += OnLocationInformationReceived;
                geocodeProvider.LayerItemsGenerating        += OnLayerItemsGenerating;
                informationLayer1.DataProvider = geocodeProvider;
            }
            else
            {
                MessageBox.Show("Sorry, No Internet Connection");
                this.Close();
            }
        }
예제 #4
0
        private void SetLabels()
        {
            if (MiscStuff.CheckForInternetConnection())
            {
                var TempDay1 = new List <double>();
                var TempDay2 = new List <double>();
                var TempDay3 = new List <double>();

                var day1       = DateTime.Today.AddDays(1);
                var startCount = 0;

                foreach (var fcast in forecast.List)
                {
                    if (MiscStuff.GetDateTimeFromUnixTime(fcast.Dt).Day == day1.Day && MiscStuff.GetDateTimeFromUnixTime(fcast.Dt).ToString("h:mm:ss tt").Equals("12:00:00 AM"))
                    {
                        break;
                    }
                    startCount++;
                }

                for (int x = startCount; x < forecast.List.Count; x++)
                {
                    if (x > (startCount - 1) && x < (startCount + 9))
                    {
                        TempDay1.Add(forecast.List[x].Main.Temp);
                    }
                    if (x > (startCount + 7) && x < (startCount + 17))
                    {
                        TempDay2.Add(forecast.List[x].Main.Temp);
                    }
                    if (x > (startCount + 15) && x < (startCount + 25))
                    {
                        TempDay3.Add(forecast.List[x].Main.Temp);
                    }
                }

                label1.Text = Convert.ToInt32(weather.List[0].Main.Temp) + string.Format("\u00B0") + "C";
                var date = MiscStuff.GetDateTimeFromUnixTime(weather.List[0].Dt);
                label11.Text = "" + date.DayOfWeek + ", " + date.Day + MiscStuff.GetSuffix(date.Day) + " " + date.ToString("MMMM") + ", " + date.Year;
                var date2 = date.AddDays(1);
                label9.Text = "" + date2.DayOfWeek + ", " + date2.Day + MiscStuff.GetSuffix(date2.Day) + " " + date2.ToString("MMMM") + ", " + date2.Year;
                var date3 = date2.AddDays(1);
                label32.Text = "" + date3.DayOfWeek + ", " + date3.Day + MiscStuff.GetSuffix(date3.Day) + " " + date3.ToString("MMMM") + ", " + date3.Year;
                var date4 = date3.AddDays(1);
                label33.Text = "" + date4.DayOfWeek + ", " + date4.Day + MiscStuff.GetSuffix(date4.Day) + " " + date4.ToString("MMMM") + ", " + date4.Year;

                label20.Text = "Australia";
                label2.Text  = "Perth, WA";
                label6.Text  = weather.List[0].Weather[0].Main;
                label31.Text = weather.List[0].Weather[0].Description;
                label7.Text  = weather.List[0].Main.Humidity + "%";
                label8.Text  = weather.List[0].Wind.Speed + "km/h";
                label12.Text = forecast.List[startCount + 4].Weather[0].Main;
                label15.Text = forecast.List[startCount + 12].Weather[0].Main;
                label17.Text = forecast.List[startCount + 20].Weather[0].Main;

                label13.Text = forecast.List[startCount + 4].Weather[0].Description;
                label14.Text = forecast.List[startCount + 12].Weather[0].Description;
                label16.Text = forecast.List[startCount + 20].Weather[0].Description;

                TempDay1.Sort();
                TempDay2.Sort();
                TempDay3.Sort();

                label21.Text = TempDay1[TempDay1.Count - 1] + string.Format("\u00B0") + "C";
                label24.Text = TempDay2[TempDay2.Count - 1] + string.Format("\u00B0") + "C";
                label26.Text = TempDay3[TempDay3.Count - 1] + string.Format("\u00B0") + "C";

                label22.Text = TempDay1[0] + string.Format("\u00B0") + "C";
                label23.Text = TempDay2[0] + string.Format("\u00B0") + "C";
                label25.Text = TempDay3[0] + string.Format("\u00B0") + "C";
                setIcons(startCount);
            }
            else
            {
                MessageBox.Show("Internet connection is down, try again later");
                this.Close();
            }
        }