/// <summary> /// Creates, initializes pads and populates the Pads list. /// </summary> protected virtual void CreatePads() { Pads.Clear(); ErrorsPad = new ErrorListPad(Platform.Project); Pads.Add(ErrorsPad); TasksPad = new TaskListPad(Platform.Project); Pads.Add(TasksPad); ProjectPad = new ProjectPad(Platform.Project); ProjectPad.ItemDoubleClicked += () => MainForm.ShowEditorFor(ProjectPad.SelectedItem); ProjectPad.AddNewItemClicked += () => AddNewProjectItem(); ProjectPad.AddExistingItemClicked += () => AddExistingProjectItem(); ProjectPad.RemoveClicked += () => RemoveProjectItem(ProjectPad.SelectedItem); Pads.Add(ProjectPad); }
/// <summary> /// Creates, initializes pads and populates the Pads list. /// </summary> protected override void CreatePads() { base.CreatePads(); WatchPad = new WatchPad(Platform.Project); WatchPad.WatchAdded += new Action <WatchPad.WatchItem>(UpdateWatchItem); WatchPad.WatchValueEdited += new Action <WatchPad.WatchItem, long>(EditWatchValue); Pads.Add(WatchPad); BreakpointsPad = new BreakpointsPad(Platform.Project); BreakpointsPad.BreakpointController = Platform.DebuggerController.BreakpointController; Pads.Add(BreakpointsPad); HardwarePad = new HardwarePad(Platform.Project); Pads.Add(HardwarePad); }
/// <summary> /// Creates, initializes pads and populates the Pads list. /// </summary> protected override void CreatePads() { base.CreatePads(); WatchPad.Types = new string[] { "Signed", "Unsigned" }; (BreakpointsPad.NewIOBreakpointDialog as NewIOBreakpointForm).SetAddress(0, false); var newRegBp = BreakpointsPad.NewRegisterBreakpointDialog as NewRegisterBreakpointForm; newRegBp.SetRegisterNames(new string[] { "SP", "PC" }); newRegBp.SetOnRead(false, false); newRegBp.SetOnWrite(true, true); ConsolePad = new ConsolePad(Platform.Project); var dc = Platform.DebuggerController as PicoDebuggerController; dc.IODevice = ConsolePad; Pads.Add(ConsolePad); }
Pad WrapPad(PadCodon padContent) { if (pads == null) { foreach (Pad p in Pads) { if (p.InternalContent == padContent) { return(p); } } } Pad pad = new Pad(workbench, padContent); Pads.Add(pad); pad.Window.PadDestroyed += delegate { Pads.Remove(pad); }; return(pad); }
public void Load() { bool settingsLoaded = false; // If configuration file not exists then... var settingsFi = new System.IO.FileInfo(InitialFile.FullName); if (settingsFi.Exists) { while (true) { SettingsFile data; // Deserialize and load data. lock (saveReadFileLock) { try { data = Serializer.DeserializeFromXmlFile <SettingsFile>(InitialFile.FullName); if (data == null) { return; } Programs.Clear(); if (data.Programs != null) { // Make sure default settings have unique by file name. var distinctPrograms = data.Programs .GroupBy(p => p.FileName.ToLower()) .Select(g => g.First()) .ToList(); for (int i = 0; i < distinctPrograms.Count; i++) { Programs.Add(distinctPrograms[i]); } } Games.Clear(); if (data.Games != null) { // Make sure default settings have unique by file name. var distinctGames = data.Games .GroupBy(p => p.FileName.ToLower()) .Select(g => g.First()) .ToList(); for (int i = 0; i < distinctGames.Count; i++) { Games.Add(distinctGames[i]); } } Pads.Clear(); if (data.Pads != null) { for (int i = 0; i < data.Pads.Count; i++) { Pads.Add(data.Pads[i]); } } settingsLoaded = true; break; } catch (Exception) { var form = new MessageBoxForm(); var backupFile = InitialFile.FullName + ".bak"; form.StartPosition = FormStartPosition.CenterParent; var result = form.ShowForm( "User settings file has become corrupted.\r\n" + "Program must reset your user settings in order to continue.\r\n\r\n" + " Click [Yes] to reset your user settings and continue.\r\n" + " Click [No] if you wish to attempt manual repair.\r\n\r\n" + "Settings File: " + InitialFile.FullName, "Corrupt user settings of " + Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result == DialogResult.Yes) { if (System.IO.File.Exists(backupFile)) { System.IO.File.Copy(backupFile, InitialFile.FullName, true); settingsFi.Refresh(); } else { System.IO.File.Delete(InitialFile.FullName); break; } } else { // Avoid the inevitable crash by killing application first. Process.GetCurrentProcess().Kill(); return; } } } } } // If settings failed to load then... if (!settingsLoaded) { var resource = EngineHelper.GetResource("x360ce_Games.xml.gz"); // If internal preset was found. if (resource != null) { var sr = new StreamReader(resource); var compressedBytes = default(byte[]); using (var memstream = new MemoryStream()) { sr.BaseStream.CopyTo(memstream); compressedBytes = memstream.ToArray(); } var bytes = EngineHelper.Decompress(compressedBytes); var xml = System.Text.Encoding.UTF8.GetString(bytes); var programs = Serializer.DeserializeFromXmlString <List <x360ce.Engine.Data.Program> >(xml); Programs.Clear(); for (int i = 0; i < programs.Count; i++) { Programs.Add(programs[i]); } } } // Check if current app doesn't exist in the list then... var currentFile = new System.IO.FileInfo(Application.ExecutablePath); var currentGame = Games.FirstOrDefault(x => x.FileName == currentFile.Name); if (currentGame == null) { // Add x360ce.exe var item = x360ce.Engine.Data.Game.FromDisk(currentFile.Name); var program = Programs.FirstOrDefault(x => x.FileName == currentFile.Name); item.LoadDefault(program); SettingsFile.Current.Games.Add(item); } else { currentGame.FullPath = currentFile.FullName; } }
void AddPad(Pad pad) { Pads.Add(pad); }
public async Task <PagedCollection <PadSeriesReadModel> > ReadAll(PagingOptions paging) { using (var conn = OpenConnection()) { // Pull in the parent records first var series = await conn.QueryAsync <PadSeriesRow, BrandRow, PadSeriesReadModel>( @" select * from pad_series ps join brands b on ps.brand_id = b.id order by b.name limit @Limit offset @Offset; ", (ps, b) => new PadSeriesReadModel( ps.Id, ps.Name, new BrandReadModel( b.Id, b.Name ), ps.PolisherTypes.ToList() ), new { Limit = paging.PageSize, Offset = paging.Offset } ); var seriesLookup = new Dictionary <Guid, PadSeriesReadModel>(series.Select(p => new KeyValuePair <Guid, PadSeriesReadModel>(p.Id, p))); // Now get the rest using (var reader = await conn.QueryMultipleAsync( @" select count(*) from pad_series; select * from pad_sizes where pad_series_id = any(@Series); select pi.* from pad_images pi join pads p on pi.pad_id = p.id where pad_series_id = any(@Series); select p.* from pads p where pad_series_id = any(@Series) group by p.id order by name; select po.* from pad_options po left join pads p on po.pad_id = p.id; select po.id as pad_option_id, pn.* from part_numbers pn join pad_option_part_numbers popn on pn.id = popn.part_number_id join pad_options po on po.id = popn.pad_option_id; " , new { Series = series.Select(s => s.Id).ToArray() // We only want series that we got back. })) { var totalCount = reader.ReadFirst <int>(); var sizes = reader.Read <PadSizeRow>(); foreach (var size in sizes) { PadSeriesReadModel?s; if (seriesLookup.TryGetValue(size.PadSeriesId, out s)) { s.Sizes.Add(new PadSizeReadModel( size.Id, new MeasurementReadModel(size.DiameterAmount, size.DiameterUnit), size.ThicknessAmount != null ? new MeasurementReadModel(size.ThicknessAmount ?? 0, size.ThicknessUnit !) : null ) ); } } var images = reader.Read <(Guid PadId, Guid ImageId)>(); var pads = new Dictionary <Guid, PadReadModel>(); var rawPads = reader.Read(); foreach (var raw in rawPads) { Guid?imageId = images.Where(i => i.PadId == raw.id).FirstOrDefault().ImageId; if (imageId == Guid.Empty) { imageId = null; } var pad = new PadReadModel( raw.id, raw.name, ((PadCategoryBitwise)raw.category).ToList(), raw.material, raw.texture, raw.color, raw.has_center_hole, imageId, new List <PadOptionReadModel>() ); pads.Add(pad.Id, pad); PadSeriesReadModel?s; if (seriesLookup.TryGetValue(raw.pad_series_id, out s)) { s !.Pads.Add(pad); } } var options = reader.Read <PadOptionRow>(); var optionDict = new Dictionary <Guid, PadOptionReadModel>(); foreach (var opt in options) { PadReadModel?pad; if (pads.TryGetValue(opt.PadId, out pad)) { var po = new PadOptionReadModel(opt.Id, opt.PadSizeId); pad.Options.Add(po); optionDict.Add(opt.Id, po); } } var partNumbers = reader.Read <Guid, PartNumberRow, (Guid PadOptionId, PartNumberRow PartNumber)>((id, pn) => (id, pn)); foreach (var partNumber in partNumbers) { PadOptionReadModel?option; if (optionDict.TryGetValue(partNumber.PadOptionId, out option)) { option.PartNumbers.Add(new PartNumberReadModel(partNumber.PartNumber.Id, partNumber.PartNumber.Value, partNumber.PartNumber.Notes)); } } return(new PagedCollection <PadSeriesReadModel>(new Paging(paging, totalCount), seriesLookup.Values)); } } }
void AddPad(Type type) { PadDescriptor descriptor = WorkbenchSingleton.Workbench.GetPad(type); Pads.Add(new PadViewModel(descriptor)); }
private void addPads() { Pads.Add(new Point(1, 6), Instantiate(grounds[10], Grid[new Point(1, 6)].transform.position, rotation: Quaternion.identity)); }