Exemplo n.º 1
0
        /// <summary>
        /// 获取用户上次使用的分辨率
        /// </summary>
        /// <returns></returns>
        public string GetLastCamera()
        {
            string Resolution = null;

            if (!File.Exists(_CameraHistoryRealPath))
            {
                return(null);
            }

            //先解密这个文件
            Base64Helper.Base64Decode4txtFile(_CameraHistoryRealPath);

            XmlTextReader reader = new XmlTextReader(_CameraHistoryRealPath);

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "LastCamera")
                    {
                        Resolution = reader.ReadElementContentAsString();
                    }
                }
            }
            //关闭流
            reader.Close();
            reader = null;
            GC.Collect();
            //重新加密这个文件
            Base64Helper.Base64Encode4txtFile(_CameraHistoryRealPath);
            return(Resolution);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取当前用户保存的所有摄像头设置
        /// </summary>
        /// <returns>当前用户保存的所有摄像头设置</returns>
        public List <VideoSettingEntity> GetAllVideoSettings()
        {
            List <VideoSettingEntity> result = new List <VideoSettingEntity>();

            #region 读取文件
            if (!File.Exists(_VideoSettingRealPath))
            {
                return(null);
            }

            //先解密这个文件
            Base64Helper.Base64Decode4txtFile(_VideoSettingRealPath);

            XmlTextReader      reader  = new XmlTextReader(_VideoSettingRealPath);
            VideoSettingEntity setting = null;
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == nameof(VideoSettingEntity))
                    {
                        setting = new VideoSettingEntity();
                        result.Add(setting);
                    }
                    if (reader.Name == nameof(setting.VideoSettingName))
                    {
                        setting.VideoSettingName = reader.ReadElementContentAsString();
                    }
                    else if (reader.Name == nameof(setting.Brightness))
                    {
                        if (setting != null)
                        {
                            setting.Brightness = reader.ReadElementContentAsInt();
                        }
                    }
                    else if (reader.Name == nameof(setting.AutoBrightness))
                    {
                        if (setting != null)
                        {
                            setting.AutoBrightness = reader.ReadElementContentAsBoolean();
                        }
                    }
                    else if (reader.Name == nameof(setting.ContrastRatio))
                    {
                        if (setting != null)
                        {
                            setting.ContrastRatio = reader.ReadElementContentAsInt();
                        }
                    }
                    else if (reader.Name == nameof(setting.AutoContrastRatio))
                    {
                        if (setting != null)
                        {
                            setting.AutoContrastRatio = reader.ReadElementContentAsBoolean();
                        }
                    }
                    else if (reader.Name == nameof(setting.Saturation))
                    {
                        if (setting != null)
                        {
                            setting.Saturation = reader.ReadElementContentAsInt();
                        }
                    }
                    else if (reader.Name == nameof(setting.AutoSaturation))
                    {
                        if (setting != null)
                        {
                            setting.AutoSaturation = reader.ReadElementContentAsBoolean();
                        }
                    }
                    else if (reader.Name == nameof(setting.DefaultSetting))
                    {
                        if (setting != null)
                        {
                            setting.DefaultSetting = reader.ReadElementContentAsBoolean();
                        }
                    }
                    else if (reader.Name == nameof(setting.Hue))
                    {
                        if (setting != null)
                        {
                            setting.Hue = reader.ReadElementContentAsInt();
                        }
                    }
                    else if (reader.Name == nameof(setting.AutoHue))
                    {
                        if (setting != null)
                        {
                            setting.AutoHue = reader.ReadElementContentAsBoolean();
                        }
                    }
                    else if (reader.Name == nameof(setting.Sharpness))
                    {
                        if (setting != null)
                        {
                            setting.Sharpness = reader.ReadElementContentAsInt();
                        }
                    }
                    else if (reader.Name == nameof(setting.AutoSharpness))
                    {
                        if (setting != null)
                        {
                            setting.AutoSharpness = reader.ReadElementContentAsBoolean();
                        }
                    }
                    else if (reader.Name == nameof(setting.Gamma))
                    {
                        if (setting != null)
                        {
                            setting.Gamma = reader.ReadElementContentAsInt();
                        }
                    }
                    else if (reader.Name == nameof(setting.AutoGamma))
                    {
                        if (setting != null)
                        {
                            setting.AutoGamma = reader.ReadElementContentAsBoolean();
                        }
                    }
                    else if (reader.Name == nameof(setting.ColorEnable))
                    {
                        if (setting != null)
                        {
                            setting.ColorEnable = reader.ReadElementContentAsBoolean();
                        }
                    }
                    else if (reader.Name == nameof(setting.WhiteBalance))
                    {
                        if (setting != null)
                        {
                            setting.WhiteBalance = reader.ReadElementContentAsInt();
                        }
                    }
                    else if (reader.Name == nameof(setting.AutoWhiteBalance))
                    {
                        if (setting != null)
                        {
                            setting.AutoWhiteBalance = reader.ReadElementContentAsBoolean();
                        }
                    }
                    else if (reader.Name == nameof(setting.BacklightCompensation))
                    {
                        if (setting != null)
                        {
                            setting.BacklightCompensation = reader.ReadElementContentAsInt();
                        }
                    }
                    else if (reader.Name == nameof(setting.AutoBacklightCompensation))
                    {
                        if (setting != null)
                        {
                            setting.AutoBacklightCompensation = reader.ReadElementContentAsBoolean();
                        }
                    }
                    else if (reader.Name == nameof(setting.Gain))
                    {
                        if (setting != null)
                        {
                            setting.Gain = reader.ReadElementContentAsInt();
                        }
                    }
                    else if (reader.Name == nameof(setting.AutoGain))
                    {
                        if (setting != null)
                        {
                            setting.AutoGain = reader.ReadElementContentAsBoolean();
                        }
                    }
                }
            }
            //关闭流
            reader.Close();
            reader = null;
            GC.Collect();
            #endregion
            //重新加密这个文件
            Base64Helper.Base64Encode4txtFile(_VideoSettingRealPath);
            return(result);
        }