/// <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); } }
/// <summary> /// load settings from configuration /// </summary> /// <returns></returns> public bool LoadSettings(string ImportFileName) { string tmpConfigFileName = Config.GetFile(Config.Dir.Config, SettingsFileName); 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); LBMaxBlackLevel = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmBlackLevel, 32), 4), 255); LBMinBlackLevel = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmMinBlackLevel, 16), 4), 255); fboverScan = reader.GetValueAsInt(ViewModeSwitcherSectionName, FallBackOverScan, 8); CropLeft = reader.GetValueAsInt("tv", "cropleft", 0); CropRight = reader.GetValueAsInt("tv", "cropright", 0); CropTop = reader.GetValueAsInt("tv", "croptop", 0); CropBottom = reader.GetValueAsInt("tv", "cropbottom", 0); disableForVideo = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmDisableForVideo, false); disableLBForVideo = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmDisableLBForVideo, false); LBSymLimitPercent = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmSymLimitPercent, 10), 5), 90); LBdetectInterval = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmLBdetectInterval, 4), 2), 120); LBMaxCropLimitPercent = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmMaxCropLimitPercent, 12), 0), 50); DetectWidthPercent = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmDetectWidthPercent, 40), 10), 90); DetectHeightPercent = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmDetectHeightPercent, 40), 10), 90); if (verboseLog) { Log.Debug("ViewModeSwitcher: Global Rule, ShowSwitchMsg: " + ShowSwitchMsg); Log.Debug("ViewModeSwitcher: Global Rule, UseFallbackRule: " + UseFallbackRule); Log.Debug("ViewModeSwitcher: Global Rule, FallBackViewMode: " + FallBackViewMode); Log.Debug("ViewModeSwitcher: Global Rule, FallbackOverscan: " + fboverScan); Log.Debug("ViewModeSwitcher: Global Rule, DisableBBDetect: " + DisableLBGlobaly); Log.Debug("ViewModeSwitcher: Global Rule, BBMaxBlackLevel: " + LBMaxBlackLevel); Log.Debug("ViewModeSwitcher: Global Rule, BBMinBlackLevel: " + LBMinBlackLevel); Log.Debug("ViewModeSwitcher: Global Rule, BBSymLimitPercent: " + LBSymLimitPercent); Log.Debug("ViewModeSwitcher: Global Rule, BBdetectInterval: " + LBdetectInterval); Log.Debug("ViewModeSwitcher: Global Rule, BBMaxCropLimPercent: " + LBMaxCropLimitPercent); Log.Debug("ViewModeSwitcher: Global Rule, BBDetectWidthPercent: " + DetectWidthPercent); Log.Debug("ViewModeSwitcher: Global Rule, BBDetectHeightPercent: " + DetectHeightPercent); Log.Debug("ViewModeSwitcher: Global Rule, disableForVideo: " + disableForVideo); Log.Debug("ViewModeSwitcher: Global Rule, disableBBForVideo: " + disableLBForVideo); } 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 SD"; tmpRule.ARFrom = 1.2; tmpRule.ARTo = 1.46; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 799; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 599; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = true; tmpRule.AutoCrop = true; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "4:3 HD"; tmpRule.ARFrom = 1.2; tmpRule.ARTo = 1.46; tmpRule.MinWidth = 800; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 600; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 16; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "16:9 SD"; tmpRule.ARFrom = 1.7; tmpRule.ARTo = 1.9; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 799; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 599; tmpRule.ViewMode = Geometry.Type.Normal; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = true; tmpRule.AutoCrop = true; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "16:9 HD"; tmpRule.ARFrom = 1.7; tmpRule.ARTo = 1.9; tmpRule.MinWidth = 800; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 600; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Normal; tmpRule.OverScan = 16; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "21:9 SD"; tmpRule.ARFrom = 2.2; tmpRule.ARTo = 2.45; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 799; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 599; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = true; tmpRule.AutoCrop = true; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "21:9 HD"; tmpRule.ARFrom = 2.2; tmpRule.ARTo = 2.45; tmpRule.MinWidth = 800; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 600; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 16; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "4:3 inside 16:9"; tmpRule.ARFrom = -1.2; tmpRule.ARTo = -1.46; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "16:9 inside 4:3"; tmpRule.ARFrom = -1.47; tmpRule.ARTo = -1.95; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "21:9 inside 16:9"; tmpRule.ARFrom = -2.1; tmpRule.ARTo = -2.57; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = 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"); int tmpARFrom = Convert.ToInt32(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARFromX1000", "1200")); tmpRule.ARFrom = ((double)tmpARFrom) / 1000.0; int tmpARTo = Convert.ToInt32(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARToX1000", "1460")); tmpRule.ARTo = ((double)tmpARTo) / 1000.0; tmpRule.MinWidth = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinWidth", "200")); tmpRule.MaxWidth = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxWidth", "2000")); tmpRule.MinHeight = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinHeight", "200")); tmpRule.MaxHeight = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxHeight", "2000")); String tmpViewMode = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ViewMode", "Normal"); tmpRule.ViewMode = StringToViewMode(tmpViewMode); tmpRule.OverScan = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Overscan", "8")); tmpRule.EnableLBDetection = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "EnableLBDetection", false); tmpRule.AutoCrop = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "AutoCrop", false); tmpRule.MaxCrop = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxCrop", true); ViewModeRules.Add(tmpRule); if (verboseLog) { Log.Debug("ViewModeSwitcher: Rule " + i + ", Name: " + tmpRule.Name); Log.Debug("ViewModeSwitcher: Rule " + i + ", Enabled: " + tmpRule.Enabled); Log.Debug("ViewModeSwitcher: Rule " + i + ", ARFrom: " + tmpRule.ARFrom); Log.Debug("ViewModeSwitcher: Rule " + i + ", ARTo: " + tmpRule.ARTo); Log.Debug("ViewModeSwitcher: Rule " + i + ", MinWidth: " + tmpRule.MinWidth); Log.Debug("ViewModeSwitcher: Rule " + i + ", MaxWidth: " + tmpRule.MaxWidth); Log.Debug("ViewModeSwitcher: Rule " + i + ", MinHeight: " + tmpRule.MinHeight); Log.Debug("ViewModeSwitcher: Rule " + i + ", MaxHeight: " + tmpRule.MaxHeight); Log.Debug("ViewModeSwitcher: Rule " + i + ", AutoCrop: " + tmpRule.AutoCrop); Log.Debug("ViewModeSwitcher: Rule " + i + ", ViewMode: " + tmpRule.ViewMode); Log.Debug("ViewModeSwitcher: Rule " + i + ", MaxCrop: " + tmpRule.MaxCrop); Log.Debug("ViewModeSwitcher: Rule " + i + ", OverScan: " + tmpRule.OverScan); Log.Debug("ViewModeSwitcher: Rule " + i + ", EnLBDet: " + tmpRule.EnableLBDetection); } } return(tmpReturn); } }