Example #1
0
 public static bool ReadSettings()
 {
     if (File.Exists("PhotoboothSettings.xml"))
     {
         try
         {
             string        settingsPath = "PhotoboothSettings.xml";
             var           xmlSave      = new PhotoBoothSetttings();
             XmlSerializer xmlSerial    = XmlSerializer.FromTypes(new[] { typeof(PhotoBoothSetttings) })[0];
             using (Stream fStream = new FileStream(settingsPath, FileMode.Open, FileAccess.Read, FileShare.None))
             {
                 xmlSave = (PhotoBoothSetttings)xmlSerial.Deserialize(fStream);
             }
             SideMargin           = xmlSave.SideMargin;
             TopMargin            = xmlSave.TopMargin;
             ImageGap             = xmlSave.ImageGap;
             WaitTimeInSeconds    = xmlSave.WaitTimeInSeconds;
             PrinterName          = xmlSave.PrinterName;
             BackgroundImagePath  = xmlSave.BackgroundImagePath;
             CameraName           = xmlSave.CameraName;
             VideoCapabilityIndex = xmlSave.VideoCapabilityIndex;
             SaveFolder           = xmlSave.SaveFolder;
             TestMode             = xmlSave.TestMode;
             return(true);
         }
         catch (Exception ex)
         {
         }
     }
     return(false);
 }
Example #2
0
        public static void WriteSettings()
        {
            string settingsPath = "PhotoboothSettings.xml";

            var xmlSave = new PhotoBoothSetttings();

            xmlSave.SideMargin           = SideMargin;
            xmlSave.TopMargin            = TopMargin;
            xmlSave.ImageGap             = ImageGap;
            xmlSave.WaitTimeInSeconds    = WaitTimeInSeconds;
            xmlSave.PrinterName          = PrinterName;
            xmlSave.BackgroundImagePath  = BackgroundImagePath;
            xmlSave.CameraName           = CameraName;
            xmlSave.VideoCapabilityIndex = VideoCapabilityIndex;
            xmlSave.SaveFolder           = SaveFolder;
            xmlSave.TestMode             = TestMode;
            XmlSerializer xmlSerial = XmlSerializer.FromTypes(new[] { typeof(PhotoBoothSetttings) })[0];

            try
            {
                using (Stream fStream = new FileStream(settingsPath, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    xmlSerial.Serialize(fStream, xmlSave);
                }
            }
            catch (Exception)
            {
            }
        }