Exemple #1
0
        public static string SaveTemplate(string outputPath)

        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            myDesign.Save(outputPath, FileTypes.ftAuto);
            stopWatch.Stop();
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                 ts.Hours, ts.Minutes, ts.Seconds,
                                                 ts.Milliseconds / 10);

            return(elapsedTime);
        }
        static void Main(string[] args)
        {
            IApplication PulseID = new Pulse.Application();

            try
            {
                IEmbDesign myDesign = PulseID.OpenDesign("C:\\Temp\\Eagle2.pxf", FileTypes.ftAuto, OpenTypes.otDefault, "Tajima");
                try
                {
                    IBitmapImage myImage = PulseID.NewImage(300, 300);
                    try
                    {
                        myDesign.Render(myImage, 0, 0, 300, 300);
                        myImage.Save("C:\\Temp\\myImage.png", ImageTypes.itAuto);

                        PrintThreadChartNames(PulseID.ThreadCharts);

                        INeedleSequence designNeedleSequence = myDesign.NeedleSequence;
                        try
                        {
                            IThreadPalette designThreadPalette = myDesign.ThreadPalette;
                            // Get the thread palette information for the design.
                            try
                            {
                                // find the needle that is used for each color in the design.  Needle sequence is zero based 0=needle 1
                                for (int i = 0; i < designNeedleSequence.Count; i++)
                                {
                                    int             needle     = designNeedleSequence[i];
                                    IThreadProperty threadInfo = designThreadPalette[needle];

                                    Console.WriteLine("Manufacturer= {0} Name= {1} Code= {2} R= {3} G= {4} B= {5}", threadInfo.Manufacturer, threadInfo.Name, threadInfo.Code, threadInfo.Red, threadInfo.Green, threadInfo.Blue);
                                }
                                UpdateThreadColor(PulseID.ThreadCharts, myDesign, 0, "Madeira Classic Rayon 40", "1002");
                                UpdateThreadColor(PulseID.ThreadCharts, myDesign, 1, "Madeira Classic Rayon 40", "1000");


                                Console.WriteLine();
                                Console.WriteLine("New Thread Sequence");
                                Console.WriteLine("------------------------------" +
                                                  "");

                                // Get the thread palette information for the design.

                                // find the needle that is used for each color in the design.  Needle sequence is zero based 0=needle 1
                                for (int i = 0; i < designNeedleSequence.Count; i++)
                                {
                                    int             needle     = designNeedleSequence[i];
                                    IThreadProperty threadInfo = designThreadPalette[needle];

                                    Console.WriteLine("Manufacturer= {0} Name= {1} Code= {2} R= {3} G= {4} B= {5}", threadInfo.Manufacturer, threadInfo.Name, threadInfo.Code, threadInfo.Red, threadInfo.Green, threadInfo.Blue);
                                }

                                Console.WriteLine("Done");

                                ;

                                Console.ReadLine();

                                myDesign.Render(myImage, 0, 0, 300, 300);
                                myImage.Save("C:\\Temp\\myNewImage.png", ImageTypes.itAuto);
                                myDesign.Save("C:\\Temp\\NewDesign.pxf", FileTypes.ftAuto);
                            }
                            finally
                            {
                                Marshal.ReleaseComObject(designThreadPalette);
                            }
                        }
                        finally
                        {
                            Marshal.ReleaseComObject(designNeedleSequence);
                        }
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(myImage);
                    }
                }
                finally
                {
                    Marshal.ReleaseComObject(myDesign);
                }
            }
            finally
            {
                Marshal.ReleaseComObject(PulseID);
            }
        }