NewLife/XCoder

筛选连接名
BearXiongLaoXiong authored at 2020-08-24 18:01:52
4aec99c
Tree
1 Parent(s) 979ebb4
Summary: 12 changed files with 109 additions and 82 deletions.
Modified +11 -0
Modified +3 -1
Added +0 -0
Added +0 -0
Added +0 -0
Added +0 -0
Renamed +0 -0
XCoderWpf/Resources/Images/SqlServer/mssql.png → XCoderWpf/Resources/Images/SqlServer/sqlserver.png
Modified +43 -42
Modified +23 -11
Modified +12 -15
Modified +7 -11
Modified +10 -2
Modified +11 -0
diff --git a/XCoderWpf/App.config b/XCoderWpf/App.config
index 7cc722f..9846875 100644
--- a/XCoderWpf/App.config
+++ b/XCoderWpf/App.config
@@ -4,11 +4,22 @@
     <add name="SQLite" connectionString="Data Source=test.db;" providerName="Sqlite" />
     <add name="MySql" connectionString="Server=.;Port=3306;Database=mysql;Uid=root;Pwd=;NameFormat=Upper" providerName="MySql.Data.MySqlClient" />
     <add name="MSSQL" connectionString="Server=.;User ID=sa;Password=sa;Database=Test;datapath=~\App_Data;NameFormat=Upper" providerName="System.Data.SqlClient" />
+    <add name="master117" connectionString="Server=10.127.1.221;User ID=sa;Password=sa;Database=Test;datapath=~\App_Data;NameFormat=Upper" providerName="System.Data.SqlClient" />
     <add name="Oracle" connectionString="Data Source=Tcp://127.0.0.1/ORC;User ID=sys;Password=admin;Owner=mis;NameFormat=Upper" providerName="System.Data.OracleClient" />
     <add name="PostgreSQL" connectionString="Server=.;Database=master;Uid=root;Pwd=root;NameFormat=Upper" providerName="PostgreSQL.Data.PostgreSQLClient" />
     <add name="MSSQL" connectionString="Server=.;Integrated Security=SSPI;Database=Test;NameFormat=Upper" providerName="System.Data.SqlClient" />
     <add name="Oracle" connectionString="Data Source=orc;User ID=sys;Password=admin;NameFormat=Upper" providerName="System.Data.OracleClient" />
     <add name="Access" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=~\App_Data\Test.mdb;Persist Security Info=False;OLE DB Services=-1;NameFormat=Upper" providerName="Access"/>
     <add name="SqlCe" connectionString="Data Source=test.sdf;" providerName="SqlCe" />
+    <add name="SqlCe1" connectionString="Data Source=test.sdf;" providerName="SqlCe" />
+    <add name="SqlCe2" connectionString="Data Source=test.sdf;" providerName="SqlCe" />
+    <add name="SqlCe3" connectionString="Data Source=test.sdf;" providerName="SqlCe" />
+    <add name="SqlCe4" connectionString="Data Source=test.sdf;" providerName="SqlCe" />
+    <add name="SqlCe5" connectionString="Data Source=test.sdf;" providerName="SqlCe" />
+    <add name="SqlCe6" connectionString="Data Source=test.sdf;" providerName="SqlCe" />
+    <add name="SqlCe7" connectionString="Data Source=test.sdf;" providerName="SqlCe" />
+    <add name="SqlCe8" connectionString="Data Source=test.sdf;" providerName="SqlCe" />
+    <add name="SqlCe9" connectionString="Data Source=test.sdf;" providerName="SqlCe" />
+    <add name="SqlCea" connectionString="Data Source=test.sdf;" providerName="SqlCe" />
   </connectionStrings>
 </configuration>
\ No newline at end of file
Modified +3 -1
diff --git a/XCoderWpf/Models/DataBasePublishModel.cs b/XCoderWpf/Models/DataBasePublishModel.cs
index 68f5a05..8d8a6db 100644
--- a/XCoderWpf/Models/DataBasePublishModel.cs
+++ b/XCoderWpf/Models/DataBasePublishModel.cs
@@ -4,7 +4,7 @@ namespace XCoderWpf.Models
 {
     public class DataBasePublishModel
     {
-      
+
     }
 
     public class ConnectionStringModel
@@ -12,5 +12,7 @@ namespace XCoderWpf.Models
         public Uri IconSource { get; set; }
         public string Title { get; set; }
         public string Server { get; set; }
+        public string ShortName => Server?.Length > 15 ? Server.Substring(0, 15) : Server ?? "";
+
     }
 }
Added +0 -0
diff --git a/XCoderWpf/Resources/Images/SqlServer/access.png b/XCoderWpf/Resources/Images/SqlServer/access.png
new file mode 100644
index 0000000..b6e3bb1
Binary files /dev/null and b/XCoderWpf/Resources/Images/SqlServer/access.png differ
Added +0 -0
diff --git a/XCoderWpf/Resources/Images/SqlServer/none.png b/XCoderWpf/Resources/Images/SqlServer/none.png
new file mode 100644
index 0000000..53f94bb
Binary files /dev/null and b/XCoderWpf/Resources/Images/SqlServer/none.png differ
Added +0 -0
diff --git a/XCoderWpf/Resources/Images/SqlServer/oracle.png b/XCoderWpf/Resources/Images/SqlServer/oracle.png
new file mode 100644
index 0000000..73ec213
Binary files /dev/null and b/XCoderWpf/Resources/Images/SqlServer/oracle.png differ
Added +0 -0
diff --git a/XCoderWpf/Resources/Images/SqlServer/postgresql.png b/XCoderWpf/Resources/Images/SqlServer/postgresql.png
new file mode 100644
index 0000000..41111ba
Binary files /dev/null and b/XCoderWpf/Resources/Images/SqlServer/postgresql.png differ
Renamed +0 -0
XCoderWpf/Resources/Images/SqlServer/mssql.png → XCoderWpf/Resources/Images/SqlServer/sqlserver.png
diff --git a/XCoderWpf/Resources/Images/SqlServer/mssql.png b/XCoderWpf/Resources/Images/SqlServer/sqlserver.png
similarity index 100%
rename from XCoderWpf/Resources/Images/SqlServer/mssql.png
rename to XCoderWpf/Resources/Images/SqlServer/sqlserver.png
Binary files a/XCoderWpf/Resources/Images/SqlServer/mssql.png and b/XCoderWpf/Resources/Images/SqlServer/sqlserver.png differ
Modified +43 -42
diff --git a/XCoderWpf/Resources/Templates.xaml b/XCoderWpf/Resources/Templates.xaml
index 8d8e0ab..2d44fe1 100644
--- a/XCoderWpf/Resources/Templates.xaml
+++ b/XCoderWpf/Resources/Templates.xaml
@@ -6,53 +6,54 @@
 
     <conver:BoolToVisibilityConverter x:Key="VisibilityConverter"/>
     <DataTemplate x:Key="DataBaseItems">
-        <ContentControl>
-            <RadioButton GroupName="ConnectionStringGroup" Command="{Binding Command}" CommandParameter="{Binding}" Style="{x:Null}">
-                <RadioButton.Template>
-                    <ControlTemplate TargetType="RadioButton">
-                        <Border>
-                            <Border.Style>
-                                <Style TargetType="Border">
-                                    <Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}"/>
-                                    <Style.Triggers>
-                                        <DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=RadioButton}}" Value="True">
-                                            <Setter Property="Background" Value="#E6E6E6"/>
-                                        </DataTrigger>
+            <ContentControl>
 
-                                        <DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource AncestorType=RadioButton}}" Value="True">
-                                            <Setter Property="Background" Value="#CECDCD"/>
-                                        </DataTrigger>
-                                    </Style.Triggers>
-                                </Style>
-                            </Border.Style>
-                            <Grid Margin="5">
-                                <Grid.RowDefinitions>
-                                    <RowDefinition Height="1*"/>
-                                    <RowDefinition Height="1*"/>
-                                </Grid.RowDefinitions>
-                                <Grid.ColumnDefinitions>
-                                    <ColumnDefinition Width="45"/>
-                                    <ColumnDefinition />
-                                </Grid.ColumnDefinitions>
-                                <Border  Grid.RowSpan="2" Width="35" Height="35" BorderThickness="1" BorderBrush="{StaticResource BorderBrush}">
-                                    <Image Source="/Resources/Images/SqlServer/mysql.png" Stretch="UniformToFill" />
-                                </Border>
-                              
-                                <TextBlock Grid.Row="0" Grid.Column="1" Padding="0" Text="{Binding Title, FallbackValue='******'}" Foreground="{StaticResource PrimaryTextBrush}" />
-                                <TextBlock Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" Padding="0" FontSize="10" Text="{Binding Server, FallbackValue='********'}" Foreground="{StaticResource BorderBrush}" />
-                                <TextBlock Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Foreground="White"  Text="已连接" Background="{StaticResource DarkDangerBrush}" 
+                <RadioButton GroupName="ConnectionStringGroup" Command="{Binding Command}" CommandParameter="{Binding}" Style="{x:Null}">
+                    <RadioButton.Template>
+                        <ControlTemplate TargetType="RadioButton">
+                            <Border>
+                                <Border.Style>
+                                    <Style TargetType="Border">
+                                        <Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}"/>
+                                        <Style.Triggers>
+                                            <DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=RadioButton}}" Value="True">
+                                                <Setter Property="Background" Value="#E6E6E6"/>
+                                            </DataTrigger>
+
+                                            <DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource AncestorType=RadioButton}}" Value="True">
+                                                <Setter Property="Background" Value="#CECDCD"/>
+                                            </DataTrigger>
+                                        </Style.Triggers>
+                                    </Style>
+                                </Border.Style>
+                                <Grid Margin="5">
+                                    <Grid.RowDefinitions>
+                                        <RowDefinition Height="1*"/>
+                                        <RowDefinition Height="1*"/>
+                                    </Grid.RowDefinitions>
+                                    <Grid.ColumnDefinitions>
+                                        <ColumnDefinition Width="45"/>
+                                        <ColumnDefinition />
+                                    </Grid.ColumnDefinitions>
+                                    <Border  Grid.RowSpan="2" Width="35" Height="35" BorderThickness="1" BorderBrush="{StaticResource BorderBrush}">
+                                        <Image Source="{Binding IconSource}" Stretch="Uniform" />
+                                    </Border>
+
+                                    <TextBlock Grid.Row="0" Grid.Column="1" Padding="0" Text="{Binding Title, FallbackValue='******'}"  Foreground="{StaticResource PrimaryTextBrush}" />
+                                    <TextBlock Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" Padding="0" FontSize="10" Text="{Binding ShortName, FallbackValue='********'}" ToolTip="{Binding Server}" Foreground="{StaticResource BorderBrush}" />
+                                    <TextBlock Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Foreground="White"  Text="已连接" Background="{StaticResource DarkDangerBrush}" 
                                            Visibility="{Binding IsChecked, RelativeSource={RelativeSource AncestorType=RadioButton},UpdateSourceTrigger=PropertyChanged, Converter={StaticResource VisibilityConverter}}"/>
-                                
-                                <!--<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Vertical" >
+
+                                    <!--<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Vertical" >
                                    
                                 </StackPanel>-->
-                            </Grid>
+                                </Grid>
 
-                        </Border>
-                    </ControlTemplate>
-                </RadioButton.Template>
-            </RadioButton>
-        </ContentControl>
+                            </Border>
+                        </ControlTemplate>
+                    </RadioButton.Template>
+                </RadioButton>
+            </ContentControl>
     </DataTemplate>
 
     <ControlTemplate x:Key="News" TargetType="ContentControl">
Modified +23 -11
diff --git a/XCoderWpf/ViewModels/DataBasePublishViewModel.cs b/XCoderWpf/ViewModels/DataBasePublishViewModel.cs
index 0ac4607..a01ecdd 100644
--- a/XCoderWpf/ViewModels/DataBasePublishViewModel.cs
+++ b/XCoderWpf/ViewModels/DataBasePublishViewModel.cs
@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
+using System.Diagnostics;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -13,15 +14,25 @@ namespace XCoderWpf.ViewModels
     public class DataBasePublishViewModel : BindableBase
     {
         private IList<string> _datalist;
-        public IList<string> DataList
+        public IList<string> DataList { get { return _datalist; } set { SetProperty(ref _datalist, value); } }
+
+        private string _searchFilter;
+        public String SearchFilter
         {
-            get { return _datalist; }
-            set { SetProperty(ref _datalist, value); }
+            get => _searchFilter;
+            set
+            {
+
+                SetProperty(ref _searchFilter, value);
+                _connectionStringCollection.Clear();
+                _connectionStringCollection.AddRange(_searchFilter?.Trim().Length > 0 ? _connectionStringList.Where(x => x.Title.ToLower().Contains(_searchFilter.ToLower())) : _connectionStringList);
+            }
         }
 
-        private ObservableCollection<ConnectionStringModel> _connectionStringList;
         /// <summary>菜单集合</summary>
-        public ObservableCollection<ConnectionStringModel> ConnectionStringList { get => _connectionStringList; set { SetProperty(ref _connectionStringList, value); } }
+        private List<ConnectionStringModel> _connectionStringList;
+        private ObservableCollection<ConnectionStringModel> _connectionStringCollection;
+        public ObservableCollection<ConnectionStringModel> ConnectionStringCollection { get => _connectionStringCollection; set { SetProperty(ref _connectionStringCollection, value); } }
 
         private MenuModel selectedMenu;
         /// <summary>选中菜单</summary>
@@ -31,16 +42,17 @@ namespace XCoderWpf.ViewModels
             set { selectedMenu = value; RaisePropertyChanged(); }
         }
 
+
         public DataBasePublishViewModel()
         {
-            var list = DAL.ConnStrs.Keys.ToList();
-            ConnectionStringList = new ObservableCollection<ConnectionStringModel>(list.Select(x => new ConnectionStringModel
+            //var list = DAL.ConnStrs.Keys.ToList();
+            _connectionStringList = new List<ConnectionStringModel>(DAL.ConnStrs.Select(x => new ConnectionStringModel
             {
-                Title = x,
-                IconSource = new Uri("/Resources/Images/SqlServer/mysql.png",UriKind.Relative),
-                Server = "192.168.102.1"
+                Title = x.Key,
+                IconSource = new Uri($"/Resources/Images/SqlServer/{DAL.Create(x.Key).DbType.ToString().ToLower()}.png", UriKind.Relative),
+                Server = x.Value
             }));
-           
+            _connectionStringCollection = new ObservableCollection<ConnectionStringModel>(_connectionStringList);
         }
     }
 
Modified +12 -15
diff --git a/XCoderWpf/Views/DataBasePublish.xaml b/XCoderWpf/Views/DataBasePublish.xaml
index 0b42579..7bc8d63 100644
--- a/XCoderWpf/Views/DataBasePublish.xaml
+++ b/XCoderWpf/Views/DataBasePublish.xaml
@@ -4,10 +4,10 @@
              xmlns:prism="http://prismlibrary.com/"    
              xmlns:hc="https://handyorg.github.io/handycontrol"
              prism:ViewModelLocator.AutoWireViewModel="True">
-    
+
     <Grid Background="{DynamicResource BackgroundBrush}">
         <Border Background="{DynamicResource RegionBrush}"  Effect="{StaticResource EffectShadow4}" CornerRadius="16" Margin="10">
-            <Grid >
+            <Grid>
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition/>
                     <ColumnDefinition Width="2*"/>
@@ -16,17 +16,14 @@
                 <Border Effect="{StaticResource EffectShadow4}" Background="{DynamicResource DarkDefaultBrush}" CornerRadius="16,0,0,16">
 
                     <StackPanel >
-                        <hc:SearchBar  Margin="20,30,20,0"  Style="{StaticResource SearchBarExtend}"/>
-
-                        <hc:TransitioningContentControl Margin="20,10,20,0">
-                            <ItemsControl ItemsSource="{Binding ConnectionStringList}" BorderThickness="1" BorderBrush="{StaticResource BorderBrush}" ItemTemplate="{StaticResource DataBaseItems}">
-                                <ItemsControl.ItemsPanel>
-                                    <ItemsPanelTemplate>
-                                        <StackPanel Orientation="Vertical"/>
-                                    </ItemsPanelTemplate>
-                                </ItemsControl.ItemsPanel>
-                            </ItemsControl>
-                        </hc:TransitioningContentControl>
+                        <hc:SearchBar  Margin="20,30,20,0" Text="{Binding SearchFilter,UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource SearchBarExtend}"/>
+                        <ItemsControl Margin="20,10,20,0" ItemsSource="{Binding ConnectionStringCollection}" BorderThickness="1" BorderBrush="{StaticResource BorderBrush}" ItemTemplate="{StaticResource DataBaseItems}">
+                            <ItemsControl.ItemsPanel>
+                                <ItemsPanelTemplate>
+                                    <StackPanel Orientation="Vertical"/>
+                                </ItemsPanelTemplate>
+                            </ItemsControl.ItemsPanel>
+                        </ItemsControl>
                         <TextBlock Margin="40,20,0,0" Foreground="White">
                             <Bold>提示</Bold>path
                         </TextBlock>
@@ -67,8 +64,8 @@
                         </TextBlock>
                     </StackPanel>
                 </Border>
-            
-            
+
+
             </Grid>
         </Border>
     </Grid>
Modified +7 -11
diff --git a/XCoderWpf/Views/MainWindow.xaml b/XCoderWpf/Views/MainWindow.xaml
index 4c920da..eae8a34 100644
--- a/XCoderWpf/Views/MainWindow.xaml
+++ b/XCoderWpf/Views/MainWindow.xaml
@@ -44,17 +44,13 @@
             <ColumnDefinition Width="170"/>
             <ColumnDefinition/>
         </Grid.ColumnDefinitions>
-        <Border x:Name="BorderMain" Margin="{Binding MenuMargin}" BorderThickness="0,1,1,1" Panel.ZIndex="1" BorderBrush="#DDDDDD">
-            <hc:TransitioningContentControl>
-                <hc:SideMenu Foreground="#7F4463" x:Name="MainSideMenu" ExpandMode="Freedom" AutoSelect="False">
-                    <hc:Interaction.Triggers>
-                        <hc:EventTrigger EventName="SelectionChanged">
-                            <hc:EventToCommand Command="{Binding SwitchItemCommand}" PassEventArgsToCommand="True"  />
-                        </hc:EventTrigger>
-                    </hc:Interaction.Triggers>
-                </hc:SideMenu>
-            </hc:TransitioningContentControl>
-        </Border>
+        <hc:SideMenu Foreground="#7F4463"  Margin="{Binding MenuMargin}" BorderBrush="#DDDDDD" x:Name="MainSideMenu" ExpandMode="Freedom" AutoSelect="False">
+            <hc:Interaction.Triggers>
+                <hc:EventTrigger EventName="SelectionChanged">
+                    <hc:EventToCommand Command="{Binding SwitchItemCommand}" PassEventArgsToCommand="True"  />
+                </hc:EventTrigger>
+            </hc:Interaction.Triggers>
+        </hc:SideMenu>
         <ContentControl prism:RegionManager.RegionName="ContentRegion" Grid.Column="1" />
     </Grid>
 </hc:Window>
Modified +10 -2
diff --git a/XCoderWpf/XCoderWpf.csproj b/XCoderWpf/XCoderWpf.csproj
index 5c7569c..e681dc0 100644
--- a/XCoderWpf/XCoderWpf.csproj
+++ b/XCoderWpf/XCoderWpf.csproj
@@ -8,15 +8,23 @@
 
   <ItemGroup>
     <None Remove="Resources\iconfont.ttf" />
-    <None Remove="Resources\Images\SqlServer\mssql.png" />
+    <None Remove="Resources\Images\SqlServer\access.png" />
     <None Remove="Resources\Images\SqlServer\mysql.png" />
+    <None Remove="Resources\Images\SqlServer\none.png" />
+    <None Remove="Resources\Images\SqlServer\Oracle.png" />
+    <None Remove="Resources\Images\SqlServer\postgresql.png" />
     <None Remove="Resources\Images\SqlServer\sqlite.png" />
+    <None Remove="Resources\Images\SqlServer\sqlserver.png" />
   </ItemGroup>
 
   <ItemGroup>
     <Resource Include="Resources\iconfont.ttf" />
-    <Resource Include="Resources\Images\SqlServer\mssql.png" />
+    <Resource Include="Resources\Images\SqlServer\access.png" />
+    <Resource Include="Resources\Images\SqlServer\sqlserver.png" />
     <Resource Include="Resources\Images\SqlServer\mysql.png" />
+    <Resource Include="Resources\Images\SqlServer\none.png" />
+    <Resource Include="Resources\Images\SqlServer\oracle.png" />
+    <Resource Include="Resources\Images\SqlServer\postgresql.png" />
     <Resource Include="Resources\Images\SqlServer\sqlite.png" />
   </ItemGroup>