📄 mbookmaker.cs.bak
字号:
{
this.pbPreview.Height = 0xd0;
}
this.tabs_SelectedIndexChanged(sender, e);
}
private void btAddChap_Click(object sender, System.EventArgs e)
{
if ((this.lbChapters.Items.Count == 1) && (((string) this.lbChapters.Items[0]) == "<添加目录标题...>"))
{
this.lbChapters.Items.Clear();
}
if ((this.tbCurrChapStr.Text == "<添加目录标题...>") || (this.tbCurrChapStr.Text.Length <= 0))
{
MessageBox.Show("您输入的标题不合法!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
this.tbCurrChapStr.Focus();
this.tbCurrChapStr.SelectAll();
}
else
{
if ((this.lbChapters.Items.Count == 0) || (this.lbChapters.SelectedIndex < 0))
{
this.lbChapters.Items.Add(this.tbCurrChapStr.Text);
this.iChapter.Add("");
}
else
{
this.lbChapters.Items.Insert(this.lbChapters.SelectedIndex + 1, this.tbCurrChapStr.Text);
this.iChapter.Insert(this.lbChapters.SelectedIndex + 1, "");
}
if (this.lbChapters.Items.Count > (this.lbChapters.SelectedIndex + 1))
{
this.lbChapters.SelectedIndex++;
}
this.tbText.Text = "";
this.tbCurrChapStr.Text = "";
}
}
private void btRenChap_Click(object sender, System.EventArgs e)
{
if ((this.lbChapters.SelectedIndex >= 0) && (this.lbChapters.SelectedIndex < this.lbChapters.Items.Count))
{
this.lbChapters.Items[this.lbChapters.SelectedIndex] = this.tbCurrChapStr.Text;
}
}
private void btDelChap_Click(object sender, System.EventArgs e)
{
if ((this.lbChapters.SelectedIndex >= 0) && (this.lbChapters.SelectedIndex < this.lbChapters.Items.Count))
{
int num1 = this.lbChapters.SelectedIndex;
this.lbChapters.Items.RemoveAt(num1);
this.iChapter.RemoveAt(num1);
if (this.lbChapters.Items.Count <= (num1 + 1))
{
this.lbChapters.SelectedIndex = this.lbChapters.Items.Count - 1;
}
else
{
this.lbChapters.SelectedIndex = num1;
}
}
}
private void btAddFile_Click(object sender, System.EventArgs e)
{
this.dlgOpenFile.Filter = "文本文件(*.txt)|*.txt";
dlgOpenFile.Multiselect = false;
if (this.dlgOpenFile.ShowDialog() == DialogResult.OK)
{
this.tbText.Clear();
FileStream stream1 = new FileStream(this.dlgOpenFile.FileName, FileMode.Open);
byte[] buffer1 = new byte[stream1.Length];
stream1.Read(buffer1, 0, 2);
if ((buffer1[0] == 0xff) && (buffer1[1] == 0xfe))
{
stream1.Read(buffer1, 0, buffer1.Length);
}
else
{
stream1.Seek((long) 0, SeekOrigin.Begin);
stream1.Read(buffer1, 0, buffer1.Length);
buffer1 = System.Text.Encoding.Convert(System.Text.Encoding.Default, System.Text.Encoding.Unicode, buffer1);
}
this.tbText.Text = System.Text.Encoding.Unicode.GetString(buffer1);
this.tbText.Modified = true;
this.tbText_TextChanged(sender, e);
stream1.Close();
}
}
private void btPaste_Click(object sender, System.EventArgs e)
{
IDataObject obj1 = Clipboard.GetDataObject();
if (obj1.GetDataPresent(DataFormats.Text))
{
if (this.tbText.SelectionLength > 0)
{
this.tbText.Text.Remove(this.tbText.SelectionStart, this.tbText.SelectionLength);
}
this.tbText.Text = this.tbText.Text.Insert(this.tbText.SelectionStart, (string) obj1.GetData(DataFormats.Text));
this.tbText.Modified = true;
this.tbText_TextChanged(this.tbText, e);
}
}
private void tbText_TextChanged(object sender, System.EventArgs e)
{
if (this.tbText.Modified)
{
this.lbModified.Visible = true;
}
else
{
this.lbModified.Visible = false;
}
this.iModified = this.lbModified.Visible;
}
private void lbChapters_SelectedIndexChanged(object sender, System.EventArgs e)
{
if ((((this.lbChapters.SelectedIndex >= 0) && (this.lbChapters.SelectedIndex < this.lbChapters.Items.Count)) && (this.lbModified.Visible && (this.iLastSelected != this.lbChapters.SelectedIndex))) && (MessageBox.Show(string.Format("目录标题:{0}\r\n内容已经被修改,是否保存?", this.lbChapters.Items[this.iLastSelected]), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
{
this.iChapter[this.iLastSelected] = this.tbText.Text;
}
this.iLastSelected = this.lbChapters.SelectedIndex;
if ((this.lbChapters.Items.Count == 1) && (((string) this.lbChapters.Items[0]) == "<添加目录标题...>"))
{
this.tbCurrChapStr.Text = (string) this.lbChapters.SelectedItem;
this.tbCurrChapStr.Focus();
this.tbCurrChapStr.SelectAll();
this.lbChapters.Items.Clear();
}
else if ((this.iChapter.Count > this.lbChapters.SelectedIndex) && (this.lbChapters.SelectedIndex >= 0))
{
this.tbText.Text = (string) this.iChapter[this.lbChapters.SelectedIndex];
this.tbCurrChapStr.Text = (string) this.lbChapters.Items[this.lbChapters.SelectedIndex];
this.lbModified.Visible = false;
this.iModified = false;
}
}
private void btGO_Click(object sender, System.EventArgs e)
{
string aResult;
string aYear = this.dtpDate.Value.Year.ToString();
string aMonth = this.dtpDate.Value.Month.ToString();
string aDay = this.dtpDate.Value.Day.ToString();
UMD_GENEGINE umd_genegine1 = new UMD_GENEGINE();
Random random1 = new Random();
int num1 = random1.Next(0x5f5e101, 1000000000);
if(iType == 0)//普通书
{
if (!umd_genegine1.Initialize(this.tbTitle.Text, this.tbAuthor.aYear, aMonth, aMonth, aDay, this.cbGender.Text, this.tbPublisher.Text, "DIY_GENERATED", this.iCoverFile, num1, this.tbSaveTo.Text, ref this.iChapter, ref this.iChapStr, out aResult))
{
MessageBox.Show("初始化生成引擎错误:\n" + text4, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else if (umd_genegine1.Make(ref this.pbar, out text4))
{
MessageBox.Show("制作成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
else
{
MessageBox.Show("生成文件错误:\n" + text4, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}else if(iType == 1)//漫画书
{
if (checkUserText.Checked == true)
{//小人书,有文字说明
}
else
{//写真书,只有图片,可能有目录
ArrayList iChapterOff = new ArrayList();//目录偏移
ArrayList sChapterStr = new ArrayList();//目录名称
ArrayList sChapterJpg = new ArrayList();//图片列表
if (checkUserChap.Checked)//有目录
{
}else//没有目录
{
string JpgFileName;
sChapterJpg.Add();
}
if (!umd_genegine1.MHInitialize(this.tbTitle.Text, this.tbAuthor.aYear, aMonth, aMonth, aDay,
this.cbGender.Text, this.tbPublisher.Text, "SUN_GENERATED",
this.iCoverFile, num1, this.tbSaveTo.Text,
ref iChapterOff, ref sChapterStr,ref sChapterJpg, out aResult))
{
MessageBox.Show("初始化生成引擎错误:\n" + text4, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else if (umd_genegine1.MHMake(ref this.pbar, out text4))
{
MessageBox.Show("制作成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
else
{
MessageBox.Show("生成文件错误:\n" + text4, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}else
{
MessageBox.Show("文件类型没有定义!",this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
private void mBookMaker_Closed(object sender, System.EventArgs e)
{
if (File.Exists(this.iCoverFile + ".tmp"))
{
File.Delete(this.iCoverFile + ".tmp");
}
}
private void cbType_SelectedIndexChanged(object sender, System.EventArgs e)
{
iType = this.cbType.SelectedIndex;
}
private void menuItemAbout_Click(object sender, System.EventArgs e)
{
this.tabs.SelectedTab = tabAbout;
}
private void menuItemExit_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void checkUserChap_CheckedChanged(object sender, System.EventArgs e)
{
bool bUser = false;
if(checkUserChap.Checked)
{
checkUserText.Checked = false;
bUser = true;
}
this.lbMhChapters.Enabled = bUser;
this.tbMhCurrChapStr.Enabled = bUser;
this.btMhAddChap.Enabled = bUser;
this.btMhRenChap.Enabled = bUser;
this.btMhDelChap.Enabled = bUser;
this.checkUserText.Enabled = !bUser;
this.tbMhText.Enabled = false;
}
private void checkUserText_CheckedChanged(object sender, System.EventArgs e)
{
bool bUser = false;
if(checkUserText.Checked)
{
checkUserChap.Checked = false;
bUser = true;
}
this.lbMhChapters.Enabled = false;
this.tbMhCurrChapStr.Enabled = false;
this.btMhAddChap.Enabled = false;
this.btMhRenChap.Enabled = false;
this.btMhDelChap.Enabled = false;
this.tbMhText.Enabled = bUser;
this.checkUserChap.Enabled = !bUser;
}
private void btJpgAdd_Click(object sender, System.EventArgs e)
{
this.dlgOpenFile.Filter = "图片文件(*.jpg)|*.jpg";
dlgOpenFile.Multiselect = true;
if (this.dlgOpenFile.ShowDialog() == DialogResult.OK)
{
for (int i = 0;i< this.dlgOpenFile.FileNames.Length;i++)
{
if (checkUserChap.Checked && lbMhChapters.Items.Count>0)
{
int iSelectIndex = lbMhChapters.SelectedIndex;
MHChapter tmpMHChapter = (MHChapter)MHChapterArray[iSelectIndex];
tmpMHChapter.JpgFileNameArray.Add(this.dlgOpenFile.FileNames[i]);
}
this.lbJpgFile.Items.Add(this.dlgOpenFile.FileNames[i]);
}
}
if (this.lbJpgFile.Items.Count > (this.lbJpgFile.SelectedIndex + 1))
{
this.lbJpgFile.SelectedIndex++;
}
}
private void lbJpgFile_SelectedIndexChanged(object sender, System.EventArgs e)
{
string BmpFileName = (string)this.lbJpgFile.SelectedItem;
if (BmpFileName == null)
{
return;
}
this.fromMhPreview.pbMhPreview.Image = Image.FromFile(BmpFileName);
this.fromMhPreview.pbMhPreview.Width = this.fromMhPreview.pbMhPreview.Image.Width;
this.fromMhPreview.pbMhPreview.Height = this.fromMhPreview.pbMhPreview.Image.Height;
this.fromMhPreview.Width = this.fromMhPreview.pbMhPreview.Image.Width+5;
this.fromMhPreview.Height = this.fromMhPreview.pbMhPreview.Image.Height+20;
}
private void btJpgClear_Click(object sender, System.EventArgs e)
{
if (checkUserChap.Checked && lbMhChapters.Items.Count>0)
{
int iSelectIndex = lbMhChapters.SelectedIndex;
MHChapter tmpMHChapter = (MHChapter)MHChapterArray[iSelectIndex];
tmpMHChapter.JpgFileNameArray.Clear();
}
this.lbJpgFile.Items.Clear();
}
private void btJpgDel_Click(object sender, System.EventArgs e)
{
if ((this.lbJpgFile.SelectedIndex >= 0) && (this.lbJpgFile.SelectedIndex < this.lbJpgFile.Items.Count))
{
int num1 = this.lbJpgFile.SelectedIndex;
if (checkUserChap.Checked && lbMhChapters.Items.Count>0)
{
int iSelectIndex = lbMhChapters.SelectedIndex;
MHChapter tmpMHChapter = (MHChapter)MHChapterArray[iSelectIndex];
tmpMHChapter.JpgFileNameArray.RemoveAt(num1);
}
this.lbJpgFile.Items.RemoveAt(num1);
if (this.lbJpgFile.Items.Count <= (num1 + 1))
{
this.lbJpgFile.SelectedIndex = this.lbJpgFile.Items.Count - 1;
}
else
{
this.lbJpgFile.SelectedIndex = num1;
}
}
}
private void btMhAddChap_Click(object sender, System.EventArgs e)
{
if (this.tbMhCurrChapStr.Text.Length <= 0)
{
MessageBox.Show("您输入的标题不合法!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
this.tbMhCurrChapStr.Focus();
this.tbMhCurrChapStr.SelectAll();
}
else
{
MHChapter lMHChapter = new MHChapter();
lMHChapter.ChapterStr = this.tbMhCurrChapStr.Text;
lMHChapter.JpgFileNameArray = new ArrayList();
if ((this.lbMhChapters.Items.Count == 0) || (this.lbMhChapters.SelectedIndex < 0))
{
this.lbMhChapters.Items.Add(this.tbMhCurrChapStr.Text);
MHChapterArray.Add(lMHChapter);
}
else
{
this.lbMhChapters.Items.Insert(this.lbMhChapters.SelectedIndex + 1, this.tbMhCurrChapStr.Text);
//this.iChapter.Insert(this.lbChapters.SelectedIndex + 1, "");
MHChapterArray.Insert(this.lbMhChapters.SelectedIndex + 1,lMHChapter);
}
if (this.lbMhChapters.Items.Count > (this.lbMhChapters.SelectedIndex + 1))
{
this.lbMhChapters.SelectedIndex++;
}
this.lbJpgFile.Items.Clear();
this.tbMhCurrChapStr.Text = "";
}
}
private void lbMhChapters_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (this.lbMhChapters.Items.Count == 0)
{
return;
}
else if ((this.MHChapterArray.Count > this.lbMhChapters.SelectedIndex) && (this.lbMhChapters.SelectedIndex >= 0))
{
MHChapter tmpMHChapter = (MHChapter)this.MHChapterArray[this.lbMhChapters.SelectedIndex];
this.tbMhCurrChapStr.Text = tmpMHChapter.ChapterStr;
this.lbJpgFile.Items.Clear();
for (int i=0;i<tmpMHChapter.JpgFileNameArray.Count;i++)
{
string tmpFileName = (string)tmpMHChapter.JpgFileNameArray[i];
this.lbJpgFile.Items.Add(tmpFileName);
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -