Beispiel #1
0
        } //TreeViewKeyUp

        private void RegionalSettingChanged(object sender, EventArgs e)
        {
            if (_selectedNode != null)
            {
                if (sender is ComboBox)
                {
                    if ((sender as ComboBox).Name.Equals("cbRSCalendar", StringComparison.Ordinal))
                    {
                        CalendarItemSelected(sender, e);
                    }
                }

                TemplateItem templateItem = _templateItems.GetItem(_selectedNode.Name);
                if (templateItem != null)
                {
                    int[] rsValues = new int[13];
                    rsValues[(int)RegionalSettingProperties.AdjustHijriDays]       = Convert.ToInt32(cbRSAdjustHijriDate.SelectedItem);
                    rsValues[(int)RegionalSettingProperties.AlternateCalendarType] = (int)cbRSAlternateCalendar.SelectedValue;
                    rsValues[(int)RegionalSettingProperties.CalendarType]          = (int)cbRSCalendar.SelectedValue;
                    rsValues[(int)RegionalSettingProperties.Collation]             = (int)cbRSSortOrder.SelectedValue;
                    rsValues[(int)RegionalSettingProperties.FirstDayOfWeek]        = (int)cbRSFirstDayOfWeek.SelectedValue;
                    rsValues[(int)RegionalSettingProperties.FirstWeekOfYear]       = (int)cbRSFirstWeekOfYear.SelectedValue;
                    rsValues[(int)RegionalSettingProperties.LocaleId]       = (int)cbRSLocale.SelectedValue;
                    rsValues[(int)RegionalSettingProperties.ShowWeeks]      = (cbRSShowWeekNumbers.Checked ? 1 : 0);
                    rsValues[(int)RegionalSettingProperties.Time24]         = (int)cbRSTimeFormat.SelectedValue;
                    rsValues[(int)RegionalSettingProperties.TimeZone]       = (int)cbRSTimeZone.SelectedValue;
                    rsValues[(int)RegionalSettingProperties.WorkDayEndHour] = (int)cbRSWorkDayEndTime.SelectedValue;

                    int workDays = 0;

                    WeekDayColllection weekDayColllection = new WeekDayColllection();

                    for (int i = 0; i < clbRSWorkDays.Items.Count; i++)
                    {
                        if (clbRSWorkDays.GetItemChecked(i))
                        {
                            WeekDay weekDay = weekDayColllection.WeekDays.Find(p => (p.WeekDayId == i));
                            workDays = workDays | weekDay.WeekDayBit;
                        }
                    }

                    rsValues[(int)RegionalSettingProperties.WorkDays]         = workDays;
                    rsValues[(int)RegionalSettingProperties.WorkDayStartHour] = (int)cbRSWorkDayStartTime.SelectedValue;

                    templateItem.Content = rsValues;

                    if (templateItem.IsChanged)
                    {
                        bSave.Visible = true;
                    }
                } //if templateItem
            }     //if _selectedNode
        }         //RegionalSettingChanged
Beispiel #2
0
        }         //BrowseForTemplate

        private void PopulateRegionalSettings(TemplateItem templateItem)
        {
            int[] regionalSettings = (int[])templateItem.Content;
            if (regionalSettings?.Length > 0)
            {
                cbRSTimeZone.DataSource = null;
                cbRSTimeZone.Items.Clear();
                TimeZoneCollection timeZoneCollection = new TimeZoneCollection();
                cbRSTimeZone.DisplayMember = timeZoneCollection.DisplayMember;
                cbRSTimeZone.ValueMember   = timeZoneCollection.ValueMember;
                cbRSTimeZone.DataSource    = timeZoneCollection.TimeZones;

                int selectedIdx = -1;
                int tmpIdx      = regionalSettings[(int)RegionalSettingProperties.TimeZone];
                for (int i = 0; i < cbRSTimeZone.Items.Count; i++)
                {
                    TimeZone timeZone = cbRSTimeZone.Items[i] as TimeZone;
                    if (timeZone.TimeZoneId == tmpIdx)
                    {
                        selectedIdx = i;
                        break;
                    }
                }

                cbRSTimeZone.SelectedIndex = selectedIdx;

                cbRSLocale.DataSource = null;
                cbRSLocale.Items.Clear();
                LocaleCollection localeCollection = new LocaleCollection();
                cbRSLocale.DisplayMember = localeCollection.DisplayMember;
                cbRSLocale.ValueMember   = localeCollection.ValueMember;
                cbRSLocale.DataSource    = localeCollection.Locales;

                selectedIdx = -1;
                tmpIdx      = regionalSettings[(int)RegionalSettingProperties.LocaleId];
                for (int i = 0; i < cbRSLocale.Items.Count; i++)
                {
                    Locale locale = cbRSLocale.Items[i] as Locale;
                    if (locale.LocaleId == tmpIdx)
                    {
                        selectedIdx = i;
                        break;
                    }
                }

                cbRSLocale.SelectedIndex = selectedIdx;

                cbRSSortOrder.DataSource = null;
                cbRSSortOrder.Items.Clear();
                SortOrderCollection sortOrderCollection = new SortOrderCollection();
                cbRSSortOrder.DisplayMember = sortOrderCollection.DisplayMember;
                cbRSSortOrder.ValueMember   = sortOrderCollection.ValueMember;
                cbRSSortOrder.DataSource    = sortOrderCollection.SortOrders;

                selectedIdx = -1;
                tmpIdx      = regionalSettings[(int)RegionalSettingProperties.Collation];
                for (int i = 0; i < cbRSSortOrder.Items.Count; i++)
                {
                    SortOrder sortOrder = cbRSSortOrder.Items[i] as SortOrder;
                    if (sortOrder.SortOrderId == tmpIdx)
                    {
                        selectedIdx = i;
                        break;
                    }
                }

                cbRSSortOrder.SelectedIndex = selectedIdx;

                cbRSCalendar.DataSource = null;
                cbRSCalendar.Items.Clear();
                CalendarCollection calendarCollection = new CalendarCollection();
                cbRSCalendar.DisplayMember = calendarCollection.DisplayMember;
                cbRSCalendar.ValueMember   = calendarCollection.ValueMember;
                cbRSCalendar.DataSource    = calendarCollection.Calendars.Where(p => p.CalendarId > 0).ToList();

                selectedIdx = -1;
                tmpIdx      = regionalSettings[(int)RegionalSettingProperties.CalendarType];
                bool isHijriSelected = tmpIdx == 6; //Hijri
                for (int i = 0; i < cbRSCalendar.Items.Count; i++)
                {
                    Calendar calendar = cbRSCalendar.Items[i] as Calendar;
                    if (calendar.CalendarId == tmpIdx)
                    {
                        selectedIdx = i;
                        break;
                    }
                }

                cbRSCalendar.SelectedIndex = selectedIdx;

                tmpIdx = regionalSettings[(int)RegionalSettingProperties.ShowWeeks];
                if (tmpIdx > 0)
                {
                    cbRSShowWeekNumbers.Checked = true;
                }
                else
                {
                    cbRSShowWeekNumbers.Checked = false;
                }

                if (isHijriSelected)
                {
                    lAdjustHijriDate.Visible    = true;
                    cbRSAdjustHijriDate.Visible = true;
                    tmpIdx = 2 + regionalSettings[(int)RegionalSettingProperties.AdjustHijriDays];
                    cbRSAdjustHijriDate.SelectedIndex = tmpIdx;
                }
                else
                {
                    lAdjustHijriDate.Visible          = false;
                    cbRSAdjustHijriDate.Visible       = false;
                    cbRSAdjustHijriDate.SelectedIndex = 2; // equal to 0 value
                }

                cbRSAlternateCalendar.DataSource = null;
                cbRSAlternateCalendar.Items.Clear();
                cbRSAlternateCalendar.DisplayMember = calendarCollection.DisplayMember;
                cbRSAlternateCalendar.ValueMember   = calendarCollection.ValueMember;
                cbRSAlternateCalendar.DataSource    = calendarCollection.Calendars.ToList();

                selectedIdx = -1;
                tmpIdx      = regionalSettings[(int)RegionalSettingProperties.AlternateCalendarType];
                for (int i = 0; i < cbRSAlternateCalendar.Items.Count; i++)
                {
                    Calendar calendar = cbRSAlternateCalendar.Items[i] as Calendar;
                    if (calendar.CalendarId == tmpIdx)
                    {
                        selectedIdx = i;
                        break;
                    }
                }

                cbRSAlternateCalendar.SelectedIndex = selectedIdx;

                clbRSWorkDays.Items.Clear();
                tmpIdx = regionalSettings[(int)RegionalSettingProperties.WorkDays];
                WeekDayColllection weekDayCollection = new WeekDayColllection();
                foreach (WeekDay weekDay in weekDayCollection.WeekDays)
                {
                    clbRSWorkDays.Items.Add(weekDay.WeekDayShortName, ((tmpIdx & weekDay.WeekDayBit) == weekDay.WeekDayBit));
                }

                cbRSFirstDayOfWeek.DataSource = null;
                cbRSFirstDayOfWeek.Items.Clear();

                cbRSFirstDayOfWeek.DisplayMember = weekDayCollection.DisplayMember;
                cbRSFirstDayOfWeek.ValueMember   = weekDayCollection.ValueMember;
                cbRSFirstDayOfWeek.DataSource    = weekDayCollection.WeekDays;
                cbRSFirstDayOfWeek.SelectedIndex = regionalSettings[(int)RegionalSettingProperties.FirstDayOfWeek];

                cbRSFirstWeekOfYear.DataSource = null;
                cbRSFirstWeekOfYear.Items.Clear();

                FirstWeekCollection firstWeekCollection = new FirstWeekCollection();
                cbRSFirstWeekOfYear.DisplayMember = firstWeekCollection.DisplayMember;
                cbRSFirstWeekOfYear.ValueMember   = firstWeekCollection.ValueMember;
                cbRSFirstWeekOfYear.DataSource    = firstWeekCollection.FirstWeeks;
                cbRSFirstWeekOfYear.SelectedIndex = regionalSettings[(int)RegionalSettingProperties.FirstWeekOfYear];

                cbRSWorkDayStartTime.DataSource = null;
                cbRSWorkDayStartTime.Items.Clear();

                DayHourCollection dayHourCollection = new DayHourCollection();
                cbRSWorkDayStartTime.DisplayMember = dayHourCollection.DisplayMember;
                cbRSWorkDayStartTime.ValueMember   = dayHourCollection.ValueMember;
                cbRSWorkDayStartTime.DataSource    = dayHourCollection.DayHours.ToList();
                cbRSWorkDayStartTime.SelectedIndex = regionalSettings[(int)RegionalSettingProperties.WorkDayStartHour];

                cbRSWorkDayEndTime.DataSource = null;
                cbRSWorkDayEndTime.Items.Clear();

                cbRSWorkDayEndTime.DisplayMember = dayHourCollection.DisplayMember;
                cbRSWorkDayEndTime.ValueMember   = dayHourCollection.ValueMember;
                cbRSWorkDayEndTime.DataSource    = dayHourCollection.DayHours.ToList();
                cbRSWorkDayEndTime.SelectedIndex = regionalSettings[(int)RegionalSettingProperties.WorkDayEndHour];

                cbRSTimeFormat.DataSource = null;
                cbRSTimeFormat.Items.Clear();

                TimeFormatCollection timeFormatCollection = new TimeFormatCollection();
                cbRSTimeFormat.DisplayMember = timeFormatCollection.DisplayMember;
                cbRSTimeFormat.ValueMember   = timeFormatCollection.ValueMember;
                cbRSTimeFormat.DataSource    = timeFormatCollection.TimeFormats;
                cbRSTimeFormat.SelectedIndex = regionalSettings[(int)RegionalSettingProperties.Time24];
            }
        } //PopulateRegionalSettings