public static VObject FromHtml(string input) { if (string.IsNullOrEmpty(input)) return null; int posIdx1 = 0; int posIdx2 = 0; posIdx1 = input.IndexOf("<!-- ##"); if (posIdx1 == -1) return null; input = input.Substring(posIdx1); string[] para = Strings.Split(input, "##"); switch (Strings.UCase(para[1])) { case "IMG": case "VIMAGE": VImage myobj = new VImage(); myobj.Deserialize(para); posIdx1 = input.IndexOf("src=\"") + 5; posIdx2 = input.IndexOf("\"", posIdx1); if (posIdx1 < 5 | posIdx2 == -1 | posIdx2 < posIdx1) return null; dynamic img = Helper.Base64ToImage(new System.Text.StringBuilder(input.Substring(posIdx1, posIdx2 - posIdx1))); ((VImage)myobj).img = img; return myobj; case "RTF": case "VTEXTBOX": VTextbox myobj = new VTextbox(); myobj.Deserialize(para); posIdx1 = input.IndexOf(Constants.vbNewLine) + 2; posIdx2 = input.LastIndexOf("</div>"); if (posIdx1 < 2 | posIdx2 == -1 | posIdx2 < posIdx1) return null; ((VTextbox)myobj).Text = Helper.StripHtmlTags(input.Substring(posIdx1, posIdx2 - posIdx1).Replace("<br>", Constants.vbNewLine).Replace("<br/>", Constants.vbNewLine)).Replace("<", "<").Replace(">", ">"); return myobj; case "VUMLCLASS": VUMLClass myobj = new VUMLClass(); myobj.Deserialize(para); posIdx1 = input.IndexOf(Constants.vbNewLine) + 2; posIdx2 = input.LastIndexOf("</div>"); if (posIdx1 < 2 | posIdx2 == -1 | posIdx2 < posIdx1) return null; myobj.ParseHtmlContent(input.Substring(posIdx1, posIdx2 - posIdx1)); return myobj; case "VRECTANGLE": VRectangle myobj = new VRectangle(); myobj.Deserialize(para); return myobj; case "VELIPSE": VElipse myobj = new VElipse(); myobj.Deserialize(para); return myobj; case "VLINE": VLine myobj = new VLine(); myobj.Deserialize(para); return myobj; default: return null; } }
public void startEditMode(VTextbox tb) { EditTB.Bounds = new Rectangle(tb.Left - 2, tb.Top + 28, tb.Width + 4, tb.Height + 4); //EditTB.Top += 28 EditTB.Text = tb.Text; EditTB.Font = tb.Font; EditTB.Show(); EditTB.Focus(); EditObject = tb; isEditMode = true; }
public void showTextEditor(VTextbox obj) { showTextEditor(obj, true); }
public void showTextEditor(VTextbox obj, bool allowFormat) { frm_textEditor f = new frm_textEditor(); f.TextBox1.Text = obj.text; if (allowFormat) f.setTextboxObject(this, obj); if (f.ShowDialog == System.Windows.Forms.DialogResult.OK) { obj.text = f.TextBox1.Text; this.Invalidate(); } }
public void readHtmlPage(string fileSpec) { dynamic sr = System.IO.File.OpenText(fileSpec); //clear All ??? int lineNr = 0; int modusCounter = 0; string line = null; string modus = null; System.Text.StringBuilder contbuffer = null; VObject myObj = default(VObject); modus = "invalid"; while (sr.EndOfStream == false) { lineNr += 1; modusCounter += 1; line = sr.ReadLine; if (line.Contains("ScreenShot 5 Collage") | line.Contains("ScreenShot 6 Collage")) { modus = "valid"; modusCounter = 0; } if (modus == "invalid") continue; if (line.StartsWith("<!-- ##page##")) { string[] para = Strings.Split(line, "##"); PicBox.BackColor = Helper.String2Color(para[5]); PicBox.Width = para[2]; PicBox.Height = para[3]; continue; } if (modus == "txt" & line == "</div>") { modus = "valid"; modusCounter = 0; if (myObj is VTextbox) { ((VTextbox)myObj).Text = Strings.Trim(contbuffer.ToString()).Replace("<br>", Constants.vbCrLf).Replace("<br/>", Constants.vbCrLf); } else if (myObj is VUMLClass) { ((VUMLClass)myObj).ParseHtmlContent(Strings.Trim(contbuffer.ToString())); } addObject(myObj); } if (modus == "txt" & modusCounter >= 1) { contbuffer.AppendLine(line); } if (modus == "img" & modusCounter >= 1) { if (modusCounter == 1) line = line.Substring(5); //src=" if (line.EndsWith("\" />")) { modus = "valid"; modusCounter = 0; line = line.Substring(0, line.Length - 4); } contbuffer.AppendLine(line); //Bild fertig if (modus == "valid") { dynamic img = Helper.Base64ToImage(contbuffer); ((VImage)myObj).img = img; addObject(myObj); } } if (line.StartsWith("<!-- ##img##") | line.StartsWith("<!-- ##VImage##")) { modus = "img"; modusCounter = 0; string[] para = Strings.Split(line, "##"); myObj = new VImage(); myObj.Deserialize(para); contbuffer = new System.Text.StringBuilder(); } if (line.StartsWith("<!-- ##rtf##") | line.StartsWith("<!-- ##VTextbox##")) { modus = "txt"; modusCounter = 0; string[] para = Strings.Split(line, "##"); myObj = new VTextbox(); myObj.Deserialize(para); contbuffer = new System.Text.StringBuilder(); } if (line.StartsWith("<!-- ##VUMLClass##")) { modus = "txt"; modusCounter = 0; string[] para = Strings.Split(line, "##"); myObj = new VUMLClass(); myObj.Deserialize(para); contbuffer = new System.Text.StringBuilder(); } if (line.StartsWith("<!-- ##VElipse##")) { modus = "valid"; modusCounter = 0; string[] para = Strings.Split(line, "##"); myObj = new VElipse(); myObj.Deserialize(para); addObject(myObj); } if (line.StartsWith("<!-- ##VLine##")) { modus = "valid"; modusCounter = 0; string[] para = Strings.Split(line, "##"); myObj = new VLine(); myObj.Deserialize(para); addObject(myObj); } if (line.StartsWith("<!-- ##VRectangle##")) { modus = "valid"; modusCounter = 0; string[] para = Strings.Split(line, "##"); myObj = new VRectangle(); myObj.Deserialize(para); addObject(myObj); } } if (modus == "invalid") { Interaction.MsgBox("Ungültiges Dateiformat.", MsgBoxStyle.Critical); } sr.Close(); }