Skip to content

Commit

Permalink
🔥 #优化未创建分组、标签提示下面增加快捷创建分组、标签按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
zfluok committed Mar 31, 2023
1 parent 165919f commit a1aedbe
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.
2 changes: 1 addition & 1 deletion SmartSQL/SmartSQL/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private void MenuGroup_OnClick(object sender, RoutedEventArgs e)
group.SelectedDataBase = selectDatabase.DbName;
group.DbData = MainContent.MenuData;
group.Owner = this;
group.ChangeRefreshEvent += MainContent.Group_ChangeRefreshEvent;
group.ChangeRefreshEvent += MainContent.ChangeRefreshMenuEvent;
group.ShowDialog();
}

Expand Down
2 changes: 1 addition & 1 deletion SmartSQL/SmartSQL/UserControl/Main/UcMainColumns.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
CellEditEnding="TableGrid_OnCellEditEnding"
Cursor="Arrow"
HeadersVisibility="All"
PreparingCellForEdit="TableGrid_OnPreparingCellForEdit"
ItemsSource="{Binding ObjectColumns}"
PreparingCellForEdit="TableGrid_OnPreparingCellForEdit"
RowHeaderWidth="60"
SelectedCellsChanged="TableGrid_OnSelectedCellsChanged"
SelectionChanged="Handled_OnSelectionChanged"
Expand Down
9 changes: 9 additions & 0 deletions SmartSQL/SmartSQL/UserControl/Main/UcMainContent.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@
Margin="0"
HorizontalAlignment="Center"
ShowType="All" />
<Button
x:Name="BtnNoData"
Margin="0,150,0,0"
Background="#f4f5f7"
BorderThickness="0"
Click="BtnNoData_OnClick"
Content="创建分组"
Cursor="Hand"
Visibility="Collapsed" />
</Grid>
<!-- 数据加载Loading -->
<localControls:Loading
Expand Down
46 changes: 42 additions & 4 deletions SmartSQL/SmartSQL/UserControl/Main/UcMainContent.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using TabControl = System.Windows.Controls.TabControl;
using TabItem = System.Windows.Controls.TabItem;
using System.IO;
using SmartSQL.Views.Category;

namespace SmartSQL.UserControl
{
Expand Down Expand Up @@ -642,9 +643,12 @@ join b in sqLiteHelper.db.Table<TagObjects>() on a.TagId equals b.TagId
{
if (!itemParentList.Any())
{
var tipText = (LeftMenuType)leftMenuType == LeftMenuType.Group ? "暂无分组,请先创建分组" : "暂无标签,请先创建标签";
var typeText = (LeftMenuType)leftMenuType == LeftMenuType.Group ? "分组" : "标签";
var tipText = $"暂无{typeText},请先创建{typeText}";
NoDataAreaText.TipText = tipText;
NoDataText.Visibility = Visibility.Visible;
BtnNoData.Content = $"创建{typeText}";
BtnNoData.Visibility = Visibility.Visible;
}
itemParentList.ForEach(treeItem =>
{
Expand All @@ -668,6 +672,7 @@ join b in sqLiteHelper.db.Table<TagObjects>() on a.TagId equals b.TagId
{
NoDataAreaText.TipText = "暂无数据";
NoDataText.Visibility = Visibility.Visible;
BtnNoData.Visibility = Visibility.Collapsed;
}
itemList.ForEach(obj =>
{
Expand Down Expand Up @@ -1216,6 +1221,7 @@ join b in sqLiteHelper.db.Table<TagObjects>() on a.TagId equals b.TagId
{
NoDataAreaText.TipText = "暂无数据";
NoDataText.Visibility = Visibility.Visible;
BtnNoData.Visibility = Visibility.Collapsed;
}
TreeViewData = itemParentList;
}
Expand All @@ -1234,6 +1240,7 @@ join b in sqLiteHelper.db.Table<TagObjects>() on a.TagId equals b.TagId
{
NoDataAreaText.TipText = "暂无数据";
NoDataText.Visibility = Visibility.Visible;
BtnNoData.Visibility = Visibility.Collapsed;
}
TreeViewData = itemList;
}
Expand Down Expand Up @@ -1309,7 +1316,7 @@ private void SelectedTable_OnClick(object sender, RoutedEventArgs e)
CornerRadius = 10;
MainW.Visibility = Visibility.Visible;
MainTabW.Visibility = Visibility.Collapsed;
MainW.ObjChangeRefreshEvent += Group_ChangeRefreshEvent;
MainW.ObjChangeRefreshEvent += ChangeRefreshMenuEvent;
MainW.MenuData = MenuData;
MainW.SelectedConnection = SelectedConnection;
MainW.SelectedDataBase = selectDatabase;
Expand Down Expand Up @@ -1346,12 +1353,43 @@ private void SelectedTable_OnClick(object sender, RoutedEventArgs e)
#endregion
}

private void BtnNoData_OnClick(object sender, RoutedEventArgs e)
{
var selectDatabase = (DataBase)SelectDatabase.SelectedItem;
if (SelectedConnection == null || selectDatabase == null)
{
Oops.Oh("请选择数据库");
return;
}
var mainWindow = Window.GetWindow(this);
if (BtnNoData.Content.ToString() == "创建分组")
{
var group = new GroupsView();
group.SelectedConnection = SelectedConnection;
group.SelectedDataBase = selectDatabase.DbName;
group.DbData = MenuData;
group.Owner = mainWindow;
group.ChangeRefreshEvent += ChangeRefreshMenuEvent;
group.ShowDialog();
}
else
{
var tags = new TagsView();
tags.SelectedConnection = SelectedConnection;
tags.SelectedDataBase = selectDatabase.DbName;
tags.DbData = MenuData;
tags.Owner = mainWindow;
tags.ChangeRefreshEvent += ChangeRefreshMenuEvent;
tags.ShowDialog();
}
}

/// <summary>
/// 子窗体刷新左侧菜单
/// </summary>
public void Group_ChangeRefreshEvent()
public void ChangeRefreshMenuEvent()
{
if (TabGroupData.IsSelected)
if (TabGroupData.IsSelected || TabTagData.IsSelected)
{
MenuBind();
}
Expand Down

0 comments on commit a1aedbe

Please sign in to comment.