コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: pwizard2/SqlPrep
        private void Window_Closed(object sender, EventArgs e)
        {
            var _h = new XmlDocumentHistory();

            if (ProcessedTabs > 0 && !DeleteHistory)
            {
                _h.SaveTabstoXml(Tabs.Items);
            }
            else
            {
                _h.DeleteHistory();
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: pwizard2/SqlPrep
        private void MnuCloseAll_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (ProcessedTabs > 0)
                {
                    var _confirm = MessageBox.Show("Do you want to save a copy of these processed queries?", "SqlPrep", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning, MessageBoxResult.Yes);


                    if (_confirm == MessageBoxResult.Yes)
                    {
                        var _s = new SaveFileDialog
                        {
                            Filter     = "XML Documents|*.xml",
                            DefaultExt = ".xml",
                            FileName   = $"Batch_{DateTime.Today.ToString("yyMMdd")}.xml"
                        };

                        var _result = _s.ShowDialog();

                        if (_result == true)
                        {
                            var _h = new XmlDocumentHistory();
                            _h.SaveTabstoXml(Tabs.Items, _s.FileName);
                        }
                        else
                        {
                            return;
                        }
                    }
                    else if (_confirm == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                }

                // Bugfix: LoadingFile prevents a new EditorDuo from showing up prematurely. --Will Kraft (3/22/2020).
                LoadingFile = true;
                Tabs.Items.Clear();
                MnuQueryList.Items.Clear();
                Fingerprints.Clear();
                LoadingFile = false;

                AddTab();
            }
            catch (Exception ex)
            {
                MessageBox.Show(DevMode ? ex.ToString() : ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: pwizard2/SqlPrep
        private void MnuOpen_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var _o = new OpenFileDialog()
                {
                    Filter     = "XML Documents|*.xml",
                    DefaultExt = ".xml",
                };
                var _result = _o.ShowDialog();

                if (_result == true)
                {
                    var _dlg = new ImportDialog
                    {
                        Owner = this
                    };

                    _dlg.ShowDialog();

                    if (!_dlg.Append)
                    {
                        LoadingFile = true;
                        Tabs.Items.Clear();
                        MnuQueryList.Items.Clear();
                        Fingerprints.Clear();
                    }


                    var _h = new XmlDocumentHistory();
                    _h.RegenerateTab += _xml_RegenerateTab;
                    _h.RecoverTabs(_o.FileName, Fingerprints);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(DevMode ? ex.ToString() : ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                LoadingFile = false;
            }
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: pwizard2/SqlPrep
        private void MnuSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var _s = new SaveFileDialog
                {
                    Filter     = "XML Documents|*.xml",
                    DefaultExt = ".xml",
                    FileName   = $"Batch_{DateTime.Today.ToString("yyMMdd")}.xml"
                };

                var _result = _s.ShowDialog();

                if (_result == true)
                {
                    var _h = new XmlDocumentHistory();
                    _h.SaveTabstoXml(Tabs.Items, _s.FileName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(DevMode ? ex.ToString() : ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: pwizard2/SqlPrep
        public MainWindow()
        {
            InitializeComponent();
            LoadingFile = false;

            var _newTabCmd = new RoutedCommand();

            _newTabCmd.InputGestures.Add(new KeyGesture(Key.N, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(_newTabCmd, NewTabClick));

            var _stripCmd = new RoutedCommand();

            _stripCmd.InputGestures.Add(new KeyGesture(Key.F3));
            CommandBindings.Add(new CommandBinding(_stripCmd, StripClick));

            var _prepCmd = new RoutedCommand();

            _prepCmd.InputGestures.Add(new KeyGesture(Key.F2));
            CommandBindings.Add(new CommandBinding(_prepCmd, PrepareClick));

            var _clCmd = new RoutedCommand();

            _clCmd.InputGestures.Add(new KeyGesture(Key.L, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(_clCmd, CopyLowerClick));

            var _cuCmd = new RoutedCommand();

            _cuCmd.InputGestures.Add(new KeyGesture(Key.U, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(_cuCmd, CopyUpperClick));

            var _closeTcmd = new RoutedCommand();

            _closeTcmd.InputGestures.Add(new KeyGesture(Key.D, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(_closeTcmd, CloseCurrentTabClick));

            var _pasteTcmd = new RoutedCommand();

            _pasteTcmd.InputGestures.Add(new KeyGesture(Key.V, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(_pasteTcmd, PasteClick));

            Fingerprints = new List <Guid>();

            var _xml = new XmlDocumentHistory();

            _xml.RegenerateTab += _xml_RegenerateTab;

            if (_xml.HistoryTabCount > 0)
            {
                _xml.RecoverTabs();
            }
            else // Start empty session...
            {
                AddTab();
                CurrentEditor.InputFocus();
            }

            MnuDeleteHistory.IsEnabled = ProcessedTabs > 0 || XmlDocumentHistory.HistoryExists;

            // Scale to primary screen size to avoid oversize windows on that small-screen laptop I'm
            // using for work these days. --Will Kraft (3/22/2020).
            Width  = SystemParameters.PrimaryScreenWidth / 1.8;
            Height = SystemParameters.PrimaryScreenHeight / 1.4;
        }