Ejemplo n.º 1
0
        private void SaveToFile(TabPage tabPage, string filePath)
        {
            IDbObjContentDisplayer control = this.GetUcControlInterface(tabPage);

            if (control != null)
            {
                control.Save(new ContentSaveInfo()
                {
                    FilePath = filePath
                });
            }
        }
Ejemplo n.º 2
0
        private bool CloseTabPage(int tabPageIndex)
        {
            bool canClose = true;

            TabPage tabPage = this.tabControl1.TabPages[tabPageIndex];

            DatabaseObjectDisplayInfo info = tabPage.Tag as DatabaseObjectDisplayInfo;

            if (info != null && info.IsNew)
            {
                IDbObjContentDisplayer control = this.GetUcControlInterface(tabPage);

                bool saveRequired = false;

                if (control is UC_SqlQuery sqlQuery)
                {
                    if (sqlQuery.Editor.Text.Trim().Length > 0)
                    {
                        saveRequired = true;
                    }
                }

                if (saveRequired)
                {
                    DialogResult result = MessageBox.Show($"Do you want to save {info.Name}?", "Confirm", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                    if (result == DialogResult.Yes)
                    {
                        this.Save();
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        canClose = false;
                    }
                }
            }

            if (canClose)
            {
                this.tabControl1.TabPages.RemoveAt(tabPageIndex);
                this.dictCloseButtonRectangle.Remove(tabPageIndex);
            }

            this.SetControlVisible();

            return(canClose);
        }