Esempio n. 1
0
        // ---------------------------------------------------------------------
        public static Settings Deserialize(TextReader textReader)
        {
            string line;

            char[]   delimiter = { '=' };
            Settings settings  = new Settings();

            while ((line = textReader.ReadLine()) != null)
            {
                string[] nameValue = line.Split(delimiter, 2);

                switch (nameValue[0])
                {
                case topMostS:
                    settings.Topmost = bool.Parse(nameValue[1]);
                    break;

                case borderS:
                    try
                    {
                        settings.Border = (Calendar.BorderStyle)Enum.Parse
                                              (typeof(Calendar.BorderStyle), nameValue[1], true);
                    }

                    catch
                    {
                        settings.Border = Calendar.BorderStyle.Thick;
                    }
                    break;

                case showWeekNumbersS:
                    settings.ShowWeekNumbers = bool.Parse(nameValue[1]);
                    break;

                case showTodayS:
                    settings.ShowToday = bool.Parse(nameValue[1]);
                    break;

                case showTodayCircleS:
                    settings.ShowTodayCircle = bool.Parse(nameValue[1]);
                    break;

                case opacityS:
                    settings.opacity = float.Parse(nameValue[1],
                                                   NumberStyles.Float,
                                                   CultureInfo.InvariantCulture);
                    break;

                case positionS:
                    char[]   delimiters = { '=', ',', '}' };
                    string[] coords     = nameValue[1].Split(delimiters);
                    settings.position.X      = EventsCollection.ToInt(coords[1]);
                    settings.position.Y      = EventsCollection.ToInt(coords[3]);
                    settings.position.Width  = EventsCollection.ToInt(coords[5]);
                    settings.position.Height = EventsCollection.ToInt(coords[7]);
                    break;

                case firstDayS:
                    settings.FirstDay = (System.DayOfWeek)
                                        Enum.Parse(typeof(System.DayOfWeek), nameValue[1]);
                    break;

                case fontS:
                    settings.font = Settings.StringToFont(nameValue[1]);
                    break;

                case colorForeS:
                    settings.colorFore = Color.FromArgb(EventsCollection.ToInt(nameValue[1]));
                    break;

                case colorBackS:
                    settings.colorBack = Color.FromArgb(EventsCollection.ToInt(nameValue[1]));
                    break;

                case colorTitleForeS:
                    settings.colorTitleFore = Color.FromArgb(EventsCollection.ToInt(nameValue[1]));
                    break;

                case colorTitleBackS:
                    settings.colorTitleBack = Color.FromArgb(EventsCollection.ToInt(nameValue[1]));
                    break;

                case colorTrailingForeS:
                    settings.colorTrailingFore = Color.FromArgb(EventsCollection.ToInt(nameValue[1]));
                    break;

                case colorHighlightDayForeS:
                    settings.colorHighlightDayFore = Color.FromArgb(EventsCollection.ToInt(nameValue[1]));
                    break;

                case colorGridlinesS:
                    settings.colorGridlines = Color.FromArgb(EventsCollection.ToInt(nameValue[1]));
                    break;

                case colorWeekdayForeS:
                    settings.ColorWeekdayFore = Color.FromArgb(EventsCollection.ToInt(nameValue[1]));
                    break;

                case colorWeekdayBackS:
                    settings.ColorWeekdayBack = Color.FromArgb(EventsCollection.ToInt(nameValue[1]));
                    break;

                case colorWeeknumberForeS:
                    settings.ColorWeeknumberFore = Color.FromArgb(EventsCollection.ToInt(nameValue[1]));
                    break;

                case colorWeeknumberBackS:
                    settings.ColorWeeknumberBack = Color.FromArgb(EventsCollection.ToInt(nameValue[1]));
                    break;

                case colorWeekdayBarS:
                    settings.ColorWeekdayBar = Color.FromArgb(EventsCollection.ToInt(nameValue[1]));
                    break;

                case trayIconS:
                    settings.trayIcon = bool.Parse(nameValue[1]);
                    break;

                case gridlinesS:
                    settings.gridlines = bool.Parse(nameValue[1]);
                    break;

                case startMonthJanuaryS:
                    settings.startMonthJanuary = bool.Parse(nameValue[1]);
                    break;

                case startMonthPreviousS:
                    settings.StartMonthPrevious = int.Parse(nameValue[1], CultureInfo.InvariantCulture);
                    break;
                }
            }

            return(settings);
        }