Jump to content

roro69

Members
  • Posts

    29
  • Joined

  • Last visited

Posts posted by roro69

  1.  

    Hello Thank you for your answers ;

    Rick:

    Yes I am sorry, I have deviated a little from the development Paint Net; my original question was about it; I wanted to know if we could program directly in paint net a script to create a new document because the dialog box of the software is not appropriate for my use.

    BoltBait: in fact it's true it's useless.Thanks

    In any case thank you for your help and your time.

  2. Good evening thank you for your solution
     I tried and the software tells me file not found.
    Here is the error log
    Quote
    
    System.IO.FileNotFoundException: Le fichier 'C:\Users\Roro\AppData\Local\Temp\tmp7E8A.tmpmyImage.png' est introuvable.
    Nom de fichier : 'C:\Users\Roro\AppData\Local\Temp\tmp7E8A.tmpmyImage.png'
       à System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       à System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
       à System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
       à PaintDotNet.Controls.DocumentWorkspace.LoadDocument(Control owner, String fileName, FileType& fileTypeResult, ProgressEventHandler progressCallback) dans D:\src\pdn\src\PaintDotNet\Controls\DocumentWorkspace.cs:ligne 3220
    
    Thank you for your help and time
  3. Good evening
    I tried with the code below but I do not understand the software tells me type
    unrecognized image
     Dim painte As String = "C:\Program Files\paint.net\PaintDotNet.exe"
            Dim s As String = System.IO.Path.GetTempFileName()
            Dim monimage As Bitmap = New Bitmap(200, 200)
    
            monimage.Save(s, Imaging.ImageFormat.Png)
    
            Dim p As Process = Process.Start(painte, s)
            'maybe here's a better way to wait
            While p.MainWindowHandle = IntPtr.Zero
                    System.Threading.Thread.Sleep(100)
                End While
    
                System.IO.File.Delete(s)

    Merci de votre aide

  4. Hello,
    I would like to know if it is possible from a plugin to create a new document.
    
    That's my problem: I create new documents but I have to calculate their area as follows:
     The height of the surface I desire is height 10 times
     The width of the surface I want is width / 2
    
     Example: My input data 624 * 22
    What will give when I create new document
     Width 312 pixels
     Height 220 pixels
    
    So what I wanted was to get my entry information; then create a new document with the good
    dimensions
    
    Thank you for your response, and thank you for your time
  5. Hello and thank you very much for all your kind message
    I will definitely update it, if some can help me code, or ideas on a cleaner graphic interface or other ideas
    I will be very happy
    I thank you in advance for the help provided
    
    Translation google sorry :)))
    • Upvote 1
  6. Good evening; Here is a plugin that I use to create logos; I share it if you want to try it. On the other hand it is in French, if really you find it interesting I will try to translate it.

    For the plugin you can add as much annotation as you want to your image, then to apply an effect to your text you have to be careful that it is selecting ::

    The plugin is in Effect ----> CreaText ------> CreaLogo
    There it is, thanks

    Rogers.dll

    • Upvote 5
  7. Hello ,
    Is it possible in the Drop down list fontname  of CodeLab .; can draw like the paint net dropdown list fontname
    I would like in the plugin that I have tried to make the Drop down list like this
     
    If it is not possible ; I will do my plugin in visual studio but I find it a bit complicated create plugin with Visual studio
    I started my visual studio code like this:
    private void MonEffetConfigDialog_Load(object sender, EventArgs e)
    		{
    			
    			this.MaCombo1.DrawMode = DrawMode.OwnerDrawFixed;
    			this.MaCombo1.ItemHeight = 18;
    			this.MaCombo1.DrawItem += new DrawItemEventHandler(this.MaCombo2_DrawItem);
    			InstalledFontCollection MesPolicesInstalle = new InstalledFontCollection();
    			FontFamily[] FontFamille = MesPolicesInstalle.Families;
    			FontFamily[] MonTableau = FontFamille;
    			for (int i = 0; i < MonTableau.Length; i++)
    			{
    				FontFamily FontFamille1 = MonTableau[i];
    				if (FontFamille1.IsStyleAvailable(FontStyle.Regular))
    				{
    					this.Macombo1.Items.Add(FontFamille1.Name);
    				}
    			}
    		}
    
    		private void MaCombo2_DrawItem(object sender, DrawItemEventArgs e)
    		{
    			e.DrawBackground();
    			ComboBox Macombo = (ComboBox)sender;
    			string texte = (e.Index > -1) ? Macombo.Items[e.Index].ToString() : Macombo.Text;
    			Font Police = new Font(texte, Macombo.Font.Size);
    			Brush Pinceau = new SolidBrush(e.ForeColor);
    			float fl = ((float)e.Bounds.Height - e.Graphics.MeasureString(texte, Police).Height) / 2f;
    			e.Graphics.DrawString(text, font, brush, (float)e.Bounds.X, (float)e.Bounds.Y +fl);
    			Police.Dispose();
    			Pinceau.Dispose();
    			e.DrawFocusRectangle();
    }
    

    But I preferred to make my plugin with codelab.

     
    Thank you very much for your answers and assistance
     
     
     
  8. Hello
    Yes I create a text effect plugins; and I wanted in my plugin manage the spacing of the letters; here is the code already implemented:
    code for transform text and drawtext
        // Write and transformation text
        g.ScaleTransform(Amount7, Amount8, System.Drawing.Drawing2D.MatrixOrder.Append);
        g.TranslateTransform(cx, cy,System.Drawing.Drawing2D.MatrixOrder.Append);
        StringFormat string_format = new StringFormat();
        string_format.Alignment = StringAlignment.Center;
        string_format.LineAlignment = StringAlignment.Center;
        g.DrawString(Amount1, SelectedFont, Brush1, 0, 0, string_format);
    

    Thank you for their time and assistance provided

    :
  9. Good evening
    Thank you for your help my code works fine; the problem was the icon file.
    If anyone here interested here is the code to write to a file excel to count pixel (This is not an effect plugin) .....
    using System;
    using System.Text;
    using System.Windows;
    using System.Reflection;
    using System.Windows.Forms;
    using PaintDotNet;
    using PaintDotNet.Effects;
    using PaintDotNet.IndirectUI;
    using PaintDotNet.PropertySystem;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Drawing.Text;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using IntSliderControl = System.Int32;
    using TextboxControl = System.String;
    using  Microsoft.Office.Interop;
    
    namespace PatronLivre
    {
        public class PluginSupportInfo : IPluginSupportInfo
        {
            public string Author
            {
                get
                {
                    return ((AssemblyCopyrightAttribute)base.GetType().Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0]).Copyright;
                }
            }
            public string Copyright
            {
                get
                {
                    return ((AssemblyDescriptionAttribute)base.GetType().Assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0]).Description;
                }
            }
    
            public string DisplayName
            {
                get
                {
                    return ((AssemblyProductAttribute)base.GetType().Assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0]).Product;
                }
            }
    
            public Version Version
            {
                get
                {
                    return base.GetType().Assembly.GetName().Version;
                }
            }
    
            public Uri WebsiteUri
            {
                get
                {
                    return new Uri("http://www.getpaint.net/redirect/plugins.html");
                }
            }
        }
    
    
        [PluginSupportInfo(typeof(PluginSupportInfo), DisplayName = "CalcPat+")]
        [EffectCategory(EffectCategory.Effect)]
        public class MonEffetEffectPlugin : PropertyBasedEffect
        {
            public static string StaticName
            {
                get
                {
                    return "CalculPatron";
                }
            }
    
            public static Bitmap StaticIcon { get { return PatronLivreEffect.Properties.Resources.EffectPluginIcon; } }
            public static string SubmenuName
            {
                get
                {
                    return SubmenuNames.Render;  // Programmer's chosen default
                }
            }
            public MonEffetEffectPlugin()
                : base(StaticName, StaticIcon, SubmenuName, EffectFlags.Configurable)
            {
                instanceSeed = unchecked((int)DateTime.Now.Ticks);
            }
            public enum PropertyNames
            {
                Amount1,
                Amount2,
                Amount3
            }
    
            [ThreadStatic]
            private static Random RandomNumber;
    
            private int randomSeed;
            private int instanceSeed;
    
    
            protected override PropertyCollection OnCreatePropertyCollection()
            {
                List<Property> props = new List<Property>();
    
                props.Add(new Int32Property(PropertyNames.Amount1, 0, 0, 1000));
                props.Add(new StringProperty(PropertyNames.Amount2, "", 255));
                props.Add(new Int32Property(PropertyNames.Amount3, 0, 0, 255));
    
                return new PropertyCollection(props);
            }
    
            protected override ControlInfo OnCreateConfigUI(PropertyCollection props)
            {
                ControlInfo configUI = CreateDefaultConfigUI(props);
    
                configUI.SetPropertyControlValue(PropertyNames.Amount1, ControlInfoPropertyNames.DisplayName, "Nombre Page Livre");
                configUI.SetPropertyControlValue(PropertyNames.Amount2, ControlInfoPropertyNames.DisplayName, "Nom du Patron");
                configUI.SetPropertyControlValue(PropertyNames.Amount3, ControlInfoPropertyNames.DisplayName, string.Empty);
                configUI.SetPropertyControlType(PropertyNames.Amount3, PropertyControlType.IncrementButton);
                configUI.SetPropertyControlValue(PropertyNames.Amount3, ControlInfoPropertyNames.ButtonText, "Sauve Patron");
    
                return configUI;
            }
    
            protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
            {
                Amount1 = newToken.GetProperty<Int32Property>(PropertyNames.Amount1).Value;
                Amount2 = newToken.GetProperty<StringProperty>(PropertyNames.Amount2).Value;
                Amount3 = (byte)newToken.GetProperty<Int32Property>(PropertyNames.Amount3).Value;
                randomSeed = Amount3;
    
                base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
            }
    
            protected override void OnCustomizeConfigUIWindowProperties(PropertyCollection props)
            {
                // Change the effect's window title
                props[ControlInfoPropertyNames.WindowTitle].Value = "CalculPatron";
                base.OnCustomizeConfigUIWindowProperties(props);
            }
    
            protected override unsafe void OnRender(Rectangle[] rois, int startIndex, int length)
            {
                if (length == 0) return;
                RandomNumber = GetRandomNumberGenerator(rois, startIndex);
                for (int i = startIndex; i < startIndex + length; ++i)
                {
                    Render(DstArgs.Surface, SrcArgs.Surface, rois[i]);
                }
            }
    
            private Random GetRandomNumberGenerator(Rectangle[] rois, int startIndex)
            {
                Rectangle roi = rois[startIndex];
                return new Random(instanceSeed ^ (randomSeed << 16) ^ (roi.X << 8) ^ roi.Y);
            }
    
            #region User Entered Code
            // Name:
            // Submenu:
            // Author:
            // Title:
            // Version:
            // Desc:
            // Keywords:
            // URL:
            // Help:
            #region UICode
            IntSliderControl Amount1 = 0; // [0,1000] Nombre Page Livre
            TextboxControl Amount2 = ""; // [0,255] Nom du Patron
            byte Amount3 = 0; // [255] Sauve Patron
    
    
    
            #endregion
            byte LastButton = 0;
            String cboard;
            public struct Folds
            {
                public double a, b, c, d;
    
                public Folds(double p1, double p2, double p3, double p4)
                {
                    a = p1;
                    b = p2;
                    c = p3;
                    d = p4;
                }
            }
    
            public void SaveImages()
            {
               
                System.Windows.Forms.SaveFileDialog SaveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
                string fp = Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                SaveFileDialog1.InitialDirectory = fp;
                SaveFileDialog1.Filter = "Text file (*.txt)|*.txt";
                SaveFileDialog1.FilterIndex = 1;
                SaveFileDialog1.RestoreDirectory = false;
    
                if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
                {
    
                    cboard = SaveFileDialog1.FileName;
    
                }
                else
                {
                    cboard = String.Empty;
                }
    
            }
    
    
    
            // Here is the main render loop function
            void Render(Surface dst, Surface src, Rectangle rect)
            {
                if (!IsCancelRequested)
                {
    
                    Rectangle sel = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
                    dst.CopySurface(src, sel.Location, sel);
                    //========================= 
                    SignalCancelRequest();
                    if (LastButton != Amount3)
                    {
                        LastButton = Amount3;
                        System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(SaveImages));
                        t.SetApartmentState(System.Threading.ApartmentState.STA);
                        t.Start();
                        t.Join();
                        Application.DoEvents();
                        if (cboard != String.Empty)
                        {
                            //try {
                            Folds[] folds = new Folds[0];
    
                            System.IO.StreamWriter pc = new System.IO.StreamWriter(cboard, false);
                            pc.WriteLine("Nom du patron:" + Amount2);
                            pc.WriteLine("----------------------------------------------");
                            pc.Close();
                            GC.Collect();
                            Microsoft.Office.Interop.Excel.Application oXL;
                            Microsoft.Office.Interop.Excel._Workbook oWB;
                            Microsoft.Office.Interop.Excel._Worksheet oSheet;
                            
                            object misvalue = System.Reflection.Missing.Value;
                            //Demarre excel
                            oXL = new Microsoft.Office.Interop.Excel.Application();
                            oXL.Visible = false;
                            //Nouveau classeur
                            oWB = (Microsoft.Office.Interop.Excel._Workbook)(oXL.Workbooks.Add(Missing.Value));
                            oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet;
                            //Ajouter les entete de cellule
    
                            oSheet.Cells[1, 1] = "Nom Patron";
                            oSheet.Cells[1, 2] = Amount2;
                            oSheet.Cells[2, 1] = "Page";
                            oSheet.Cells[2, 2] = "Haut";
                            oSheet.Cells[2, 3] = "Bas";
                            
    
    
                            
                            for (int i = sel.Left; i < sel.Right; i++)
                            {
                                double toppix = 0;
                                double pixlength = 0;
    
                                for (int y = sel.Top; y < sel.Bottom; y++)
                                {
                                    ColorBgra CP = src.GetBilinearSample(i, y);
                                    int total = CP.R + CP.G + CP.B;
                                    if (toppix == 0)
                                    {
                                        if (total < 765)
                                        {
                                            toppix = y;
                                            pixlength = 1;
                                        }
                                    }
                                    else
                                    {
                                        if (total < 765)
                                        {
                                            pixlength++;
                                        }
                                        else
                                        {
    
    
                                            Array.Resize(ref folds, folds.Length + 1);
                                            folds[folds.Length - 1] = new Folds(i, (toppix - 1) / 10, (pixlength + toppix) / 10, 0);
    
    
                                            toppix = 0;
                                            pixlength = 0;
    
    
                                        }
                                    }
                                }
                            }
                            int x = 0;
    
                            for (int i = 1; i <= folds.Length - 1; i++)
                            {
                                if (folds[i].a == folds[i - 1].a)
                                {
                                    folds[x].d = folds[x].d + 1;
                                }
                                else
                                {
                                    x = i;
                                    folds[x].d = folds[x].d + 1;
    
    
                                }
                            }
                            int p = (Amount1 - (folds.Length * 2)) / 2;
                            int ligne = 2;
                            for (int i = 1; i <= folds.Length - 1; i++)
                            {
                                if (folds[i].d == 0)
                                {
                                    folds[i].d = folds[i - 1].d;
    
                                }
    
                                if ((folds[i].a + folds[i].d + i) % folds[i].d == 0)
                                {
                                    p = p + 2;
                                    ligne = ligne + 1;
    
                                    System.IO.StreamWriter pc2 = new System.IO.StreamWriter(cboard, true);
                                    pc2.WriteLine("Pages : " + p + "| " + "Haut: " + folds[i].b + "  cm" + " | " + "Bas: " + folds[i].c + " cm");
                                    pc2.WriteLine("----------------------------------------------");
                                    pc2.Close();
                                    oSheet.Cells[ligne, 1] = p;
                                    oSheet.Cells[ligne, 2] = folds[i].b;
                                    oSheet.Cells[ligne, 3] = folds[i].c;
                                }
    
                            }
    
                              oSheet.UsedRange.HorizontalAlignment =
                               Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;
                            oXL.UserControl = false;
                            oWB.SaveAs(Amount2, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing,
                        false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
                        Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    
                            oWB.Close();
                            oXL.Quit();
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(oXL);
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(oWB);
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(oSheet);
                            oSheet = null;
                            oWB = null;
                            oXL = null;
                            GC.Collect();
                        }
    
                        //}catch(Exception e){}
                    }//cboard
    
                }//last button
    
            }
    
    
            #endregion
        }
    }
    

    Thank you for your help and time spent

  10. Hello

    Sorry for the delay in replying; it was super helpful to have me answer ainsi.Je went t through visual studio to create my plugin, I debug (like here : http://forums.getpaint.net/index.php?/topic/4209-how-to-debug-your-plugin/)and built my dll; but it does not load in net paint .:

    Should I change the framework? (I work with the framework 4.5)

    Thank you for your answers and time spent.

    Sorry for my English ; I am French and I have a little trouble with English

×
×
  • Create New...