⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbquery.cs

📁 通过数据库结构自动 生成三层结构代码,相当不错的一款软件
💻 CS
📖 第 1 页 / 共 4 页
字号:
                {
                    item16.MenuItems.Add(item17);
                }
                foreach (XmlNode node in elementsByTagName[0].ChildNodes)
                {
                    SnippetMenuItem item18 = new SnippetMenuItem();
                    item18.Text = node.Attributes["name"].Value;
                    item18.statement = node.InnerText;
                    item18.Click += new EventHandler(this.miSnippet_Click);
                    item16.MenuItems.Add(item18);
                }
                this.cmShortcutMeny.Show(this.txtContent, new Point(e.X, e.Y));
            }
        }

        public void RefreshLineRangeColor(int firstLine, int toLine)
        {
        }

        public int Replace(Regex regex, int startPos, string replaceWith)
        {
            if (this.txtContent.SelectedText.Length > 0)
            {
                int offset = this.txtContent.ActiveTextAreaControl.SelectionManager.SelectionCollection[0].Offset;
                int length = this.txtContent.SelectedText.Length;
                this.txtContent.Document.Replace(offset, length, replaceWith);
                return this.Find(regex, length + offset);
            }
            string input = this.txtContent.Text.Substring(startPos);
            Match match = regex.Match(input);
            if (!match.Success)
            {
                MessageBox.Show("没有找到指定文本.", "Codematic", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return 0;
            }
            this.txtContent.Document.Replace(match.Index + startPos, match.Length, replaceWith);
            return ((match.Index + match.Length) + startPos);
        }

        public void ReplaceAll(Regex regex, string replaceWith)
        {
            string text = this.txtContent.Text;
            this.txtContent.Text = regex.Replace(this.txtContent.Text, replaceWith);
        }

        public void RunCurrentQuery()
        {
            try
            {
                this.RunQuery();
            }
            catch (Exception exception)
            {
                LogInfo.WriteLog(exception);
            }
        }

        public void RunQuery()
        {
            this.ExecuteSql();
        }

        public void RunQueryLine()
        {
            Point positionFromCharIndex = this.txtContent.GetPositionFromCharIndex(this.txtContent.SelectionStart);
            positionFromCharIndex.X = 0;
            int charIndexFromPosition = this.txtContent.GetCharIndexFromPosition(positionFromCharIndex);
            int index = this.txtContent.Text.IndexOf("\n", charIndexFromPosition);
            if (index == -1)
            {
                index = this.txtContent.Text.Length;
            }
            this.txtContent.Select(charIndexFromPosition, index - charIndexFromPosition);
            this.RunQuery();
        }

        public void SaveAs(string path)
        {
            try
            {
                FileInfo info = new FileInfo(path);
                if (info.Exists && ((info.Attributes & FileAttributes.ReadOnly) != 0))
                {
                    if (MessageBox.Show("Overwrite read-only file?", path, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                    {
                        return;
                    }
                    info.Attributes -= 1;
                    info.Delete();
                }
                this.txtContent.SaveFile(path);
                this.FileName = path;
            }
            catch (Exception exception)
            {
                LogInfo.WriteLog(exception);
                MessageBox.Show(string.Format("Errors Ocurred\n{0}", exception.Message), "Save Error", MessageBoxButtons.OK);
            }
        }

        public void SendToOutPutWindow()
        {
        }

        public void SetDatabaseConnection(string dbName, IDbConnection conn)
        {
        }

        private void SetDragAndDropContextMenu(TreeNode node)
        {
            foreach (MenuItem item in this.cmDragAndDrp.MenuItems)
            {
                item.Visible = false;
            }
            this.menuItemObjectName.Visible = true;
            this.menuItemObjectName.Text = node.Text;
            this.menuItemSplitter.Visible = true;
            if ((node.Tag.ToString() == "table") || (node.Tag.ToString() == "view"))
            {
                this.menuItemSelect1.Visible = true;
                this.menuItemSelect2.Visible = true;
                this.menuItemJoin.Visible = true;
                this.menuItemLeftOuterJoin.Visible = true;
                this.menuItemRightOuterJoin.Visible = true;
            }
            else
            {
                bool flag1 = node.Tag.ToString() == "column";
            }
        }

        private void SetDragAndDropMenuIcons()
        {
        }

        public void StopCurrentExecution()
        {
            this.txtContent.Enabled = true;
        }

        private void TextArea_Click(object sender, EventArgs e)
        {
            this.txtContent.ActiveTextAreaControl.Caret.Line.ToString();
            this.txtContent.ActiveTextAreaControl.Caret.Column.ToString();
        }

        private void TextArea_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetData("System.Windows.Forms.TreeNode", false) != null)
            {
                TreeNode data = (TreeNode) e.Data.GetData("System.Windows.Forms.TreeNode", false);
                if (((data.Tag.ToString() == "table") || (data.Tag.ToString() == "view")) || (data.Tag.ToString() == "column"))
                {
                    Rectangle rectangle = this.txtContent.RectangleToClient(this.txtContent.ClientRectangle);
                    Point position = new Point(e.X + rectangle.X, e.Y + rectangle.Y);
                    this._dragPos = this.txtContent.GetCharIndexFromPosition(position);
                    this._dragObject = data;
                    string text = data.Text;
                    this.SetDragAndDropContextMenu(data);
                    this.cmDragAndDrp.Show(this.txtContent, position);
                }
            }
            else if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] strArray = (string[]) e.Data.GetData(DataFormats.FileDrop);
                try
                {
                    string path = strArray[0];
                    if (strArray.Length <= 1)
                    {
                        MainForm mdiParentForm = (MainForm) this.MdiParentForm;
                        Path.GetFileName(path);
                        string str2 = "";
                        StreamReader reader = new StreamReader(path);
                        str2 = reader.ReadToEnd();
                        reader.Close();
                        reader = null;
                        this.Content = str2;
                    }
                }
                catch (Exception exception)
                {
                    LogInfo.WriteLog(exception);
                    MessageBox.Show(exception.Message);
                }
            }
        }

        private void TextArea_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetData("System.Windows.Forms.TreeNode", false) != null)
            {
                TreeNode data = (TreeNode) e.Data.GetData("System.Windows.Forms.TreeNode", false);
                if ((data.Tag.ToString() == "table") || (data.Tag.ToString() == "view"))
                {
                    e.Effect = DragDropEffects.Copy;
                }
                else if (data.Tag.ToString() == "column")
                {
                    e.Effect = DragDropEffects.Copy;
                }
            }
            else if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.Copy;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }

        private void TextArea_KeyPress(object sender, KeyPressEventArgs e)
        {
            char keyChar = e.KeyChar;
            if (((keyChar != '\b') && (keyChar != '\r')) && (keyChar != '\x001b'))
            {
                this.keyPressCount++;
                if (this.Text.IndexOf("*") <= 0)
                {
                    this.Text = this.Text + "*";
                }
            }
        }

        private void TextArea_KeyUp(object sender, KeyEventArgs e)
        {
            if ((((e.KeyCode == Keys.Tab) || (e.KeyCode == Keys.Delete)) || ((e.KeyCode == Keys.Back) || (e.KeyCode == Keys.Return))) && (this.Text.IndexOf("*") <= 0))
            {
                this.Text = this.Text + "*";
            }
        }

        public void Undo()
        {
            this.txtContent.UndoAction();
        }

        public bool ClosingCanceled
        {
            get
            {
                return this._canceled;
            }
        }

        public string Content
        {
            get
            {
                return this.txtContent.Text;
            }
            set
            {
                this.txtContent.Text = value;
                this.txtContent.Refresh();
            }
        }

        public Font EditorFont
        {
            get
            {
                return this.txtContent.Font;
            }
            set
            {
                this.txtContent.Font = value;
            }
        }

        public string FileName
        {
            get
            {
                return this.m_fileName;
            }
            set
            {
                if (value != string.Empty)
                {
                    string str = value;
                    this.Text = str;
                }
                this.m_fileName = value;
            }
        }

        private class Alias
        {
            public string AliasName;
            public string TableName;

            public Alias(string alias, string table)
            {
                this.AliasName = alias;
                this.TableName = table;
            }
        }

        public class SnippetMenuItem : MenuItem
        {
            public string statement = "";
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -