矿山建设网站,用wordpress开发网站,织梦cms做好的网站怎样上传到服务器,网站做代码图像显示不出来的项目背景公司业务历史悠久且复杂#xff0c;数据库的表更是多而繁杂#xff0c;每次基于老业务做功能开发都需要去翻以前的表和业务代码。需要理解旧的表的用途以及包含的字段的含义#xff0c;表少还好说#xff0c;但是表一多这就很浪费时间#xff0c;而且留下来的文档… 项目背景公司业务历史悠久且复杂数据库的表更是多而繁杂每次基于老业务做功能开发都需要去翻以前的表和业务代码。需要理解旧的表的用途以及包含的字段的含义表少还好说但是表一多这就很浪费时间而且留下来的文档都是残缺不全每次查一些表的含义都要捯饬很久。在网上搜索关于数据库文档管理工具搜到最多的就是Screw和DBCHM一个是基于Java的工具、另一个则是bug很多表一多就一直转圈圈进不去。所以自己就动手开发了这款SmartSQL的工具。它是一款基于.Net 4.6.1、WPF开发的一款数据库文档管理不仅支持多种数据库(SQLServer、MySQL、PostgreSQL、SQLite)表、视图、存储过程的查询管理还支持对其进行导出成离线文档支持的文档包括CHM、Word、Excel、PDF、HTML、Xml、Json、MarkDown等多种格式。现在将它开源分享出来供更多的小伙伴使用和参考学习文末附开源地址。技术栈.Net 4.6.1WPFHandyControlSqlSugarAvalonEditSharpVectorsHandyControl是一款非常优秀的WPF框架做出来的页面都很漂亮所以我们选择使用它。Nuget中引用HandyControl一.菜单栏然后我们要实现一个基于WPF边框上的菜单栏刚好HandyControl中有这么一个菜单栏的控件,下面就是实现菜单栏的方法hc:GlowWindow.NonClientAreaContentStackPanel Height29 Margin25,0,0,0Menu HorizontalAlignmentLeftMenuItemx:NameSwitchMenuCursorHandFontWeightBoldForeground{DynamicResource DarkPrimaryBrush}Header选择连接MenuItem.IconPathData{StaticResource DownGeometry}Fill{DynamicResource DarkPrimaryBrush}StretchUniform //MenuItem.IconMenuItem.ItemTemplateHierarchicalDataTemplateMenuItemWidth160Margin0Padding0HorizontalAlignmentLeftVerticalAlignmentStretchClickSwitchMenu_ClickCursorHandFontWeightNormalHeader{Binding ConnectName}MenuItem.Iconsvgc:SvgViewboxWidth16Height16HorizontalAlignmentLeftIsHitTestVisibleFalseSource{Binding Icon} //MenuItem.Icon/MenuItem/HierarchicalDataTemplate/MenuItem.ItemTemplate/MenuItemMenuItemNameMenuConnectCursorHandFontWeightBoldForeground{DynamicResource DarkPrimaryBrush}Header文件MenuItem.IconPathData{StaticResource FileGeometry}Fill{DynamicResource DarkPrimaryBrush}StretchUniform //MenuItem.IconMenuItemNameAddConnectClickAddConnect_OnClickFontWeightNormalHeader新建连接MenuItem.IconPathData{StaticResource NewConnectGeometry}Fill{DynamicResource DarkPrimaryBrush}StretchUniform //MenuItem.Icon/MenuItemMenuItemNameImportMarkClickImportMark_OnClickFontWeightNormalHeader导入备注MenuItem.IconPathData{StaticResource ImportGeometry}Fill{DynamicResource DarkPrimaryBrush}StretchUniform //MenuItem.Icon/MenuItemMenuItemNameExportDocClickExportDoc_OnClickFontWeightNormalHeader导出文档MenuItem.IconPathData{StaticResource ExportGeometry}Fill{DynamicResource DarkPrimaryBrush}StretchUniform //MenuItem.Icon/MenuItem/MenuItemMenuItemNameMenuGroupClickMenuGroup_OnClickCursorHandFontWeightBoldForeground{DynamicResource DarkPrimaryBrush}Header分组MenuItem.IconPathData{StaticResource GroupGeometry}Fill{DynamicResource DarkPrimaryBrush}StretchUniform //MenuItem.Icon/MenuItemMenuItemNameMenuSettingClickMenuSetting_OnClickCursorHandFontWeightBoldForeground{DynamicResource DarkPrimaryBrush}Header设置MenuItem.IconPathData{StaticResource SettingGeometry}Fill{DynamicResource DarkPrimaryBrush}StretchUniform //MenuItem.Icon/MenuItemMenuItemNameMenuAboutClickMenuAbout_OnClickCursorHandFontWeightBoldForeground{DynamicResource DarkPrimaryBrush}Header关于MenuItem.IconPathData{StaticResource InfoGeometry}Fill{DynamicResource DarkPrimaryBrush}StretchUniform //MenuItem.Icon/MenuItem/Menu/StackPanel
/hc:GlowWindow.NonClientAreaContent
!-- 工具栏菜单 --其中有个小插曲在WPF中是默认不支持svg图形的所以我们需要引用一个组件SharpVectors,它的使用方法是这样的引用svg界面需要引入下面语句xmlns:svgchttp://sharpvectors.codeplex.com/svgc/然后引用要显示的svg图形svgc:SvgViewboxWidth16Height16HorizontalAlignmentLeftIsHitTestVisibleFalseSource{Binding Icon} /二.左侧菜单栏然后就是左侧的菜单栏我们要实现一个数据库的选择和数据库对象的搜索可以搜索相关表、视图、存储过程等对象。首先我们要对我们的主界面进行一个简单的1:1:1的竖向布局分别为左侧菜单栏、中间可以移动的分隔栏、右面的主界面!-- Main区域 --
Grid x:NameGridMain Background{StaticResource CloudDrawingBrush}Grid.RowDefinitionsRowDefinition Height* //Grid.RowDefinitionsGrid.ColumnDefinitionsColumnDefinition Width3.3* MinWidth200 /ColumnDefinition WidthAuto /ColumnDefinition Width6.6* //Grid.ColumnDefinitions
/Grid现在我们要实现一个左侧树形的菜单栏我们使用的是WPF里面的TreeView控件进行实现这样一个功能下面是相关代码DockPanel Grid.Row0 Grid.Column0hc:SimplePanelBorderMargin5,5,0,5Background{DynamicResource RegionBrush}CornerRadius{Binding CornerRadius}GridHeightAutoMargin5BackgroundTransparentTextBox x:NameHidSelectDatabase VisibilityHidden /GridGrid.ColumnDefinitionsColumnDefinition Width8* /ColumnDefinition Width1* MinWidth30 //Grid.ColumnDefinitionsComboBoxx:NameSelectDatabaseHeight30VerticalAlignmentTopHorizontalContentAlignmentStretchhc:BorderElement.CornerRadius5hc:InfoElement.Placeholder请选择数据库CursorHandIsTextSearchEnabledTrueSelectionChangedSelectDatabase_OnSelectionChangedStyle{StaticResource ComboBoxExtend}Text{Binding DbName}ComboBox.ItemTemplateDataTemplateStackPanel VerticalAlignmentCenter OrientationHorizontalImageWidth11Height15Source/SmartSQL;component/Resources/Img/dataBase.ico /TextBlockMargin5,0,0,0HorizontalAlignmentCenterVerticalAlignmentCenterText{Binding DbName} //StackPanel/DataTemplate/ComboBox.ItemTemplate/ComboBoxButtonNameBtnFreshGrid.Column2Margin0,0,0,0Padding4VerticalAlignmentTopBackgroundTransparentBorderThickness0ClickBtnFresh_OnClickCursorHandButton.ContentImage Source/SmartSQL;component/Resources/Img/Refresh.png StretchFill //Button.Content/Button/Gridhc:SearchBarx:NameSearchMenuHeight30Margin0,34,0,0Padding5,0,5,0VerticalAlignmentTopHorizontalContentAlignmentStretchhc:BorderElement.CornerRadius5hc:InfoElement.Placeholder搜索数据表/视图/存储过程FontSize13ShowClearButtonTrueStyle{StaticResource SearchBarPlus}TextChangedSearchMenu_OnTextChanged /TabControlx:NameTabLeftTypeMargin0,65,0,40SelectionChangedTabLeftType_OnSelectionChangedStyle{StaticResource TabControlInLine}TabItemx:NameTabAllDataCursorHandHeader全部IsSelectedTrue /TabItemx:NameTabGroupDataCursorHandHeader分组IsSelectedFalse /!--TabItemx:NameTabFavDataCursorHandHeader收藏IsSelectedFalse /--/TabControlTreeViewx:NameTreeViewTablesMargin0,100,0,0VerticalAlignmentTopBorderThickness0ItemsSource{Binding TreeViewData}SelectedItemChangedSelectedTable_OnClickTreeView.ItemContainerStyleStyle BasedOn{StaticResource TreeViewItemBaseStyle} TargetType{x:Type TreeViewItem}Setter PropertyIsExpanded Value{Binding IsExpanded} /Setter PropertyFontWeight Value{Binding FontWeight} /Setter PropertyFontSize Value12 /Setter PropertyVisibility Value{Binding Visibility} /Setter PropertyForeground Value{Binding TextColor} /Setter PropertyCursor ValueHand /!-- 禁止水平滚动条自动滚动 --EventSetter EventRequestBringIntoView HandlerEventSetter_OnHandler /Style.TriggersTrigger PropertyIsSelected ValueTrueSetter PropertyFontWeight ValueBold //Trigger/Style.Triggers
/Style/TreeView.ItemContainerStyleTreeView.ContextMenu!-- 右键菜单 --ContextMenu VisibilityVisibleMenuItemx:NameMenuSelectedItemPadding5,0,5,0VerticalAlignmentCenterClickMenuSelectedItem_OnClickCursorHandHeader复制对象名 //ContextMenu/TreeView.ContextMenuTreeView.ItemTemplateHierarchicalDataTemplate DataType{x:Type models:TreeNodeItem} ItemsSource{Binding Children}StackPanel OrientationHorizontalsvgc:SvgViewboxWidth12Height12Margin0,0,5,0HorizontalAlignmentLeftSource{Binding Icon} /TextBlockVerticalAlignmentCenterFontSize12Text{Binding DisplayName}ToolTip{Binding DisplayName} //StackPanel/HierarchicalDataTemplate/TreeView.ItemTemplate/TreeViewGridx:NameNoDataTextMargin0,100,0,5HorizontalAlignmentStretchBackgroundWhiteCursorArrowlocal:NoDataAreax:NameNoDataAreaTextMargin0HorizontalAlignmentCenterShowTypeAll //GridGridMargin0VerticalAlignmentBottomVisibilityHiddenGrid.ColumnDefinitionsColumnDefinition Width4* /ColumnDefinition Width6* /ColumnDefinition WidthAuto //Grid.ColumnDefinitionsGridComboBoxx:NameCbTargetConnectHeight26VerticalAlignmentBottomHorizontalContentAlignmentLefthc:InfoElement.Placeholder目标连接CursorHandDisplayMemberPathConnectNameIsTextSearchEnabledTrueSelectedValuePathDbMasterConnectStringSelectionChangedCbTargetConnect_OnSelectionChangedStyle{StaticResource ComboBoxExtend} //GridGrid Grid.Column1 Margin5,0,0,0ComboBoxx:NameCbTargetDatabaseMinWidth50VerticalAlignmentBottomHorizontalContentAlignmentLefthc:InfoElement.Placeholder目标数据库CursorHandIsTextSearchEnabledTrueStyle{StaticResource ComboBoxExtend} //GridGrid Grid.Column2!-- 差异比较按钮 --Buttonx:NameBtnCompareHeight30Margin5,5,0,0HorizontalAlignmentRighthc:BorderElement.CornerRadius6hc:IconElement.Geometry{StaticResource CompareGeometry}ClickBtnCompare_OnClickContent差异比较CursorHand //Grid/Grid!-- 数据加载Loading --hc:LoadingLinex:NameLoadingLineMargin0,0,0,0VisibilityCollapsed //Grid/Border/hc:SimplePanel/DockPanel在这里我没有详细介绍底层c#的相关代码里面逻辑有些复杂感兴趣的可以去我的开源项目中学习。在上面的左侧菜单代码中我们使用的不仅有TreeView控件、也有ContextMenu、hc:LoadingLine等控件还有自己写的自定义控件。其实WPF要比WinForm好用不少不仅支持MVVM数据绑定还支持灵活的页面渲染自从用了WPF再也不用WinForm了。今天分享暂时到这里下一篇将介绍DataGrid表格数据绑定及相关条件搜索。下面是工具的开源地址感兴趣的可以Clone下来学习一下。码砖不易喜欢的麻烦点下Star.开源地址https://gitee.com/izhaofu/SmartSQL