xod

Members
  • Content Count

    563
  • Joined

  • Last visited

  • Days Won

    14

Posts posted by xod


  1. Very nice plugin! Thanks.

     

    First crash: Enter some data and click on Tuesday.

     

    Exception details:
    System.ArgumentException: Object must be of type Double.
       at System.Double.CompareTo(Object value)
       at System.Windows.Forms.DataGridViewRowCollection.RowComparer.CompareObjects(Object value1, Object value2, Int32 rowIndex1, Int32 rowIndex2)
       at System.Windows.Forms.DataGridViewRowCollection.RowArrayList.Pivot(Int32 left, Int32 center, Int32 right)
       at System.Windows.Forms.DataGridViewRowCollection.RowArrayList.CustomQuickSort(Int32 left, Int32 right)
       at System.Windows.Forms.DataGridViewRowCollection.Sort(IComparer customComparer, Boolean ascending)
       at System.Windows.Forms.DataGridView.SortInternal(IComparer comparer, DataGridViewColumn dataGridViewColumn, ListSortDirection direction)
       at System.Windows.Forms.DataGridView.OnColumnHeaderMouseClick(DataGridViewCellMouseEventArgs e)
       at System.Windows.Forms.DataGridView.OnMouseClick(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
     


  2. Another issue.

    Try to run this code:

    Spoiler
    
    // Name: test
    // Submenu:
    // Author: 
    // Title: test
    // Version: 
    // Desc:
    // Keywords:
    // URL:
    // Help:
    
    #region UICode
    PanSliderControl Amount1 = Pair.Create(1.000,1.000); // {Amount2} 
    CheckboxControl Amount2 = false; // [0,1] Enable
    #endregion
    
    void Render(Surface dst, Surface src, Rectangle rect)
    {
        
    }

    PDN crashes. It only works if parameters for Pair.Create is 0, 0 values: PairCreate(0.000, 0.000):

     


  3. Wrong alignment for braces when I try to format document because the statement is in line with 'if' keyword.

     

    Spoiler
    
    // Name: TextWarp
    // Submenu:
    // Author: xod
    // Title: TextWarp
    // Version: 1.0.0
    // Desc:
    // Keywords:
    // URL:
    // Help:
    
    #region UICode
    MultiLineTextboxControl Amount1 = "Text Warp"; // [1,32767]
    FontFamily Amount2 = new FontFamily("Arial"); // Font
    IntSliderControl Amount3 = 50; // [3,800] Font size
    PanSliderControl Amount4 = Pair.Create(-1.000,-1.000); //
    PanSliderControl Amount5 = Pair.Create(1.000,-1.000); //
    PanSliderControl Amount6 = Pair.Create(-1.000,1.000); //
    PanSliderControl Amount7 = Pair.Create(1.000,1.000); //
    IntSliderControl Amount8 = 0; // [0,360] Rotate
    CheckboxControl Amount9 = false; // [0,1] Shape
    #endregion
    
    void Render(Surface dst, Surface src, Rectangle rect)
    {
        Rectangle sel = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
        Color PrimaryColor = EnvironmentParameters.PrimaryColor;
    
        float x1 = (float)Math.Round((Amount4.First + 1) * sel.Width / 2);
        float y1 = (float)Math.Round((Amount4.Second + 1) * sel.Height / 2);
    
        float x2 = (float)Math.Round((Amount5.First + 1) * sel.Width / 2);
        float y2 = (float)Math.Round((Amount5.Second + 1) * sel.Height / 2);
    
        float x3 = (float)Math.Round((Amount6.First + 1) * sel.Width / 2);
        float y3 = (float)Math.Round((Amount6.Second + 1) * sel.Height / 2);
    
        float x4 = (float)Math.Round((Amount7.First + 1) * sel.Width / 2);
        float y4 = (float)Math.Round((Amount7.Second + 1) * sel.Height / 2);
    
        string text = Amount1;
        int font_size = Amount3;
        FontStyle font_style = FontStyle.Regular;
    
        dst.CopySurface(src, rect.Location, rect);
    
        using (RenderArgs ra = new RenderArgs(dst))
        using (Pen pen = new Pen(PrimaryColor, 1))
        using (GraphicsPath path = new GraphicsPath())
        using (SolidBrush brush = new SolidBrush(PrimaryColor))
        using (FontFamily font_family = new FontFamily(Amount2.Name))
        using (Font font = new Font(font_family, font_size, font_style))
        using (StringFormat string_format = new StringFormat())
        {
            string_format.Alignment = StringAlignment.Near;
            string_format.LineAlignment = StringAlignment.Near;
            Graphics g = ra.Graphics;
            g.Clip = new Region(rect);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
    
            // Create a rectangle.
            RectangleF srcRect = new RectangleF(0, 0, sel.Width, sel.Height);
    
            PointF p1 = new PointF(x1, y1);
            PointF p2 = new PointF(x2, y2);
            PointF p3 = new PointF(x3, y3);
            PointF p4 = new PointF(x4, y4);
    
            if(Amount9) path.AddRectangle(srcRect);
                path.AddString(text, font_family, (int)font_style, g.DpiY * font_size / 72, new PointF(0, 0), string_format);
    
            // Create a destination for the warped rectangle.
            PointF[] destPoints = {p1, p2, p3, p4};
    
            // Create a translation matrix.
            Matrix matrix = new Matrix();
            matrix.Translate(0, 0);
            if (Amount8 > 0)
            {
                // Move TopLeft corner to center of the canvas then rotate.
                matrix.Translate(sel.Width / 2, sel.Height / 2);
                matrix.Rotate(Amount8);
            }
    
            // Warp the source path.
            path.Warp(destPoints, srcRect, matrix, WarpMode.Perspective, 0.5f);
    
            // Draw the warped path to the screen.
            g.DrawPath(pen, path);
            if(!Amount9) g.FillPath(brush, path);
                }//Wrong alignment for braces when I try to format document
                 //because the statement is in line with 'if' keyword
        }

     

     


  4. Thank you for yours hard work !

     

    Very interesting behavior for Alt + Mouse click:

     

    1. Choose Paintbrush tool: size = 10 (or any other size)
    2. Press Alt key for locking the position of the brush
    3. Release Alt key and move the mouse anywhere on the canvas
    4. Left click to draw a straight line with the primary color or right click for secondary color

     

    This behavior also exists in the previous version.

    This is very useful for me. All I need now is a grid and Snap to grid option.


  5. On 3/25/2019 at 7:37 PM, toe_head2001 said:

     

    If your script is causing CodeLab to freeze, that's an issue.

    Can you share the script with us, so we can investigate?

     

    Spoiler
    
    // Name: Test
    // Author: 
    // Submenu: 
    // URL:
    // Title: 
    
    #region UICode
    ListBoxControl Amount1 = 0; // Options|Move X, Y|Diagonals
    IntSliderControl Amount2 = 20; // [0,800] {Amount1} X
    IntSliderControl Amount3 = 20; // [0,800] {Amount1} Y
    IntSliderControl Amount4 = 20; // [0,800] {!Amount1} Step
    CheckboxControl Amount5 = false; // [0,1] {Amount1} Show coordinates
    #endregion
    
    void Render(Surface dst, Surface src, Rectangle rect)
    {
        Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
        dst.CopySurface(src, rect.Location, rect);
    
        float selTop = selection.Top;
        float selBot = selection.Bottom;
        float selLeft = selection.Left;
        float selRight = selection.Right;
        int step = Amount4;
        float fontSize = selection.Right/100;
    
        using (RenderArgs ra = new RenderArgs(dst))
        {
            Graphics gr = ra.Graphics;
            gr.Clip = new Region(rect);
            gr.SmoothingMode = SmoothingMode.AntiAlias;
    
            StringFormat format = new StringFormat();
            using(Pen pen = new Pen(Color.Black,1))
            using (Font txtFont = new Font("Tahoma", fontSize, FontStyle.Regular))
            using (SolidBrush txtBrush = new SolidBrush(Color.Blue))
            {
                switch(Amount1)
                {
                    case 0: // Move Lines
                        PointF left = new PointF(selLeft - 1f, selTop + Amount2);
                        PointF rite = new PointF(selRight, selTop + Amount2);
                        PointF top = new PointF(Amount3 + selLeft, selTop - 1f);
                        PointF bot = new PointF(Amount3 + selLeft, selBot);
                        gr.DrawLine(pen, top, bot);
                        gr.DrawLine(pen, left, rite);
                        if (Amount5)
                        {
                            txtBrush.Color = Color.Blue;
                            format.Alignment = StringAlignment.Near;
                            format.LineAlignment = StringAlignment.Far;
                            gr.DrawString(Amount2.ToString(), txtFont, txtBrush, selLeft, selTop + Amount2, format);
                            txtBrush.Color = Color.Red;
                            format.Alignment = StringAlignment.Far;
                            format.LineAlignment = StringAlignment.Center;
                            gr.DrawString(Amount3.ToString(), txtFont, txtBrush, selLeft + Amount3, selTop + fontSize, format);
                        }
                        break;
                    case 1: // Diagonals
                        for (int i = 1; i < selRight; i+=step) // if step (Amount4) = 0 CodeLab freezes. Logic Amount4 must be > 0. [1,800]
                        {
                            PointF topleft = new PointF(selLeft, selTop - i + 1f);
                            PointF botrite = new PointF(selRight + i - 1f, selBot);
                            gr.DrawLine(pen, topleft, botrite);
                            PointF topleft2 = new PointF(selLeft - i + 1f, selTop);
                            PointF botrite2 = new PointF(selRight, selBot + i - 1f );
                            gr.DrawLine(pen, topleft2, botrite2);
                        }
                        break;
                }
            }
        }
    }