From: <du...@us...> - 2007-03-04 14:21:13
|
Revision: 153 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=153&view=rev Author: dukus Date: 2007-03-04 06:21:06 -0800 (Sun, 04 Mar 2007) Log Message: ----------- Online update. Manny changes. First release. Modified Paths: -------------- trunk/plugins/mpinstaler/MPInstaler/Form1.Designer.cs trunk/plugins/mpinstaler/MPInstaler/Form1.cs trunk/plugins/mpinstaler/MPInstaler/MPInstaler.csproj trunk/plugins/mpinstaler/MPInstaler/MPinstalerStruct.cs trunk/plugins/mpinstaler/MPInstaler/MPpackageStruct.cs trunk/plugins/mpinstaler/MPInstaler/Program.cs trunk/plugins/mpinstaler/MPInstaler/start_form.cs trunk/plugins/mpinstaler/MPInstaler/wizard/controlp.Designer.cs trunk/plugins/mpinstaler/MPInstaler/wizard/controlp.cs trunk/plugins/mpinstaler/MPInstaler/wizard/wizard_1.Designer.cs trunk/plugins/mpinstaler/MPInstaler/wizard/wizard_1.cs trunk/plugins/mpinstaler/MPInstaler.suo Added Paths: ----------- trunk/plugins/mpinstaler/MPInstaler/download_form.Designer.cs trunk/plugins/mpinstaler/MPInstaler/download_form.cs Modified: trunk/plugins/mpinstaler/MPInstaler/Form1.Designer.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/Form1.Designer.cs 2007-03-02 21:08:07 UTC (rev 152) +++ trunk/plugins/mpinstaler/MPInstaler/Form1.Designer.cs 2007-03-04 14:21:06 UTC (rev 153) @@ -53,9 +53,9 @@ this.fullToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.languageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.textToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.otherToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.textToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.otherToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.bossview = new System.Windows.Forms.ListView(); this.columnHeader1 = new System.Windows.Forms.ColumnHeader(); this.columnHeader2 = new System.Windows.Forms.ColumnHeader(); @@ -89,8 +89,10 @@ this.thumbst_comboBox1 = new System.Windows.Forms.ComboBox(); this.label7 = new System.Windows.Forms.Label(); this.tabPage_Other = new System.Windows.Forms.TabPage(); + this.othert_comboBox1 = new System.Windows.Forms.ComboBox(); this.label8 = new System.Windows.Forms.Label(); - this.othert_comboBox1 = new System.Windows.Forms.ComboBox(); + this.proiectt_textBox5 = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); this.menuStrip1.SuspendLayout(); this.contextMenuStrip1.SuspendLayout(); this.tabPage_Skin.SuspendLayout(); @@ -209,7 +211,7 @@ this.tagReadersToolStripMenuItem, this.externalPlayersToolStripMenuItem}); this.windowPluginToolStripMenuItem.Name = "windowPluginToolStripMenuItem"; - this.windowPluginToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.windowPluginToolStripMenuItem.Size = new System.Drawing.Size(132, 22); this.windowPluginToolStripMenuItem.Text = "Plugin"; // // windowToolStripMenuItem @@ -254,7 +256,7 @@ this.mediaToolStripMenuItem, this.fullToolStripMenuItem}); this.skinToolStripMenuItem.Name = "skinToolStripMenuItem"; - this.skinToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.skinToolStripMenuItem.Size = new System.Drawing.Size(132, 22); this.skinToolStripMenuItem.Text = "Skin"; // // componentToolStripMenuItem @@ -282,37 +284,37 @@ // languageToolStripMenuItem // this.languageToolStripMenuItem.Name = "languageToolStripMenuItem"; - this.languageToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.languageToolStripMenuItem.Size = new System.Drawing.Size(132, 22); this.languageToolStripMenuItem.Text = "Language"; this.languageToolStripMenuItem.Click += new System.EventHandler(this.languageToolStripMenuItem_Click); // // textToolStripMenuItem // this.textToolStripMenuItem.Name = "textToolStripMenuItem"; - this.textToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.textToolStripMenuItem.Size = new System.Drawing.Size(132, 22); this.textToolStripMenuItem.Text = "Text"; this.textToolStripMenuItem.Click += new System.EventHandler(this.textToolStripMenuItem_Click); // - // otherToolStripMenuItem - // - this.otherToolStripMenuItem.Name = "otherToolStripMenuItem"; - this.otherToolStripMenuItem.Size = new System.Drawing.Size(152, 22); - this.otherToolStripMenuItem.Text = "Other"; - this.otherToolStripMenuItem.Click += new System.EventHandler(this.otherToolStripMenuItem_Click); - // // settingsToolStripMenuItem // this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; - this.settingsToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.settingsToolStripMenuItem.Size = new System.Drawing.Size(132, 22); this.settingsToolStripMenuItem.Text = "Settings"; // // textToolStripMenuItem1 // this.textToolStripMenuItem1.Name = "textToolStripMenuItem1"; - this.textToolStripMenuItem1.Size = new System.Drawing.Size(152, 22); + this.textToolStripMenuItem1.Size = new System.Drawing.Size(132, 22); this.textToolStripMenuItem1.Text = "Thumbs"; this.textToolStripMenuItem1.Click += new System.EventHandler(this.textToolStripMenuItem1_Click); // + // otherToolStripMenuItem + // + this.otherToolStripMenuItem.Name = "otherToolStripMenuItem"; + this.otherToolStripMenuItem.Size = new System.Drawing.Size(132, 22); + this.otherToolStripMenuItem.Text = "Other"; + this.otherToolStripMenuItem.Click += new System.EventHandler(this.otherToolStripMenuItem_Click); + // // bossview // this.bossview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -492,6 +494,8 @@ // // tabPage_Proiect // + this.tabPage_Proiect.Controls.Add(this.label9); + this.tabPage_Proiect.Controls.Add(this.proiectt_textBox5); this.tabPage_Proiect.Controls.Add(this.proiectt_textBox4); this.tabPage_Proiect.Controls.Add(this.label5); this.tabPage_Proiect.Controls.Add(this.proiectt_textBox3); @@ -630,6 +634,15 @@ this.tabPage_Other.Text = "Properties"; this.tabPage_Other.UseVisualStyleBackColor = true; // + // othert_comboBox1 + // + this.othert_comboBox1.FormattingEnabled = true; + this.othert_comboBox1.Location = new System.Drawing.Point(9, 28); + this.othert_comboBox1.Name = "othert_comboBox1"; + this.othert_comboBox1.Size = new System.Drawing.Size(269, 21); + this.othert_comboBox1.TabIndex = 1; + this.othert_comboBox1.TextChanged += new System.EventHandler(this.tab_other_change); + // // label8 // this.label8.AutoSize = true; @@ -639,15 +652,24 @@ this.label8.TabIndex = 0; this.label8.Text = "Directory (relative) :"; // - // othert_comboBox1 + // proiectt_textBox5 // - this.othert_comboBox1.FormattingEnabled = true; - this.othert_comboBox1.Location = new System.Drawing.Point(9, 28); - this.othert_comboBox1.Name = "othert_comboBox1"; - this.othert_comboBox1.Size = new System.Drawing.Size(269, 21); - this.othert_comboBox1.TabIndex = 1; - this.othert_comboBox1.TextChanged += new System.EventHandler(this.tab_other_change); + this.proiectt_textBox5.Location = new System.Drawing.Point(398, 21); + this.proiectt_textBox5.Multiline = true; + this.proiectt_textBox5.Name = "proiectt_textBox5"; + this.proiectt_textBox5.Size = new System.Drawing.Size(229, 84); + this.proiectt_textBox5.TabIndex = 8; + this.proiectt_textBox5.TextChanged += new System.EventHandler(this.proiectt_textBox1_TextChanged); // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(395, 5); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(66, 13); + this.label9.TabIndex = 9; + this.label9.Text = "Description :"; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -743,6 +765,8 @@ private System.Windows.Forms.TabPage tabPage_Other; private System.Windows.Forms.ComboBox othert_comboBox1; private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox proiectt_textBox5; } } Modified: trunk/plugins/mpinstaler/MPInstaler/Form1.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/Form1.cs 2007-03-02 21:08:07 UTC (rev 152) +++ trunk/plugins/mpinstaler/MPInstaler/Form1.cs 2007-03-04 14:21:06 UTC (rev 153) @@ -21,6 +21,19 @@ { InitializeComponent(); } + public Form1(string fil) + { + proiect_file_name = fil; + InitializeComponent(); + _struct.LoadFromFile(fil); + _struct.ProiectdFileName = fil; + loadProperties(); + this.Text = proiect_file_name; + for (int i = 0; i < _struct.FileList.Count; i++) + { + addrow((MPIFileList)_struct.FileList[i]); + } + } private void button1_Click(object sender, EventArgs e) { @@ -191,6 +204,7 @@ _struct.LoadFromFile(fil); _struct.ProiectdFileName = fil; loadProperties(); + this.Text = proiect_file_name; for (int i=0;i<_struct.FileList.Count;i++) { addrow((MPIFileList)_struct.FileList[i]); @@ -205,6 +219,7 @@ proiectt_textBox2.Text = _struct.Author; proiectt_textBox3.Text = _struct.UpdateURL; proiectt_textBox4.Text = _struct.Version; + proiectt_textBox5.Text = _struct.Description; _loading = false; } private void languageToolStripMenuItem_Click(object sender, EventArgs e) @@ -260,6 +275,7 @@ _struct.ProiectdFileName = proiect_file_name; _struct.AddFileList(bossview); _struct.SaveToFile(proiect_file_name); + this.Text = proiect_file_name; } } @@ -403,6 +419,7 @@ _struct.Author = proiectt_textBox2.Text; _struct.UpdateURL = proiectt_textBox3.Text; _struct.Version = proiectt_textBox4.Text; + _struct.Description = proiectt_textBox5.Text; } } Modified: trunk/plugins/mpinstaler/MPInstaler/MPInstaler.csproj =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/MPInstaler.csproj 2007-03-02 21:08:07 UTC (rev 152) +++ trunk/plugins/mpinstaler/MPInstaler/MPInstaler.csproj 2007-03-04 14:21:06 UTC (rev 153) @@ -75,6 +75,12 @@ <Compile Include="Build dialog.Designer.cs"> <DependentUpon>Build dialog.cs</DependentUpon> </Compile> + <Compile Include="download_form.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="download_form.Designer.cs"> + <DependentUpon>download_form.cs</DependentUpon> + </Compile> <Compile Include="MPinstalerStruct.cs" /> <Compile Include="Form1.cs"> <SubType>Form</SubType> @@ -101,6 +107,10 @@ <SubType>Designer</SubType> <DependentUpon>Build dialog.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="download_form.resx"> + <SubType>Designer</SubType> + <DependentUpon>download_form.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="Form1.resx"> <SubType>Designer</SubType> <DependentUpon>Form1.cs</DependentUpon> Modified: trunk/plugins/mpinstaler/MPInstaler/MPinstalerStruct.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/MPinstalerStruct.cs 2007-03-02 21:08:07 UTC (rev 152) +++ trunk/plugins/mpinstaler/MPInstaler/MPinstalerStruct.cs 2007-03-04 14:21:06 UTC (rev 153) @@ -39,7 +39,9 @@ string _update = string.Empty; string _name = string.Empty; string _version = string.Empty; + string _description = string.Empty; + public ArrayList Uninstall = new ArrayList(); public ArrayList FileList = new ArrayList(); public MPinstalerStruct() { @@ -68,6 +70,12 @@ get { return _author; } set {_author = value; } } + + public string Description + { + get { return _description; } + set { _description = value; } + } public string Name { get { return _name; } @@ -146,6 +154,8 @@ writer.WriteElementString("Author", this.Author); writer.WriteElementString("UpdateURL", this.UpdateURL); writer.WriteElementString("Version", this.Version); + writer.WriteElementString("Description", this.Description); + writer.WriteEndElement(); writer.WriteEndElement(); writer.Flush(); @@ -172,6 +182,20 @@ pb.Value = 0; pb.Maximum = FileList.Count; ls.Items.Add("Build file :" + _builFileName); + if (File.Exists(ProiectdFileName)) + { + FileStream fs = File.OpenRead(Path.GetFullPath(ProiectdFileName)); + byte[] buffer = new byte[fs.Length]; + fs.Read(buffer, 0, buffer.Length); + + ZipEntry entry = new ZipEntry("instaler.xmp"); + + s.PutNextEntry(entry); + + s.Write(buffer, 0, buffer.Length); + } + else ls.Items.Add("Error : Proiect file not found !"); + foreach (MPIFileList file in FileList) { ls.Items.Add("Adding file :" + file.FileName); @@ -194,18 +218,6 @@ else ls.Items.Add("Error : File not found !"); } - if (File.Exists(ProiectdFileName)) - { - FileStream fs = File.OpenRead(Path.GetFullPath(ProiectdFileName)); - byte[] buffer = new byte[fs.Length]; - fs.Read(buffer, 0, buffer.Length); - - ZipEntry entry = new ZipEntry("instaler.xmp"); - - s.PutNextEntry(entry); - - s.Write(buffer, 0, buffer.Length); - } s.Finish(); s.Close(); } @@ -232,7 +244,9 @@ this.Author = nodeoption.SelectSingleNode("Author").InnerText; this.UpdateURL = nodeoption.SelectSingleNode("UpdateURL").InnerText; this.Version = nodeoption.SelectSingleNode("Version").InnerText; - + XmlNode node_des = nodeoption.SelectSingleNode("Description"); + if (node_des != null) + this._description = node_des.InnerText; } public MPIFileList FindList(string typ, string stpy) @@ -424,4 +438,33 @@ } } + + public class UninstallInfo + { + private DateTime _date; + private string _path; + + public UninstallInfo(string fil) + { + Path = System.IO.Path.GetFullPath(fil); + Date = System.IO.File.GetCreationTime(fil); + } + public UninstallInfo(string fil, string dt) + { + Path = fil; + Date = DateTime.FromFileTime(long.Parse(dt)); + } + public DateTime Date + { + get { return _date; } + set { _date = value; } + } + + public string Path + { + get { return _path; } + set { _path = value; } + } + + } } Modified: trunk/plugins/mpinstaler/MPInstaler/MPpackageStruct.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/MPpackageStruct.cs 2007-03-02 21:08:07 UTC (rev 152) +++ trunk/plugins/mpinstaler/MPInstaler/MPpackageStruct.cs 2007-03-04 14:21:06 UTC (rev 153) @@ -3,11 +3,15 @@ using System.Collections; using System.Text; using System.IO; +using System.Net; using System.Xml; using ICSharpCode.SharpZipLib.Zip; using System.Windows.Forms; using MediaPortal.Configuration; +using MediaPortal.Util; +using MediaPortal; + namespace MPInstaler { public class MPpackageStruct @@ -26,7 +30,7 @@ } - public void instal_file(ProgressBar pb, MPIFileList fl) + public void instal_file(ProgressBar pb,ListBox lb, MPIFileList fl) { string fil = FileName; byte[] data = new byte[2048]; @@ -63,6 +67,13 @@ fs.Write(data, 0, nb); } fs.Close(); + this._intalerStruct.Uninstall.Add(new UninstallInfo(tpf)); + if (lb != null) + { + lb.Items.Add(tpf); + lb.Refresh(); + lb.Update(); + } } } s.Close(); @@ -170,10 +181,6 @@ public MPInstallHelper() { FileName = InstalDir + @"\" + "config.xml"; - if (!Directory.Exists(InstalDir)) - { - Directory.CreateDirectory(InstalDir); - } //LoadFromFile(); } @@ -189,8 +196,22 @@ File.Copy(pk.FileName, InstalDir + @"\" + Path.GetFileName(pk.FileName), true); } + public int IndexOf(MPpackageStruct pk) + { + for (int i = 0; i < lst.Count; i++) + { + if (((MPpackageStruct)lst[i])._intalerStruct.Name.Trim() == pk._intalerStruct.Name.Trim()) + return i; + } + return -1; + } + public void SaveToFile() { + if (!Directory.Exists(InstalDir)) + { + Directory.CreateDirectory(InstalDir); + } Stream myStream; if ((myStream = File.Open(FileName, FileMode.Create, FileAccess.Write, FileShare.None)) != null) { @@ -219,7 +240,17 @@ writer.WriteElementString("URL", it._intalerStruct.UpdateURL); writer.WriteElementString("Version", it._intalerStruct.Version); writer.WriteElementString("Author", it._intalerStruct.Author); + writer.WriteElementString("Description", it._intalerStruct.Description); + writer.WriteStartElement("Uninstall"); + for (int j = 0; j < it._intalerStruct.Uninstall.Count; j++) + { + writer.WriteStartElement("FileInfo"); + writer.WriteElementString("FileName", ((UninstallInfo)it._intalerStruct.Uninstall[j]).Path); + writer.WriteElementString("Date", Path.GetFileName(((UninstallInfo)it._intalerStruct.Uninstall[j]).Date.ToFileTime().ToString())); + writer.WriteEndElement(); + } writer.WriteEndElement(); + writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteStartElement("Option"); @@ -235,7 +266,36 @@ myStream.Close(); } } - + + public static bool Download(string url, string fil) + { + int code = 0; + + if (!Win32API.IsConnectedToInternet(ref code)) + { + return false; + } + using (WebClient client = new WebClient()) + { + try + { + client.DownloadFile(url,fil ); + return true; + } + catch (Exception ex) + { + return false; + } + } + return false; + } + + public void LoadFromFile(string fil) + { + FileName = fil; + LoadFromFile(); + } + public void LoadFromFile() { XmlDocument doc = new XmlDocument(); @@ -253,6 +313,14 @@ pkg._intalerStruct.Author = nodefile.SelectSingleNode("Author").InnerText; pkg._intalerStruct.Version = nodefile.SelectSingleNode("Version").InnerText; pkg._intalerStruct.UpdateURL = nodefile.SelectSingleNode("URL").InnerText; + XmlNode node_des = nodefile.SelectSingleNode("Description"); + XmlNodeList uninstallList = nodefile.SelectNodes("Uninstall/FileInfo"); + foreach (XmlNode un in uninstallList) + { + pkg._intalerStruct.Uninstall.Add(new UninstallInfo(un.SelectSingleNode("FileName").InnerText, un.SelectSingleNode("Date").InnerText)); + } + if (node_des != null) + pkg._intalerStruct.Description = node_des.InnerText; this.lst.Add(pkg); } //XmlNode nodeoption = ver.SelectSingleNode("Option"); Modified: trunk/plugins/mpinstaler/MPInstaler/Program.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/Program.cs 2007-03-02 21:08:07 UTC (rev 152) +++ trunk/plugins/mpinstaler/MPInstaler/Program.cs 2007-03-04 14:21:06 UTC (rev 153) @@ -1,7 +1,9 @@ using System; +using System.IO; using System.Collections.Generic; using System.Windows.Forms; using Microsoft.Win32; +using MediaPortal.Configuration; namespace MPInstaler { @@ -11,11 +13,41 @@ /// The main entry point for the application. /// </summary> [STAThread] - static void Main() + static void Main(string[] args) { + string fil = String.Empty; + if (args.Length > 0) + fil = args[0]; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new start_form()); + if (File.Exists(Config.GetFolder(Config.Dir.Base) + @"\MediaPortal.exe")) + { + if (!String.IsNullOrEmpty(fil)) + { + if (Path.GetExtension(fil) == ".mpi") + { + wizard_1 wiz = new wizard_1(); + wiz.package.LoadFromFile(fil); + if (wiz.package.isValid) + { + wiz.starStep(); + } + else + MessageBox.Show("Invalid package !"); + } + if (Path.GetExtension(fil) == ".xmp") + { + Form1 create_dlg = new Form1(Path.GetFullPath(fil)); + create_dlg.ShowDialog(); + } + } + else + Application.Run(new start_form()); + } + else + { + MessageBox.Show(Config.GetFolder(Config.Dir.Base) + @"\MediaPortal.exe not found. Program Exit....."); + } } } } \ No newline at end of file Added: trunk/plugins/mpinstaler/MPInstaler/download_form.Designer.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/download_form.Designer.cs (rev 0) +++ trunk/plugins/mpinstaler/MPInstaler/download_form.Designer.cs 2007-03-04 14:21:06 UTC (rev 153) @@ -0,0 +1,87 @@ +namespace MPInstaler +{ + partial class download_form + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(166, 77); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(110, 25); + this.button1.TabIndex = 0; + this.button1.Text = "Cancel"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // progressBar1 + // + this.progressBar1.Location = new System.Drawing.Point(12, 34); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(419, 23); + this.progressBar1.TabIndex = 1; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(69, 13); + this.label1.TabIndex = 2; + this.label1.Text = "Downloading"; + // + // download_form + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(443, 114); + this.Controls.Add(this.label1); + this.Controls.Add(this.progressBar1); + this.Controls.Add(this.button1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "download_form"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Download"; + this.Shown += new System.EventHandler(this.download_form_Shown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file Added: trunk/plugins/mpinstaler/MPInstaler/download_form.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/download_form.cs (rev 0) +++ trunk/plugins/mpinstaler/MPInstaler/download_form.cs 2007-03-04 14:21:06 UTC (rev 153) @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using System.Net; + +namespace MPInstaler +{ + public partial class download_form : Form + { + string source = string.Empty; + string dest = string.Empty; + WebClient client = new WebClient(); + public download_form(string s, string d) + { + InitializeComponent(); + source = s; + dest = d; + client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback); + client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadEnd); + progressBar1.Minimum = 0; + progressBar1.Maximum = 100; + progressBar1.Value = 0; + } + + private void download_form_Shown(object sender, EventArgs e) + { + if (!String.IsNullOrEmpty(source) && !String.IsNullOrEmpty(dest)) + { + client.DownloadFileAsync(new System.Uri(source), dest); + //client.DownloadFile(new System.Uri(source), dest); + } + } + private void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e) + { + // Displays the operation identifier, and the transfer progress. + //Console.WriteLine("{0} downloaded {1} of {2} bytes. {3} % complete...", + // (string)e.UserState, + // e.BytesReceived, + // e.TotalBytesToReceive, + // e.ProgressPercentage); + progressBar1.Value = e.ProgressPercentage; + } + private void DownloadEnd(object sender, AsyncCompletedEventArgs e) + { + if (e.Error!=null) + MessageBox.Show(e.Error.Message); + button1.Enabled = false; + this.Close(); + } + + private void button1_Click(object sender, EventArgs e) + { + client.CancelAsync(); + this.Close(); + } + } +} \ No newline at end of file Modified: trunk/plugins/mpinstaler/MPInstaler/start_form.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/start_form.cs 2007-03-02 21:08:07 UTC (rev 152) +++ trunk/plugins/mpinstaler/MPInstaler/start_form.cs 2007-03-04 14:21:06 UTC (rev 153) @@ -39,7 +39,7 @@ wiz.package.LoadFromFile(fil); if (wiz.package.isValid) { - wiz.nextStep(1); + wiz.starStep(); } else MessageBox.Show("Invalid package !"); Modified: trunk/plugins/mpinstaler/MPInstaler/wizard/controlp.Designer.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/wizard/controlp.Designer.cs 2007-03-02 21:08:07 UTC (rev 152) +++ trunk/plugins/mpinstaler/MPInstaler/wizard/controlp.Designer.cs 2007-03-04 14:21:06 UTC (rev 153) @@ -39,15 +39,16 @@ this.button4 = new System.Windows.Forms.Button(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); + this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.tabPage2 = new System.Windows.Forms.TabPage(); - this.comboBox1 = new System.Windows.Forms.ComboBox(); - this.label1 = new System.Windows.Forms.Label(); + this.button5 = new System.Windows.Forms.Button(); this.listView2 = new System.Windows.Forms.ListView(); this.columnHeader5 = new System.Windows.Forms.ColumnHeader(); this.columnHeader6 = new System.Windows.Forms.ColumnHeader(); this.columnHeader7 = new System.Windows.Forms.ColumnHeader(); - this.button5 = new System.Windows.Forms.Button(); - this.linkLabel1 = new System.Windows.Forms.LinkLabel(); + this.columnHeader8 = new System.Windows.Forms.ColumnHeader(); + this.label1 = new System.Windows.Forms.Label(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); @@ -105,6 +106,7 @@ this.button1.TabIndex = 1; this.button1.Text = "Uninstall"; this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // @@ -166,6 +168,16 @@ this.tabPage1.Text = "Local"; this.tabPage1.UseVisualStyleBackColor = true; // + // linkLabel1 + // + this.linkLabel1.AutoSize = true; + this.linkLabel1.Location = new System.Drawing.Point(7, 321); + this.linkLabel1.Name = "linkLabel1"; + this.linkLabel1.Size = new System.Drawing.Size(113, 13); + this.linkLabel1.TabIndex = 5; + this.linkLabel1.TabStop = true; + this.linkLabel1.Text = "http://dukus.extra.hu/"; + // // tabPage2 // this.tabPage2.Controls.Add(this.button5); @@ -180,31 +192,24 @@ this.tabPage2.Text = "Online"; this.tabPage2.UseVisualStyleBackColor = true; // - // comboBox1 + // button5 // - this.comboBox1.FormattingEnabled = true; - this.comboBox1.Items.AddRange(new object[] { - "d:\\MPExtension_list.xml"}); - this.comboBox1.Location = new System.Drawing.Point(6, 21); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(675, 21); - this.comboBox1.TabIndex = 0; + this.button5.Location = new System.Drawing.Point(10, 286); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(215, 23); + this.button5.TabIndex = 3; + this.button5.Text = "Download && Install"; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.button5_Click); // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(7, 5); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(46, 13); - this.label1.TabIndex = 1; - this.label1.Text = "Provider"; - // // listView2 // this.listView2.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader5, this.columnHeader6, - this.columnHeader7}); + this.columnHeader7, + this.columnHeader8}); + this.listView2.FullRowSelect = true; this.listView2.Location = new System.Drawing.Point(7, 48); this.listView2.Name = "listView2"; this.listView2.Size = new System.Drawing.Size(672, 220); @@ -227,25 +232,30 @@ this.columnHeader7.Text = "Version"; this.columnHeader7.Width = 91; // - // button5 + // columnHeader8 // - this.button5.Location = new System.Drawing.Point(10, 286); - this.button5.Name = "button5"; - this.button5.Size = new System.Drawing.Size(215, 23); - this.button5.TabIndex = 3; - this.button5.Text = "Download && Install"; - this.button5.UseVisualStyleBackColor = true; + this.columnHeader8.Text = "File"; // - // linkLabel1 + // label1 // - this.linkLabel1.AutoSize = true; - this.linkLabel1.Location = new System.Drawing.Point(7, 321); - this.linkLabel1.Name = "linkLabel1"; - this.linkLabel1.Size = new System.Drawing.Size(113, 13); - this.linkLabel1.TabIndex = 5; - this.linkLabel1.TabStop = true; - this.linkLabel1.Text = "http://dukus.extra.hu/"; + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(7, 5); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(46, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Provider"; // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "http://dukus.extra.hu"}); + this.comboBox1.Location = new System.Drawing.Point(6, 21); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(675, 21); + this.comboBox1.TabIndex = 0; + this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // // controlp // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -288,5 +298,6 @@ private System.Windows.Forms.ColumnHeader columnHeader6; private System.Windows.Forms.ColumnHeader columnHeader7; private System.Windows.Forms.LinkLabel linkLabel1; + private System.Windows.Forms.ColumnHeader columnHeader8; } } \ No newline at end of file Modified: trunk/plugins/mpinstaler/MPInstaler/wizard/controlp.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/wizard/controlp.cs 2007-03-02 21:08:07 UTC (rev 152) +++ trunk/plugins/mpinstaler/MPInstaler/wizard/controlp.cs 2007-03-04 14:21:06 UTC (rev 153) @@ -13,6 +13,7 @@ public partial class controlp : Form { public MPInstallHelper lst = new MPInstallHelper(); + public MPInstallHelper lst_online = new MPInstallHelper(); public controlp() { InitializeComponent(); @@ -33,17 +34,23 @@ { } + public void LoadToListview() { - listView1.Items.Clear(); - for (int i = 0; i < lst.lst.Count; i++) + LoadToListview(lst, listView1); + } + + public void LoadToListview(MPInstallHelper mpih, ListView lv) + { + lv.Items.Clear(); + for (int i = 0; i < mpih.lst.Count; i++) { - MPpackageStruct pk = (MPpackageStruct)lst.lst[i]; + MPpackageStruct pk = (MPpackageStruct)mpih.lst[i]; ListViewItem item1 = new ListViewItem(pk._intalerStruct.Name, 0); item1.SubItems.Add(pk._intalerStruct.Author); item1.SubItems.Add(pk._intalerStruct.Version); item1.SubItems.Add(Path.GetFileName(pk.FileName)); - listView1.Items.AddRange(new ListViewItem[] { item1 }); + lv.Items.AddRange(new ListViewItem[] { item1 }); } } @@ -53,13 +60,13 @@ { button1.Enabled = true; button2.Enabled = true; - button3.Enabled = true; + button4.Enabled = true; } else { button1.Enabled = false; button2.Enabled = false; - button3.Enabled = false; + button4.Enabled = false; } } @@ -69,11 +76,73 @@ wiz.package.LoadFromFile(Config.GetFolder(Config.Dir.Base) + @"\" + "Instaler" + @"\" + listView1.SelectedItems[0].SubItems[3].Text); if (wiz.package.isValid) { - wiz.nextStep(1); + wiz.starStep(); } else MessageBox.Show("Invalid package !"); } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + //MPExtensionFileList.xml + //Path.GetFullPath(Environment.GetEnvironmentVariable("TEMP"))+@"\" + + string temp_file = Path.GetFullPath(Environment.GetEnvironmentVariable("TEMP")) + @"\" + "MPExtensionFileList.xml"; + if (MPInstallHelper.Download(comboBox1.Text + "/" + "MPExtensionFileList.xml",temp_file)) + { + if (File.Exists(temp_file)) + { + lst_online.LoadFromFile(temp_file); + LoadToListview(lst_online, listView2); + } + else MessageBox.Show("File read error"); + } + else + { + MessageBox.Show("Download Error!"); + } + } + + private void button5_Click(object sender, EventArgs e) + { + if (listView2.SelectedItems.Count > 0) + { + string file_name = listView2.SelectedItems[0].SubItems[3].Text; + string temp_file = Path.GetFullPath(Environment.GetEnvironmentVariable("TEMP")) + @"\" + file_name; + download_form dw = new download_form(comboBox1.Text+"/"+file_name,temp_file); + dw.Text = listView2.SelectedItems[0].SubItems[3].Text; + dw.ShowDialog(); + if (File.Exists(temp_file)) + { + wizard_1 wiz = new wizard_1(); + wiz.package.LoadFromFile(temp_file); + if (wiz.package.isValid) + { + wiz.starStep(); + listView1.Items.Clear(); + lst.LoadFromFile(); + LoadToListview(); + } + else + MessageBox.Show("Invalid package !"); + } + } + } + + private void button1_Click(object sender, EventArgs e) + { + wizard_1 wiz = new wizard_1(); + wiz.package.LoadFromFile(Config.GetFolder(Config.Dir.Base) + @"\" + "Instaler" + @"\" + listView1.SelectedItems[0].SubItems[3].Text); + if (wiz.package.isValid) + { + wiz.uninstall(listView1.SelectedItems[0].Text); + listView1.Items.Clear(); + lst.LoadFromFile(); + LoadToListview(); + } + else + MessageBox.Show("Invalid package !"); + + } } } \ No newline at end of file Modified: trunk/plugins/mpinstaler/MPInstaler/wizard/wizard_1.Designer.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/wizard/wizard_1.Designer.cs 2007-03-02 21:08:07 UTC (rev 152) +++ trunk/plugins/mpinstaler/MPInstaler/wizard/wizard_1.Designer.cs 2007-03-04 14:21:06 UTC (rev 153) @@ -40,6 +40,7 @@ this.button_back = new System.Windows.Forms.Button(); this.button_next = new System.Windows.Forms.Button(); this.button_cancel = new System.Windows.Forms.Button(); + this.listBox1 = new System.Windows.Forms.ListBox(); this.panel1.SuspendLayout(); this.panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); @@ -48,6 +49,7 @@ // panel1 // this.panel1.BackColor = System.Drawing.Color.White; + this.panel1.Controls.Add(this.listBox1); this.panel1.Controls.Add(this.progressBar2); this.panel1.Controls.Add(this.progressBar1); this.panel1.Controls.Add(this.label2); @@ -150,6 +152,15 @@ this.button_cancel.UseVisualStyleBackColor = true; this.button_cancel.Click += new System.EventHandler(this.button_cancel_Click); // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.HorizontalScrollbar = true; + this.listBox1.Location = new System.Drawing.Point(14, 174); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(308, 108); + this.listBox1.TabIndex = 5; + // // wizard_1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -187,5 +198,6 @@ private System.Windows.Forms.RichTextBox richTextBox1; private System.Windows.Forms.ProgressBar progressBar2; private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.ListBox listBox1; } } \ No newline at end of file Modified: trunk/plugins/mpinstaler/MPInstaler/wizard/wizard_1.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/wizard/wizard_1.cs 2007-03-02 21:08:07 UTC (rev 152) +++ trunk/plugins/mpinstaler/MPInstaler/wizard/wizard_1.cs 2007-03-04 14:21:06 UTC (rev 153) @@ -13,11 +13,21 @@ { public int step = 0; public MPpackageStruct package; + MPInstallHelper inst = new MPInstallHelper(); public wizard_1() { package = new MPpackageStruct(); InitializeComponent(); } + public void starStep() + { + inst.LoadFromFile(); + if (inst.IndexOf(package) < 0) + nextStep(1); + else + if (MessageBox.Show("Extension already installed. Do you want continue ?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) + nextStep(1); + } public void nextStep(int m) { @@ -31,11 +41,13 @@ button_back.Visible = false; progressBar1.Visible = false; progressBar2.Visible = false; + listBox1.Items.Clear(); + listBox1.Visible = false; label2.Visible = false; title_label.Text = package._intalerStruct.Name; button_next.Text = "Next"; richTextBox1.Visible = true; - richTextBox1.Text = String.Format(" Name : {0} \n\n Author : {1} \n\n Version : {2}", package._intalerStruct.Name,package._intalerStruct.Author,package._intalerStruct.Version); + richTextBox1.Text = String.Format(" Name : {0} \n\n Author : {1} \n\n Version : {2} \n\n Description :\n {3} \n", package._intalerStruct.Name, package._intalerStruct.Author, package._intalerStruct.Version, package._intalerStruct.Description); if (!this.Visible) this.ShowDialog(); break; } @@ -44,6 +56,7 @@ label2.Visible = true; progressBar1.Visible = false; progressBar2.Visible = false; + listBox1.Visible = false; label2.Text = "License Agreement"; button_next.Text = "I Agree"; button_back.Visible = true; @@ -56,6 +69,7 @@ label2.Visible = true; progressBar1.Visible = false; progressBar2.Visible = false; + listBox1.Visible = false; label2.Text = "Change log"; button_next.Text = "Next"; button_back.Visible = true; @@ -67,6 +81,7 @@ { progressBar1.Visible = false; progressBar2.Visible = false; + listBox1.Visible = false; label2.Visible = true; label2.Text = "Read me"; button_back.Visible = true; @@ -78,6 +93,7 @@ { progressBar1.Visible = false; progressBar2.Visible = false; + listBox1.Visible = false; label2.Visible = true; label2.Text = "Select skin"; button_next.Text = "Next"; @@ -89,12 +105,17 @@ { progressBar1.Visible = false; progressBar2.Visible = false; + listBox1.Visible = false; label2.Visible = true; label2.Text = "Instaling ..."; button_next.Text = "Next"; button_back.Visible = true; richTextBox1.Visible = true; - richTextBox1.Text = String.Format("Intall paths : \nPlugins : {0}\nSkin : {1}", Config.GetFolder(Config.Dir.Plugins), Config.GetFolder(Config.Dir.Skin)); + richTextBox1.Text = String.Format("Intall paths : \n"); + foreach (Config.Dir option in Enum.GetValues(typeof(Config.Dir))) + { + richTextBox1.Text += String.Format("{0} - {1}\n", option, Config.GetFolder(option)); + } break; } case 7: @@ -102,6 +123,7 @@ label2.Visible = true; progressBar1.Visible = true; progressBar2.Visible = true; + listBox1.Visible = true; ; label2.Text = "Instaling ..."; button_next.Visible = false; button_back.Visible = true; @@ -116,8 +138,6 @@ private void install() { - MPInstallHelper inst = new MPInstallHelper(); - inst.LoadFromFile(); button_next.Visible = false; button_back.Visible = false; button_cancel.Enabled = false; @@ -128,7 +148,7 @@ } for (int i = 0; i < package._intalerStruct.FileList.Count; i++) { - package.instal_file(progressBar2,(MPIFileList) package._intalerStruct.FileList[i]); + package.instal_file(progressBar2,listBox1,(MPIFileList) package._intalerStruct.FileList[i]); progressBar1.Value++; this.Refresh(); this.Update(); @@ -190,5 +210,66 @@ { nextStep(-1); } + + internal void uninstall(string tit) + { + inst.LoadFromFile(); + int index = -1; + int ind=-1; + foreach (MPpackageStruct p in inst.lst) + { + ind++; + if (p._intalerStruct.Name.Trim() == tit.Trim()) + { + index = ind; + break; + } + } + if (index > -1) + if (((MPpackageStruct)inst.lst[index])._intalerStruct.Uninstall.Count>0) + { + if (MessageBox.Show("Uninstalling extension." + tit + "\nDo you want continue ?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + if (!this.Visible) this.Show(); + MPpackageStruct p = (MPpackageStruct)inst.lst[index]; + label2.Visible = true; + progressBar1.Visible = true; + progressBar2.Visible = false; + listBox1.Visible = true; + this.Text = "Uninstalling "+p._intalerStruct.Name; + title_label.Text = p._intalerStruct.Name; + label2.Text = "Uninstalling ..."; + button_next.Visible = false; + button_back.Visible = false; + richTextBox1.Text = ""; + richTextBox1.Visible = false; + progressBar1.Maximum = p._intalerStruct.Uninstall.Count; + for (int i = 0; i < p._intalerStruct.Uninstall.Count; i++) + { + UninstallInfo u = (UninstallInfo)p._intalerStruct.Uninstall[i]; + progressBar1.Value++; + progressBar1.Update(); + progressBar1.Refresh(); + if (System.IO.File.Exists(u.Path)) + { + if (System.IO.File.GetCreationTime(u.Path) == u.Date) + { + listBox1.Items.Add(u.Path); + }else + listBox1.Items.Add("File date changed :"+u.Path); + } + else listBox1.Items.Add("File not found :"+u.Path); + } + inst.lst.RemoveAt(index); + inst.SaveToFile(); + } + } + else + MessageBox.Show("Uninstall information not found !"); + else + MessageBox.Show("Uninstall information not found !"); + + button_cancel.Text = "Finish"; + } } } \ No newline at end of file Modified: trunk/plugins/mpinstaler/MPInstaler.suo =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |