Example #1
0
        public MainForm(string filename)
        {
            InitializeComponent();

            // For performance https://stackoverflow.com/questions/4255148/how-to-improve-painting-performance-of-datagridview
            grdResult.DoubleBuffered(true);

            _synchronizationContext = SynchronizationContext.Current;

            _codeCompletion = new SqlCodeCompletion(txtSql, imgCodeCompletion);

            if (string.IsNullOrWhiteSpace(filename))
            {
                this.Disconnect();
            }
            else
            {
                this.Connect(new ConnectionString(filename));
            }

            txtSql.ActiveTextAreaControl.TextArea.Caret.PositionChanged += (s, e) =>
            {
                if (this.ActiveTask == null)
                {
                    return;
                }

                this.ActiveTask.EditorContent = txtSql.Text;
                this.ActiveTask.SelectedTab   = tabResult.SelectedTab.Name;
                this.ActiveTask.Position      = new Tuple <int, int>(txtSql.ActiveTextAreaControl.TextArea.Caret.Line, txtSql.ActiveTextAreaControl.TextArea.Caret.Column);

                lblCursor.Text = $"Line: {(txtSql.ActiveTextAreaControl.Caret.Line + 1)} - Column: {(txtSql.ActiveTextAreaControl.Caret.Column + 1)}";
            };

            // stop all threads
            this.FormClosing += (s, e) =>
            {
                if (_db != null)
                {
                    this.Disconnect();
                }
            };

            // set assembly version on window title
            this.Text += $" (v.{typeof(MainForm).Assembly.GetName().Version.ToString()})";
        }
Example #2
0
        public MainForm(string filename)
        {
            InitializeComponent();

            // For performance https://stackoverflow.com/questions/4255148/how-to-improve-painting-performance-of-datagridview
            grdResult.DoubleBuffered(true);

            _synchronizationContext = SynchronizationContext.Current;

            _codeCompletion = new SqlCodeCompletion(txtSql, imgCodeCompletion);

            if (string.IsNullOrWhiteSpace(filename))
            {
                this.Disconnect();
            }
            else
            {
                this.Connect(new ConnectionString(filename));
            }

            txtSql.ActiveTextAreaControl.TextArea.Caret.PositionChanged += (s, e) =>
            {
                if (this.ActiveTask == null)
                {
                    return;
                }

                this.ActiveTask.EditorContent = txtSql.Text;
                this.ActiveTask.SelectedTab   = tabResult.SelectedTab.Name;
                this.ActiveTask.Position      = new Tuple <int, int>(txtSql.ActiveTextAreaControl.TextArea.Caret.Line, txtSql.ActiveTextAreaControl.TextArea.Caret.Column);

                lblCursor.Text = $"Line: {(txtSql.ActiveTextAreaControl.Caret.Line + 1)} - Column: {(txtSql.ActiveTextAreaControl.Caret.Column + 1)}";
            };

            // stop all threads
            this.FormClosing += (s, e) =>
            {
                if (_db != null)
                {
                    this.Disconnect();
                }
            };

            // set assembly version on window title
            this.Text += $" (v{typeof(MainForm).Assembly.GetName().Version.ToString()})";

            // load last db

            if (AppSettingsManager.ApplicationSettings.LoadLastDbOnStartup && AppSettingsManager.IsLastDbExist())
            {
                this.Connect(AppSettingsManager.ApplicationSettings.LastConnectionStrings);
            }

            // set load last db status to checkbox

            loadLastDb.Checked       = AppSettingsManager.ApplicationSettings.LoadLastDbOnStartup;
            maxRecentListItems.Value = AppSettingsManager.ApplicationSettings.MaxRecentListItems;

            // validate recent list
            AppSettingsManager.ValidateRecentList();

            // add tooltip to Max Recent List Items UpDown Counter
            maxRecentItemsTooltip.SetToolTip(maxRecentListItems, "Max Recent Items, (Apply After Restart)");

            // populate recent db list
            PopulateRecentList();
        }