Skip to content

Commit

Permalink
v0.9.6.0 Release!
Browse files Browse the repository at this point in the history
1.新增词云功能,导出时选择与他的词云即可。
2.修复公钥头推断失败BUG
3.修复创建工作区与已有工作区切换不成功BUG
  • Loading branch information
Suxue committed Dec 15, 2023
1 parent db79e51 commit 6234ad3
Show file tree
Hide file tree
Showing 17 changed files with 848,191 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Helpers/DecryptionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class DecryptionHelper
List<int> offset = new List<int>();
if (NativeAPI.ReadProcessMemory(process.Handle, module.BaseAddress, buffer, buffer.Length, out read))
{
for (int i = 0; i < buffer.Length - 8; i++)
for (int i = 0; i < buffer.Length - 1; i++)
{
if (buffer[i] == search[0])
{
Expand Down
1 change: 1 addition & 0 deletions Main2.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ private void list_workspace_SelectionChanged(object sender, SelectionChangedEven

private void new_workspace_fill_MouseDown(object sender, MouseButtonEventArgs e)
{
list_workspace.SelectedItem = null;
MainFrame.Navigate(new Uri("pack://application:,,,/Pages/CreateWork.xaml?datatime=" + DateTime.Now.Ticks));
}

Expand Down
82 changes: 79 additions & 3 deletions Pages/Workspace.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using JiebaNet.Segmenter;
using JiebaNet.Segmenter.Common;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -8,7 +10,6 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
Expand All @@ -20,6 +21,10 @@
using WechatBakTool.Helpers;
using WechatBakTool.Model;
using WechatBakTool.ViewModel;
using WordCloudSharp;
using System.Drawing;
using System.Windows.Controls;
using System.Text.RegularExpressions;

namespace WechatBakTool.Pages
{
Expand All @@ -35,6 +40,7 @@ public Workspace()
ViewModel.ExportItems = new System.Collections.ObjectModel.ObservableCollection<ExportItem> {
new ExportItem(){ Name="导出为HTML",Value=1 },
new ExportItem(){ Name="导出为TXT",Value=2 },
new ExportItem(){ Name="与他的词云",Value=3 },
};
ViewModel.SelectExportItem = ViewModel.ExportItems[0];
InitializeComponent();
Expand Down Expand Up @@ -137,7 +143,77 @@ private void Export_Click(object sender, RoutedEventArgs e)
MessageBox.Show("请选择导出方式", "错误");
return;
}
string path = Path.Combine(Main2.CurrentUserBakConfig!.UserWorkspacePath, ViewModel.WXContact.UserName);
if(ViewModel.SelectExportItem.Value == 3)
{
if(UserReader != null && ViewModel.WXContact != null)
{
WordCloudSettingViewModel setting = new WordCloudSettingViewModel() {
ImgWidth = "1000",
ImgHeight = "1000",
EnableRemoveOneKey = true,
};
Dispatcher.Invoke(() => {
WordCloudSetting wordCloudSetting = new WordCloudSetting(setting);
wordCloudSetting.ShowDialog();
});

var jieba = new JiebaSegmenter();
Counter<string> counter = new Counter<string>();

ViewModel.ExportCount = "词频统计ing...";
List<WXMsg>? msgs = UserReader.GetWXMsgs(ViewModel.WXContact.UserName);
if(msgs!= null)
{
foreach(WXMsg msg in msgs)
{
if(msg.Type == 1)
{
List<string> list = jieba.Cut(msg.StrContent).ToList();
counter.Add(list);
}

}
}
var orderBy = counter.MostCommon();
ViewModel.ExportCount = "移除部分词语...";
string[] remove_string_list = setting.RemoveKey.Split(",");
foreach(string remove_string in remove_string_list)
{
counter.Remove(remove_string);
}
foreach(var key in orderBy)
{
if (key.Key.Length == 1 && setting.EnableRemoveOneKey)
counter.Remove(key.Key);
}

ViewModel.ExportCount = "渲染词云结果";
string resultPath = "result.jpg";

var wordCloud = new WordCloud(int.Parse(setting.ImgWidth), int.Parse(setting.ImgHeight), allowVerical: true, fontname: setting.Font);

if(orderBy.Count() >= setting.MaxKeyCount)
orderBy = orderBy.Take(setting.MaxKeyCount);
//var wordCloud = new WordCloud(1000, 1000,false, null,-1,1,null, false);
var result = wordCloud.Draw(orderBy.Select(it => it.Key).ToList(), orderBy.Select(it => it.Value).ToList());
result.Save(resultPath);
ViewModel.ExportCount = "完成";
MessageBox.Show("生成完毕", "提示");
}
return;
}

string name = ViewModel.WXContact.NickName;
name = name.Replace(@"\", "");
name = Regex.Replace(name, "[ \\[ \\] \\^ \\-_*×――(^)$%~!/@#$…&%¥—+=<>《》|!!???::•`·、。,;,.;\"‘’“”-]", "");
string path = Path.Combine(
Main2.CurrentUserBakConfig!.UserWorkspacePath,
string.Format(
"{0}-{1}",
ViewModel.WXContact.UserName,
ViewModel.WXContact.Remark == "" ? name : ViewModel.WXContact.Remark
)
);
IExport export;

#if DEBUG
Expand Down
Loading

0 comments on commit 6234ad3

Please sign in to comment.