Search code examples
c#visual-studio-2010visual-studiovisual-studio-2013zebra-printers

How to perform function in .exe file using a C# application


I have a C# application in which it does some basic printing options to Zebraprinets. In my application i am opening the .net paint using the C# application. By using .net paint i need to convert the a .jpeg file to pcx format. I am using it now manually.. So my real question is, can i perform all these actions from my C# application. i want my application to perform the functions of .net paints

For example. after opening the .net paint. I want to import the file using Open + O..Select file from folder @c:\users\user\sample.jpeg then in .net paint perform the functions (ctrl + Shift + L) then (ctrl + Shift + G). After all these save ctrl + Shift + S in location C:\out\.

Can i do this. Please let me know.

code snippet:-

private void button2_Click(object sender, EventArgs e)
    {
        OpenFileDialog ofd = new OpenFileDialog();
        string filename = "";

        if (ofd.ShowDialog() == DialogResult.OK)
        {
            filename = System.IO.Path.GetFullPath(ofd.FileName);
        }
       // MessageBox.Show(filename, "file");
        pictureBox1.ImageLocation = filename;
        pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;

        DialogResult result = MessageBox.Show("Do you wish to continue?", "Save Changes", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        if (result == DialogResult.Yes)
        {
            System.Diagnostics.Process.Start(@"C:\Program Files\Paint.NET\PaintDotNet.exe");
           // here i need to perform the function like
           //Open + O`
           //ctrl + Shift + L)` then `
           //(ctrl + Shift + G)`. then save 
           //`ctrl + Shift + S`
        }
        else
        {
            return;
        }
    }

Solution

  • You can just reference the Paint.NET assemblies directly and use a surprising amount of its functionality that way. I don't know about the API you are referring to specifically but I have used it in the past to generate sprites from .pdn files in a compile pipeline.

    Try adding a reference to these assemblies: C:\Program Files\Paint.NET\PaintDotNet.*.dll Then poke around the classes in those namespaces.