diff --git a/ThemePacker/MainForm.cs b/ThemePacker/MainForm.cs index 76f07eb..e9df09d 100644 --- a/ThemePacker/MainForm.cs +++ b/ThemePacker/MainForm.cs @@ -27,7 +27,8 @@ public partial class ThemePacker : Form private Dictionary _shownImages; private string _path; private int _currentPic; - + private bool _isFolderBased; + private OptionDialogBox _opb; private CustomProgressBar _pbProgression; private EventHandler _btnNextClick; @@ -235,10 +236,11 @@ private void BtnLike_Click(object sender, EventArgs e) private void BtnGenerate_Click(object sender, EventArgs e) { - OptionDialogBox opb = new OptionDialogBox(); - opb.ShowDialog(); - opb.Focus(); - Generate(); + _opb = new OptionDialogBox(); + if (_opb.ShowDialog() == DialogResult.OK) + { + Generate(); + } } public void Generate() @@ -267,6 +269,13 @@ public void Generate() theme["Control Panel_Desktop"]["WallpaperStyle"] = "2"; theme["Slideshow"]["Interval"] = "60000"; + //read and replace + string text = File.ReadAllText("temp\\super.theme"); + text = text.Replace("DisplayName=Tinderspirobot", "DisplayName=" + fileName); + text = text.Replace("Interval=1000", "Interval=" + _opb.TimeChange); + text = text.Replace("TileWallpaper=1", "TileWallpaper="+ _opb.TileWallpaper); + text = text.Replace("WallpaperStyle=0", "WallpaperStyle=" + _opb.WallPaperStyle); + File.WriteAllText("temp\\super.theme", text); tfs.JSON = theme; tfs.JsonSerialize($"temp\\themepack\\{fileName}.theme"); diff --git a/ThemePacker/OptionDialogBox.Designer.cs b/ThemePacker/OptionDialogBox.Designer.cs index 7368ffb..c95d257 100644 --- a/ThemePacker/OptionDialogBox.Designer.cs +++ b/ThemePacker/OptionDialogBox.Designer.cs @@ -28,24 +28,28 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.cbPicPos = new System.Windows.Forms.ComboBox(); this.lblChangePosition = new System.Windows.Forms.Label(); - this.comboBox2 = new System.Windows.Forms.ComboBox(); + this.cbTimeChange = new System.Windows.Forms.ComboBox(); this.lblChangeTime = new System.Windows.Forms.Label(); this.btnGenerateFromDB = new System.Windows.Forms.Button(); this.SuspendLayout(); // - // comboBox1 + // cbPicPos // - this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBox1.FormattingEnabled = true; - this.comboBox1.Items.AddRange(new object[] { - "Remplissage", - "Ajuster"}); - this.comboBox1.Location = new System.Drawing.Point(32, 40); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(108, 21); - this.comboBox1.TabIndex = 0; + this.cbPicPos.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbPicPos.FormattingEnabled = true; + this.cbPicPos.Items.AddRange(new object[] { + "Fill", + "Fit", + "Stretch", + "Tile", + "Center"}); + this.cbPicPos.Location = new System.Drawing.Point(32, 40); + this.cbPicPos.Name = "cbPicPos"; + this.cbPicPos.Size = new System.Drawing.Size(108, 21); + this.cbPicPos.TabIndex = 0; + this.cbPicPos.SelectedIndexChanged += new System.EventHandler(this.CbPicPos_SelectedIndexChanged); // // lblChangePosition // @@ -56,14 +60,24 @@ private void InitializeComponent() this.lblChangePosition.TabIndex = 1; this.lblChangePosition.Text = "Picture position"; // - // comboBox2 + // cbTimeChange // - this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBox2.FormattingEnabled = true; - this.comboBox2.Location = new System.Drawing.Point(207, 40); - this.comboBox2.Name = "comboBox2"; - this.comboBox2.Size = new System.Drawing.Size(108, 21); - this.comboBox2.TabIndex = 2; + this.cbTimeChange.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbTimeChange.FormattingEnabled = true; + this.cbTimeChange.Items.AddRange(new object[] { + "10 seconds", + "30 seconds", + "1 minute", + "5 minutes", + "10 minutes", + "20 minutes", + "30 minutes", + "1 hour"}); + this.cbTimeChange.Location = new System.Drawing.Point(207, 40); + this.cbTimeChange.Name = "cbTimeChange"; + this.cbTimeChange.Size = new System.Drawing.Size(108, 21); + this.cbTimeChange.TabIndex = 2; + this.cbTimeChange.SelectedIndexChanged += new System.EventHandler(this.CbTimeChange_SelectedIndexChanged); // // lblChangeTime // @@ -91,9 +105,9 @@ private void InitializeComponent() this.ClientSize = new System.Drawing.Size(345, 169); this.Controls.Add(this.btnGenerateFromDB); this.Controls.Add(this.lblChangeTime); - this.Controls.Add(this.comboBox2); + this.Controls.Add(this.cbTimeChange); this.Controls.Add(this.lblChangePosition); - this.Controls.Add(this.comboBox1); + this.Controls.Add(this.cbPicPos); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Name = "OptionDialogBox"; this.Text = "OptionDialogBox"; @@ -105,9 +119,9 @@ private void InitializeComponent() #endregion - private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.ComboBox cbPicPos; private System.Windows.Forms.Label lblChangePosition; - private System.Windows.Forms.ComboBox comboBox2; + private System.Windows.Forms.ComboBox cbTimeChange; private System.Windows.Forms.Label lblChangeTime; private System.Windows.Forms.Button btnGenerateFromDB; } diff --git a/ThemePacker/OptionDialogBox.cs b/ThemePacker/OptionDialogBox.cs index cbcdf0f..0dff1a9 100644 --- a/ThemePacker/OptionDialogBox.cs +++ b/ThemePacker/OptionDialogBox.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; +using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; @@ -12,6 +13,9 @@ namespace ThemePacker { public partial class OptionDialogBox : Form { + public string TimeChange { get; private set; } + public string TileWallpaper { get; private set; } + public string WallPaperStyle { get; private set; } public OptionDialogBox() { InitializeComponent(); @@ -22,11 +26,74 @@ private void OptionDialogBox_Load(object sender, EventArgs e) this.MaximizeBox = false; this.MinimizeBox = false; this.FormBorderStyle = FormBorderStyle.FixedDialog; + cbPicPos.SelectedItem = "Tile"; + cbTimeChange.SelectedItem = "1 minute"; } private void BtnGenerateFromDB_Click(object sender, EventArgs e) { - + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void CbPicPos_SelectedIndexChanged(object sender, EventArgs e) + { + string wallpaper = cbPicPos.SelectedItem.ToString(); + switch (wallpaper) + { + case "Fill": + TileWallpaper = "0"; + WallPaperStyle = "10"; + break; + case "Fit": + TileWallpaper = "0"; + WallPaperStyle = "6"; + break; + case "Stretch": + TileWallpaper = "0"; + WallPaperStyle = "2"; + break; + case "Tile": + TileWallpaper = "1"; + WallPaperStyle = "0"; + break; + case "Center": + TileWallpaper = "0"; + WallPaperStyle = "0"; + break; + } + } + + private void CbTimeChange_SelectedIndexChanged(object sender, EventArgs e) + { + string time = cbTimeChange.SelectedItem.ToString(); + switch (time) + { + case "10 seconds": + TimeChange = "10000"; + break; + case "30 seconds": + TimeChange = "30000"; + break; + case "1 minute": + TimeChange = "60000"; + break; + case "5 minutes": + TimeChange = "300000"; + break; + case "10 minutes": + TimeChange = "600000"; + break; + case "20 minutes": + TimeChange = "1200000"; + break; + case "30 minutes": + TimeChange = "1800000"; + break; + case "1 hour": + TimeChange = "3600000"; + break; + } } } }