private void ColorPicker1_SetColor(Color c) { inkControl1.Brush = PBrush.CreateSolid(c); if (inkControl1.Page.GetSelectedLines().Count() > 0) { inkControl1.Page.SetSelectionBrush(inkControl1.Brush); inkControl1.RefreshPage(); } }
public virtual void Render(Renderer.BaseRenderer g, float quality = 1, int start = 0, bool simple = false) { if (g.RenderSpecial && Selected) { renderFull(g, PBrush.CreateSolid(Color.Black), 4, quality, start, simple); renderFull(g, PBrush.CreateSolid(Color.White), 2, quality, start, simple); } renderFull(g, Brush, 0, quality, start, simple); }
public static Line[] PasteLines(int pageHash = 0) { string text = PasteString(); string[] lines = text.Split('\n', '\r'); string header = lines[0].Trim(); if (lines.Length < 2 || !header.StartsWith(LineID)) { return(new Line[0]); } string hashStr = lines[0].Substring(LineID.Length); bool shiftLines = false; if (pageHash != 0 && pageHash.ToString("X") == hashStr) { shiftLines = true; } List <Line> ret = new List <Line>(); for (int i = 1; i < lines.Length; i++) { try { string[] parts = lines[i].Split(new string[] { ";" }, 3, StringSplitOptions.RemoveEmptyEntries); string typeName = parts[1]; Type t = Assembly.GetCallingAssembly().GetType(typeName); if (t != null) { Line line = t.GetConstructor(new Type[0]).Invoke(new object[0]) as Line; if (line != null) { line.FromParamString(parts[2]); if (shiftLines) { line.Transform(Matrix3x3.Translation(16, 16)); } line.CalcSpline(); line.CalculateBounds(); } line.Brush = PBrush.CreateSolid(ColorTranslator.FromHtml(parts[0])); line.Selected = true; ret.Add(line); } } catch (Exception) { } } return(ret.ToArray()); }
public void SetSelectionBrush(PBrush brush) { lock (this) { for (int i = 0; i < lines.Count; i++) { if (lines[i].Selected) { lines[i].Brush = brush; } } HistoryManager.StoreState(this); Version++; } }
private void button1_Click(object sender, EventArgs e) { switch (tabControl1.TabIndex) { case 0: if (lvNamedColor.FocusedItem.Tag is Color) { Brush = PBrush.CreateSolid((Color)lvNamedColor.FocusedItem.Tag); } break; } this.DialogResult = DialogResult.OK; this.Close(); }
void renderFull(Renderer.BaseRenderer g, PBrush brush, float border, float quality, int start, bool simple) { if (Points.Count == 1) { g.BeginCircles(brush); LPoint pt = Points[0]; renderPoint(g, pt, border); g.EndCircle(); } else if (Points.Count > 1 && !simple) { g.BeginCircles(brush); renderPoint(g, Points[0], border); if (start < 1) { start = 1; } for (int i = start; i < Points.Count; i++) { if (Points[i] == null) { continue; } renderPoint(g, Points[i], border); renderSegment(g, Points[i - 1], Points[i], quality, border); PointF p1 = new PointF(Points[i].X - Points[i].dX * 16, Points[i].Y - Points[i].dY * 16); PointF p2 = new PointF(Points[i].X + Points[i].dX * 16, Points[i].Y + Points[i].dY * 16); //g.DrawLine(Color.Lime, 1, p1, p2, false, true); } RenderPos = Points.Count - 1; g.EndCircle(); } else if (Points.Count > 1) { for (int i = start + 1; i < Points.Count; i++) { g.DrawLine(Color.Black, 1, Points[i - 1].ToPointF(), Points[i].ToPointF()); } } }
public void Draw(Renderer.BaseRenderer r) { lock (this) { SizeF pSize = Format.GetPixelSize(); if (Background != null) { Background.Draw(r, Format, Border, Util.ApplyFilter(BackgroundColor1, this.Filter), Util.ApplyFilter(BackgroundColor2, this.Filter)); } if (ShowDate) { r.DrawText(CreationTime.ToLongDateString() + " " + CreationTime.ToShortTimeString(), PBrush.CreateSolid(Util.ApplyFilter(BackgroundColor1, this.Filter)), new RectangleF(Border + 1, Border - 5, 300, 50), 2); } for (int i = 0; i < lines.Count; i++) { if (lines[i] is Forms.TransformableForm) { ((Forms.TransformableForm)lines[i]).RenderTransformed(r); } else if (!(lines[i] is Forms.IBackground)) { lines[i].Render(r); if (Configuration.ShowLineBoundingBoxes) { r.DrawRect(Color.Green, 1, lines[i].Bounds); } } } } }
public void LoadFromString(string txt, MessageLog log) { lock (this) { StringReader input = new StringReader(txt); Line line = null; lines.Clear(); using (XmlReader xml = XmlReader.Create(input)) { while (xml.Read()) { if (xml.NodeType == XmlNodeType.Element) { if (xml.Name == "Line") { string typeN = xml.GetAttribute("type"); string param = xml.GetAttribute("params"); string color = null; try { color = xml.GetAttribute("color"); } catch (Exception) { } Type t = Assembly.GetCallingAssembly().GetType(typeN); line = t.GetConstructor(new Type[0]).Invoke(new object[0]) as Line; if (line != null) { if (line is Forms.TransformableForm) { try { var strMat = xml.GetAttribute("matrix"); ((Forms.TransformableForm)line).Transformation = Matrix3x3.LoadFromString(strMat); } catch (Exception) { } } line.FromParamString(param); line.CalcSpline(); line.CalculateBounds(); } if (color == null) { line.Brush = PBrush.CreateSolid(Color.Black); } else { line.Brush = PBrush.CreateSolid(ColorTranslator.FromHtml(color)); } lines.Add(line); } else if (xml.Name == "Brush") { PBrush brush = PBrush.FromStrings( xml.GetAttribute("type"), xml.GetAttribute("color"), xml.GetAttribute("nums")); if (line != null) { line.Brush = brush; } } else if (xml.Name == "Format") { float w = 1; float h = 1; float border = 15; Util.TrySToF(xml.GetAttribute("w"), out w); Util.TrySToF(xml.GetAttribute("h"), out h); Util.TrySToF(xml.GetAttribute("border"), out border); Border = border; Format = new PageFormat(w, h); string backgroundName = xml.GetAttribute("background"); Type backgroundType = Type.GetType(backgroundName); Backgrounds.Background bgr; if (backgroundType == null) { bgr = null; if (backgroundName != "null") { log?.Add(MessageType.WARN, "Background '{0}'", backgroundName); } } else { bgr = (Backgrounds.Background)backgroundType .GetConstructor(new Type[0]) .Invoke(new object[0]); } Background = bgr; } else if (xml.Name == "CreationTime") { bool show = xml.GetAttribute("show") == "true"; long time = 0; long.TryParse(xml.GetAttribute("date"), out time); ShowDate = show; CreationTime = DateTime.FromFileTime(time); } else if (xml.Name == "Name") { Name = xml.GetAttribute("value"); } else if (xml.Name == "Filter") { string filterName = xml.ReadElementContentAsString(); if (Enum.TryParse <ColorFilter>(filterName, out ColorFilter filter)) { Filter = filter; } else { log?.Add(0, MessageType.WARN, "Cant parse the ColorFilter '{0}'", filterName); } } } else if (xml.NodeType == XmlNodeType.EndElement) { if (xml.Name == "Line") { line = null; } } } } } }