Skip to content

Commit

Permalink
Add package dropdown box
Browse files Browse the repository at this point in the history
  • Loading branch information
oxygen-TW committed Jul 3, 2020
1 parent 3aefa57 commit 2a54b61
Show file tree
Hide file tree
Showing 212 changed files with 5,171 additions and 74 deletions.
Binary file not shown.
25 changes: 25 additions & 0 deletions OtherCode/PackageWizard/PackageWizard/PackageWizard.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30011.22
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageWizard", "PackageWizard\PackageWizard.csproj", "{3AD3A079-3D74-4561-9B5B-24EDC133049C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3AD3A079-3D74-4561-9B5B-24EDC133049C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3AD3A079-3D74-4561-9B5B-24EDC133049C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3AD3A079-3D74-4561-9B5B-24EDC133049C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3AD3A079-3D74-4561-9B5B-24EDC133049C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B3B67123-4C65-4BCF-BBEC-6679A721ED8D}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
200 changes: 200 additions & 0 deletions OtherCode/PackageWizard/PackageWizard/PackageWizard/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

158 changes: 158 additions & 0 deletions OtherCode/PackageWizard/PackageWizard/PackageWizard/Form1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
using Tommy;
using System.IO;
using System.IO.Compression;

namespace PackageWizard
{
public partial class Form1 : Form
{

String ImagePath = "";
String Ans = "";
String FolderPath = "test";
Int32 counter = 1;
TomlTable TomlT;
Image imageShow;

public Form1()
{
InitializeComponent();
}

public void SaveTOML(TomlTable Data)
{

using (StreamWriter writer = new StreamWriter(File.OpenWrite(FolderPath + "\\config.toml")))
Data.ToTomlString(writer);
}

private void FileImportLable_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.All;//调用DragDrop事件
}
else
{
e.Effect = DragDropEffects.None;
}
}

private void FileImportLable_DragEnter(object sender, DragEventArgs e)
{
string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
ImagePath = filePaths[0];

Image image1 = Image.FromFile(ImagePath);
ImageFormat format = image1.RawFormat;

int width = 800; //寬度
int heigt = 600; //高度
Bitmap imgoutput = new Bitmap(image1, width, heigt); //輸出一個新圖片
imgoutput.Save("tmp.jpg", format); //存檔路徑,格式

imgoutput.Dispose();
image1.Dispose();

imageShow = Image.FromFile("tmp.jpg");
FileImportLable.Image = imageShow;

}

private void WriteBtn_Click(object sender, EventArgs e)
{
}

private void Form1_Load(object sender, EventArgs e)
{
TomlT = new TomlTable
{
["title"] = "TOML Example",
["answer"] = { }

};

if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
FolderPath = folderBrowserDialog1.SelectedPath;
Console.Write(FolderPath);
PathtoolStripLabel.Text = FolderPath;
}

// Determine whether the directory exists.
if (!Directory.Exists(FolderPath))
{
Console.WriteLine("That path not exists.");
Application.Exit();
}
}


private void AnswerTB_TextChanged(object sender, EventArgs e)
{

}

private void toolStripLabel2_Click(object sender, EventArgs e)
{
TomlT["answer"].Add(counter.ToString(), AnswerTB.Text);
SaveTOML(TomlT);

Image image1 = Image.FromFile(ImagePath);
image1.Save(FolderPath + "\\" + counter.ToString() + ".jpg", image1.RawFormat);
counter += 1;

MessageBox.Show("題目新增成功", counter.ToString()+"成功",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
UsertoolStripLabel.Text = "目前編號:" + counter.ToString();
AnswerTB.Text = "";
FileImportLable.Image = null;
imageShow.Dispose();
}

private void toolStripLabel1_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
FolderPath = folderBrowserDialog1.SelectedPath;
Console.Write(FolderPath);
PathtoolStripLabel.Text = FolderPath;
}
else
{
return;
}

// Determine whether the directory exists.
if (!Directory.Exists(FolderPath))
{
Console.WriteLine("That path not exists.");
return;
}
}

private void toolStripLabel3_Click(object sender, EventArgs e)
{
saveFileDialog1.ShowDialog();

if (saveFileDialog1.FileName != "")
{
string zipPath = saveFileDialog1.FileName;
ZipFile.CreateFromDirectory(FolderPath, zipPath);
}

}
}
}
Loading

0 comments on commit 2a54b61

Please sign in to comment.