/// <summary>
        /// Place the module at the given positions and return the resulting partial bitstream
        /// </summary>
        /// <param name="libraryElementname"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        private void PlaceModuleAndAddBatchFileEntry(Tile anchor, string batchFile)
        {
            string xdlFile = GetFileName(anchor.LocationX, anchor.LocationY, "xdl");
            string ncdFile = GetFileName(anchor.LocationX, anchor.LocationY, "ncd");
            string bitFile = GetFileName(anchor.LocationX, anchor.LocationY, "bit");

            string libraryElement = Path.GetFileNameWithoutExtension(Module);

            // read in module
            if (!Objects.Library.Instance.Contains(libraryElement))
            {
                AddBinaryLibraryElement addCmd = new AddBinaryLibraryElement();
                addCmd.FileName = Module;
                CommandExecuter.Instance.Execute(addCmd);
            }

            // place module
            PlaceModule placeCmd = new PlaceModule();

            placeCmd.AnchorLocation       = anchor.Location;
            placeCmd.AutoClearModuleSlot  = true;
            placeCmd.InstanceName         = "inst_" + libraryElement;
            placeCmd.LibraryElementName   = libraryElement;
            placeCmd.NetlistContainerName = NetlistContainerName;
            placeCmd.Mute = Mute;
            CommandExecuter.Instance.Execute(placeCmd);

            // save as netlist
            SaveAsBlocker saveCmd = new SaveAsBlocker();

            saveCmd.FileName = xdlFile;
            saveCmd.NetlistContainerNames.Add(NetlistContainerName);
            CommandExecuter.Instance.Execute(saveCmd);

            TextWriter tw = new StreamWriter(batchFile, true);

            tw.WriteLine("xdl -xdl2ncd " + xdlFile + " " + ncdFile + " -nodrc");
            tw.WriteLine("bitgen " + ncdFile + " -d -w -g ActiveReconfig:Yes -g CRC:Disable -g binary:Yes -r " + EmptyBitfile);
            tw.Close();

            /*
             * // do it
             * Process xdl2ncd = new Process();
             * xdl2ncd.StartInfo.FileName = "xdl";
             * xdl2ncd.StartInfo.Arguments = "-xdl2ncd " + xdlFile + " " + ncdFile + " -nodrc";
             * xdl2ncd.Start();
             * xdl2ncd.WaitForExit();
             *
             * Process bitgen = new Process();
             * bitgen.StartInfo.FileName = "bitgen";
             * bitgen.StartInfo.Arguments = ncdFile + " -d -w -g ActiveReconfig:Yes -g CRC:Disable -g binary:Yes -r " + this.EmptyBitfile;
             * bitgen.Start();
             * bitgen.WaitForExit();
             */
            // clean up
            Reset resetCmd = new Reset();

            CommandExecuter.Instance.Execute(resetCmd);
        }
        private void m_btnOk_Click(object sender, EventArgs e)
        {
            string fileName = m_fileSelCtrl.FileName;

            List <string> netlistContainerNames = new List <string>();

            foreach (string name in m_chkListBoxMacros.CheckedItems)
            {
                netlistContainerNames.Add(name);
            }

            if (netlistContainerNames.Count == 0)
            {
                MessageBox.Show("No netlist container selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            switch (CurrentSaveType)
            {
            case SaveForm.SaveType.SaveAsDesign:
            {
                SaveAsDesign cmd = new SaveAsDesign();
                cmd.FileName = fileName;
                cmd.NetlistContainerNames = netlistContainerNames;
                Commands.CommandExecuter.Instance.Execute(cmd);
                break;
            }

            case SaveForm.SaveType.SaveAsBlocker:
            {
                SaveAsBlocker cmd = new SaveAsBlocker();
                cmd.FileName = fileName;
                cmd.NetlistContainerNames = netlistContainerNames;
                Commands.CommandExecuter.Instance.Execute(cmd);
                break;
            }

            case SaveForm.SaveType.SaveAsMacro:
            {
                SaveAsMacro cmd = new SaveAsMacro();
                cmd.FileName = fileName;
                cmd.NetlistContainerNames = netlistContainerNames;
                Commands.CommandExecuter.Instance.Execute(cmd);
                break;
            }

            default:
                throw new ArgumentException("Unexpected save type: " + CurrentSaveType);
            }


            if (ParentForm != null)
            {
                ParentForm.Close();
            }
        }