Пример #1
0
        public static vCalendar Parse(string data)
        {
            vCalendar cal = new vCalendar();

            data       = ActiveUp.Net.Groupware.vCard.Parser.Unfold(data);
            cal.Events = ActiveUp.Net.Groupware.vCalendar.Parser.GetEvents(data);
            cal.Todos  = ActiveUp.Net.Groupware.vCalendar.Parser.GetTodos(data);
            if ((cal.Events.Count + cal.Todos.Count) > 0)
            {
                data = data.Substring(data.IndexOf("\r\n"), data.IndexOf("BEGIN:", data.IndexOf("\r\n")) - data.IndexOf("\r\n"));
            }
            foreach (string line in System.Text.RegularExpressions.Regex.Split(data, "\r\n"))
            {
                string fulltype = line.Split(':')[0];
                string type     = fulltype.Split(';')[0].ToUpper();
                switch (type)
                {
                case "VERSION": Parser.SetVersion(cal, line);
                    break;

                case "DAYLIGHT": Parser.SetDayLight(cal, line);
                    break;

                case "GEO": Parser.SetGeo(cal, line);
                    break;

                case "TZ": Parser.SetTimeZone(cal, line);
                    break;

                case "PRODID": Parser.SetGeneratorId(cal, line);
                    break;
                }
            }
            return(cal);
        }
 public static vCalendar Parse(string data)
 {
     vCalendar cal = new vCalendar();
     data = ActiveUp.Net.Groupware.vCard.Parser.Unfold(data);
     cal.Events = ActiveUp.Net.Groupware.vCalendar.Parser.GetEvents(data);
     cal.Todos = ActiveUp.Net.Groupware.vCalendar.Parser.GetTodos(data);
     if((cal.Events.Count+cal.Todos.Count)>0) data = data.Substring(data.IndexOf("\r\n"),data.IndexOf("BEGIN:",data.IndexOf("\r\n"))-data.IndexOf("\r\n"));
     foreach(string line in System.Text.RegularExpressions.Regex.Split(data,"\r\n"))
     {
         string fulltype = line.Split(':')[0];
         string type = fulltype.Split(';')[0].ToUpper();
         switch(type)
         {
             case "VERSION": Parser.SetVersion(cal,line);
                 break;
             case "DAYLIGHT": Parser.SetDayLight(cal,line);
                 break;
             case "GEO": Parser.SetGeo(cal,line);
                 break;
             case "TZ": Parser.SetTimeZone(cal,line);
                 break;
             case "PRODID": Parser.SetGeneratorId(cal,line);
                 break;
         }
     }
     return cal;
 }
 private static void SetGeo(vCalendar cal, string line)
 {
     GeographicalPosition geo = new GeographicalPosition();
     string val = line.Split(':')[1];
     string[] values = val.Split(';');
     geo.Latitude = System.Convert.ToDecimal(values[0]);
     geo.Longitude = System.Convert.ToDecimal(values[1]);
     cal.GeographicalPosition = geo;
 }
Пример #4
0
        private static void SetGeo(vCalendar cal, string line)
        {
            GeographicalPosition geo = new GeographicalPosition();
            string val = line.Split(':')[1];

            string[] values = val.Split(';');
            geo.Latitude             = System.Convert.ToDecimal(values[0]);
            geo.Longitude            = System.Convert.ToDecimal(values[1]);
            cal.GeographicalPosition = geo;
        }
 private static void SetDayLight(vCalendar cal, string line)
 {
     DayLightSavings savings = new DayLightSavings();
     string[] compounds = line.Split(':')[1].Split(';');
     if(compounds[0].ToUpper()=="TRUE")
     {
         savings.IsObserved = true;
         savings.Offset = System.Int32.Parse(compounds[1]);
         savings.Start = ActiveUp.Net.Groupware.vCard.Parser.ParseDate(compounds[2]);
         savings.End = ActiveUp.Net.Groupware.vCard.Parser.ParseDate(compounds[3]);
         savings.StandardTimeDesignation = compounds[4];
         savings.Designation = compounds[5];
     }
     else savings.IsObserved = false;
     cal.DayLightSavings = savings;
 }
Пример #6
0
 private void btnReadCard_Click_1(object sender, EventArgs e)
 {
     DialogResult dresult = dlgOpen.ShowDialog();
     System.Threading.Thread.Sleep(0);
     if (dresult != DialogResult.Cancel)
     {
         string FileName = dlgOpen.FileName;
         cal = vCalendar.LoadFromFile(FileName);
         if (cal.Events.Count > 0)
         {
             txtDescription.Text = cal.Events[0].Description;
             txtName.Text = cal.Events[0].Summary;
             dtStart.Value = cal.Events[0].Start;
             dtEnd.Value = cal.Events[0].End;
         }
     }
 }
Пример #7
0
        private static void SetDayLight(vCalendar cal, string line)
        {
            DayLightSavings savings = new DayLightSavings();

            string[] compounds = line.Split(':')[1].Split(';');
            if (compounds[0].ToUpper() == "TRUE")
            {
                savings.IsObserved = true;
                savings.Offset     = System.Int32.Parse(compounds[1]);
                savings.Start      = ActiveUp.Net.Groupware.vCard.Parser.ParseDate(compounds[2]);
                savings.End        = ActiveUp.Net.Groupware.vCard.Parser.ParseDate(compounds[3]);
                savings.StandardTimeDesignation = compounds[4];
                savings.Designation             = compounds[5];
            }
            else
            {
                savings.IsObserved = false;
            }
            cal.DayLightSavings = savings;
        }
Пример #8
0
 private static void SetVersion(vCalendar cal, string line)
 {
     cal.Version = line.Split(':')[1];
 }
Пример #9
0
 private static void SetGeneratorId(vCalendar cal, string line)
 {
     cal.GeneratorId = line.Replace(line.Split(':')[0] + ":", "");
 }
Пример #10
0
 private static void SetTimeZone(vCalendar cal, string line)
 {
     cal.TimeZone = line.Replace(line.Split(':')[0] + ":", "");
 }
Пример #11
0
        private void saveAsButton_Click(object sender, EventArgs e)
        {
            this.savevCalendarDialog.ShowDialog();

            vCalendar calendar = new vCalendar();
            vEvent newEvent = new vEvent();
            newEvent.Summary = this.objectTextbox.Text;
            newEvent.Location = this.placeTextbox.Text;
            newEvent.Start = DateTime.Now;
            newEvent.End = DateTime.Now;
            calendar.Events.Add(newEvent);
            calendar.SaveToFile(this.savevCalendarDialog.FileName);
        }
Пример #12
0
 private static void SetGeneratorId(vCalendar cal, string line)
 {
     cal.GeneratorId = line.Replace(line.Split(':')[0]+":","");
 }
Пример #13
0
 private static void SetTimeZone(vCalendar cal, string line)
 {
     cal.TimeZone = line.Replace(line.Split(':')[0]+":","");
 }
Пример #14
0
 private static void SetVersion(vCalendar cal, string line)
 {
     cal.Version = line.Split(':')[1];
 }
Пример #15
0
 public frmVcalendar()
 {
     InitializeComponent();
     cal = new vCalendar();
 }