mirror of
https://github.com/zs-yg/kortapp-z.git
synced 2025-12-07 00:20:43 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43027d7953 | ||
|
|
6d2711da08 | ||
|
|
e47f905a8c | ||
|
|
6899e4767f | ||
|
|
d5a0564847 |
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
@@ -57,7 +51,7 @@ namespace AppStore
|
||||
|
||||
// 初始化并添加应用信息
|
||||
infoLabel = new Label();
|
||||
infoLabel.Text = "kortapp-z\n版本: 1.2.5\n作者: zs-yg\n一个简单、开源的应用商店\nkortapp-z是完全免费\n基于.NET8和C/C++的软件";
|
||||
infoLabel.Text = "kortapp-z\n版本: 1.2.7\n作者: zs-yg\n一个简单、开源的应用商店\nkortapp-z是完全免费\n基于.NET8和C/C++的软件";
|
||||
infoLabel.Font = new Font("Microsoft YaHei", 12);
|
||||
infoLabel.AutoSize = false;
|
||||
infoLabel.Width = 300;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
@@ -59,10 +53,11 @@ namespace AppStore
|
||||
this.BackColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light
|
||||
? Color.White
|
||||
: Color.Black;
|
||||
this.BorderStyle = BorderStyle.FixedSingle;
|
||||
this.BorderStyle = BorderStyle.None; // 禁用默认边框
|
||||
this.ForeColor = ThemeManager.CurrentTheme == ThemeManager.ThemeMode.Light
|
||||
? Color.Black
|
||||
: Color.White;
|
||||
this.Paint += DownloadItem_Paint; // 添加自定义绘制
|
||||
|
||||
// 文件名标签
|
||||
nameLabel = new Label();
|
||||
@@ -104,6 +99,17 @@ namespace AppStore
|
||||
nameLabel.Text = FileName;
|
||||
progressBar.Value = Progress;
|
||||
statusLabel.Text = Status;
|
||||
this.Invalidate(); // 触发重绘
|
||||
}
|
||||
|
||||
private void DownloadItem_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
// 自定义边框绘制
|
||||
using (var pen = new Pen(ThemeManager.BorderColor, 1))
|
||||
{
|
||||
e.Graphics.DrawRectangle(pen,
|
||||
new Rectangle(0, 0, this.Width - 1, this.Height - 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelBtn_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
|
||||
82
MainForm.cs
82
MainForm.cs
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Drawing;
|
||||
@@ -132,6 +126,10 @@ namespace AppStore
|
||||
private Button btnAbout = null!;
|
||||
// 内容显示面板
|
||||
private Panel contentPanel = null!;
|
||||
// 系统托盘图标
|
||||
private NotifyIcon trayIcon = null!;
|
||||
// 托盘右键菜单
|
||||
private ContextMenuStrip trayMenu = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化窗体组件
|
||||
@@ -146,6 +144,41 @@ namespace AppStore
|
||||
this.StartPosition = FormStartPosition.CenterScreen;
|
||||
this.Icon = new Icon("img/ico/icon.ico"); // 设置窗体图标
|
||||
|
||||
// 初始化系统托盘
|
||||
trayMenu = new ContextMenuStrip();
|
||||
trayMenu.Items.Add("打开", null, (s, e) => {
|
||||
this.Show();
|
||||
this.WindowState = FormWindowState.Normal;
|
||||
});
|
||||
trayMenu.Items.Add("退出", null, (s, e) => Application.Exit());
|
||||
|
||||
trayIcon = new NotifyIcon();
|
||||
trayIcon.Text = "kortapp-z";
|
||||
trayIcon.Icon = new Icon("img/ico/icon.ico");
|
||||
trayIcon.ContextMenuStrip = trayMenu;
|
||||
trayIcon.Visible = true;
|
||||
trayIcon.DoubleClick += (s, e) => {
|
||||
this.Show();
|
||||
this.WindowState = FormWindowState.Normal;
|
||||
};
|
||||
|
||||
// 窗体最小化到托盘处理
|
||||
this.Resize += (s, e) => {
|
||||
if (this.WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
this.Hide();
|
||||
}
|
||||
};
|
||||
|
||||
// 窗体关闭按钮处理 - 隐藏到托盘而不是退出
|
||||
this.FormClosing += (s, e) => {
|
||||
if (e.CloseReason == CloseReason.UserClosing)
|
||||
{
|
||||
e.Cancel = true;
|
||||
this.Hide();
|
||||
}
|
||||
};
|
||||
|
||||
// 注册主题变更事件
|
||||
ThemeManager.ThemeChanged += (theme) =>
|
||||
{
|
||||
@@ -569,6 +602,43 @@ namespace AppStore
|
||||
}
|
||||
flowPanel.Controls.Add(iconExtractorCard);
|
||||
|
||||
// 文本转换器工具卡片
|
||||
var textConverterCard = new ToolCard();
|
||||
textConverterCard.ToolName = "文本转换器";
|
||||
try
|
||||
{
|
||||
string iconPath = Path.Combine(Application.StartupPath, "img", "resource", "png", "text converter.png");
|
||||
if (File.Exists(iconPath))
|
||||
{
|
||||
textConverterCard.ToolIcon = Image.FromFile(iconPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
textConverterCard.ToolIcon = SystemIcons.Shield.ToBitmap();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
textConverterCard.ToolIcon = SystemIcons.Shield.ToBitmap();
|
||||
}
|
||||
|
||||
textConverterCard.UpdateDisplay();
|
||||
textConverterCard.ToolCardClicked += (s, e) => {
|
||||
try {
|
||||
string toolPath = Path.Combine(Application.StartupPath, "resource", "text_converter.exe");
|
||||
if (File.Exists(toolPath)) {
|
||||
Process.Start(toolPath);
|
||||
} else {
|
||||
MessageBox.Show("文本转换器工具未找到,请确保已正确安装", "错误",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
MessageBox.Show($"启动文本转换器失败: {ex.Message}", "错误",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
};
|
||||
flowPanel.Controls.Add(textConverterCard);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
||||
|
||||
#define MyAppName "kortapp-z"
|
||||
#define MyAppVersion "1.2.5"
|
||||
#define MyAppVersion "1.2.7"
|
||||
#define MyAppPublisher "zsyg"
|
||||
#define MyAppURL "https://github.com/zs-yg/kortapp-z"
|
||||
#define MyAppExeName "kortapp-z.exe"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
||||
|
||||
#define MyAppName "kortapp-z"
|
||||
#define MyAppVersion "1.2.5"
|
||||
#define MyAppVersion "1.2.7"
|
||||
#define MyAppPublisher "zsyg"
|
||||
#define MyAppURL "https://github.com/zs-yg/kortapp-z"
|
||||
#define MyAppExeName "kortapp-z.exe"
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include <chrono>
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
// _ _
|
||||
//| | _____ _ __| |_ __ _ _ __ _ __ ____
|
||||
//| |/ / _ \| '__| __/ _` | '_ \| '_ \ ____|_ /
|
||||
//| | (_) | | | || (_| | |_) | |_) |_____/ /
|
||||
//|_|\_\___/|_| \__\__,_| .__/| .__/ /___|
|
||||
// |_| |_|
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
37
others/C++/text converter/Makefile
Normal file
37
others/C++/text converter/Makefile
Normal file
@@ -0,0 +1,37 @@
|
||||
# 编译器设置
|
||||
CXX = g++
|
||||
FLTK_CONFIG = fltk-config
|
||||
|
||||
# 编译选项
|
||||
CXXFLAGS = -std=c++11 -Wall -Iinclude
|
||||
LDFLAGS = -static -mwindows `$(FLTK_CONFIG) --use-images --ldstaticflags` -lcrypto -lws2_32 -lcrypt32
|
||||
|
||||
# 源文件和目标文件
|
||||
SRC_DIR = src
|
||||
OBJ_DIR = obj
|
||||
SRCS = $(wildcard $(SRC_DIR)/*.cpp)
|
||||
OBJS = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRCS))
|
||||
|
||||
# 可执行文件
|
||||
TARGET = text_converter.exe
|
||||
|
||||
# 默认目标
|
||||
all: $(OBJ_DIR) $(TARGET)
|
||||
|
||||
# 创建obj目录
|
||||
$(OBJ_DIR):
|
||||
mkdir -p $(OBJ_DIR)
|
||||
|
||||
# 生成目标文件
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
|
||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
# 链接生成可执行文件
|
||||
$(TARGET): $(OBJS)
|
||||
$(CXX) $^ -o $@ $(LDFLAGS)
|
||||
|
||||
# 清理
|
||||
clean:
|
||||
rm -rf $(OBJ_DIR) $(TARGET)
|
||||
|
||||
.PHONY: all clean
|
||||
16
others/C++/text converter/include/About.hpp
Normal file
16
others/C++/text converter/include/About.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef ABOUT_HPP
|
||||
#define ABOUT_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
class About {
|
||||
public:
|
||||
static std::string getName() { return "文本转换器"; }
|
||||
static std::string getVersion() { return "1.0.0"; }
|
||||
static std::string getAuthor() { return "zsyg"; }
|
||||
static std::string getDescription() {
|
||||
return "一个简单的文本转换工具,支持文本转换";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // ABOUT_HPP
|
||||
13
others/C++/text converter/include/Ascii85Converter.hpp
Normal file
13
others/C++/text converter/include/Ascii85Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef ASCII85CONVERTER_HPP
|
||||
#define ASCII85CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class Ascii85Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "Ascii85"; }
|
||||
};
|
||||
|
||||
#endif // ASCII85CONVERTER_HPP
|
||||
13
others/C++/text converter/include/Base32Converter.hpp
Normal file
13
others/C++/text converter/include/Base32Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef BASE32CONVERTER_HPP
|
||||
#define BASE32CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class Base32Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "Base32"; }
|
||||
};
|
||||
|
||||
#endif // BASE32CONVERTER_HPP
|
||||
13
others/C++/text converter/include/Base64Converter.hpp
Normal file
13
others/C++/text converter/include/Base64Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef BASE64CONVERTER_HPP
|
||||
#define BASE64CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class Base64Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "Base64"; }
|
||||
};
|
||||
|
||||
#endif // BASE64CONVERTER_HPP
|
||||
14
others/C++/text converter/include/BinaryConverter.hpp
Normal file
14
others/C++/text converter/include/BinaryConverter.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef BINARYCONVERTER_HPP
|
||||
#define BINARYCONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
#include <bitset>
|
||||
|
||||
class BinaryConverter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "二进制"; }
|
||||
};
|
||||
|
||||
#endif // BINARYCONVERTER_HPP
|
||||
13
others/C++/text converter/include/CRC32Converter.hpp
Normal file
13
others/C++/text converter/include/CRC32Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef CRC32CONVERTER_HPP
|
||||
#define CRC32CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class CRC32Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "CRC32"; }
|
||||
};
|
||||
|
||||
#endif // CRC32CONVERTER_HPP
|
||||
30
others/C++/text converter/include/Config.hpp
Normal file
30
others/C++/text converter/include/Config.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef CONFIG_HPP
|
||||
#define CONFIG_HPP
|
||||
|
||||
namespace Config {
|
||||
constexpr int WINDOW_WIDTH = 450;
|
||||
constexpr int WINDOW_HEIGHT = 250;
|
||||
constexpr const char* WINDOW_TITLE = "文本转换器";
|
||||
|
||||
constexpr int INPUT_X = 70;
|
||||
constexpr int INPUT_Y = 40;
|
||||
constexpr int INPUT_WIDTH = 360;
|
||||
constexpr int INPUT_HEIGHT = 30;
|
||||
|
||||
constexpr int OUTPUT_X = 70;
|
||||
constexpr int OUTPUT_Y = 100;
|
||||
constexpr int OUTPUT_WIDTH = 360;
|
||||
constexpr int OUTPUT_HEIGHT = 30;
|
||||
|
||||
constexpr int CHOICE_X = 70;
|
||||
constexpr int CHOICE_Y = 160;
|
||||
constexpr int CHOICE_WIDTH = 120;
|
||||
constexpr int CHOICE_HEIGHT = 30;
|
||||
|
||||
constexpr int BUTTON_X = 210;
|
||||
constexpr int BUTTON_Y = 160;
|
||||
constexpr int BUTTON_WIDTH = 100;
|
||||
constexpr int BUTTON_HEIGHT = 30;
|
||||
};
|
||||
|
||||
#endif // CONFIG_HPP
|
||||
13
others/C++/text converter/include/Converter.hpp
Normal file
13
others/C++/text converter/include/Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef CONVERTER_HPP
|
||||
#define CONVERTER_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
class Converter {
|
||||
public:
|
||||
virtual ~Converter() = default;
|
||||
virtual std::string convert(const std::string& input) = 0;
|
||||
virtual std::string getName() const = 0;
|
||||
};
|
||||
|
||||
#endif // CONVERTER_HPP
|
||||
15
others/C++/text converter/include/HexConverter.hpp
Normal file
15
others/C++/text converter/include/HexConverter.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef HEXCONVERTER_HPP
|
||||
#define HEXCONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
class HexConverter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "十六进制"; }
|
||||
};
|
||||
|
||||
#endif // HEXCONVERTER_HPP
|
||||
13
others/C++/text converter/include/MD5Converter.hpp
Normal file
13
others/C++/text converter/include/MD5Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef MD5CONVERTER_HPP
|
||||
#define MD5CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class MD5Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "MD5"; }
|
||||
};
|
||||
|
||||
#endif // MD5CONVERTER_HPP
|
||||
26
others/C++/text converter/include/MainWindow.hpp
Normal file
26
others/C++/text converter/include/MainWindow.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef MAINWINDOW_HPP
|
||||
#define MAINWINDOW_HPP
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Window.H>
|
||||
#include <FL/Fl_Button.H>
|
||||
#include <FL/Fl_Input.H>
|
||||
#include <FL/Fl_Output.H>
|
||||
#include <FL/Fl_Choice.H>
|
||||
|
||||
class MainWindow : public Fl_Window {
|
||||
public:
|
||||
MainWindow(int w, int h, const char* title);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
Fl_Input* inputText;
|
||||
Fl_Output* outputText;
|
||||
Fl_Choice* conversionType;
|
||||
Fl_Button* convertButton;
|
||||
|
||||
static void ConvertCallback(Fl_Widget* widget, void* data);
|
||||
void ConvertText();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_HPP
|
||||
14
others/C++/text converter/include/ROT13Converter.hpp
Normal file
14
others/C++/text converter/include/ROT13Converter.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef ROT13CONVERTER_HPP
|
||||
#define ROT13CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
#include <cctype>
|
||||
|
||||
class ROT13Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "ROT13"; }
|
||||
};
|
||||
|
||||
#endif // ROT13CONVERTER_HPP
|
||||
13
others/C++/text converter/include/SHA1Converter.hpp
Normal file
13
others/C++/text converter/include/SHA1Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef SHA1CONVERTER_HPP
|
||||
#define SHA1CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class SHA1Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "SHA1"; }
|
||||
};
|
||||
|
||||
#endif // SHA1CONVERTER_HPP
|
||||
13
others/C++/text converter/include/SHA256Converter.hpp
Normal file
13
others/C++/text converter/include/SHA256Converter.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef SHA256CONVERTER_HPP
|
||||
#define SHA256CONVERTER_HPP
|
||||
|
||||
#include "Converter.hpp"
|
||||
#include <string>
|
||||
|
||||
class SHA256Converter : public Converter {
|
||||
public:
|
||||
std::string convert(const std::string& input) override;
|
||||
std::string getName() const override { return "SHA256"; }
|
||||
};
|
||||
|
||||
#endif // SHA256CONVERTER_HPP
|
||||
14
others/C++/text converter/include/Utils.hpp
Normal file
14
others/C++/text converter/include/Utils.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef UTILS_HPP
|
||||
#define UTILS_HPP
|
||||
|
||||
#include <memory>
|
||||
#include "Converter.hpp"
|
||||
#include "BinaryConverter.hpp"
|
||||
#include "HexConverter.hpp"
|
||||
|
||||
class Utils {
|
||||
public:
|
||||
static std::unique_ptr<Converter> createConverter(int type);
|
||||
};
|
||||
|
||||
#endif // UTILS_HPP
|
||||
47
others/C++/text converter/src/Ascii85Converter.cpp
Normal file
47
others/C++/text converter/src/Ascii85Converter.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "../include/Ascii85Converter.hpp"
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include <cstdint>
|
||||
|
||||
const std::string ASCII85_PREFIX = "<~";
|
||||
const std::string ASCII85_SUFFIX = "~>";
|
||||
|
||||
std::string Ascii85Converter::convert(const std::string& input) {
|
||||
std::stringstream result;
|
||||
result << ASCII85_PREFIX;
|
||||
|
||||
size_t i = 0;
|
||||
while (i < input.size()) {
|
||||
uint32_t value = 0;
|
||||
int bytes = 0;
|
||||
|
||||
// 读取4个字节
|
||||
for (int j = 0; j < 4 && (i + j) < input.size(); j++) {
|
||||
value = (value << 8) | static_cast<unsigned char>(input[i + j]);
|
||||
bytes++;
|
||||
}
|
||||
i += bytes;
|
||||
|
||||
// 特殊处理全0的4字节
|
||||
if (value == 0 && bytes == 4) {
|
||||
result << 'z';
|
||||
continue;
|
||||
}
|
||||
|
||||
// 转换为Ascii85
|
||||
char chars[5];
|
||||
for (int j = 4; j >= 0; j--) {
|
||||
chars[j] = value % 85 + '!';
|
||||
value /= 85;
|
||||
}
|
||||
|
||||
// 写入结果(只写入bytes+1个字符)
|
||||
for (int j = 0; j < bytes + 1; j++) {
|
||||
result << chars[j];
|
||||
}
|
||||
}
|
||||
|
||||
result << ASCII85_SUFFIX;
|
||||
return result.str();
|
||||
}
|
||||
37
others/C++/text converter/src/Base32Converter.cpp
Normal file
37
others/C++/text converter/src/Base32Converter.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "../include/Base32Converter.hpp"
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
const std::string BASE32_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
||||
|
||||
std::string Base32Converter::convert(const std::string& input) {
|
||||
std::string result;
|
||||
int buffer = 0;
|
||||
int bitsLeft = 0;
|
||||
int count = 0;
|
||||
|
||||
for (unsigned char c : input) {
|
||||
buffer <<= 8;
|
||||
buffer |= c;
|
||||
bitsLeft += 8;
|
||||
count++;
|
||||
|
||||
while (bitsLeft >= 5) {
|
||||
int index = (buffer >> (bitsLeft - 5)) & 0x1F;
|
||||
result += BASE32_CHARS[index];
|
||||
bitsLeft -= 5;
|
||||
}
|
||||
}
|
||||
|
||||
if (bitsLeft > 0) {
|
||||
int index = (buffer << (5 - bitsLeft)) & 0x1F;
|
||||
result += BASE32_CHARS[index];
|
||||
}
|
||||
|
||||
// 添加填充字符
|
||||
while (result.size() % 8 != 0) {
|
||||
result += '=';
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
22
others/C++/text converter/src/Base64Converter.cpp
Normal file
22
others/C++/text converter/src/Base64Converter.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "../include/Base64Converter.hpp"
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <string>
|
||||
|
||||
std::string Base64Converter::convert(const std::string& input) {
|
||||
// Base64编码
|
||||
BIO *b64 = BIO_new(BIO_f_base64());
|
||||
BIO *bio = BIO_new(BIO_s_mem());
|
||||
BIO_push(b64, bio);
|
||||
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
|
||||
|
||||
BIO_write(b64, input.c_str(), input.length());
|
||||
BIO_flush(b64);
|
||||
|
||||
char* buffer;
|
||||
long length = BIO_get_mem_data(bio, &buffer);
|
||||
std::string result(buffer, length);
|
||||
|
||||
BIO_free_all(b64);
|
||||
return result;
|
||||
}
|
||||
27
others/C++/text converter/src/BinaryConverter.cpp
Normal file
27
others/C++/text converter/src/BinaryConverter.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "../include/BinaryConverter.hpp"
|
||||
#include <bitset>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
std::string BinaryConverter::convert(const std::string& input) {
|
||||
if (input.empty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::stringstream result;
|
||||
for (char c : input) {
|
||||
std::string binary = std::bitset<8>(c).to_string();
|
||||
// 去除前导0,保留后6位
|
||||
size_t firstOne = binary.find('1');
|
||||
if (firstOne != std::string::npos) {
|
||||
binary = binary.substr(firstOne);
|
||||
}
|
||||
result << binary << " ";
|
||||
}
|
||||
|
||||
std::string output = result.str();
|
||||
if (!output.empty()) {
|
||||
output.pop_back(); // 移除最后一个空格
|
||||
}
|
||||
return output;
|
||||
}
|
||||
28
others/C++/text converter/src/CRC32Converter.cpp
Normal file
28
others/C++/text converter/src/CRC32Converter.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "../include/CRC32Converter.hpp"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <cstdint>
|
||||
|
||||
// CRC32多项式
|
||||
const uint32_t CRC32_POLY = 0xEDB88320;
|
||||
|
||||
uint32_t computeCRC32(const std::string& input) {
|
||||
uint32_t crc = 0xFFFFFFFF;
|
||||
|
||||
for (char c : input) {
|
||||
crc ^= static_cast<unsigned char>(c);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
crc = (crc >> 1) ^ ((crc & 1) ? CRC32_POLY : 0);
|
||||
}
|
||||
}
|
||||
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
std::string CRC32Converter::convert(const std::string& input) {
|
||||
uint32_t crc = computeCRC32(input);
|
||||
std::stringstream ss;
|
||||
ss << std::hex << std::setw(8) << std::setfill('0') << crc;
|
||||
return ss.str();
|
||||
}
|
||||
23
others/C++/text converter/src/HexConverter.cpp
Normal file
23
others/C++/text converter/src/HexConverter.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "../include/HexConverter.hpp"
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
std::string HexConverter::convert(const std::string& input) {
|
||||
if (input.empty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::stringstream result;
|
||||
for (char c : input) {
|
||||
result << std::hex << std::setw(2) << std::setfill('0')
|
||||
<< static_cast<int>(static_cast<unsigned char>(c)) << " ";
|
||||
}
|
||||
|
||||
std::string output = result.str();
|
||||
// 移除最后一个空格
|
||||
if (!output.empty()) {
|
||||
output.pop_back();
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
23
others/C++/text converter/src/MD5Converter.cpp
Normal file
23
others/C++/text converter/src/MD5Converter.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "../include/MD5Converter.hpp"
|
||||
#include <openssl/evp.h>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
std::string MD5Converter::convert(const std::string& input) {
|
||||
EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
|
||||
const EVP_MD* md = EVP_md5();
|
||||
unsigned char digest[EVP_MAX_MD_SIZE];
|
||||
unsigned int digest_len;
|
||||
|
||||
EVP_DigestInit_ex(mdctx, md, nullptr);
|
||||
EVP_DigestUpdate(mdctx, input.c_str(), input.length());
|
||||
EVP_DigestFinal_ex(mdctx, digest, &digest_len);
|
||||
EVP_MD_CTX_free(mdctx);
|
||||
|
||||
std::stringstream ss;
|
||||
for(unsigned int i = 0; i < digest_len; i++) {
|
||||
ss << std::hex << std::setw(2) << std::setfill('0') << (int)digest[i];
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
14
others/C++/text converter/src/Main.cpp
Normal file
14
others/C++/text converter/src/Main.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "../include/MainWindow.hpp"
|
||||
#include "../include/Config.hpp"
|
||||
#include <FL/Fl.H>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// 创建主窗口
|
||||
MainWindow window(Config::WINDOW_WIDTH, Config::WINDOW_HEIGHT, Config::WINDOW_TITLE);
|
||||
|
||||
// 显示窗口
|
||||
window.show(argc, argv);
|
||||
|
||||
// 运行FLTK主循环
|
||||
return Fl::run();
|
||||
}
|
||||
66
others/C++/text converter/src/MainWindow.cpp
Normal file
66
others/C++/text converter/src/MainWindow.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "../include/MainWindow.hpp"
|
||||
#include "../include/Utils.hpp"
|
||||
#include "../include/Config.hpp"
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <FL/fl_ask.H>
|
||||
|
||||
MainWindow::MainWindow(int w, int h, const char* title) : Fl_Window(w, h, title) {
|
||||
// 初始化UI元素
|
||||
inputText = new Fl_Input(Config::INPUT_X, Config::INPUT_Y,
|
||||
Config::INPUT_WIDTH, Config::INPUT_HEIGHT, "输入文本:");
|
||||
outputText = new Fl_Output(Config::OUTPUT_X, Config::OUTPUT_Y,
|
||||
Config::OUTPUT_WIDTH, Config::OUTPUT_HEIGHT, "输出结果:");
|
||||
conversionType = new Fl_Choice(Config::CHOICE_X, Config::CHOICE_Y,
|
||||
Config::CHOICE_WIDTH, Config::CHOICE_HEIGHT, "转换类型:");
|
||||
convertButton = new Fl_Button(Config::BUTTON_X, Config::BUTTON_Y,
|
||||
Config::BUTTON_WIDTH, Config::BUTTON_HEIGHT, "转换");
|
||||
|
||||
// 设置转换类型选项
|
||||
conversionType->add("二进制");
|
||||
conversionType->add("十六进制");
|
||||
conversionType->add("ROT13");
|
||||
conversionType->add("MD5");
|
||||
conversionType->add("SHA1");
|
||||
conversionType->add("SHA256");
|
||||
conversionType->add("Base64");
|
||||
conversionType->add("Base32");
|
||||
conversionType->add("Ascii85");
|
||||
conversionType->add("CRC32");
|
||||
conversionType->value(0); // 默认选择二进制
|
||||
|
||||
// 设置按钮回调
|
||||
convertButton->callback(ConvertCallback, this);
|
||||
|
||||
end(); // 结束窗口组件添加
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
// 清理资源
|
||||
delete inputText;
|
||||
delete outputText;
|
||||
delete conversionType;
|
||||
delete convertButton;
|
||||
}
|
||||
|
||||
void MainWindow::ConvertCallback(Fl_Widget* widget, void* data) {
|
||||
MainWindow* window = static_cast<MainWindow*>(data);
|
||||
window->ConvertText();
|
||||
}
|
||||
|
||||
void MainWindow::ConvertText() {
|
||||
const char* input = inputText->value();
|
||||
if (!input || strlen(input) == 0) {
|
||||
fl_alert("请输入要转换的文本");
|
||||
return;
|
||||
}
|
||||
|
||||
int type = conversionType->value();
|
||||
auto converter = Utils::createConverter(type);
|
||||
if (!converter) {
|
||||
fl_alert("不支持的转换类型");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string result = converter->convert(input);
|
||||
outputText->value(result.c_str());
|
||||
}
|
||||
13
others/C++/text converter/src/ROT13Converter.cpp
Normal file
13
others/C++/text converter/src/ROT13Converter.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "../include/ROT13Converter.hpp"
|
||||
|
||||
std::string ROT13Converter::convert(const std::string& input) {
|
||||
std::string result;
|
||||
for (char c : input) {
|
||||
if (isalpha(c)) {
|
||||
char base = isupper(c) ? 'A' : 'a';
|
||||
c = (c - base + 13) % 26 + base;
|
||||
}
|
||||
result += c;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
23
others/C++/text converter/src/SHA1Converter.cpp
Normal file
23
others/C++/text converter/src/SHA1Converter.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "../include/SHA1Converter.hpp"
|
||||
#include <openssl/evp.h>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
std::string SHA1Converter::convert(const std::string& input) {
|
||||
EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
|
||||
const EVP_MD* md = EVP_sha1();
|
||||
unsigned char digest[EVP_MAX_MD_SIZE];
|
||||
unsigned int digest_len;
|
||||
|
||||
EVP_DigestInit_ex(mdctx, md, nullptr);
|
||||
EVP_DigestUpdate(mdctx, input.c_str(), input.length());
|
||||
EVP_DigestFinal_ex(mdctx, digest, &digest_len);
|
||||
EVP_MD_CTX_free(mdctx);
|
||||
|
||||
std::stringstream ss;
|
||||
for(unsigned int i = 0; i < digest_len; i++) {
|
||||
ss << std::hex << std::setw(2) << std::setfill('0') << (int)digest[i];
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
23
others/C++/text converter/src/SHA256Converter.cpp
Normal file
23
others/C++/text converter/src/SHA256Converter.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "../include/SHA256Converter.hpp"
|
||||
#include <openssl/evp.h>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
std::string SHA256Converter::convert(const std::string& input) {
|
||||
EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
|
||||
const EVP_MD* md = EVP_sha256();
|
||||
unsigned char digest[EVP_MAX_MD_SIZE];
|
||||
unsigned int digest_len;
|
||||
|
||||
EVP_DigestInit_ex(mdctx, md, nullptr);
|
||||
EVP_DigestUpdate(mdctx, input.c_str(), input.length());
|
||||
EVP_DigestFinal_ex(mdctx, digest, &digest_len);
|
||||
EVP_MD_CTX_free(mdctx);
|
||||
|
||||
std::stringstream ss;
|
||||
for(unsigned int i = 0; i < digest_len; i++) {
|
||||
ss << std::hex << std::setw(2) << std::setfill('0') << (int)digest[i];
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
25
others/C++/text converter/src/Utils.cpp
Normal file
25
others/C++/text converter/src/Utils.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "../include/Utils.hpp"
|
||||
#include "../include/ROT13Converter.hpp"
|
||||
#include "../include/MD5Converter.hpp"
|
||||
#include "../include/SHA1Converter.hpp"
|
||||
#include "../include/SHA256Converter.hpp"
|
||||
#include "../include/Base64Converter.hpp"
|
||||
#include "../include/Base32Converter.hpp"
|
||||
#include "../include/Ascii85Converter.hpp"
|
||||
#include "../include/CRC32Converter.hpp"
|
||||
|
||||
std::unique_ptr<Converter> Utils::createConverter(int type) {
|
||||
switch (type) {
|
||||
case 0: return std::unique_ptr<Converter>(new BinaryConverter());
|
||||
case 1: return std::unique_ptr<Converter>(new HexConverter());
|
||||
case 2: return std::unique_ptr<Converter>(new ROT13Converter());
|
||||
case 3: return std::unique_ptr<Converter>(new MD5Converter());
|
||||
case 4: return std::unique_ptr<Converter>(new SHA1Converter());
|
||||
case 5: return std::unique_ptr<Converter>(new SHA256Converter());
|
||||
case 6: return std::unique_ptr<Converter>(new Base64Converter());
|
||||
case 7: return std::unique_ptr<Converter>(new Base32Converter());
|
||||
case 8: return std::unique_ptr<Converter>(new Ascii85Converter());
|
||||
case 9: return std::unique_ptr<Converter>(new CRC32Converter());
|
||||
default: return nullptr;
|
||||
}
|
||||
}
|
||||
BIN
resource/text_converter.exe
Normal file
BIN
resource/text_converter.exe
Normal file
Binary file not shown.
Reference in New Issue
Block a user