public void ShowPage() { Text = Tag + "[" + (pageIndex + 1) + "/" + pageCount + "]"; schoolPage1.Image = FileHelper.GetFile(FileHelper.imagePath, Tag.ToString(), (pageIndex + 1) + ".jpg"); string[] contents = FileHelper.ReadFile(FileHelper.htmlPath, Tag.ToString(), (pageIndex + 1) + ".html"); List <string> content = new List <string>(); string title = ""; foreach (string s in contents) { if (s.EndsWith("</strong></font>")) { int index1 = s.IndexOf("<strong>"); int index2 = s.IndexOf("</strong>"); if (index1 < 0 || index2 < 0 || index2 < index1 + 8) { continue; } title = s.Substring(index1, index2 - index1).Substring(8); } if (s.EndsWith("</br>")) { content.Add(s.Replace("</br>", "")); } } schoolPage1.Content = string.Join("\r\n", content.ToArray()); schoolPage1.Title = title; }
private void Form4_Load(object sender, EventArgs e) { try { ftpfiles = new Dictionary <string, string>(); string[] folders = FileHelper.GetFolders(FileHelper.htmlPath); foreach (string folder in folders) { string[] files = FileHelper.GetFiles(FileHelper.htmlPath, folder); foreach (string file in files) { ftpfiles[FileHelper.GetFile(FileHelper.htmlPath, folder, file)] = FileHelper.htmlPath.Replace('\\', '/') + "/" + folder + "/" + file; } } folders = FileHelper.GetFolders(FileHelper.imagePath); foreach (string folder in folders) { if (folder == "demo") { continue; } string[] files = FileHelper.GetFiles(FileHelper.imagePath, folder); foreach (string file in files) { ftpfiles[FileHelper.GetFile(FileHelper.imagePath, folder, file)] = FileHelper.imagePath.Replace('\\', '/') + "/" + folder + "/" + file; } } progressBar1.Maximum = ftpfiles.Count; Text = "资料上传[" + progressBar1.Value + "/" + progressBar1.Maximum + "]"; if (ftpfiles.Count == 0) { button1.Enabled = false; } } catch (Exception ex) { label1.Text = ex.Message; button1.Enabled = false; } }
public void Add(string folder, bool focused, bool refresh) { SchoolInfo info = new SchoolInfo(); info.Click += SchoolInfo_Click; info.Location = new Point(0, Controls.Count == 0 ? 0 : Controls[Controls.Count - 1].Top + Controls[Controls.Count - 1].Height); info.Anchor |= AnchorStyles.Right; info.Width = ClientSize.Width; info.TabIndex = Controls.Count; info.TabStop = false; info.Title = folder; info.Content = string.Join(Environment.NewLine, FileHelper.ReadFile(FileHelper.htmlPath, folder, "0.html")); info.Image = FileHelper.GetFile(FileHelper.imagePath, folder, "0.jpg"); Controls.Add(info); if (focused) { focusedIndex = Controls.Count - 1; } if (refresh) { ShowRefresh(); } }
private void button4_Click(object sender, EventArgs e) { OpenFileDialog obj = new OpenFileDialog(); obj.Filter = "图片文件|*.jpg|所有文件|*.*"; if (obj.ShowDialog() == DialogResult.OK) { try { Bitmap img = new Bitmap(obj.FileName); if (img.Width != img.Height) { throw new Exception("图片格式必须为1:1,默认800*800"); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } FileHelper.CopyFile(FileHelper.imagePath, schoolMenu1.FocusedSchool.Title, "0.jpg", obj.FileName); schoolMenu1.FocusedSchool.Image = FileHelper.GetFile(FileHelper.imagePath, schoolMenu1.FocusedSchool.Title, "0.jpg"); } }
private void button4_Click(object sender, EventArgs e) { try { Process.Start(FileHelper.GetFile(FileHelper.htmlPath, Tag.ToString(), (pageIndex + 1) + ".html")); } catch (Exception ex) { MessageBox.Show(ex.Message); } }