Пример #1
0
 private void ColorPicker1_SetColor(Color c)
 {
     inkControl1.Brush = PBrush.CreateSolid(c);
     if (inkControl1.Page.GetSelectedLines().Count() > 0)
     {
         inkControl1.Page.SetSelectionBrush(inkControl1.Brush);
         inkControl1.RefreshPage();
     }
 }
Пример #2
0
 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);
 }
Пример #3
0
        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());
        }
Пример #4
0
        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();
        }
Пример #5
0
        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);
                        }
                    }
                }
            }
        }
Пример #6
0
 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;
                     }
                 }
             }
         }
     }
 }