コード例 #1
0
        private void ParseRecentColors(XmlReader _xmlReader)
        {
            m_RecentColors.Clear();

            while (_xmlReader.Read())
            {
                if (_xmlReader.IsStartElement())
                {
                    if (_xmlReader.Name == "Color")
                    {
                        Color col = XmlHelper.ColorParse(_xmlReader.ReadString(), ';');
                        m_RecentColors.Add(col);
                    }
                    else
                    {
                        // forward compatibility : ignore new fields.
                    }
                }
                else if (_xmlReader.Name == "RecentColors")
                {
                    break;
                }
                else
                {
                    // Fermeture d'un tag interne.
                }
            }
        }
コード例 #2
0
        private void ParseConfigFile(string filePath)
        {
            // Fill the local variables with infos found in the XML file.
            XmlReader PreferencesReader = new XmlTextReader(filePath);

            if (PreferencesReader != null)
            {
                try
                {
                    while (PreferencesReader.Read())
                    {
                        if ((PreferencesReader.IsStartElement()) && (PreferencesReader.Name == "KinoveaPreferences"))
                        {
                            while (PreferencesReader.Read())
                            {
                                if (PreferencesReader.IsStartElement())
                                {
                                    switch (PreferencesReader.Name)
                                    {
                                    case "HistoryCount":
                                        m_iFilesToSave = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "Language":
                                        m_UICultureName = PreferencesReader.ReadString();
                                        break;

                                    case "TimeCodeFormat":
                                        m_TimeCodeFormat = ParseTimeCodeFormat(PreferencesReader.ReadString());
                                        break;

                                    case "SpeedUnit":
                                        m_SpeedUnit = ParseSpeedUnit(PreferencesReader.ReadString());
                                        break;

                                    case "ImageAspectRatio":
                                        m_AspectRatio = ParseImageAspectRatio(PreferencesReader.ReadString());
                                        break;

                                    case "DeinterlaceByDefault":
                                        m_bDeinterlaceByDefault = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "GridColorRGB":
                                        m_GridColor = XmlHelper.ColorParse(PreferencesReader.ReadString(), ';');
                                        break;

                                    case "Plane3DColorRGB":
                                        m_Plane3DColor = XmlHelper.ColorParse(PreferencesReader.ReadString(), ';');
                                        break;

                                    case "WorkingZoneSeconds":
                                        m_iWorkingZoneSeconds = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "WorkingZoneMemory":
                                        m_iWorkingZoneMemory = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "InfosFading":
                                        m_DefaultFading.FromXml(PreferencesReader);
                                        break;

                                    case "DrawOnPlay":
                                        m_bDrawOnPlay = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerThumbnailsSize":
                                        m_iExplorerThumbsSize = (ExplorerThumbSizes)ExplorerThumbSizes.Parse(m_iExplorerThumbsSize.GetType(), PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerVisible":
                                        m_bIsExplorerVisible = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerSplitterDistance":
                                        m_iExplorerSplitterDistance = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ActiveFileBrowserTab":
                                        m_ActiveFileBrowserTab = (ActiveFileBrowserTab)ActiveFileBrowserTab.Parse(m_ActiveFileBrowserTab.GetType(), PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerFilesSplitterDistance":
                                        m_iExplorerFilesSplitterDistance = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ShortcutsFilesSplitterDistance":
                                        m_iShortcutsFilesSplitterDistance = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "Shortcuts":
                                        ParseShortcuts(PreferencesReader);
                                        break;

                                    case "CaptureImageDirectory":
                                        m_CaptureImageDirectory = PreferencesReader.ReadString();
                                        break;

                                    case "CaptureVideoDirectory":
                                        m_CaptureVideoDirectory = PreferencesReader.ReadString();
                                        break;

                                    case "RecentColors":
                                        ParseRecentColors(PreferencesReader);
                                        break;

                                    case "SURFParameters":
                                        ParseSurfParameters(PreferencesReader);
                                        break;

                                    default:
                                        // Preference from a newer file format...
                                        // We don't have a holder variable for it.
                                        break;
                                    }
                                }
                                else if (PreferencesReader.Name == "KinoveaPreferences")
                                {
                                    break;
                                }
                                else
                                {
                                    // Fermeture d'un tag interne.
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    log.Error("Error happenned while parsing preferences. We'll keep the default values.");
                }
                finally
                {
                    PreferencesReader.Close();
                }
            }
        }
コード例 #3
0
        public static InfosTextDecoration FromXml(XmlReader _xmlReader)
        {
            // When we land in this method we MUST already be at the "TextDecoration" node.

            InfosTextDecoration result = new InfosTextDecoration();
            string fontName            = "Arial";
            int    fontSize            = 8;

            while (_xmlReader.Read())
            {
                if (_xmlReader.IsStartElement())
                {
                    if (_xmlReader.Name == "FontName")
                    {
                        fontName = _xmlReader.ReadString();
                    }
                    else if (_xmlReader.Name == "FontSize")
                    {
                        fontSize = int.Parse(_xmlReader.ReadString());
                    }
                    else if (_xmlReader.Name == "ForeColor")
                    {
                        result.m_ForeColor = XmlHelper.ColorParse(_xmlReader.ReadString(), ';');
                    }
                    else if (_xmlReader.Name == "BackColor")
                    {
                        result.m_BackColor = XmlHelper.ColorParse(_xmlReader.ReadString(), ';');
                    }
                }
                else if (_xmlReader.Name == "TextDecoration")
                {
                    break;
                }
                else
                {
                    // Fermeture d'un tag interne.
                }
            }

            #region old format

            /*private static void ParseBackgroundBrush(XmlTextReader _xmlReader, KeyframeLabel _kfl)
             * {
             * while (_xmlReader.Read())
             * {
             * if (_xmlReader.IsStartElement())
             * {
             *  if (_xmlReader.Name == "Alpha")
             *  {
             *      _kfl.m_iBackgroundAlpha = int.Parse(_xmlReader.ReadString());
             *  }
             *  else if (_xmlReader.Name == "ColorRGB")
             *  {
             *      _kfl.BackgroundColor = XmlHelper.ColorParse(_xmlReader.ReadString(), ';');
             *  }
             * }
             * else if (_xmlReader.Name == "BackgroundBrush")
             * {
             *  break;
             * }
             * else
             * {
             *  // Fermeture d'un tag interne.
             * }
             * }
             *
             * }*/
            /*private static void ParseFont(XmlTextReader _xmlReader, KeyframeLabel _kfl)
             * {
             *  while (_xmlReader.Read())
             *  {
             *      if (_xmlReader.IsStartElement())
             *      {
             *          if (_xmlReader.Name == "Size")
             *          {
             *              _kfl.m_iFontSize = int.Parse(_xmlReader.ReadString());
             *          }
             *          else if (_xmlReader.Name == "Name")
             *          {
             *              _kfl.m_FontName = _xmlReader.ReadString();
             *          }
             *          else if (_xmlReader.Name == "ColorRGB")
             *          {
             *              _kfl.m_FontColor = XmlHelper.ColorParse(_xmlReader.ReadString(), ';');
             *          }
             *      }
             *      else if (_xmlReader.Name == "Font")
             *      {
             *          break;
             *      }
             *      else
             *      {
             *          // Fermeture d'un tag interne.
             *      }
             *  }
             * }*/
            #endregion

            result.m_Font = new Font(fontName, fontSize, FontStyle.Bold);
            result.FixForeColor();
            return(result);
        }