using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization.Formatters.Binary;
namespace Plugin2
{
public partial class UserPlugin : UserControl
{
public UserPlugin()
{
InitializeComponent();
}
private void UserPlugin_Load(object sender, EventArgs e)
{
this.comboBox_Transition_Effect.SelectedIndex = 23;
}
private Plugin parentplugin;
public void SetParent(Plugin parent)
{
parentplugin = parent;
}
/// <summary>
/// Serialize the plugin
/// </summary>
/// <param name="myStream"></param>
/// <param name="formatter"></param>
public void Serialize(Stream myStream, ref IFormatter formatter)
{
formatter.Serialize(myStream, this.checkBox_AlternateCells.Checked);
formatter.Serialize(myStream, this.checkBox_EnlargedTextDesc.Checked);
formatter.Serialize(myStream, this.checkBox_EnlargedTextFile.Checked);
formatter.Serialize(myStream, this.checkBox_Table_BackGround.Checked);
formatter.Serialize(myStream, this.checkBox_Table_BackImage.Checked);
formatter.Serialize(myStream, this.checkBox_ThumbTextDesc.Checked);
formatter.Serialize(myStream, this.checkBox_ThumbTextFile.Checked);
formatter.Serialize(myStream, this.checkBox_Title_Enlarged_Add.Checked);
formatter.Serialize(myStream, this.checkBox_Title_Enlarged_Change.Checked);
formatter.Serialize(myStream, this.checkBox_Transition_Enabled.Checked);
formatter.Serialize(myStream, this.checkBoxEnlargedHorizFillet.Checked);
formatter.Serialize(myStream, this.comboBox_Transition_Effect.SelectedIndex);
formatter.Serialize(myStream, this.domainUpDown_TableStyle.SelectedIndex);
formatter.Serialize(myStream, this.numericUpDown_HSpace.Value);
formatter.Serialize(myStream, this.numericUpDown_ImageBorder.Value);
formatter.Serialize(myStream, this.numericUpDown_TableBorder.Value);
formatter.Serialize(myStream, this.numericUpDown_Title_Enlarged_Breaks.Value);
formatter.Serialize(myStream, this.numericUpDownVSpace.Value);
formatter.Serialize(myStream, this.pictureBox_Alternate1.BackColor);
formatter.Serialize(myStream, this.pictureBox_Alternate2.BackColor);
formatter.Serialize(myStream, this.pictureBox_DarkColor.BackColor);
formatter.Serialize(myStream, this.pictureBox_LightColor.BackColor);
formatter.Serialize(myStream, this.pictureBox_MainColor.BackColor);
//formatter.Serialize(myStream, this.pictureBox_Nav_Home_Image.Image);
//formatter.Serialize(myStream, this.pictureBox_Nav_Menu.Image);
//formatter.Serialize(myStream, this.pictureBox_Nav_Next.Image);
//formatter.Serialize(myStream, this.pictureBox_Nav_Previous.Image);
formatter.Serialize(myStream, this.pictureBox_Table_BackGround.BackColor);
//formatter.Serialize(myStream, this.pictureBox_Table_BackImage.Image);
formatter.Serialize(myStream, this.radioButton_Title_Enlarged_Auto.Checked);
formatter.Serialize(myStream, this.radioButton_Title_Enlarged_Description.Checked);
formatter.Serialize(myStream, this.radioButton_Title_Enlarged_Filename.Checked);
formatter.Serialize(myStream, this.radioButton_Title_Enlarged_Manual.Checked);
formatter.Serialize(myStream, this.radioButton_Transition_Enter.Checked);
formatter.Serialize(myStream, this.radioButton_Transition_Exit.Checked);
}
/// <summary>
/// Deserialize the plugin
/// </summary>
/// <param name="myStream"></param>
/// <param name="formatter"></param>
public void DeSerialize(Stream myStream, ref IFormatter formatter)
{
this.checkBox_AlternateCells.Checked = (bool)formatter.Deserialize(myStream);
this.checkBox_EnlargedTextDesc.Checked = (bool)formatter.Deserialize(myStream);
this.checkBox_EnlargedTextFile.Checked = (bool)formatter.Deserialize(myStream);
this.checkBox_Table_BackGround.Checked = (bool)formatter.Deserialize(myStream);
this.checkBox_Table_BackImage.Checked = (bool)formatter.Deserialize(myStream);
this.checkBox_ThumbTextDesc.Checked = (bool)formatter.Deserialize(myStream);
this.checkBox_ThumbTextFile.Checked = (bool)formatter.Deserialize(myStream);
this.checkBox_Title_Enlarged_Add.Checked = (bool)formatter.Deserialize(myStream);
this.checkBox_Title_Enlarged_Change.Checked = (bool)formatter.Deserialize(myStream);
this.checkBox_Transition_Enabled.Checked = (bool)formatter.Deserialize(myStream);
this.checkBoxEnlargedHorizFillet.Checked = (bool)formatter.Deserialize(myStream);
this.comboBox_Transition_Effect.SelectedIndex = (int)formatter.Deserialize(myStream);
this.domainUpDown_TableStyle.SelectedIndex = (int)formatter.Deserialize(myStream);
this.numericUpDown_HSpace.Value = (decimal)formatter.Deserialize(myStream);
this.numericUpDown_ImageBorder.Value = (decimal)formatter.Deserialize(myStream);
this.numericUpDown_TableBorder.Value = (decimal)formatter.Deserialize(myStream);
this.numericUpDown_Title_Enlarged_Breaks.Value = (decimal)formatter.Deserialize(myStream);
this.numericUpDownVSpace.Value = (decimal)formatter.Deserialize(myStream);
this.pictureBox_Alternate1.BackColor = (Color)formatter.Deserialize(myStream);
this.pictureBox_Alternate2.BackColor = (Color)formatter.Deserialize(myStream);
this.pictureBox_DarkColor.BackColor = (Color)formatter.Deserialize(myStream);
this.pictureBox_LightColor.BackColor = (Color)formatter.Deserialize(myStream);
this.pictureBox_MainColor.BackColor = (Color)formatter.Deserialize(myStream);
//formatter.Serialize(myStream, this.pictureBox_Nav_Home_Image.Image);
//formatter.Serialize(myStream, this.pictureBox_Nav_Menu.Image);
//formatter.Serialize(myStream, this.pictureBox_Nav_Next.Image);
//formatter.Serialize(myStream, this.pictureBox_Nav_Previous.Image);
this.pictureBox_Table_BackGround.BackColor = (Color)formatter.Deserialize(myStream);
//formatter.Serialize(myStream, this.pictureBox_Table_BackImage.Image);
this.radioButton_Title_Enlarged_Auto.Checked = (bool)formatter.Deserialize(myStream);
this.radioButton_Title_Enlarged_Description.Checked = (bool)formatter.Deserialize(myStream);
this.radioButton_Title_Enlarged_Filename.Checked = (bool)formatter.Deserialize(myStream);
this.radioButton_Title_Enlarged_Manual.Checked = (bool)formatter.Deserialize(myStream);
this.radioButton_Transition_Enter.Checked = (bool)formatter.Deserialize(myStream);
this.radioButton_Transition_Exit.Checked = (bool)formatter.Deserialize(myStream);
}
private void numericUpDown_HSpace_ValueChanged(object sender, EventArgs e)
{
parentplugin.SetHSpace((int)this.numericUpDown_HSpace.Value);
}
private void numericUpDownVSpace_ValueChanged(object sender, EventArgs e)
{
parentplugin.SetVSpace((int)this.numericUpDownVSpace.Value);
}
private void numericUpDown_TableBorder_ValueChanged(object sender, EventArgs e)
{
parentplugin.SetTBorder((int)this.numericUpDown_TableBorder.Value);
}
private void numericUpDown_ImageBorder_ValueChanged(object sender, EventArgs e)
{
parentplugin.SetIBorder((int)this.numericUpDown_ImageBorder.Value);
}
private void domainUpDown_TableStyle_SelectedItemChanged(object sender, EventArgs e)
{
switch (this.domainUpDown_TableStyle.SelectedIndex)
{
case 0:
parentplugin.SetBorderStyle(Html.CHtmlGenerator.BorderStyle.normal);
this.panel_TableCols.Enabled = true;
this.button_DarkColor.Enabled = false;
this.button_LightColor.Enabled = false;
this.button_MainColor.Enabled = true;
this.numericUpDown_TableBorder.Value = 1;
parentplugin.SetTBorder((int)this.numericUpDown_TableBorder.Value);
break;
case 1:
parentplugin.SetBorderStyle(Html.CHtmlGenerator.BorderStyle.none);
this.panel_TableCols.Enabled = false;
this.button_DarkColor.Enabled = false;
this.button_LightColor.Enabled = false;
this.button_MainColor.Enabled = false;
this.numericUpDown_TableBorder.Value = 0;
parentplugin.SetTBorder((int)this.numericUpDown_TableBorder.Value);
break;
case 2:
parentplugin.SetBorderStyle(Html.CHtmlGenerator.BorderStyle.doubled);
this.panel_TableCols.Enabled = true;
this.button_DarkColor.Enabled = true;
this.button_LightColor.Enabled = true;
this.button_MainColor.Enabled = true;
this.numericUpDown_TableBorder.Value = 1;
parentplugin.SetTBorder((int)this.numericUpDown_TableBorder.Value);
break;
}
}
private void button_MainColor_Click(object sender, EventArgs e)
{
DialogResult result = this.colorDialog1.ShowDialog();
if (result == DialogResult.OK)
{
this.pictureBox_MainColor.BackColor = this.colorDialog1.Color;
parentplugin.SetBorderColor(this.colorDialog1.Color);
}
}
private void button_LightColor_Click(object sender, EventArgs e)
{
DialogResult result = this.colorDialog1.ShowDialog();
if (result == DialogResult.OK)
{
this.pictureBox_LightColor.BackColor = this.colorDialog1.Color;
parentplugin.SetBorderLightColor(this.colorDialog1.Color);
}
}
private void button_DarkColor_Click(object sender, EventArgs e)
{
DialogResult result = this.colorDialog1.ShowDialog();
if (result == DialogResult.OK)
{
this.pictureBox_DarkColor.BackColor = this.colorDialog1.Color;
parentplugin.SetBorderDarkColor(this.colorDialog1.Color);
}
}
private void checkBox_ThumbTextFile_CheckedChanged(object sender, EventArgs e)
{
parentplugin.SetTxtThumbFile(this.checkBox_ThumbTextFile.Checked);
}
private void checkBox_ThumbTextDesc_CheckedChanged(object sender, EventArgs e)
{
parentplugin.SetTxtThumbDescr(this.checkBox_ThumbTextDesc.Checked);
}
private void checkBox_EnlargedTextFile_CheckedChanged(object sender, EventArgs e)
{
parentplugin.SetTxtEnlargedFile(this.checkBox_EnlargedTextFile.Checked);
}
private void checkBox_EnlargedTextDesc_CheckedChanged(object sender, EventArgs e)
{
parentplugin.SetTxtEnlargedDescr(this.checkBox_EnlargedTextDesc.Checked);
}
private void button_ThumbFont_Click(object sender, EventArgs e)
{
DialogResult result = fontDialog1.ShowDialog();
if (result == DialogResult.OK)
{
parentplugin.SetThumbDescFont(fontDialog1.Font);
parentplugin.SetThumbDescColor(fontDialog1.Color);
}
}
private void button1_EnlargedFont_Click(object sender, EventArgs e)
{
DialogResult result = fontDialog1.ShowDialog();
if (result == DialogResult.OK)
{
parentplugin.SetEnlargedDescFont(fontDialog1.Font);
parentplugin.SetEnlargedDescColor(fontDialog1.Color);
}
}
private void checkBoxEnlargedHorizFillet_CheckedChanged(object sender, EventArgs e)
{
parentplugin.SetImagesHFillet(this.checkBoxEnlargedHorizFillet.Checked);
}
private void checkBox_Table_BackGround_CheckedChanged(object sender, EventArgs e)
{
parentplugin.SetTablebackcolorenable(checkBox_Table_BackGround.Checked);
}
private void button_Table_BackColor_Click(object sender, EventArgs e)
{
DialogResult result = this.colorDialog1.ShowDialog();
if (result == DialogResult.OK)
{
this.pictureBox_Table_BackGround.BackColor = this.colorDialog1.Color;
parentplugin.SetTablebackColor(this.colorDialog1.Color);
}
}
private void checkBox_Table_BackImage_CheckedChanged(object sender, EventArgs e)
{
parentplugin.SetTablebackimageenable(checkBox_Table_BackImage.Checked);
}
private void button_Table_BackGroundImage_Click(object sender, EventArgs e)
{
DialogResult result = this.openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
string FilePath = this.openFileDialog1.FileName;
try
{
Bitmap bit = new Bitmap(FilePath);
this.pictureBox_Table_BackImage.Image = bit;
parentplugin.SetTablebackimagepath(FilePath);
}
catch
{
MessageBox.Show("Invalid image", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
checkBox_Table_BackImage.Checked = false;
}
}
}
private void checkBox_AlternateCells_CheckedChanged(object sender, EventArgs e)
{
parentplugin.SetCellalternate(checkBox_AlternateCells.Checked);
}
private void button_Alternate1_Click(object sender, EventArgs e)
{
DialogResult result = this.colorDialog1.ShowDialog();
if (result == DialogResult.OK)
{
this.pictureBox_Alternate1.BackColor = this.colorDialog1.Color;
parentplugin.SetAlternateColor1(this.colorDialog1.Color);
}
}
private void button1_Alternate2_Click(object sender, EventArgs e)
{
DialogResult result = this.colorDialog1.ShowDialog();
if (result == DialogResult.OK)
{
this.pictureBox_Alternate2.BackColor = this.colorDialog1.Color;
parentplugin.SetAlternateColor2(this.colorDialog1.Color);
}
}
private void checkBox_Title_Enlarged_Change_CheckedChanged(object sender, EventArgs e)
{
parentplugin.SetTitleenlargedchange(checkBox_Title_Enlarged_Change.Checked);
}
private void checkBox_Title_Enlarged_Add_CheckedChanged(object sender, EventArgs e)
{
parentplugin.SetTitleenlargedtextual(checkBox_Title_Enlarged_Add.Checked);
}
private void radioButton_Title_Enlarged_Description_CheckedChanged(object sender, EventArgs e)
{
if (radioButton_Title_Enlarged_Description.Checked) parentplugin.SetTitleenlargedmodedescription(radioButton_Title_Enlarged_Description.Checked);
}
private void radioButton_Title_Enlarged_Filename_CheckedChanged(object sender, EventArgs e)
{
if (radioButton_Title_Enlarged_Filename.Checked) parentplugin.SetTitleenlargedmodefilename(radioButton_Title_Enlarged_Filename.Checked);
}
private void radioButton_Title_Enlarged_Auto_CheckedChanged(object sender, EventArgs e)
{
if (radioButton_Title_Enlarged_Auto.Checked) parentplugin.SetTitleenlargedmodeauto(radioButton_Title_Enlarged_Auto.Checked);
}
private void radioButton_Title_Enlarged_Manual_CheckedChanged(object sender, EventArgs e)
{
if (radioButton_Title_Enlarged_Manual.Checked) parentplugin.SetTitleenlargedmodemanual(radioButton_Title_Enlarged_Manual.Checked);
}
private void textBox_Title_Enlarged_Text_TextChanged(object sender, EventArgs e)
{
parentplugin.SetTitleenlargedtext(textBox_Title_Enlarged_Text.Text);
}
private void numericUpDown_Title_Enlarged_Breaks_ValueChanged(object sender, EventArgs e)
{
parentplugin.SetTitleenlargedbreaks((int)numericUpDown_Title_Enlarged_Breaks.Value);
}
private void button1_Click(object sender, EventArgs e)
{
DialogResult result = fontDialog1.ShowDialog();
if (result == DialogResult.OK)
{
parentplugin.SetTitleenlargedfont(fontDialog1.Font);
parentplugin.SetTitleenlargedcolor(fontDialog1.Color);
}
}
private void button_Title_Thumbs_Font_Click(object sender, EventArgs e)
{
DialogResult result = fontDialog1.ShowDialog();
if (result == DialogResult.OK)
{
parentplugin.SetTitlethumbsfont(fontDialog1.Font);
parentplugin.SetTitlethumbscolor(fontDialog1.Color);
}
}
private void checkBox_Transition_Enabled_CheckedChanged(object sender, EventArgs e)
{
parentplugin.SetTransitionenable(checkBox_Transition_Enabled.Checked);
}
private void radioButton_Transition_Enter_CheckedChanged(object sender, EventArgs e)
{
parentplugin.SetTransitionpageenter(true);
}
private void radioButton_Transition_Exit_CheckedChanged(object sender, EventArgs e)
{
parentplugin.SetTransitionpageenter(false);
}
private void comboBox_Transition_Effect_SelectedIndexChanged(object sender, EventArgs e)
{
parentplugin.SetTransitionpagetype((Html.CHtmlGenerator.TransitionType)comboBox_Transition_Effect.SelectedIndex);
}
}
}