Exemple #1
0
        /// <summary>
        /// Populates the assembler combo box.  Attempts to match the defaultAsm arg with
        /// the entries to configure the initial value.
        /// </summary>
        private void PopulateAssemblerComboBox(string defaultAsm)
        {
            //assemblerComboBox.DisplayMember = "Name";   // show this property

            assemblerComboBox.Items.Clear();
            IEnumerator <AssemblerInfo> iter = AssemblerInfo.GetInfoEnumerator();
            bool foundMatch = false;

            while (iter.MoveNext())
            {
                AssemblerInfo    info    = iter.Current;
                AssemblerVersion version = AssemblerVersionCache.GetVersion(info.AssemblerId);
                AsmComboItem     item    = new AsmComboItem(info, version);
                assemblerComboBox.Items.Add(item);
                if (item.AssemblerId.ToString() == defaultAsm)
                {
                    Debug.WriteLine("matched current " + defaultAsm);
                    assemblerComboBox.SelectedItem = item;
                    foundMatch = true;
                }
            }
            if (!foundMatch)
            {
                // Need to do this or box will show empty.
                assemblerComboBox.SelectedIndex = 0;
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a populated AssemblerConfig from the app settings for the specified ID.
        /// If the assembler hasn't been configured yet, the default configuration object
        /// will be returned.
        /// </summary>
        /// <param name="settings">Settings object to pull the values from.</param>
        /// <param name="id">Assembler ID.</param>
        /// <returns>The AssemblerConfig.</returns>
        public static AssemblerConfig GetConfig(AppSettings settings, AssemblerInfo.Id id)
        {
            string cereal = settings.GetString(GetSettingName(id), null);

            if (string.IsNullOrEmpty(cereal))
            {
                IAssembler asm = AssemblerInfo.GetAssembler(id);
                return(asm.GetDefaultConfig());
            }

            JavaScriptSerializer ser = new JavaScriptSerializer();

            try {
                AssemblerConfig config = ser.Deserialize <AssemblerConfig>(cereal);
                if (config.ColumnWidths == null || config.ColumnWidths.Length != NUM_COLUMNS)
                {
                    throw new Exception("Bad column widths");
                }
                if (config.ExecutablePath == null)
                {
                    throw new Exception("Missing exe path");
                }
                return(config);
            } catch (Exception ex) {
                Debug.WriteLine("AssemblerConfig deserialization failed: " + ex.Message);
                return(null);
            }
        }
        /// <summary>
        /// Queries the versions from all known assemblers, replacing any previously held data.
        /// </summary>
        public static void QueryVersions()
        {
            IEnumerator <AssemblerInfo> iter = AssemblerInfo.GetInfoEnumerator();

            while (iter.MoveNext())
            {
                AssemblerInfo.Id id = iter.Current.AssemblerId;
                if (id == AssemblerInfo.Id.Unknown)
                {
                    continue;
                }

                AssemblerVersion vers = null;
                IAssembler       asm  = AssemblerInfo.GetAssembler(id);
                if (asm != null)
                {
                    vers = asm.QueryVersion();
                }

                Debug.WriteLine("Asm version query: " + id + "=" + vers);
                sVersions[id] = vers;
            }

            sQueried = true;
        }
        public static AssemblerVersion GetVersion(AssemblerInfo.Id id)
        {
            IAssembler asm = AssemblerInfo.GetAssembler(id);

            if (asm == null)
            {
                Debug.WriteLine("Assembler " + id + " not configured");
                return(null);
            }
            return(asm.QueryVersion());
        }
Exemple #5
0
        private void generateButton_Click(object sender, EventArgs e)
        {
            IGenerator gen = AssemblerInfo.GetGenerator(mSelectedAssemblerId);

            if (gen == null)
            {
                Debug.WriteLine("Unable to get generator for " + mSelectedAssemblerId);
                return;
            }
            gen.Configure(mProject, mWorkDirectory, mBaseFileName,
                          AssemblerVersionCache.GetVersion(mSelectedAssemblerId), AppSettings.Global);

            GeneratorProgress dlg = new GeneratorProgress(gen);

            dlg.ShowDialog();
            Debug.WriteLine("Dialog returned: " + dlg.DialogResult);

            List <string> pathNames = dlg.Results;

            dlg.Dispose();

            if (pathNames == null)
            {
                // errors already reported
                return;
            }

            ResetElements();
            mGenerationResults = pathNames;
            previewFileComboBox.Items.Clear();
            foreach (string str in pathNames)
            {
                previewFileComboBox.Items.Add(new ComboPath(str));
            }
            previewFileComboBox.SelectedIndex = 0;      // should trigger update

            UpdateAssemblerControls();
        }
Exemple #6
0
        private void runAssemblerButton_Click(object sender, EventArgs e)
        {
            IAssembler asm = AssemblerInfo.GetAssembler(mSelectedAssemblerId);

            if (asm == null)
            {
                Debug.WriteLine("Unable to get assembler for " + mSelectedAssemblerId);
                return;
            }

            asm.Configure(mGenerationResults, mWorkDirectory);
            AssemblerProgress dlg = new AssemblerProgress(asm);

            dlg.ShowDialog();
            Debug.WriteLine("Dialog returned: " + dlg.DialogResult);
            if (dlg.DialogResult != DialogResult.OK)
            {
                // Cancelled, or failed to even run the assembler.
                return;
            }

            AssemblerResults results = dlg.Results;

            if (results == null)
            {
                Debug.WriteLine("Dialog returned OK, but no assembler results found");
                Debug.Assert(false);
                return;
            }

            StringBuilder sb =
                new StringBuilder(results.Stdout.Length + results.Stderr.Length + 200);

            sb.Append(results.CommandLine);
            sb.Append("\r\n");
            sb.AppendFormat("ExitCode={0} - ", results.ExitCode);
            if (results.ExitCode == 0)
            {
                FileInfo fi = new FileInfo(results.OutputPathName);
                if (!fi.Exists)
                {
                    MessageBox.Show(this, Properties.Resources.ASM_OUTPUT_NOT_FOUND,
                                    Properties.Resources.ASM_MISMATCH_CAPTION,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    sb.Append(Properties.Resources.ASM_MATCH_FAILURE);
                }
                else if (!CommonUtil.FileUtil.CompareBinaryFile(mProject.FileData,
                                                                results.OutputPathName, out int offset, out byte fileVal))
                {
                    if (fi.Length != mProject.FileData.Length &&
                        offset == fi.Length || offset == mProject.FileData.Length)
                    {
                        // The files matched up to the point where one ended.
                        string msg = string.Format(Properties.Resources.ASM_MISMATCH_LENGTH_FMT,
                                                   fi.Length, mProject.FileData.Length);
                        MessageBox.Show(this, msg, Properties.Resources.ASM_MISMATCH_CAPTION,
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        sb.Append(msg);
                    }
                    else
                    {
                        string msg = string.Format(Properties.Resources.ASM_MISMATCH_DATA_FMT,
                                                   offset, fileVal, mProject.FileData[offset]);
                        MessageBox.Show(this, msg, Properties.Resources.ASM_MISMATCH_CAPTION,
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        sb.Append(msg);
                    }
                }
                else
                {
                    sb.Append(Properties.Resources.ASM_MATCH_SUCCESS);
                }
            }
Exemple #7
0
 public AsmComboItem(AssemblerInfo info, AssemblerVersion version)
 {
     AssemblerId = info.AssemblerId;
     Name        = info.Name;
     AsmVersion  = version;
 }