예제 #1
0
        static void Main()
        {
            string[] args            = Environment.GetCommandLineArgs();
            Boolean  interactiveMode = true;

            switch (args.Length)
            {
            case 2:
                args[1] = Path.GetExtension(args[1]).ToLower().EndsWith(".lxf") ? args[1] : "";
                break;

            case 3:
                interactiveMode = false;
                break;

            default:
                args = new string[] { Application.ExecutablePath, "", "" };
                break;
            }
            if (interactiveMode)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new LDDPartsListForm(args));
            }
            else
            {
                try
                {
                    string commandLineModelArg  = Path.GetExtension(args[1]).ToLower().EndsWith(".lxf") ? args[1] : args[2];
                    string commandLineSchemeArg = Path.GetExtension(args[1]).ToLower().EndsWith(".xsl") ? args[1] : args[2];

                    string saveName   = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "partslist");
                    string outputType = Path.GetFileNameWithoutExtension(commandLineSchemeArg);
                    outputType = outputType.Split(new char[] { '2' })[1];

                    Unzip  z     = new Unzip(commandLineModelArg);
                    String lxfml = z.GetLXFML();

                    PartsReader pr = new PartsReader(lxfml);
                    SortedDictionary <int, Brick> partslist = pr.Extract();

                    XMLCreator xc = new XMLCreator(partslist);

                    new XSLTransformer(outputType).Save(xc.GetXML(), saveName);
                }
                catch (Exception ex) { MessageBox.Show(ex.ToString(), Application.ProductName); }
            }
        }
예제 #2
0
        /// <summary>
        /// If "Go!" is pressed, start processing the input to the output.
        /// </summary>
        /// <param name="sender">The invoker object.</param>
        /// <param name="e">Event parameters.</param>
        private void gobutton_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            XmlDocument partsxml = new XmlDocument();

            progress(0, "");
            try
            {
                progress(10, "Started...");

                Unzip  z     = new Unzip(lxfName.Text);
                String lxfml = z.GetLXFML();

                progress(10, "LXFML unzipped. ");

                PartsReader pr = new PartsReader(lxfml);

                progress(20, "LXFML loaded. ");

                SortedDictionary <int, Brick> partslist = pr.Extract();

                progress(20, "LXFML extracted. ");

                XMLCreator xc = new XMLCreator(partslist);
                partsxml = xc.GetXML();

                progress(20, "XML generated. ");

                z = null;
                if (!FileTypes.Save(partsxml, saveName.Text, outputType.SelectedIndex))
                {
                    progress(20, "Can't save the output. Sorry. Maybe I can't write there? ");
                }
                else
                {
                    progress(20, "Output formatted and saved. Done. ");
                }
            }
            catch (Exception ex)
            {
                progressText.Text += ex.Message;
            }
            Cursor.Current = Cursors.Arrow;
        }