Ejemplo n.º 1
0
 private void StartForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     GPStrings.getSharedStrings().Save();
     GPLocationList.getShared().Save();
     GPEventList.getShared().Save();
     GPCountryList.getShared().Save();
     GPTimeZoneList.sharedTimeZones().Save();
     GPLocationProvider.SaveRecent();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public LocationPickerControl()
        {
            InitializeComponent();
            ActiveControl = textBox1;

            foreach (GPCountry cn in GPCountryList.getShared().countries)
            {
                comboBox1.Items.Add(cn.getCode());
            }

            foreach (GPTimeZone tz in GPTimeZoneList.sharedTimeZones().getTimeZones())
            {
                comboBox8.Items.Add(tz.Name);
            }

            for (int i = 0; i <= 180; i++)
            {
                comboBox2.Items.Add(i.ToString());
            }
            for (int i = 0; i < 90; i++)
            {
                comboBox7.Items.Add(i.ToString());
            }
            for (int i = 0; i < 60; i++)
            {
                comboBox4.Items.Add(i.ToString());
                comboBox5.Items.Add(i.ToString());
            }

            comboBox3.Items.Add("East");
            comboBox3.Items.Add("West");
            comboBox6.Items.Add("North");
            comboBox6.Items.Add("South");

            comboBox2.SelectedIndex = 0;
            comboBox3.SelectedIndex = 0;
            comboBox4.SelectedIndex = 0;
            comboBox5.SelectedIndex = 0;
            comboBox6.SelectedIndex = 0;
            comboBox7.SelectedIndex = 0;

            UpdateEnabledButtons();

            Debugger.Log(0, "", "textBox1 focus start\n");
            textBox1.Select();
//            textBox1.Focus();
//            textBox1.Select(0, textBox1.Text.Length);
            Debugger.Log(0, "", "textBox1 focus end\n");
        }
Ejemplo n.º 3
0
        //
        // initialization of main window
        //
        public Form1()
        {
            InitializeComponent();

            //
            // initialization of combobox with list of timezones
            //
            GPTimeZoneList    tzl    = GPTimeZoneList.sharedTimeZones();
            List <GPTimeZone> tzlist = tzl.getTimeZones();

            comboBox1.BeginUpdate();
            foreach (GPTimeZone tz in tzlist)
            {
                comboBox1.Items.Add(tz);
            }
            comboBox1.EndUpdate();

            comboBox1.Text = "Europe/Bratislava";
        }
Ejemplo n.º 4
0
        private void comboBox8_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox8.SelectedIndex < 0 || comboBox8.SelectedIndex >= comboBox8.Items.Count)
            {
                return;
            }

            GPTimeZone tzone = GPTimeZoneList.sharedTimeZones().GetTimezoneByName(comboBox8.SelectedItem as string);

            if (tzone == null)
            {
                label8.Text = "-";
                return;
            }

            if (tzone.Transitions.Count == 0)
            {
                label8.Text = "-";
                return;
            }

            /*GPTimestamp ts = new GPTimestamp(DateTime.Now);
             * GPTimeZone.Transition trans = tzone.GetNextTransition(ts);
             * if (trans == null)
             * {
             *  label8.Text = "-";
             *  return;
             * }
             *
             * DateTime dt = trans.getDateTime();
             * label8.Text = dt.ToLongDateString() + " - " + dt.ToShortTimeString();*/

            if (comboBox1.SelectedItem != null && comboBox8.SelectedItem != null && tabControl1.SelectedIndex == 1)
            {
                OnSelectedLocationChanged(this, e);
            }
            ModifyNameOfCity();
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            //if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //XmlDocument doc = new XmlDocument();
                //doc.Load(openFileDialog1.SafeFileName);

                GPTimeZoneListOld oldList = new GPTimeZoneListOld();
                oldList.getTimeZones();
                GPTimeZoneList newList = oldList.convertTimezones();

                listBox1.BeginUpdate();
                listBox1.Items.Clear();
                foreach (string s in oldList.log)
                {
                    listBox1.Items.Add(s);
                }
                listBox1.EndUpdate();

                oldList.saveXml("c:\\Temp\\Timezones-q.xml");
                //oldList.saveXml("d:\\Temp\\Timezones-q.xml");
            }
        }
Ejemplo n.º 6
0
        public EditLocationProperties()
        {
            InitializeComponent();

            GPCountryList  list   = GPCountryList.getShared();
            GPTimeZoneList tzones = GPTimeZoneList.sharedTimeZones();

            comboBox1.BeginUpdate();
            foreach (GPCountry country in list.countries)
            {
                comboBox1.Items.Add(country);
            }
            comboBox1.EndUpdate();

            comboBox2.BeginUpdate();
            foreach (GPTimeZone tzone in tzones.getTimeZones())
            {
                comboBox2.Items.Add(tzone);
            }
            comboBox2.EndUpdate();

            ValidateInfo();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// do not merge
        /// </summary>
        ///
        public GPTimeZoneList convertTimezones()
        {
            GPTimeZoneList list = new GPTimeZoneList();
            int            c1;
            int            wom = 0;

            GPTimeZoneOld.Rule activeRule = null;

            foreach (GPTimeZoneOld tz in tzonesList)
            {
                if (tz.Transitions.Count > 0)
                {
                    for (int i = 0; i < tz.Transitions.Count; i++)
                    {
                        try
                        {
                            GPTimeZoneOld.Transition trans = tz.Transitions[i];
                            DateTime dt = trans.getDateTime(tz.OffsetSeconds);
                            c1 = tz.getTransCountForYear(dt.Year);
                            if (c1 == 2)
                            {
                                trans.Paired = true;
                            }
                            if (c1 > 2)
                            {
                                log.Add("More than 2 transition in year " + dt.Year + " for timezone " + tz.Name + "\n");
                            }

                            //trans.Rule1 = string.Format("{0}-{1}", dt.Month, dt.Day);

/*                            DateTime dta = new DateTime(dt.Year, dt.Month, 1);
 *                          int womFdm = (dayOfWeek(dta.DayOfWeek) + 6)%7;
 *                          int virt = 1 - womFdm;
 *                          dta = dta.AddDays((7 - womFdm)%7);
 *                          wom = 1;
 *                          for (int y = 0; y < 10; y++)
 *                          {
 *                              if (dt < dta)
 *                              {
 *                                  if (dta.Month != dt.Month)
 *                                  {
 *                                      wom = 5;
 *                                  }
 *                                  break;
 *                              }
 *                              dta = dta.AddDays(7);
 *                              wom++;
 *                          }
 */
                            // TODO: correct offset determination should be applied
                            // now there are difreneces against actual offset
                            int sd = dt.Day;
                            while (sd > 0)
                            {
                                wom++;
                                sd -= 7;
                            }
                            if (wom > 5)
                            {
                                wom = 5;
                            }
                            trans.Rule2 = string.Format("{0}-{1}-{2}-{3:00}", dt.Month, wom, dayOfWeek(dt.DayOfWeek), dt.Hour);

                            if (trans.Dst == true)
                            {
                                activeRule               = new GPTimeZoneOld.Rule();
                                activeRule.OffsetStart   = trans.OffsetInSeconds / 60;
                                activeRule.RuleTextStart = trans.Rule2;
                                activeRule.YearStart     = dt.Year;
                            }
                            else if (trans.Dst == false)
                            {
                                if (activeRule != null)
                                {
                                    activeRule.OffsetEnd   = trans.OffsetInSeconds / 60;
                                    activeRule.RuleTextEnd = trans.Rule2;
                                    activeRule.YearEnd     = dt.Year;
                                    tz.Rules.Add(activeRule);
                                    activeRule = null;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            log.Add(tz.Name + " - exception: " + ex.Message);
                        }
                    }
                }

                c1          = tz.getTransCountForYear(2014) + tz.getTransCountForYear(2015);
                tz.UsingDst = (c1 > 0);

                if (tz.UsingDst)
                {
                    tz.SymbolNormalTime   = tz.getTimeAbbr(false);
                    tz.SymbolDaylightTime = tz.getTimeAbbr(true);

                    int idx = tz.Transitions.Count - 1;
                    GPTimeZoneOld.Transition tr = tz.Transitions[idx];
                    if (tr.Paired == false && tr.getDateTime().Year > 2040)
                    {
                        tz.Transitions.RemoveAt(idx);
                    }

                    /*tr = tz.Transitions[0];
                     * while (true)
                     * {
                     *  if (tr.Paired == false && tr.getDateTime().Year < 2005)
                     *      tz.Transitions.RemoveAt(0);
                     *  else
                     *      break;
                     *  if (tz.Transitions.Count > 0)
                     *      tr = tz.Transitions[0];
                     * }*/
                }
                else
                {
                    GPTimeZoneOld.Transition tr = tz.Transitions[tz.Transitions.Count - 1];
                    tz.OffsetSeconds      = tr.OffsetInSeconds;
                    tz.SymbolNormalTime   = tr.Abbreviation;
                    tz.SymbolDaylightTime = tr.Abbreviation;
                    tz.Transitions.Clear();
                    tz.Rules.Clear();
                }

                for (int u = 0; u < tz.Rules.Count; u++)
                {
                    if (u + 1 < tz.Rules.Count)
                    {
                        if (tz.Rules[u].OffsetStart == tz.Rules[u + 1].OffsetStart &&
                            tz.Rules[u].OffsetEnd == tz.Rules[u + 1].OffsetEnd &&
                            tz.Rules[u].RuleTextEnd == tz.Rules[u + 1].RuleTextEnd &&
                            tz.Rules[u].RuleTextStart == tz.Rules[u + 1].RuleTextStart
                            )
                        {
                            tz.Rules[u].YearEnd = tz.Rules[u + 1].YearEnd;
                            tz.Rules.RemoveAt(u + 1);
                            u--;
                        }
                    }
                }
                for (int u = 0; u < tz.Rules.Count; u++)
                {
                    if (tz.Rules[u].YearEnd > 2050)
                    {
                        tz.Rules[u].YearEnd = 2200;
                    }
                    if ((tz.Rules[u].YearEnd - tz.Rules[u].YearStart < 4)
                        )
                    {
                        tz.Rules.RemoveAt(u);
                        u--;
                    }
                }
                foreach (GPTimeZoneOld.Rule rule in tz.Rules)
                {
                    tz.RemoveTransitionsForRule(rule);
                }
                for (int u = tz.Transitions.Count - 1; u >= 0; u--)
                {
                    if (tz.Transitions[u].OffsetInSeconds == tz.OffsetSeconds)
                    {
                        tz.Transitions.RemoveAt(u);
                    }
                }
            }


            return(list);
        }