/// <summary> /// Initializes a new instance of the <see cref="BucketManager"/> class. /// </summary> /// <param name="opts">The simulation options.</param> public BucketManager(SimOptions opts) { _numBuckets = new IntVector((int)Math.Ceiling((double)opts.FieldWidth / BucketSize), (int)Math.Ceiling((double)opts.FieldHeight / BucketSize)); _buckets = new Bucket[_numBuckets.X, _numBuckets.Y]; for (var y = 0; y < _numBuckets.Y; y++) { for (var x = 0; x < _numBuckets.X; x++) { _buckets[x, y] = new Bucket(); } } for (var y = 0; y < _numBuckets.Y; y++) { for (var x = 0; x < _numBuckets.X; x++) { if (x > 0) { _buckets[x, y].Adjacent.Add(_buckets[x - 1, y]); } if (x < _numBuckets.X - 1) { _buckets[x, y].Adjacent.Add(_buckets[x + 1, y]); } if (y > 0) { _buckets[x, y].Adjacent.Add(_buckets[x, y - 1]); } if (y < _numBuckets.Y - 1) { _buckets[x, y].Adjacent.Add(_buckets[x, y + 1]); } if (x > 0 & y > 0) { _buckets[x, y].Adjacent.Add(_buckets[x - 1, y - 1]); } if (x > 0 & y < _numBuckets.Y - 1) { _buckets[x, y].Adjacent.Add(_buckets[x - 1, y + 1]); } if (x < _numBuckets.X - 1 && y > 0) { _buckets[x, y].Adjacent.Add(_buckets[x + 1, y - 1]); } if (x < _numBuckets.X - 1 && y < _numBuckets.Y - 1) { _buckets[x, y].Adjacent.Add(_buckets[x + 1, y + 1]); } } } }
public UsbService( IEventAggregator eventAggregator, IOptions <SimOptions> options) { _eventAggregator = eventAggregator; _options = options.Value; _searchQuery = $"SELECT * FROM WIN32_SerialPort WHERE Description = '{options.Value.DeviceName}'"; StartConnect(); }
public SimConnectService( IEventAggregator eventAggregator, IOptions <SimOptions> options) { _eventAggregator = eventAggregator; _options = options.Value; _simVarsByRequests = _simVars.ToDictionary(kvp => kvp.SimVar, kvp => kvp); _registerDataDefineStructMethodInfo = typeof(SimConnect).GetMethod(nameof(SimConnect.RegisterDataDefineStruct)); }
private void OK_Click(object sender, EventArgs e) { Psc.Molecule = QueryMolCtl.Molecule.Clone(); Psc.Molecule.RemoveStructureCaption(); // remove any structure caption that may cause a problem try { if (None.Checked || Lex.IsNullOrEmpty(Psc.Molecule.PrimaryValue)) // say none if checked or no structure { Psc.SearchType = StructureSearchType.Unknown; } else if (SubStruct.Checked) { SSOptions.GetValues(Psc); } else if (Similarity.Checked) { SimOptions.GetValues(Psc); } else if (Full.Checked) { FSOptions.GetValues(Psc); } else if (SmallWorld.Checked) { SmallWorldOptions.GetValues(Psc); UpdateAssociatedSmallWorldQueryColumns(Psc); } else { throw new Exception("No recognized search type checked"); // shouldn't happen } Psc.ConvertToQueryColumnCriteria(Qc); } catch (Exception ex) { MessageBoxMx.ShowError(ex.Message); return; } MoleculeSelectorControl.AddToMruList(QueryMolCtl, Psc.SearchType); DialogResult = DialogResult.OK; return; }
public void AssignsBucket(double x, double y, int bucketX, int bucketY) { var options = new SimOptions { FieldHeight = FieldHeight, FieldWidth = FieldWidth }; var manager = new BucketManager(options); var bot = new Robot(manager) { Position = new DoubleVector(x, y) }; bot.BucketPosition.Should().Be(new IntVector(-1, -1)); manager.UpdateBotBucket(bot); bot.BucketPosition.Should().Be(new IntVector(bucketX, bucketY)); }
private void MapPanel_Click(object sender, EventArgs e) { SimOptions.Select(); }
/// <summary> /// Display proper options subform or hide options if not showing /// based on the Psc settings /// </summary> void SetupOptions(bool initialSetup = false) { FormMetricsInfo fmi = WindowsHelper.GetFormMetrics(this); SetupDepth++; bool showOptions = ShowOptions; if (Psc.SearchType != StructureSearchType.Unknown) // && Psc.SearchType != StructureSearchType.SSS) // don't show SS options for now { ShowOptionsButton.Enabled = true; } else // no options available { showOptions = false; ShowOptionsButton.Enabled = false; } ShowOptionsButton.ImageIndex = (showOptions ? 1 : 0); // set proper ShowOptions Expand/Contract image button BottomDivider.Visible = (showOptions || Psc.SearchType == StructureSearchType.SmallWorld); // line above OK/Cancel if (Psc.SearchType == StructureSearchType.Substructure) { FSOptions.Visible = SimOptions.Visible = SmallWorldOptions.Visible = PreviewPanel.Visible = false; SSOptions.Visible = showOptions; int optHeight = showOptions ? SSOptions.Height + BottomCtlsHeight : 0; Size = new Size(InitialFormSize.Width, InitialFormSize.Height + optHeight); SSOptions.Setup(Psc); } else if (Psc.SearchType == StructureSearchType.MolSim) { SSOptions.Visible = FSOptions.Visible = SmallWorldOptions.Visible = PreviewPanel.Visible = false; SimOptions.Visible = showOptions; int optHeight = showOptions ? SimOptions.Height + BottomCtlsHeight : 0; Size = new Size(InitialFormSize.Width, InitialFormSize.Height + optHeight); SimOptions.Setup(Psc); } else if (Psc.SearchType == StructureSearchType.FullStructure) { SSOptions.Visible = SimOptions.Visible = SmallWorldOptions.Visible = PreviewPanel.Visible = false; FSOptions.Visible = showOptions; int optHeight = showOptions ? FSOptions.Height + BottomCtlsHeight : 0; Size = new Size(InitialFormSize.Width, InitialFormSize.Height + optHeight); FSOptions.Setup(Psc); } else if (Psc.SearchType == StructureSearchType.SmallWorld) { SSOptions.Visible = FSOptions.Visible = SimOptions.Visible = false; SmallWorldOptions.Visible = showOptions; SmallWorldOptions.CriteriaStructureForm = this; // link SmallWorldOptions to us SmallWorldPredefinedParameters swp = Psc.SmallWorldParameters; SmallWorldOptions.Setup(swp); Size = SmallWorldSize; // set form size same as last time if (!PreviewPanel.Visible) // if preview not visible then adjust size and show { PreviewCtl.InitializeView(); Size cs = this.ClientRectangle.Size; PreviewPanel.Width = cs.Width - PreviewPanel.Left - 2; PreviewPanel.Height = BottomDivider.Top - PreviewPanel.Top + 2; PreviewPanel.Visible = true; } if (initialSetup) { SmallWorldOptions.StartInitialQueryExecution(); // start search if initial setup } } else { Size = InitialFormSize; // no search type } Refresh(); SetupDepth--; return; }