public DocumentViewModel() { WindowTitle = new PropertyDelegateReadonlyModel <string>(() => ".NET Master Password - " + FilePathName.Value + " " + (HasChanges.Value ? "*" : "")); HasChanges = new PropertyReadonlyModel <bool>(); FilePathValid = new PropertyReadonlyModel <bool>(); FilePathName = new PropertyReadonlyModel <string>(FileNameNew); WindowTitle.MonitorForChanges(HasChanges, FilePathName); Open = new DelegateCommand(() => DoOpen()); ImportForMerge = new DelegateCommand(DoImportMerge); Save = new DelegateCommand(() => DoSave()); SaveAs = new DelegateCommand(() => DoSaveAs()); New = new DelegateCommand(DoNew); // data Config = new ConfigurationViewModel(); Config.DetectChanges.DataChanged += () => HasChanges.SetValue(true); // try to load last file try { if (Settings.Default.HasMostRecentFile) { // we have an old path PerformOpen(Settings.Default.MostRecentFile); } } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } HasChanges.SetValue(false); }
public DocumentViewModel() { WindowTitle = new PropertyDelegateReadonlyModel<string>(() => ".NET Master Password - " + FilePathName.Value + " " + (HasChanges.Value ? "*" : "")); HasChanges = new PropertyReadonlyModel<bool>(); FilePathValid = new PropertyReadonlyModel<bool>(); FilePathName = new PropertyReadonlyModel<string>(FileNameNew); WindowTitle.MonitorForChanges(HasChanges, FilePathName); Open = new DelegateCommand(() => DoOpen()); Save = new DelegateCommand(() => DoSave()); SaveAs = new DelegateCommand(() => DoSaveAs()); New = new DelegateCommand(DoNew); // data Config = new ConfigurationViewModel(); Config.DetectChanges.DataChanged += () => HasChanges.SetValue(true); // try to load last file try { if (Settings.Default.HasMostRecentFile) { // we have an old path PerformOpen(Settings.Default.MostRecentFile); } } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } HasChanges.SetValue(false); }