📄 mbookmaker.cs
字号:
}
else if ((iType == 1) & (tabs.SelectedTab == tabText))//漫画书
{
tabs.SelectedTab = tabImage;
MessageBox.Show("漫画书不设计目录内容,\n设计目录图片", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
if ((iType == 0) & (tabs.SelectedTab == tabImage))//普通书
{
tabs.SelectedTab = tabText;
MessageBox.Show("普通书不设计目录图片,\n设计目录内容", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else if ((iType == 1) & (tabs.SelectedTab == tabImage))//漫画书
{
tabs.SelectedTab = tabImage;
}
//**********************
if (this.tabs.TabPages[this.tabs.SelectedIndex].Text == "3-目录图片")
{
this.fromMhPreview.Show();
}else
{
this.fromMhPreview.Hide();
}
//**********************
if (((this.tabs.TabPages[this.tabs.SelectedIndex].Text != "3-目录内容") && (this.lbChapters.SelectedIndex >= 0)) && ((this.lbChapters.SelectedIndex < this.iChapter.Count) && this.iModified))
{
this.iChapter[this.lbChapters.SelectedIndex] = this.tbText.Text;
this.iModified = false;
}
if (this.tabs.TabPages[this.tabs.SelectedIndex].Text == "3-目录内容")
{
this.lbModified.Visible = this.iModified;
}
if (this.tabs.TabPages[this.tabs.SelectedIndex].Text == "4-确认制作")
{
if (!File.Exists(this.iCoverFile + ".tmp"))
{
if (this.iCoverFile == (Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Remove(0, 8)) + @"\cover.jpg"))
{
SizeF ef1;
string[] textArray1;
this.myCover = Image.FromFile(this.iCoverFile);
Graphics graphics1 = Graphics.FromImage(this.myCover);
ArrayList list1 = new ArrayList();
Font font1 = new Font("宋体", 16f);
string text1 = "";
for (int num1 = 0; num1 < this.tbTitle.Text.Length; num1++)
{
text1 = text1 + this.tbTitle.Text.Substring(num1, 1);
ef1 = graphics1.MeasureString(text1, font1);
if (((int) ef1.Width) > 150)
{
list1.Add(text1.Substring(0, text1.Length - 1));
text1 = this.tbTitle.Text.Substring(num1, 1);
}
}
list1.Add(text1);
for (int num2 = 0; num2 < list1.Count; num2++)
{
ef1 = graphics1.MeasureString((string) list1[num2], font1);
graphics1.DrawString((string) list1[num2], font1, Brushes.White, (float) ((176f - ef1.Width) / 2f), (float) (30 + ((font1.Height + 3) * num2)));
}
graphics1.ReleaseHdc(graphics1.GetHdc());
this.pbPreview.Image = Image.FromFile(this.iCoverFile);
Graphics graphics2 = Graphics.FromImage(this.pbPreview.Image);
for (int num3 = 0; num3 < list1.Count; num3++)
{
ef1 = graphics2.MeasureString((string) list1[num3], font1);
graphics2.DrawString((string) list1[num3], font1, Brushes.White, (float) ((176f - ef1.Width) / 2f), (float) (30 + ((font1.Height + 3) * num3)));
}
graphics2.ReleaseHdc(graphics2.GetHdc());
this.myCover.Save(this.iCoverFile + ".tmp", ImageFormat.Jpeg);
if (this.tbSaveTo.Text.EndsWith(@"\"))
{
textArray1 = new string[5] { "您的缺省封面保存在:\n", Path.GetDirectoryName(this.tbSaveTo.Text), @"\", this.tbTitle.Text, ".jpg" } ;
this.lbDefCover.Text = string.Concat(textArray1);
}
else
{
textArray1 = new string[5] { "您的缺省封面保存在:\n", this.tbSaveTo.Text, @"\", this.tbTitle.Text, ".jpg" } ;
this.lbDefCover.Text = string.Concat(textArray1);
}
}
}
//*************************************************************************
this.lbCheckList.Items.Clear();
if (iType == 0)//普通书
{
this.lbCheckList.Items.Add(string.Format("图书类型:普通书"));
}else if (iType == 1)//漫画书
{
this.lbCheckList.Items.Add(string.Format("图书类型:漫画书"));
}
this.lbCheckList.Items.Add(" ");
this.lbCheckList.Items.Add(string.Format("书名标题:{0}", this.tbTitle.Text));
this.lbCheckList.Items.Add(string.Format("作 者:{0}", this.tbAuthor.Text));
this.lbCheckList.Items.Add(string.Format("出版日期:{0}", this.dtpDate.Text));
this.lbCheckList.Items.Add(string.Format("体裁类型:{0}", this.cbGender.Text));
this.lbCheckList.Items.Add(string.Format("出版发行:{0}", this.tbPublisher.Text));
if (File.Exists(this.iCoverFile))
{
this.lbCheckList.Items.Add(string.Format("封面文件:{0}", this.iCoverFile));
}
else
{
this.lbCheckList.Items.Add("封面文件:(无)");
}
this.lbCheckList.Items.Add(" ");
if (iType == 0)//普通书
{
this.lbCheckList.Items.Add(string.Format("章节目录:共({0})个", this.lbChapters.Items.Count));
this.iTotalen = 0;
if ((this.lbChapters.Items.Count > 0) && (this.iChapter.Count > 0))
{
for (int num4 = 0; num4 < this.lbChapters.Items.Count; num4++)
{
this.lbCheckList.Items.Add(string.Format("第{0}章:(长度:{1} 字节)", num4 + 1, ((string) this.iChapter[num4]).Length * 2));
this.iTotalen += ((((string) this.iChapter[num4]).Length + 1) * 2);
this.iChapStr.Add(this.lbChapters.Items[num4]);
this.lbCheckList.Items.Add(string.Format(" 标题:{0}", (string) this.lbChapters.Items[num4]));
}
}
this.lbCheckList.Items.Add(" ");
this.lbCheckList.Items.Add(string.Format("内容总长:{0} 字节", this.iTotalen));
this.lbCheckList.Items.Add(" ");
this.lbCheckList.Items.Add("准备制作...");
this.lbCheckList.Items.Add(" ");
}else if (iType == 1)//漫画书
{
if (checkUserChap.Checked)
{
this.lbCheckList.Items.Add(string.Format("章节目录:共({0})个", this.lbMhChapters.Items.Count));
this.iTotalen = 0;
if ((this.lbMhChapters.Items.Count > 0) && (this.MHChapterArray.Count > 0))
{
for (int num4 = 0; num4 < this.lbMhChapters.Items.Count; num4++)
{
MHChapter tmpMHChapter = (MHChapter)this.MHChapterArray[num4];
this.lbCheckList.Items.Add(string.Format("第{0}章:(共有:{1} 个图片)", num4 + 1,tmpMHChapter.JpgFileNameArray.Count));
this.lbCheckList.Items.Add(string.Format(" 标题:{0}", tmpMHChapter.ChapterStr));
}
}
}else
{
this.lbCheckList.Items.Add(string.Format("无章节目录:共有{0} 个图片",lbJpgFile.Items.Count));
}
this.lbCheckList.Items.Add("准备制作...");
this.lbCheckList.Items.Add(" ");
}
}
}
private void btSelCover_Click(object sender, System.EventArgs e)
{
FileStream stream1;
if (File.Exists(this.iCoverFile + ".tmp"))
{
File.Delete(this.iCoverFile + ".tmp");
}
this.dlgOpenFile.Filter = "封面文件(*.jpg)|*.jpg";
bool flag1 = false;
do
{
if (this.dlgOpenFile.ShowDialog() != DialogResult.OK)
{
return;
}
this.iCoverFile = this.dlgOpenFile.FileName;
stream1 = File.OpenRead(this.dlgOpenFile.FileName);
if (stream1.Length < 0x4000)
{
flag1 = true;
}
else
{
MessageBox.Show("您指定的封面文件过大!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
while (!flag1);
stream1.Close();
File.Copy(this.iCoverFile, this.iCoverFile + ".tmp", true);
this.pbPreview.Image = Image.FromFile(this.iCoverFile);
this.pbPreview.Width = this.pbPreview.Image.Width;
this.pbPreview.Height = this.pbPreview.Image.Height;
if (this.pbPreview.Width > 0xb0)
{
this.pbPreview.Width = 0xb0;
}
if (this.pbPreview.Height > 0xd0)
{
this.pbPreview.Height = 0xd0;
}
}
private void btDefCover_Click(object sender, System.EventArgs e)
{
this.iCoverFile = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Remove(0, 8)) + @"\cover.jpg";
if (this.pbPreview.Width < 0xb0)
{
this.pbPreview.Width = 0xb0;
}
if (this.pbPreview.Height < 0xd0)
{
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];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -