Exemplo n.º 1
0
        public void SaveSettings(string ExportFileName)
        {
            string tmpConfigFileName = Config.GetFile(Config.Dir.Config, "ViewModeSwitcher.xml");

            if (ExportFileName != string.Empty)
            {
                tmpConfigFileName = ExportFileName;
            }

            using (Settings xmlwriter = new Settings(tmpConfigFileName))
            {
                xmlwriter.SetValueAsBool(ViewModeSwitcherSectionName, ParmDisableLBGlobaly, DisableLBGlobaly);
                xmlwriter.SetValueAsBool(ViewModeSwitcherSectionName, ParmVerboselog, verboseLog);
                xmlwriter.SetValueAsBool(ViewModeSwitcherSectionName, ParmShowSwitchMsg, ShowSwitchMsg);
                xmlwriter.SetValueAsBool(ViewModeSwitcherSectionName, ParmUseFallbackRule, UseFallbackRule);
                xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmFallbackViewMode, FallBackViewMode.ToString());
                xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmRuleCount, ViewModeRules.Count.ToString());
                xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmBlackLevel, LBBlackLevel.ToString());
                xmlwriter.SetValue(ViewModeSwitcherSectionName, FallBackOverScan, fboverScan.ToString());

                for (int i = 1; i <= ViewModeRules.Count; i++)
                {
                    Rule tmpRule = ViewModeRules[i - 1];
                    xmlwriter.SetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Enabled",
                                             tmpRule.Enabled);
                    xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Name", tmpRule.Name);
                    xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARFrom",
                                       tmpRule.ARFrom.ToString());
                    xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARTo",
                                       tmpRule.ARTo.ToString());
                    xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinWidth",
                                       tmpRule.MinWidth.ToString());
                    xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxWidth",
                                       tmpRule.MaxWidth.ToString());
                    xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinHeight",
                                       tmpRule.MinHeight.ToString());
                    xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxHeight",
                                       tmpRule.MaxHeight.ToString());
                    xmlwriter.SetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ChangeAR",
                                             tmpRule.ChangeAR);
                    xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ViewMode",
                                       tmpRule.ViewMode.ToString());
                    xmlwriter.SetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ChangeOS",
                                             tmpRule.ChangeOs);
                    xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Overscan",
                                       tmpRule.OverScan.ToString());
                    xmlwriter.SetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "EnableLBDetection",
                                             tmpRule.EnableLBDetection);

                    xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmRulePrefix + i + "VerticalOffSetZoom",
                                       tmpRule.VerticalOffSetZoom.ToString());
                    xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmRulePrefix + i + "VerticalOffSet14_9",
                                       tmpRule.VerticalOffSet14_9.ToString());
                    xmlwriter.SetValue(ViewModeSwitcherSectionName, ParmRulePrefix + i + "VerticalOffSetWide14_9",
                                       tmpRule.VerticalOffSetWide14_9.ToString());
                }
                if (ExportFileName != string.Empty)
                {
                    Settings.SaveCache();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// load settings from configuration
        /// </summary>
        /// <returns></returns>
        public bool LoadSettings(string ImportFileName)
        {
            string tmpConfigFileName = Config.GetFile(Config.Dir.Config, "ViewModeSwitcher.xml");

            if (ImportFileName != string.Empty)
            {
                tmpConfigFileName = ImportFileName;
            }

            using (Settings reader = new Settings(tmpConfigFileName))
            {
                verboseLog      = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmVerboselog, false);
                ShowSwitchMsg   = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmShowSwitchMsg, false);
                UseFallbackRule = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmUseFallbackRule, true);
                String tmpFallbackViewMode = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmFallbackViewMode, "Normal");
                FallBackViewMode = StringToViewMode(tmpFallbackViewMode);
                DisableLBGlobaly = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmDisableLBGlobaly, false);
                LBBlackLevel     = reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmBlackLevel, 40);
                fboverScan       = reader.GetValueAsInt(ViewModeSwitcherSectionName, FallBackOverScan, 0);
                CropLeft         = reader.GetValueAsInt("tv", "cropleft", 0);
                CropRight        = reader.GetValueAsInt("tv", "cropright", 0);
                CropTop          = reader.GetValueAsInt("tv", "croptop", 0);
                CropBottom       = reader.GetValueAsInt("tv", "cropbottom", 0);

                bool tmpReturn = false;
                ViewModeRules.Clear();
                int tmpRuleCount = reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmRuleCount, 0);
                if (tmpRuleCount <= 0)
                {
                    Rule tmpRule = new Rule();
                    tmpRule.Enabled           = true;
                    tmpRule.Name              = "4:3";
                    tmpRule.ARFrom            = 1.1f;
                    tmpRule.ARTo              = 1.334f;
                    tmpRule.MinWidth          = 200;
                    tmpRule.MaxWidth          = 2000;
                    tmpRule.MinHeight         = 200;
                    tmpRule.MaxHeight         = 2000;
                    tmpRule.ChangeAR          = true;
                    tmpRule.ViewMode          = Geometry.Type.NonLinearStretch;
                    tmpRule.ChangeOs          = true;
                    tmpRule.OverScan          = 8;
                    tmpRule.EnableLBDetection = true;
                    ViewModeRules.Add(tmpRule);

                    tmpRule                   = new Rule();
                    tmpRule.Enabled           = true;
                    tmpRule.Name              = "16:9";
                    tmpRule.ARFrom            = 1.77f;
                    tmpRule.ARTo              = 1.78f;
                    tmpRule.MinWidth          = 200;
                    tmpRule.MaxWidth          = 2000;
                    tmpRule.MinHeight         = 200;
                    tmpRule.MaxHeight         = 2000;
                    tmpRule.ChangeAR          = true;
                    tmpRule.ViewMode          = Geometry.Type.Normal;
                    tmpRule.ChangeOs          = true;
                    tmpRule.OverScan          = 8;
                    tmpRule.EnableLBDetection = true;
                    ViewModeRules.Add(tmpRule);
                    return(true);
                }

                for (int i = 1; i <= tmpRuleCount; i++)
                {
                    Rule tmpRule = new Rule();
                    tmpRule.Enabled = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Enabled", false);
                    if (tmpRule.Enabled)
                    {
                        tmpReturn = true;
                    }
                    tmpRule.Name   = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Name", "noname");
                    tmpRule.ARFrom =
                        (float)
                        Convert.ToDouble(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARFrom", "0"));
                    tmpRule.ARTo =
                        (float)
                        Convert.ToDouble(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARTo", "0"));
                    tmpRule.MinWidth =
                        Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinWidth", "0"));
                    tmpRule.MaxWidth =
                        Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxWidth", "0"));
                    tmpRule.MinHeight =
                        Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinHeight", "0"));
                    tmpRule.MaxHeight =
                        Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxHeight", "0"));
                    tmpRule.ChangeAR = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ChangeAR", true);
                    String tmpViewMode = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ViewMode",
                                                                 "Normal");
                    tmpRule.ViewMode = StringToViewMode(tmpViewMode);
                    tmpRule.ChangeOs = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ChangeOS", true);
                    tmpRule.OverScan =
                        Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Overscan", "0"));
                    tmpRule.EnableLBDetection = reader.GetValueAsBool(ViewModeSwitcherSectionName,
                                                                      ParmRulePrefix + i + "EnableLBDetection", false);
                    tmpRule.VerticalOffSetZoom =
                        Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName,
                                                                ParmRulePrefix + i + "VerticalOffSetZoom", "0"));
                    tmpRule.VerticalOffSet14_9 =
                        Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName,
                                                                ParmRulePrefix + i + "VerticalOffSet14_9", "0"));
                    tmpRule.VerticalOffSetWide14_9 =
                        Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName,
                                                                ParmRulePrefix + i + "VerticalOffSetWide14_9", "0"));
                    ViewModeRules.Add(tmpRule);
                }
                return(tmpReturn);
            }
        }