public void Test1() { var p1 = new Point(0, 0); var p2 = new Point(0, 10); var angle = PointHelper.GetHorizontalAngle(p1, p2); Assert.That(angle, Is.EqualTo(90)); }
static public PointHelper GetInstance() { if (null == instance) { instance = new PointHelper(); } return(instance); }
public void ClickAt(int str, int chr) { var relativePoint = PointHelper.GetPointToClickOn(str, chr, Regex.Split(Text, "\r\n").ToList()); var absolutePoint = GetAbsolutePoint(relativePoint); TestLogger.Instance.Info($"Clicking at {absolutePoint} (relative: {relativePoint}) in '{_name}'"); Mouse.Instance.Click(absolutePoint); }
/// <summary> /// Adds a stone to a gameboard /// </summary> private void InsertRockImage(System.Windows.Input.MouseButtonEventArgs e) { if (MouseInTableArea(e, dragImage_new)) { int left = (int)e.GetPosition(tablePanel).X - dragImage_mousePos_X; int top = (int)e.GetPosition(tablePanel).Y - dragImage_mousePos_Y; // sets handler so that we can manipulate with the object dragImage_new.MouseDown += new System.Windows.Input.MouseButtonEventHandler(RockImageOld_MouseDown); dragImage_new.MouseUp += new System.Windows.Input.MouseButtonEventHandler(rockImage_MouseUp); // check the type of the object to insert A_TableObject object_to_put = null; if ((A_TableObject)dragImage_new.DataContext is Graviton) { object_to_put = new Graviton(); ((Graviton)object_to_put).Name = "Graviton"; ((Graviton)object_to_put).BaseSettings = tableManager.TableDepositor.table.Settings.gravitonSettings; } if ((A_TableObject)dragImage_new.DataContext is Generator) { object_to_put = new Generator(); ((Generator)object_to_put).Name = "Generator"; ((Generator)object_to_put).BaseSettings = tableManager.TableDepositor.table.Settings.generatorSettings; } if ((A_TableObject)dragImage_new.DataContext is Magneton) { object_to_put = new Magneton(); ((Magneton)object_to_put).Name = "Magneton"; ((Magneton)object_to_put).BaseSettings = tableManager.TableDepositor.table.Settings.magnetonSettings; } if ((A_TableObject)dragImage_new.DataContext is BlackHole) { object_to_put = new BlackHole(); ((BlackHole)object_to_put).Name = "BlackHole"; ((BlackHole)object_to_put).BaseSettings = tableManager.TableDepositor.table.Settings.blackHoleSettings; } // sets position object_to_put.Position = PointHelper.TransformPointToEuc(new FPoint(left * CommonAttribService.ACTUAL_TABLE_SIZE_MULTIPLIER + dragImage_new.Width / 2, top * CommonAttribService.ACTUAL_TABLE_SIZE_MULTIPLIER + dragImage_new.Height / 2), CommonAttribService.ACTUAL_TABLE_WIDTH, CommonAttribService.ACTUAL_TABLE_HEIGHT); dragImage_new.DataContext = object_to_put; // add it into a system tableManager.InsertObject(object_to_put); rockImages.Add(dragImage_new); } else { // icon is beyond the border of the game table -> delete it if (tablePanel.mainGrid.Children.Contains(dragImage_new)) { tablePanel.mainGrid.Children.Remove(dragImage_new); } } dragImage_new = null; }
public override void UpdateObject(MainGameEnginePanel _mainGameEnginePanel) { if (gameManager.keysDown.Contains(Keys.W)) { this.objectVelocity = new PointF(this.objectVelocity.X, -playerSpeed); } else if (gameManager.keysDown.Contains(Keys.S)) { this.objectVelocity = new PointF(this.objectVelocity.X, playerSpeed); } else { this.objectVelocity = new PointF(this.objectVelocity.X, 0); } if (gameManager.keysDown.Contains(Keys.D)) { this.objectVelocity = new PointF(playerSpeed, this.objectVelocity.Y); } else if (gameManager.keysDown.Contains(Keys.A)) { this.objectVelocity = new PointF(-playerSpeed, this.objectVelocity.Y); } else { this.objectVelocity = new PointF(0, this.objectVelocity.Y); } if (gameManager.keysDown.Contains(Keys.Space)) { if (gameManager.gameTime - lastShootTime > shootDelay) { Console.Out.WriteLine(gameManager.mouseLocation + " " + this.gameObjectLocation); PointF locationDifference = PointHelper.Subtract(gameManager.mouseLocation, this.gameObjectLocation); PointF projectileVelocity = new PointF(0, 0); if (locationDifference.X > locationDifference.Y) { float yVelocity = locationDifference.Y * 100 / locationDifference.X; projectileVelocity = new PointF(projectileMaxVelocity, yVelocity * projectileMaxVelocity / 100); } else //Y bigger { float xVelocity = locationDifference.X * 100 / locationDifference.Y; projectileVelocity = new PointF(xVelocity * projectileMaxVelocity / 100, projectileMaxVelocity); } Console.Out.WriteLine(projectileVelocity); Projectile newProjectile = new Projectile(gameManager, this.gameObjectLocation, projectileVelocity); gameManager.AddGameObjectToScene(newProjectile, 0); lastShootTime = gameManager.gameTime; } } base.UpdateObject(_mainGameEnginePanel); }
void Update() { var mouesPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); sr.flipX = flipWeapon; this.transform.localScale = new Vector3(flipWeapon?-1:1, this.transform.localScale.y, 1); PointHelper.PointAtTarget(this.transform, Camera.main.ScreenToWorldPoint(Input.mousePosition), flipWeapon); }
/// <summary> /// 序列化matchingpoint所需的所有数据 发送那个给服务器 /// </summary> /// <returns></returns> static public string MergMatchingpointNeed() { JObject jo = MergMatchingPointsJson(PointHelper.GetInstance().userdataformweb); jo["type"] = "obj"; jo["case_id"] = PlayerDataCenter.Currentillnessdata.ID; return(jo.ToString()); }
private void AutomaticUpdate_Load(object sender, EventArgs e) { string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; try { using (new WaitCursor()) { if (!PointHelper.PointIsEmpty(TopLeft)) { Left = (int)TopLeft.X; Top = (int)TopLeft.Y; } string currentVersionNumber = CurrentVersion.Root.Element("Number").Value; DateTime currentReleaseDate = SafeDate.Parse(CurrentVersion.Root.Element("Released").Value); lblInfo.Text = "Your current version of Chem4Word is " + currentVersionNumber + "; Released " + SafeDate.ToShortDate(currentReleaseDate); _telemetry.Write(module, "AutomaticUpdate", lblInfo.Text); var versions = NewVersions.XPathSelectElements("//Version"); foreach (var version in versions) { if (string.IsNullOrEmpty(_downloadUrl)) { _downloadUrl = version.Element("Url").Value; } var thisVersionNumber = version.Element("Number").Value; DateTime thisVersionDate = SafeDate.Parse(version.Element("Released").Value); if (currentReleaseDate >= thisVersionDate) { break; } AddHeaderLine("Version " + thisVersionNumber + "; Released " + SafeDate.ToShortDate(thisVersionDate), Color.Blue); var changes = version.XPathSelectElements("Changes/Change"); foreach (var change in changes) { if (change.Value.StartsWith("Note:")) { AddBulletItem(change.Value.Remove(0, 6), Color.Red); } else { AddBulletItem(change.Value, Color.Black); } } } } } catch (Exception ex) { new ReportError(_telemetry, TopLeft, module, ex).ShowDialog(); } }
public static void Init() { pointHelperA = new PointHelper { BoxTexture = Gizmo.ATexture, DrawCube = true }; pointHelperB = new PointHelper { BoxTexture = Gizmo.BTexture, DrawCube = true }; }
void AutoNext(string message) { int group = PointHelper.GetInstance().currentgroup; int index = PointHelper.GetInstance().currentindex; MatchingItemButton b = SearchHelper.GetInstance().SerchChoise(buttonmap, group, index); b.OnEditHit(); }
private void UpdateFailure_Load(object sender, EventArgs e) { if (!PointHelper.PointIsEmpty(TopLeft)) { Left = (int)TopLeft.X; Top = (int)TopLeft.Y; } webBrowser1.DocumentText = WebPage; }
void CreateNormalOwnedPointer(NormalPointer p, Vector3 hitinfopoint, int _group, int _index, bool avtive = true) { p.CreateOwnedUserPointer(materialmap, hitinfopoint, userimport.transform, avtive, (_localpos, _g, _i) => { Vector3 localpos = _localpos; int group = _g; int index = _i; PointHelper.GetInstance().AddPoint(group, index, localpos); }); }
/// <summary> /// 根据normalmodledata数据刷新两列button /// </summary> public void RefreshViewByNormalModleData() { Clear(); pointmap = PointHelper.GetInstance().normaldataformlocaljson;//PointHelper.GetInstance().normalmodelInSceneMap; if (null == pointmap || pointmap.Count == 0) { Debug.LogError("pointmap 为空!!!"); return; } foreach (KeyValuePair <int, Dictionary <int, Vector3> > item in pointmap) { int group = item.Key; GameObject but = SpawnChildren(Groupbuttonitem); Button b = but.GetComponent <Button>(); string groupstr = Tool.NumberToChar(group + 1).ToUpper(); b.GetComponentInChildren <Text>().text = groupstr; b.onClick.AddListener(() => { ResetLastAndSetThis(b); if (dropdownindex == 0) { MSGCenter.Execute(Enums.PointControll.Choise.ToString(), group.ToString()); } ChoisePanel(b); choiseindex = group; }); if (group == choiseindex) { ChoisePanel(b); lastchoiselistbutton = b; } Dictionary <int, Vector3> templist = item.Value; List <GameObject> tempgos = new List <GameObject>(); List <MatchingItemButton> tempbuts = new List <MatchingItemButton>(); foreach (KeyValuePair <int, Vector3> it in templist) { GameObject g = SpawnChildren(Pointbuttonitem); g.SetActive(false); int tempgroup = group; int tempindex = it.Key; g.GetComponentInChildren <Text>().text = groupstr + " " + (tempindex + 1).ToString(); MatchingItemButton Matchingitem = g.GetComponent <MatchingItemButton>(); Matchingitem.Init(tempgroup, tempindex, SetLastMatchingItem); tempgos.Add(g); tempbuts.Add(Matchingitem); } listmap.Add(b, tempgos); buttonmap.Add(group, tempbuts); buttonindex.Add(group, b); } RefreshViewByUserModelData(); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append($"{Text}"); sb.Append(" "); sb.Append($"at {PointHelper.AsString(BoundingBox.Location)}"); sb.Append(" "); sb.Append($"size {SafeDouble.AsString4(BoundingBox.Size.Width)}x{SafeDouble.AsString4(BoundingBox.Size.Height)}"); return(sb.ToString()); }
public override object ConvertTo( ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object value, Type destinationType) { object result = null; ZoomboxView view = value as ZoomboxView; if (view != null) { if (destinationType == typeof(string)) { result = "Empty"; switch (view.ViewKind) { case ZoomboxViewKind.Absolute: if (PointHelper.IsEmpty(view.Position)) { if (!DoubleHelper.IsNaN(view.Scale)) { result = view.Scale.ToString(); } } else if (DoubleHelper.IsNaN(view.Scale)) { result = String.Format("{0},{1}", view.Position.X, view.Position.Y); } else { result = String.Format("{0},{1},{2}", view.Scale, view.Position.X, view.Position.Y); } break; case ZoomboxViewKind.Center: result = "Center"; break; case ZoomboxViewKind.Fill: result = "Fill"; break; case ZoomboxViewKind.Fit: result = "Fit"; break; case ZoomboxViewKind.Region: result = String.Format("{0},{1},{2},{3}", view.Region.X, view.Region.Y, view.Region.Width, view.Region.Height); break; } } } return(result == null ? base.ConvertTo(typeDescriptorContext, cultureInfo, value, destinationType) : result); }
public override string ToString() { string result = $"{Style} from {PointHelper.AsString(Start)} to {PointHelper.AsString(End)}"; if (Bond != null) { result += $" [{Bond}]"; } return(result); }
private void FormProgress_Load(object sender, System.EventArgs e) { if (!PointHelper.PointIsEmpty(TopLeft)) { Left = (int)TopLeft.X; Top = (int)TopLeft.Y; } #if DEBUG this.TopMost = false; #endif }
private void generatePoint() { PointInfo point = PointHelper.addNewPoint(); point.Position = location; point.BlipColor = 3; point.BlipType = 75; point.Text = "Tattoo Shop"; point.DrawLabel = true; point.Id = "SHOP_TATTOO"; point.InteractionEnabled = true; }
public void UpdatePlayerScoreFalse() { Player playerTest = new Player("Foo", PlayerType.Human); PointHelper PointManager = new PointHelper(); playerTest.Points = 6; int pointsToAdd = 1; PointManager.UpdatePlayerPoints(playerTest, pointsToAdd); Assert.IsFalse(playerTest.Points == 21); }
private void generatePoint() { PointInfo point = PointHelper.addNewPoint(); point.Position = location; point.BlipColor = 3; point.BlipType = 362; point.Text = "Mask Shop"; point.DrawLabel = true; point.Id = "SHOP_MASK"; point.InteractionEnabled = true; }
private void generatePoint() { PointInfo point = PointHelper.addNewPoint(); point.Position = location; point.BlipColor = 3; point.BlipType = 71; point.Text = "Barber"; point.DrawLabel = true; point.Id = "SHOP_BARBER"; point.InteractionEnabled = true; }
private void generatePoint() { PointInfo point = PointHelper.addNewPoint(); point.BlipColor = 3; point.BlipType = 477; point.Text = "Chop Shop - Cars for Cash"; point.DrawLabel = true; point.Id = "JOB_CHOP_SHOP"; point.InteractionEnabled = true; point.Position = startPoint; }
private void generatePoint() { PointInfo point = PointHelper.addNewPoint(); point.BlipColor = 3; point.BlipType = 477; point.Text = "Short Range Trucking"; point.DrawLabel = true; point.Id = "JOB_SHORT_RANGE_TRUCKING"; point.InteractionEnabled = true; point.Position = startPoint; }
void HighLightPoint(string message) { if (lasthighlight) { lasthighlight.SetMaterialOrigin(); } NormalPointer p = PointHelper.GetInstance().CheckChoisePointer(); p.SetMaterialHighlight(); lasthighlight = p; }
public void Select(int strFrom, int chrFrom, int strTo, int chrTo) { var textByLines = Regex.Split(Text, "\r\n").ToList(); TestLogger.Instance.Info($"Select from at {strFrom}, {chrFrom} to {strTo}, {chrTo} in '{_name}'"); Mouse.Instance.Location = GetAbsolutePoint(PointHelper.GetPointToClickOn(strFrom, chrFrom, textByLines)); Mouse.LeftDown(); Mouse.Instance.Location = GetAbsolutePoint(PointHelper.GetPointToClickOn(strTo, chrTo, textByLines)); Mouse.LeftUp(); }
private void generatePoint() { PointInfo point = PointHelper.addNewPoint(); point.Position = location; point.BlipColor = 2; point.BlipType = 431; point.Text = "ATM"; point.DrawLabel = true; point.Id = "SHOP_ATM"; point.InteractionEnabled = true; }
public void Test5() { var p1 = new Point(5, 0); var p2 = new Point(5, 10); var p3 = new Point(0, 10); var rectInfo = PointHelper.GetRectInfoFromPoints(p1, p2, p3); Assert.That(rectInfo.Angle, Is.EqualTo(90)); Assert.That(rectInfo.Width, Is.EqualTo(10)); Assert.That(rectInfo.Height, Is.EqualTo(5)); Assert.That(rectInfo.InitialPoint.X, Is.EqualTo(-2.5)); Assert.That(rectInfo.InitialPoint.Y, Is.EqualTo(2.5).Within(.001)); }
private void EditorHost_Load(object sender, EventArgs e) { using (new WaitCursor()) { IsLoading = true; if (!PointHelper.PointIsEmpty(TopLeft)) { Left = (int)TopLeft.X; Top = (int)TopLeft.Y; } MinimumSize = new Size(900, 600); if (FormSize.Width != 0 && FormSize.Height != 0) { Width = FormSize.Width; Height = FormSize.Height; } // Fix bottom panel int margin = Buttons.Height - Save.Bottom; splitContainer1.SplitterDistance = splitContainer1.Height - Save.Height - margin * 2; splitContainer1.FixedPanel = FixedPanel.Panel2; splitContainer1.IsSplitterFixed = true; // Set Up WPF UC if (elementHost1.Child is Chem4Word.ACME.Editor editor) { editor.ShowFeedback = false; editor.TopLeft = TopLeft; editor.Telemetry = Telemetry; editor.SetProperties(_cml, _used1DProperties, _options); editor.OnFeedbackChange += AcmeEditorOnFeedbackChange; var model = editor.ActiveViewModel.Model; if (model == null || model.Molecules.Count == 0) { Text = "ACME - New structure"; } else { List <MoleculeFormulaPart> parts = FormulaHelper.ParseFormulaIntoParts(editor.ActiveViewModel.Model.ConciseFormula); var x = FormulaHelper.FormulaPartsAsUnicode(parts); Text = "ACME - Editing " + x; } } IsLoading = false; } }
/// <summary> /// creates a new cursor that tracks the mouse /// </summary> public Cursor() { GM.engineM.AddSprite(this); Frame.Define(Tex.Triangle); RotationAngle = -35; Align = Engine7.Align.topLeft; Layer = RenderLayer.hud; Position2D = PointHelper.Vector2FromPoint(GM.screenSize.Center); Z = 50000; WorldCoordinates = false; //add mouse logic to fire as fast as engine is updating GM.eventM.AddEvent(evLogic = new Event(GM.eventM.MaximumRate, "mouse cursor", Logic)); }
private void setupPoint(StashInfo stashinfo) { PointInfo point = PointHelper.addNewPoint(); point.BlipColor = 1; point.BlipType = 1; point.Text = string.Format("Contains - {0} ~n~ Quantity: {1}", stashinfo.Type.ToString(), stashinfo.Quantity.ToString()); point.DrawLabel = true; point.Id = stashinfo.ID.ToString(); point.InteractionEnabled = false; point.Position = stashinfo.Location; point.BlipEnabled = false; point.StashType = true; }
private void OnReportStatus(GeneticAlgorithmStatus status) { var pointHelper = new PointHelper(status.IterationNumber); AvgFitness.Add(pointHelper.Create(status.CurrentPopulation.AvgFitness)); BestChromosome.Add(pointHelper.Create(status.BestChromosome.Value)); Selection.Add(pointHelper.Create(status.SelectionOverhead)); Crossover.Add(pointHelper.Create(status.CrossoverOverhead)); Mutation.Add(pointHelper.Create(status.MutationOverhead)); Repair.Add(pointHelper.Create(status.RepairOverhead)); Transform.Add(pointHelper.Create(status.TransformOverhead)); Evaluation.Add(pointHelper.Create(status.EvaluationOverhead)); SelectionOverhead = status.SelectionOverhead; CrossoverOverhead = status.CrossoverOverhead; MutationOverhead = status.MutationOverhead; RepairOverhead = status.RepairOverhead; TransformOverhead = status.TransformOverhead; EvaluationOverhead = status.EvaluationOverhead; MaxIterations = status.MaxIterations; CurrentIteration = status.IterationNumber; PercentCompleted = (CurrentIteration * 100) / MaxIterations; BestChromosomeValue = status.BestChromosome.Value; ProgressInfo = String.Format("Iteration {0} of {1}", CurrentIteration, MaxIterations); OnPropertyChanged("StatisticsChanged"); }