/// <summary> /// Form load handler /// </summary> private void MainApplicationForm_Load(object sender, EventArgs e) { fdSaveData.DefaultExt = Consts.Application.DefaultExtension; fdSaveData.Filter = Resources.Labels.FileFilter; fdOpenData.DefaultExt = Consts.Application.DefaultExtension; fdOpenData.Filter = Resources.Labels.FileFilter; keeper = MoneyDataKeeper.Instance; if ((Environment.GetCommandLineArgs().Count() == 1) && (Parameters.ShowOpenDialogEachStart)) { if (fdOpenData.ShowDialog(this) == DialogResult.OK) { keeper.Password = String.Empty; keeper.Filename = fdOpenData.FileName; } } FileLoadForm frmLoad = new FileLoadForm(Resources.Labels.ApplicationLoadingMessage, true); frmLoad.ShowDialog(this); updateFormTitle(); imageListTabs.ImageSize = new System.Drawing.Size(16, 16); imageListTabs.ColorDepth = ColorDepth.Depth32Bit; imageListTabs.TransparentColor = Color.Transparent; imageListTabs.Images.Add(Consts.ImageKeys.TabAbout, Properties.Resources.information); imageListTabs.Images.Add(Consts.ImageKeys.TabPlans, Properties.Resources.date); imageListTabs.Images.Add(Consts.ImageKeys.TabSettings, Properties.Resources.cog); imageListTabs.Images.Add(Consts.ImageKeys.TabReports, Properties.Resources.chart_bar); imageListTabs.Images.Add(Consts.ImageKeys.TabWelcome, Properties.Resources.star); imageListTabs.Images.Add(Consts.ImageKeys.TabTransactions, Properties.Resources.table_multiple); imageListTabs.Images.Add(Consts.ImageKeys.TabSearch, Properties.Resources.magnifier); imageListTabs.Images.Add(Consts.ImageKeys.TabAccounts, Properties.Resources.book_open); tabWelcome.ImageKey = Consts.ImageKeys.TabWelcome; tabAbout.ImageKey = Consts.ImageKeys.TabAbout; tabPlannedTransactions.ImageKey = Consts.ImageKeys.TabPlans; tabSettings.ImageKey = Consts.ImageKeys.TabSettings; tabReports.ImageKey = Consts.ImageKeys.TabReports; tabTransactions.ImageKey = Consts.ImageKeys.TabTransactions; tabSearch.ImageKey = Consts.ImageKeys.TabSearch; tabAccounts.ImageKey = Consts.ImageKeys.TabAccounts; // setting data binding column names lbAccounts.DisplayMember = MoneyDataSet.IDs.SpecialColumns.FullTitleColumnName; lbAccounts.ValueMember = keeper.DataSet.Accounts.IDColumn.ColumnName; lbTransactions.DisplayMember = MoneyDataSet.IDs.SpecialColumns.FullTitleColumnName; lbTransactions.ValueMember = keeper.DataSet.Transactions.IDColumn.ColumnName; lbPlannedTransactions.DisplayMember = MoneyDataSet.IDs.SpecialColumns.FullTitleColumnName; lbPlannedTransactions.ValueMember = keeper.DataSet.PlannedTransactions.IDColumn.ColumnName; // update accounts tab updateAccountsTab(); // setting transaction tab updateTransactionsTab(); // setting planned transaction tab updatePlannedTransactionsTab(); // updating welcome screen updateWelcomeTab(); // update Reports tab lbReports.DisplayMember = Reports.ReportEntry.FieldTitle; lbReports.ValueMember = Reports.ReportEntry.FieldID; lbReports.DataSource = Reports.GetAvailableReports(); // update Settings tab updateSettingsTab(); // setting about tab lblVersionApplication.Text = String.Format(Consts.UI.FullVersionFormat, Consts.Application.Version, Consts.Application.VersionCodeName); lblVersionAssembly.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); lblBuildDate.Text = (new DateTime(2000, 1, 1)).AddDays(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Build).ToShortDateString(); // update tag list on search tab updateTagCloud(); this.Activate(); if (!String.IsNullOrWhiteSpace(keeper.ValidationErrors)) { ErrorHelper.ShowErrorBox(keeper.ValidationErrors); } if (!Parameters.IntroductionShown) { showIntroduction(); Parameters.IntroductionShown = true; } if ((Parameters.CheckForUpdates) && (Parameters.LastUpdateDate.AddDays(Consts.Application.AutoUpdatePeriod) < DateTime.Now)) { bgwUpdateCheck.RunWorkerAsync(); Parameters.LastUpdateDate = DateTime.Now; } (new Forms.WelcomeScreenForm()).Show(); }
/// <summary> /// Open data file, showing "please wait" window /// </summary> private bool openDataFile() { if (fdOpenData.ShowDialog(this) == DialogResult.OK) { try { keeper.FileSave(); keeper.Password = String.Empty; keeper.Filename = fdOpenData.FileName; FileLoadForm frmLoad = new FileLoadForm(Resources.Labels.DataLoadingMessage, false); if (frmLoad.ShowDialog(this) != DialogResult.OK) { return false; } updateFormTitle(); updateFileSpecificSettings(); updateWelcomeTab(); updateTransactionsTab(); updatePlannedTransactionsTab(); updateAccountsTab(); updateTagCloud(); return true; } catch (Exception e) { ErrorHelper.ShowErrorBox(e: e); return false; } } return false; }