private void CommandSave(object sender, ExecutedRoutedEventArgs e)
{
if (this.currentTabIndex >= 0)
{
try
{
bool fileSaved = false;
if (this.tab[this.currentTabIndex].FullFileName != null)
{
this.tab[this.currentTabIndex].SaveFile(this.tab[this.currentTabIndex].FullFileName);
fileSaved = true;
}
else
{
SaveFileDialog dlg = new SaveFileDialog();
FileExtensions flex = new FileExtensions();
dlg.Filter = flex.GetFilterString();
if (this.currentTabIndex >= 0 && this.tab[this.currentTabIndex].FullFileName != null)
{
string initialDirectory = System.IO.Path.GetDirectoryName(this.tab[this.currentTabIndex].FullFileName);
if (initialDirectory != null && initialDirectory.Length != 0)
{
dlg.InitialDirectory = initialDirectory;
}
}
if (dlg.ShowDialog(this) ?? false)
{
this.tab[this.currentTabIndex].SaveFile(dlg.FileName);
fileSaved = true;
}
}
if (fileSaved)
{
this.SetStatusText("FILE SAVED");
System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(SaveDispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
dispatcherTimer.Start();
}
}
catch (Exception exception)
{
StyledMessageBox.Show("ERROR", "Error Saving File" + exception.ToString());
}
}
}