Exemple #1
0
        private void SavePlusButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                if (this.currentTabIndex >= 0)
                {
                    try
                    {
                        SaveFileDialog dlg = new SaveFileDialog();
                        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;
                            }
                        }

                        FileExtensions flex = new FileExtensions();
                        dlg.Filter = flex.GetFilterString();
                        if (dlg.ShowDialog(this) ?? false)
                        {
                            this.tab[this.currentTabIndex].SaveFile(dlg.FileName);
                        }
                    }
                    catch (Exception exception)
                    {
                        StyledMessageBox.Show("ERROR", "Error Saving File" + exception.ToString());
                    }
                }
            }
            e.Handled = true;
        }
Exemple #2
0
        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());
                }
            }
        }
Exemple #3
0
        private void CommandOpen(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.CheckFileExists = true;
            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)
            {
                // No tabs / Non Empty new file / tab has some file open
                if (this.currentTabIndex < 0 || this.tab[this.currentTabIndex].TextEditor.Document.TextLength != 0 || this.tab[this.currentTabIndex].FullFileName != null)
                {
                    if (this.currentTabIndex >= 0)
                    {
                        tab[this.currentTabIndex].Title.Opacity         = 0.5;
                        tab[this.currentTabIndex].TextEditor.Visibility = Visibility.Hidden;
                    }

                    this.AddNewTab();

                    this.currentTabIndex = tab.Count - 1;
                    tab[this.currentTabIndex].TextEditor.Focus();
                }

                this.tab[this.currentTabIndex].OpenFile(dlg.FileName);
            }
        }
Exemple #4
0
        private void SavePlusButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                if (this.currentTabIndex >= 0)
                {
                    try
                    {
                        SaveFileDialog dlg = new SaveFileDialog();
                        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;
                            }
                        }

                        FileExtensions flex = new FileExtensions();
                        dlg.Filter = flex.GetFilterString();
                        if (dlg.ShowDialog(this) ?? false)
                        {
                            this.tab[this.currentTabIndex].SaveFile(dlg.FileName);
                        }
                    }
                    catch (Exception exception)
                    {
                        StyledMessageBox.Show("ERROR", "Error Saving File" + exception.ToString());
                    }
                }
            }
            e.Handled = true;
        }
Exemple #5
0
        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());
                }
            }
        }
Exemple #6
0
        private void CommandOpen(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.CheckFileExists = true;
            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)
            {
                // No tabs / Non Empty new file / tab has some file open
                if (this.currentTabIndex < 0 || this.tab[this.currentTabIndex].TextEditor.Document.TextLength != 0 || this.tab[this.currentTabIndex].FullFileName != null)
                {
                    if (this.currentTabIndex >= 0)
                    {
                        tab[this.currentTabIndex].Title.Opacity = 0.5;
                        tab[this.currentTabIndex].TextEditor.Visibility = Visibility.Hidden;
                    }

                    this.AddNewTab();

                    this.currentTabIndex = tab.Count - 1;
                    tab[this.currentTabIndex].TextEditor.Focus();
                }

                this.tab[this.currentTabIndex].OpenFile(dlg.FileName);
            }
        }