From e7c74636f1dee01b1a0f4d7407a6a7d832a57cf3 Mon Sep 17 00:00:00 2001
From: lwh <2679599887@qq.com>
Date: Wed, 31 May 2023 21:29:30 +0800
Subject: [PATCH] init
---
wpf/DMSkin.sln | 4 +
.../CyanDesignDemo/CyanDesignDemo.csproj | 7 +
wpf/Demos/CyanDesignDemo/DataBaseWindow.xaml | 110 ++++++++++
.../CyanDesignDemo/DataBaseWindow.xaml.cs | 193 ++++++++++++++++++
.../CyanDesignDemo/SqlResultWindow.xaml.cs | 16 +-
.../View/Business/PageCreateTable.xaml | 10 +-
.../View/Business/PageCreateTable.xaml.cs | 6 +
.../View/Business/PageMind.xaml | 2 +-
.../Business/Mind/MindMapViewModel.cs | 25 +--
9 files changed, 339 insertions(+), 34 deletions(-)
create mode 100644 wpf/Demos/CyanDesignDemo/DataBaseWindow.xaml
create mode 100644 wpf/Demos/CyanDesignDemo/DataBaseWindow.xaml.cs
diff --git a/wpf/DMSkin.sln b/wpf/DMSkin.sln
index 5183829..e7e6a68 100644
--- a/wpf/DMSkin.sln
+++ b/wpf/DMSkin.sln
@@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DMSkin.CyanDesign", "Design
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CyanDesignDemo", "Demos\CyanDesignDemo\CyanDesignDemo.csproj", "{F4C3340C-A5E8-4324-B512-AE8C10C00E14}"
EndProject
+Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Aerwen工具箱", "Aerwen工具箱\Aerwen工具箱.vdproj", "{C8F85820-377F-4E8D-9B2A-A8E5601E5030}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -39,6 +41,8 @@ Global
{F4C3340C-A5E8-4324-B512-AE8C10C00E14}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4C3340C-A5E8-4324-B512-AE8C10C00E14}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4C3340C-A5E8-4324-B512-AE8C10C00E14}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C8F85820-377F-4E8D-9B2A-A8E5601E5030}.Debug|Any CPU.ActiveCfg = Debug
+ {C8F85820-377F-4E8D-9B2A-A8E5601E5030}.Release|Any CPU.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/wpf/Demos/CyanDesignDemo/CyanDesignDemo.csproj b/wpf/Demos/CyanDesignDemo/CyanDesignDemo.csproj
index 9627987..eebbba0 100644
--- a/wpf/Demos/CyanDesignDemo/CyanDesignDemo.csproj
+++ b/wpf/Demos/CyanDesignDemo/CyanDesignDemo.csproj
@@ -125,6 +125,9 @@
MSBuild:Compile
Designer
+
+ DataBaseWindow.xaml
+
Login.xaml
@@ -182,6 +185,10 @@
PageOpenFilesDialog.xaml
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/wpf/Demos/CyanDesignDemo/DataBaseWindow.xaml b/wpf/Demos/CyanDesignDemo/DataBaseWindow.xaml
new file mode 100644
index 0000000..70aaa8d
--- /dev/null
+++ b/wpf/Demos/CyanDesignDemo/DataBaseWindow.xaml
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/wpf/Demos/CyanDesignDemo/DataBaseWindow.xaml.cs b/wpf/Demos/CyanDesignDemo/DataBaseWindow.xaml.cs
new file mode 100644
index 0000000..5463f06
--- /dev/null
+++ b/wpf/Demos/CyanDesignDemo/DataBaseWindow.xaml.cs
@@ -0,0 +1,193 @@
+using MySqlConnector;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace CyanDesignDemo
+{
+ ///
+ /// DataBaseWindow.xaml 的交互逻辑
+ ///
+ public partial class DataBaseWindow : Window
+ {
+ public DataBaseWindow()
+ {
+ InitializeComponent();
+
+ GetValue();
+
+ }
+
+ ///
+ /// 保存
+ ///
+ ///
+ ///
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ var connectionStringTemplate = "server=IP地址;Database=数据库名称;Uid=用户名;Pwd=密码;";
+ var ip = IPTextBox.Text;
+ var dataBase = DataBaseTextBox.Text;
+ var userName = UserNameTextBox.Text;
+ var passWord = PassWordTextBox.Text;
+
+ // 替换占位符
+ var connectionString = connectionStringTemplate
+ .Replace("IP地址", ip)
+ .Replace("数据库名称", dataBase)
+ .Replace("用户名", userName)
+ .Replace("密码", passWord);
+
+ // 写入文件
+ var filePath = "dataBase.txt";
+
+ if (File.Exists(filePath))
+ {
+ // 文件存在,执行打开文件的逻辑操作
+ File.WriteAllText(filePath, connectionString);
+ }
+ else
+ {
+ AddFile(filePath, "server=IP地址;Database=数据库名称;Uid=用户名;Pwd=密码;");
+ File.WriteAllText(filePath, connectionString);
+ }
+
+ string connectionStringText = File.ReadAllText("dataBase.txt");
+ try
+ {
+ using (MySqlConnection connection = new MySqlConnection(connectionStringText))
+ {
+ connection.Open();
+ MessageBox.Show("连接成功!");
+ this.Hide();
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"连接失败,请检查连接字符串: {ex.Message}");
+ }
+
+ }
+ catch (Exception)
+ {
+
+ throw;
+ }
+
+ }
+
+ ///
+ /// 取消
+ ///
+ ///
+ ///
+ private void Button_Click_1(object sender, RoutedEventArgs e)
+ {
+ this.Hide();
+ }
+
+
+
+ // 打开文件的方法
+ private void OpenFile(string filePath)
+ {
+ try
+ {
+ Process.Start(filePath);
+ }
+ catch (Exception ex)
+ {
+ // 处理异常情况
+ MessageBox.Show($"无法打开文件: {ex.Message}");
+ }
+ }
+
+
+ // 添加文件的方法
+ private void AddFile(string filePath, string content)
+ {
+ try
+ {
+ // 检查文件是否已存在
+ if (File.Exists(filePath))
+ {
+ MessageBox.Show("文件已存在。");
+ return;
+ }
+
+ // 写入文件内容
+ File.WriteAllText(filePath, content);
+
+ // 文件添加成功后,执行打开文件操作
+ OpenFile(filePath);
+ }
+ catch (Exception ex)
+ {
+ // 处理异常情况
+ MessageBox.Show($"无法添加文件: {ex.Message}");
+ }
+ }
+
+
+ public void GetValue()
+ {
+ var filePath = "dataBase.txt";
+
+ if (File.Exists(filePath))
+ {
+ string connectionStringText = File.ReadAllText(filePath);
+ var connectionValues = connectionStringText.Split(';');
+
+ foreach (var value in connectionValues)
+ {
+ var keyValue = value.Split('=');
+ if (keyValue.Length == 2)
+ {
+ var key = keyValue[0].Trim().ToLower();
+ var val = keyValue[1].Trim();
+
+ switch (key)
+ {
+ case "server":
+ case "data source":
+ case "ip":
+ IPTextBox.Text = val;
+ break;
+ case "database":
+ DataBaseTextBox.Text = val;
+ break;
+ case "uid":
+ case "user":
+ case "username":
+ UserNameTextBox.Text = val;
+ break;
+ case "pwd":
+ case "password":
+ PassWordTextBox.Text = val;
+ break;
+ default:
+ // Handle unrecognized key or value
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ }
+}
diff --git a/wpf/Demos/CyanDesignDemo/SqlResultWindow.xaml.cs b/wpf/Demos/CyanDesignDemo/SqlResultWindow.xaml.cs
index bcc6123..9387e46 100644
--- a/wpf/Demos/CyanDesignDemo/SqlResultWindow.xaml.cs
+++ b/wpf/Demos/CyanDesignDemo/SqlResultWindow.xaml.cs
@@ -85,20 +85,8 @@ namespace CyanDesignDemo
private void Button_Click_1(object sender, RoutedEventArgs e)
{
- string filePath = "dataBase.txt";
- if (File.Exists(filePath))
- {
- // 文件存在,执行打开文件的逻辑操作
- OpenFile(filePath);
- }
- else
- {
- // 文件不存在,执行添加文件的逻辑操作
- AddFile(filePath, "server=127.0.0.1;Database=database;Uid=uid;Pwd=pwd;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;");
-
- // 添加文件后立即打开
- OpenFile(filePath);
- }
+ DataBaseWindow dataBaseWindow = new DataBaseWindow();
+ dataBaseWindow.Show();
}
diff --git a/wpf/Demos/CyanDesignDemo/View/Business/PageCreateTable.xaml b/wpf/Demos/CyanDesignDemo/View/Business/PageCreateTable.xaml
index 5f1097c..b5961f0 100644
--- a/wpf/Demos/CyanDesignDemo/View/Business/PageCreateTable.xaml
+++ b/wpf/Demos/CyanDesignDemo/View/Business/PageCreateTable.xaml
@@ -467,7 +467,7 @@
-
+
+
+ Content="测试连接" />
+ Content="手动编辑" />
diff --git a/wpf/Demos/CyanDesignDemo/View/Business/PageCreateTable.xaml.cs b/wpf/Demos/CyanDesignDemo/View/Business/PageCreateTable.xaml.cs
index 0748c3d..d91f52b 100644
--- a/wpf/Demos/CyanDesignDemo/View/Business/PageCreateTable.xaml.cs
+++ b/wpf/Demos/CyanDesignDemo/View/Business/PageCreateTable.xaml.cs
@@ -91,6 +91,12 @@ namespace CyanDesignDemo.View.Business
createTableViewModel.GenField.FiledDecimal = mappingValue.FiledDecimal;
}
}
+
+ private void Button_Click_1(object sender, RoutedEventArgs e)
+ {
+ DataBaseWindow dataBaseWindowdataBaseWindow = new DataBaseWindow();
+ dataBaseWindowdataBaseWindow.Show();
+ }
}
}
diff --git a/wpf/Demos/CyanDesignDemo/View/Business/PageMind.xaml b/wpf/Demos/CyanDesignDemo/View/Business/PageMind.xaml
index 43a3fad..0a0f968 100644
--- a/wpf/Demos/CyanDesignDemo/View/Business/PageMind.xaml
+++ b/wpf/Demos/CyanDesignDemo/View/Business/PageMind.xaml
@@ -52,7 +52,7 @@
+ Content="测试连接" />