Exemplo n.º 1
0
        /// <summary>
        /// Runs custom wizard logic at the beginning of a template wizard run.
        /// </summary>
        /// <param name="automationObject">
        /// The automation object being used by the template wizard.
        /// </param>
        /// <param name="replacementsDictionary">
        /// The list of standard parameters to be replaced.
        /// </param>
        /// <param name="runKind">
        /// A <see cref="T:Microsoft.VisualStudio.TemplateWizard.WizardRunKind" />
        /// indicating the type of wizard run.
        /// </param>
        /// <param name="customParams">
        /// The custom parameters with which to perform parameter replacement in the project.
        /// </param>
        public void RunStarted(object automationObject,
                               Dictionary <string, string> replacementsDictionary,
                               WizardRunKind runKind,
                               object[] customParams)
        {
            if (!ShowSpectrumDialog)
            {
                return;
            }

            var spectrumDialog = new ProjectWizardDialog();
            var result         = spectrumDialog.ShowDialog();
            var selected       = spectrumDialog.Vm.SelectedItem;

            if (result == null || !result.Value || selected == null)
            {
                if (replacementsDictionary.TryGetValue("$solutiondirectory$", out var solutionDir) &&
                    replacementsDictionary.TryGetValue("$projectname$", out var projectName))
                {
                    var innerDir = Path.Combine(solutionDir, projectName);
                    try
                    {
                        Directory.Delete(innerDir);
                        Directory.Delete(solutionDir);
                    }
                    catch
                    {
                        // --- This exception in intntionally ignored.
                    }
                }
                throw new WizardCancelledException();
            }

            try
            {
                SelectedEdition = SpectrumModels.StockModels[selected.ModelKey]
                                  .Editions[selected.RevisionKey];
            }
            catch
            {
                // --- If the selected edition is unavailable, stop the wizard
                throw new WizardCancelledException();
            }

            replacementsDictionary.Add("$ModelKey$", selected.ModelKey);
            replacementsDictionary.Add("$RevisionKey$", selected.RevisionKey);

            // --- Collect .rom and .disann items to add to the project
            var romInfo = SelectedEdition.Rom;
            var sb      = new StringBuilder();

            for (var i = 0; i < romInfo.NumberOfRoms; i++)
            {
                var romName = romInfo.RomName + (romInfo.NumberOfRoms == 1 ? "" : $"-{i}");
                sb.Append($"<Rom Include=\"Rom\\{romName}.rom\" />\n");
                sb.Append($"<DisassAnn Include=\"Rom\\{romName}.disann\" />\n");
            }

            replacementsDictionary.Add("$romItems$", sb.ToString());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Create the collection of devices for the Spectrum 48K virtual machine
 /// </summary>
 /// <param name="spectrumConfig">Machine configuration</param>
 /// <returns></returns>
 private DeviceInfoCollection CreateSpectrum48Devices(SpectrumEdition spectrumConfig)
 {
     return(new DeviceInfoCollection
     {
         new CpuDeviceInfo(spectrumConfig.Cpu),
         new RomDeviceInfo(new PackageRomProvider(), spectrumConfig.Rom, new SpectrumRomDevice()),
         new MemoryDeviceInfo(spectrumConfig.Memory, new Spectrum48MemoryDevice()),
         new PortDeviceInfo(null, new Spectrum48PortDevice()),
         new ClockDeviceInfo(new ClockProvider()),
         new KeyboardDeviceInfo(new KeyboardProvider(), new KeyboardDevice()),
         new ScreenDeviceInfo(spectrumConfig.Screen),
         new BeeperDeviceInfo(spectrumConfig.Beeper, new AudioWaveProvider()),
         new TapeDeviceInfo(new VsIntegratedTapeProvider())
     });
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create the collection of devices for the Spectrum 48K virtual machine
 /// </summary>
 /// <param name="spectrumConfig">Machine configuration</param>
 /// <returns></returns>
 private static DeviceInfoCollection CreateSpectrum48Devices(SpectrumEdition spectrumConfig)
 {
     return(new DeviceInfoCollection
     {
         new CpuDeviceInfo(spectrumConfig.Cpu),
         new RomDeviceInfo(GetProvider <IRomProvider>(false), spectrumConfig.Rom, new SpectrumRomDevice()),
         new MemoryDeviceInfo(spectrumConfig.Memory, new Spectrum48MemoryDevice()),
         new PortDeviceInfo(null, new Spectrum48PortDevice()),
         new ClockDeviceInfo(new ClockProvider()),
         new KeyboardDeviceInfo(GetProvider <IKeyboardProvider>(), new KeyboardDevice()),
         new ScreenDeviceInfo(spectrumConfig.Screen),
         new BeeperDeviceInfo(spectrumConfig.Beeper, GetProvider <IBeeperProvider>()),
         new TapeDeviceInfo(GetProvider <ITapeProvider>())
     });
 }
Exemplo n.º 4
0
        /// <summary>
        /// Loads the Spectrum model information
        /// </summary>
        private void LoadSpectrumModelInfo()
        {
            var configFilename = Path.Combine(ProjectDir, CONFIG_FILE);

            try
            {
                var data = File.ReadAllText(configFilename);
                SpectrumProjectConfigSerializer.Deserialize(data, out var confVm);
                ModelName             = confVm.ModelName;
                EditionName           = confVm.EditionName;
                SpectrumConfiguration = confVm.ConfigurationData;
            }
            catch
            {
                // --- This exception is intentionally ignored
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Create the collection of devices for the Spectrum +3E virtual machine
 /// </summary>
 /// <param name="spectrumConfig">Machine configuration</param>
 /// <returns></returns>
 private static DeviceInfoCollection CreateSpectrumP3Devices(SpectrumEdition spectrumConfig)
 {
     return(new DeviceInfoCollection
     {
         new CpuDeviceInfo(spectrumConfig.Cpu),
         new RomDeviceInfo(GetProvider <IRomProvider>(false), spectrumConfig.Rom, new SpectrumRomDevice()),
         new MemoryDeviceInfo(spectrumConfig.Memory, new SpectrumP3MemoryDevice()),
         new PortDeviceInfo(null, new SpectrumP3PortDevice()),
         new KeyboardDeviceInfo(GetProvider <IKeyboardProvider>(), new KeyboardDevice()),
         new KempstonDeviceInfo(GetProvider <IKempstonProvider>()),
         new ScreenDeviceInfo(spectrumConfig.Screen),
         new BeeperDeviceInfo(spectrumConfig.Beeper, GetProvider <IBeeperProvider>()),
         new TapeLoadDeviceInfo(GetProvider <ITapeLoadProvider>()),
         new TapeSaveDeviceInfo(GetProvider <ITapeSaveProvider>()),
         new SoundDeviceInfo(spectrumConfig.Sound, GetProvider <ISoundProvider>()),
         new FloppyDeviceInfo(spectrumConfig.Floppy, new FloppyDevice())
     });
 }
 /// <summary>
 /// Loads the Spectrum model information
 /// </summary>
 private void LoadSpectrumModelInfo()
 {
     var configItem = SpConfProjectItems.FirstOrDefault();
     var data = "";
     if (configItem != null)
     {
         try
         {
             data = File.ReadAllText(configItem.Filename);
         }
         catch
         {
             // --- This exception is intentionally ignored
         }
     }
     SpConfSerializer.Deserialize(data, out var confVm);
     ModelName = confVm.ModelName;
     EditionName = confVm.EditionName;
     SpectrumConfiguration = confVm.ConfigurationData;
 }