private void btn_PublishPost_Click(object sender, EventArgs e) { string content = txt_Content.Text; // Add title string title = "<title>" + titleElem.InnerHtml + "</title>"; // Upload images ProgressForm p = new ProgressForm(); p.Text = "Uploading files..."; Thread t = new Thread(new ThreadStart(delegate() { while (!p.Visible) { } p.Progress = 0; double count = 0; int itemcount = list_images.Items.Count; for (int i = 0; i < itemcount; i++) { ImageInformation ii = null; Invoke(new Invoker(delegate() { ListViewItem lvi = list_images.Items[i]; ii = lvi.Tag as ImageInformation; })); if (ii.uploadedToDevServer) { FileUploadReturnInfo retval = UploadFile(ii, targetserver); if (retval == null) { MessageBox.Show("Unable to upload a file"); return; } string localfullurl = Uri.EscapeUriString(ii.fullurl); string localmedurl = Uri.EscapeUriString(ii.medurl); ii.fullurl = retval.url; GetMedWidth(ii); content = content.Replace(localfullurl, ii.fullurl); content = content.Replace(localmedurl, ii.medurl); } count++; Invoke(new Invoker(delegate() { p.Progress = count / (double)list_images.Items.Count; p.DisplayText = ii.filename; })); } Invoke(new Invoker(delegate() { p.Close(); })); })); t.Start(); p.ShowDialog(); // Make the content string and send it off content = title + content; int postid = targetserver.conn.NewPost(0, 0, targetserver.username, targetserver.password, content, true); // Set the category List<CategoryFullInfo> cfis = new List<CategoryFullInfo>(); foreach (Control ctl in flow_Categories.Controls) { CheckBox cb = ctl as CheckBox; if (cb.Checked) { cfis.Add(cb.Tag as CategoryFullInfo); } } targetserver.conn.SetPostCategories(postid, targetserver.username, targetserver.password, cfis.ToArray()); // Set the tags MWPost post = targetserver.conn.MWGetPost(postid, targetserver.username, targetserver.password); tags.ForEach(x => post.mt_keywords += (post.mt_keywords.Length == 0 ? "" : ",") + x); targetserver.conn.MWEditPost(postid, targetserver.username, targetserver.password, post); }
private void btn_PublishPost_Click(object sender, EventArgs e) { string content = txt_Content.Text; // Add title string title = "<title>" + titleElem.InnerHtml + "</title>"; // Upload images ProgressForm p = new ProgressForm(); p.Text = "Uploading files..."; Thread t = new Thread(new ThreadStart(delegate() { while (!p.Visible) { } p.Progress = 0; double count = 0; int itemcount = list_images.Items.Count; for (int i = 0; i < itemcount; i++) { ImageInformation ii = null; Invoke(new Invoker(delegate() { ListViewItem lvi = list_images.Items[i]; ii = lvi.Tag as ImageInformation; })); if (ii.uploadedToDevServer) { FileUploadReturnInfo retval = UploadFile(ii, targetserver); if (retval == null) { MessageBox.Show("Unable to upload a file"); return; } string localfullurl = Uri.EscapeUriString(ii.fullurl); string localmedurl = Uri.EscapeUriString(ii.medurl); ii.fullurl = retval.url; GetMedWidth(ii); content = content.Replace(localfullurl, ii.fullurl); content = content.Replace(localmedurl, ii.medurl); } count++; Invoke(new Invoker(delegate() { p.Progress = count / (double)list_images.Items.Count; p.DisplayText = ii.filename; })); } Invoke(new Invoker(delegate() { p.Close(); })); })); t.Start(); p.ShowDialog(); // Make the content string and send it off content = title + content; int postid = targetserver.conn.NewPost(0, 0, targetserver.username, targetserver.password, content, true); // Set the category List <CategoryFullInfo> cfis = new List <CategoryFullInfo>(); foreach (Control ctl in flow_Categories.Controls) { CheckBox cb = ctl as CheckBox; if (cb.Checked) { cfis.Add(cb.Tag as CategoryFullInfo); } } targetserver.conn.SetPostCategories(postid, targetserver.username, targetserver.password, cfis.ToArray()); // Set the tags MWPost post = targetserver.conn.MWGetPost(postid, targetserver.username, targetserver.password); tags.ForEach(x => post.mt_keywords += (post.mt_keywords.Length == 0 ? "" : ",") + x); targetserver.conn.MWEditPost(postid, targetserver.username, targetserver.password, post); }
private void btn_AddImage_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = true; ofd.Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.*"; ofd.ShowDialog(); if (ofd.FileNames != null && ofd.FileNames.Length != 0) { ProgressForm p = new ProgressForm(); p.Text = "Uploading files..."; Thread t = new Thread(new ThreadStart(delegate() { // Wait for the window to open while (!p.Visible) { }; double count = 0; foreach (string filename in ofd.FileNames) { p.DisplayText = filename; Invoke(new Invoker(delegate() { AddToImageList(filename); })); count++; p.Progress = count / (double)ofd.FileNames.Length; } Invoke(new Invoker(delegate() { p.Close(); })); })); t.Start(); p.ShowDialog(); } }