Ejemplo n.º 1
0
        public void DisplayValue(System.TimeZone value)
        {
            EnsureInitialised();

            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (value == System.TimeZone.CurrentTimeZone)
            {
                radCurrent.Checked = true;
            }
            else
            {
                LinkMeType.TimeZone typeTz = value as LinkMeType.TimeZone;
                if (typeTz == null)
                {
                    throw new ArgumentException("Unsupported type of TimeZone object: "
                                                + value.GetType().FullName, "value");
                }

                if (typeTz.Equals(LinkMeType.TimeZone.UTC))
                {
                    radUtc.Checked = true;
                }
                else
                {
                    radSpecified.Checked = true;

                    bool found = false;
                    for (int index = 0; index < cboTimeZone.Items.Count; index++)
                    {
                        if (typeTz.StandardName == (string)cboTimeZone.Items[index])
                        {
                            found = true;
                            cboTimeZone.SelectedIndex = index;
                            break;
                        }
                    }

                    if (!found)
                    {
                        cboTimeZone.Items.Insert(0, value.StandardName);
                        cboTimeZone.SelectedIndex = 0;
                    }
                }
            }

            m_original = value;
            SetButtonEnabled(DialogResult.OK, false);
        }
Ejemplo n.º 2
0
        protected override void ReadAllSettings(XmlNode xmlSettings, XmlNamespaceManager xmlNsManager)
        {
            // Message Reader

            XmlNode xmlSection = GetSection(xmlSettings, xmlNsManager, SectionMessageReader, false);

            if (xmlSection != null)
            {
                RemoveWhenReading = ReadSettingBoolean(xmlSection, xmlNsManager, SettingRemoveWhenReading,
                                                       DefaultRemoveWhenReading);
                MaxCountToAutoStart = ReadSettingInt32(xmlSection, xmlNsManager, SettingMaxCountToAutoStart,
                                                       DefaultMaxCountToAutoStart);
            }

            // Visual

            xmlSection = GetSection(xmlSettings, xmlNsManager, SectionVisual, false);
            if (xmlSection != null)
            {
                ReadSettingIntoObject(xmlSection, xmlNsManager, SettingMainWindow, MainWindow);
                ReadSettingIntoObject(xmlSection, xmlNsManager, SettingLogWindow, LogWindow);
                ReadSettingIntoObject(xmlSection, xmlNsManager, SettingDetailsWindow, DetailsWindow);
                ReadSettingIntoObject(xmlSection, xmlNsManager, SettingExceptionWindow, ExceptionWindow);
                ReadSettingIntoObject(xmlSection, xmlNsManager, SettingGenericEditorWindow, GenericEditorWindow);
                LogColumnWidths = ReadSettingInt32Array(xmlSection, xmlNsManager, SettingLogColumnWidths,
                                                        DefaultLogColumnWidths);
                LogSplitRatio = ReadSettingSingle(xmlSection, xmlNsManager, SettingLogSplitterRatio,
                                                  DefaultLogSplitterRatio);
                DetailsSplitterRatioTop = ReadSettingSingle(xmlSection, xmlNsManager, SettingDetailsSplitterRatioTop,
                                                            DefaultDetailsSplitterRatioTop);
                DetailsSplitterRatioBottom = ReadSettingSingle(xmlSection, xmlNsManager,
                                                               SettingDetailsSplitterRatioBottom, DefaultDetailsSplitterRatioBottom);

                TC.DataGrid.ColumnWidths widths = new TC.DataGrid.ColumnWidths();
                if (ReadSettingIntoObject(xmlSection, xmlNsManager, SettingDetailColumnWidths, widths))
                {
                    DetailColumnWidths = widths;
                }

                widths = new TC.DataGrid.ColumnWidths();
                if (ReadSettingIntoObject(xmlSection, xmlNsManager, SettingParameterColumnWidths, widths))
                {
                    ParameterColumnWidths = widths;
                }
            }

            // View

            xmlSection = GetSection(xmlSettings, xmlNsManager, SectionView, false);
            if (xmlSection != null)
            {
                PreviewPane = ReadSettingBoolean(xmlSection, xmlNsManager, SettingPreviewPane,
                                                 DefaultPreviewPane);
                StatusBar = ReadSettingBoolean(xmlSection, xmlNsManager, SettingStatusBar,
                                               DefaultStatusBar);
                AutoScrollMessages = ReadSettingBoolean(xmlSection, xmlNsManager, SettingAutoScrollMessages,
                                                        DefaultAutoScrollMessage);

                // Read the standard name of the time zone and create a TimeZone object.

                string tzName = ReadSettingString(xmlSection, xmlNsManager, SettingDisplayTimeZone, null);
                if (tzName == null || tzName == CurrentTimeZoneName)
                {
                    DisplayTimeZone = System.TimeZone.CurrentTimeZone;
                }
                else
                {
                    try
                    {
                        DisplayTimeZone = new LinkMeType.TimeZone(tzName);
                    }
                    catch (System.Exception ex)
                    {
                        // If the time zone is not found don't prevent the rest of the settings from loading.

                        new TC.ExceptionDialog(ex, "An error occurred in reading the Display Time Zone from"
                                               + " the settings. Local time will be used instead.",
                                               MessageBoxButtons.OK, MessageBoxIcon.Warning).ShowDialog();
                        DisplayTimeZone = System.TimeZone.CurrentTimeZone;
                    }
                }
            }

            // Recently used

            xmlSection = GetSection(xmlSettings, xmlNsManager, SectionRecentlyUsed, false);
            if (xmlSection != null)
            {
                MaxRecentlyUsed = ReadSettingInt32(xmlSection, xmlNsManager, SettingMaxRecentlyUsed,
                                                   DefaultMaxRecentlyUsed);
                ReadSettingIntoObject(xmlSection, xmlNsManager, SettingRecentlyUsedList, RecentlyUsedList);
                LastActive = ReadSettingString(xmlSection, xmlNsManager, SettingLastActive, null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the XML representation of the object in a format similar to XSD dateTime
        /// (http://www.w3.org/TR/xmlschema-2/#dateTime). The returned value is always in UTC.
        /// If xsdCompliant is true then the returned value complies with XSD dateTime
        /// exactly, but time zone information is lost. Otherwise the name of the time zone
        /// is appended to the value, so it is not a valid XSD dateTime.
        /// </summary>
        internal string ToXml(bool xsdCompliant)
        {
            // The length of the output string not including the time zone, which is variable
            const int dateTimeLength = 30;

            // Get the time zone name, unless the user specified that the output should
            // comply with XSD dateTime format or the time zone is, in fact, UTC.

            string timeZoneName = null;
            int    outputLength = dateTimeLength;

            if (!xsdCompliant && !TimeZone.Equals(Type.TimeZone.UTC))
            {
                timeZoneName  = Type.TimeZone.ToString(TimeZone);
                outputLength += timeZoneName.Length + 1;
            }

            StringBuilder sb = new StringBuilder(outputLength);

            // Year
            sb.Append(DateTimeHelper.Digits(Universal.Year, 4));
            sb.Append('-');

            // Month
            sb.Append(DateTimeHelper.Digits(Universal.Month, 2));
            sb.Append('-');

            // Day
            sb.Append(DateTimeHelper.Digits(Universal.Day, 2));
            sb.Append('T');

            // Hour
            sb.Append(DateTimeHelper.Digits(Universal.Hour, 2));
            sb.Append(':');

            // Minute
            sb.Append(DateTimeHelper.Digits(Universal.Minute, 2));
            sb.Append(':');

            // Second
            sb.Append(DateTimeHelper.Digits(Second, 2));

            // Fractional seconds (if any) to a maximum of 9 decimal places
            long nanoseconds = (long)Nanosecond
                               + (long)Microsecond * DateTimeHelper.Microseconds2Nanoseconds
                               + (long)Millisecond * DateTimeHelper.Milliseconds2Nanoseconds;

            if (nanoseconds != 0)
            {
                sb.Append('.');
                string ns = nanoseconds.ToString();
                ns = ns.PadLeft(9, '0');
                sb.Append(ns.TrimEnd('0'));
            }

            sb.Append('Z');             // Specifies that this value is in UTC

            if (timeZoneName != null)
            {
                sb.Append(' ');
                sb.Append(timeZoneName);
            }

            return(sb.ToString());
        }