Example #1
0
        public static EAverageStorageLoadResult Load(out AverageStorage storage)
        {
            storage = null;

            try {
                string filepath = Path.Combine(Environment.CurrentDirectory, "Statistics.xml");
                if (File.Exists(filepath) == false)
                {
                    return(EAverageStorageLoadResult.FailedNotFound);
                }

                XmlSerializer xml = new XmlSerializer(typeof(AverageStorage));
                using (FileStream fs = File.OpenRead(filepath)) {
                    storage = (AverageStorage)xml.Deserialize(fs);
                }
            } catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex);
                storage = null;

                return(EAverageStorageLoadResult.FailedException);
            }

            return(EAverageStorageLoadResult.Success);
        }
Example #2
0
		private void frmMain_Load(object sender, EventArgs e) {
			// Load locale
			if (Properties.Settings.Default.SelectedLanguage == ELanguage.None) {
				Program.LoadLanguage(this);
			}

			// Load last used device
			if (string.IsNullOrEmpty(Properties.Settings.Default.SelectedDevice) == false) {
				if (SelectDevice(Properties.Settings.Default.SelectedDevice) == false) {
					Properties.Settings.Default.SelectedDevice = null;
				}
			}

			// CLeanup timer (10sec)
			mCleanupTimer = new System.Windows.Forms.Timer();
			mCleanupTimer.Interval = 10000;
			mCleanupTimer.Tick += new EventHandler(CleanupTimer_Tick);
			mCleanupTimer.Enabled = true;
			mCleanupTimer.Start();

			// Load item stats
			var avgStorageLoadResult = AverageStorage.Load(out ItemStats);
			if (avgStorageLoadResult == EAverageStorageLoadResult.FailedException) {
				MessageBox.Show("Failed to load \"Statistics.xml\".", "Statistics load error", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
			// Failed or file not found
			if (ItemStats == null) {
				ItemStats = new AverageStorage();
			}

			// Load filter profiles
			if (LoadFilterProfiles() == false) {
				return;
			}
		}
Example #3
0
		public static EAverageStorageLoadResult Load(out AverageStorage storage) {
			storage = null;

			try {
				string filepath = Path.Combine(Environment.CurrentDirectory, "Statistics.xml");
				if (File.Exists(filepath) == false) {
					return EAverageStorageLoadResult.FailedNotFound;
				}

				XmlSerializer xml = new XmlSerializer(typeof(AverageStorage));
				using (FileStream fs = File.OpenRead(filepath)) {
					storage = (AverageStorage)xml.Deserialize(fs);
				}
			} catch (Exception ex) {
				System.Diagnostics.Debug.WriteLine(ex);
				storage = null;

				return EAverageStorageLoadResult.FailedException;
			}

			return EAverageStorageLoadResult.Success;
		}