⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mbookmaker.cs

📁 用VC.NET开发的应用于Symbian上的电子书开发源代码.
💻 CS
📖 第 1 页 / 共 5 页
字号:
				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.Text,aYear, 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" + aResult, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				}
				else if (umd_genegine1.Make(ref this.pbar, out aResult))
				{
					MessageBox.Show("制作成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
				else
				{
					MessageBox.Show("生成文件错误:\n" + aResult, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				}
			}else if(iType == 1)//漫画书
			{
				if (checkUserText.Checked == true)
				{//连环画,有文字说明
					ArrayList iChapterOff = new ArrayList();//文字偏移
					ArrayList sChapterStr = new ArrayList();//文字内容
					ArrayList sChapterJpg = new ArrayList();//图片列表
					for (int i = 0;i<this.lbJpgFile.Items.Count;i++)
					{
						iChapterOff.Add(i);
						sChapterStr.Add(MHChapterTextArray[i]);
						string JpgFileName = lbJpgFile.Items[i].ToString();
						sChapterJpg.Add(JpgFileName);
					}
					if (!umd_genegine1.MHInitialize(this.tbTitle.Text, this.tbAuthor.Text, aYear, 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" + aResult, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					}
					else if (umd_genegine1.LHHMake(ref this.pbar, out aResult))//连环画
					{
						MessageBox.Show("制作成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
					}
					else
					{
						MessageBox.Show("生成文件错误:\n" + aResult, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					}
				}
				else
				{//写真书,只有图片,可能有目录
					ArrayList iChapterOff = new ArrayList();//目录偏移
					ArrayList sChapterStr = new ArrayList();//目录名称
					ArrayList sChapterJpg = new ArrayList();//图片列表
					if (checkUserChap.Checked)//有目录
					{
						for (int num4 = 0; num4 < this.lbMhChapters.Items.Count; num4++)
						{
							MHChapter tmpMHChapter = (MHChapter)this.MHChapterArray[num4];
							iChapterOff.Add(sChapterJpg.Count);
							sChapterStr.Add(tmpMHChapter.ChapterStr);
							for (int i=0;i<tmpMHChapter.JpgFileNameArray.Count;i++)
							{
								sChapterJpg.Add(tmpMHChapter.JpgFileNameArray[i]);
							}
						}
					}
					else//没有目录
					{
						for (int i =0;i<this.lbJpgFile.Items.Count;i++)
						{
							string JpgFileName = lbJpgFile.Items[i].ToString();
							sChapterJpg.Add(JpgFileName);
						}
					}
					if (!umd_genegine1.MHInitialize(this.tbTitle.Text, this.tbAuthor.Text, aYear, 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" + aResult, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					}
					else if (umd_genegine1.MHMake(ref this.pbar, out aResult))
					{
						MessageBox.Show("制作成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
					}
					else
					{
						MessageBox.Show("生成文件错误:\n" + aResult, 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)
		{
			MHChapterTextArray.Clear();
			lbJpgFile.Items.Clear();
			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]);
					}
					if (checkUserText.Checked)
					{
						this.MHChapterTextArray.Add(tbMhText.Text);
					}
					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 JpgFileName = (string)this.lbJpgFile.SelectedItem;
			if (JpgFileName == null)
			{
				return;
			}
			if (checkUserText.Checked)
			{
				this.tbMhText.Text = (string)this.MHChapterTextArray[this.lbJpgFile.SelectedIndex];
			}
			this.fromMhPreview.pbMhPreview.Image = Image.FromFile(JpgFileName);
			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();
			if (this.checkUserText.Checked)
				MHChapterTextArray.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 (checkUserText.Checked)
					MHChapterTextArray.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);
				}
			}
		}

		private void btMhRenChap_Click(object sender, System.EventArgs e)
		{
			if ((this.lbMhChapters.SelectedIndex >= 0) && (this.lbMhChapters.SelectedIndex < this.lbMhChapters.Items.Count))
			{
				MHChapter tmpMHChapter = (MHChapter)MHChapterArray[this.lbMhChapters.SelectedIndex];
				tmpMHChapter.ChapterStr = this.tbMhCurrChapStr.Text;
				lbMhChapters.Items[this.lbMhChapters.SelectedIndex] = this.tbMhCurrChapStr.Text;
				MHChapterArray[this.lbMhChapters.SelectedIndex] =  tmpMHChapter ;
				//this.lbChapters.Items[this.lbChapters.SelectedIndex] = this.tbCurrChapStr.Text;
			}
		}

		private void btMhDelChap_Click(object sender, System.EventArgs e)
		{
			if ((this.lbMhChapters.SelectedIndex >= 0) && (this.lbMhChapters.SelectedIndex < this.lbMhChapters.Items.Count))
			{
				int num1 = this.lbMhChapters.SelectedIndex;
				this.MHChapterArray.RemoveAt(num1);
				lbMhChapters.Items.RemoveAt(num1);
				if (this.lbMhChapters.Items.Count <= (num1 + 1))
				{
					this.lbMhChapters.SelectedIndex = this.lbMhChapters.Items.Count - 1;
				}
				else
				{
					this.lbMhChapters.SelectedIndex = num1;
				}
			}
		}

		private void tbMhText_TextChanged(object sender, System.EventArgs e)
		{
			if ((this.lbJpgFile.SelectedIndex >= 0) && (this.lbJpgFile.Sele

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -