public void CloneMildot() { var r1 = new MilDotReticle(); var r2 = r1.Clone(); r2.Should().NotBeNull(); r2.Should().NotBeSameAs(r1); r2.Name.Should().Be(r1.Name); r2.Size.Should().Be(r1.Size); r2.Size.Should().NotBeSameAs(r1.Size); r2.Zero.Should().Be(r1.Zero); (r2.GetType().IsInstanceOfType(r1) || r1.GetType().IsInstanceOfType(r2)).Should().BeTrue(); ShouldHavePositionsDifferent(r1, r2); r2.Elements.Should().HaveCount(r1.Elements.Count); for (int i = 0; i < r2.Elements.Count; i++) { r2.Elements[i].Should().Be(r1.Elements[i]); ShouldHavePositionsDifferent(r2.Elements[i], r1.Elements[i]); } r2.BulletDropCompensator.Should().HaveCount(r2.BulletDropCompensator.Count); for (int i = 0; i < r2.BulletDropCompensator.Count; i++) { r2.BulletDropCompensator[i].Should().Be(r1.BulletDropCompensator[i]); ShouldHavePositionsDifferent(r2.Elements[i], r1.Elements[i]); } }
private static void Mildot() { var reticle = new MilDotReticle(); Draw(reticle, "mildot"); DrawGraphics(reticle, "mildot"); }
public void LoadReticle() { BallisticCalculatorNet.ReticleEditor.AppForm appForm = new BallisticCalculatorNet.ReticleEditor.AppForm(); MilDotReticle r1 = new MilDotReticle(); using (var ms1 = new MemoryStream()) { r1.BallisticXmlSerialize(ms1); using var ms2 = new MemoryStream(ms1.ToArray()); appForm.LoadReticle(ms2, "reticle1"); } //make sure reticle is loaded appForm.ReticleFileName.Should().Be("reticle1"); appForm.Reticle.Name.Should().Be(r1.Name); appForm.TextBox("reticleName").Should().HaveText(r1.Name); appForm.MeasurementControl("reticleWidth").Should().HaveExactValue(r1.Size.X); appForm.MeasurementControl("reticleHeight").Should().HaveExactValue(r1.Size.Y); appForm.MeasurementControl("zeroOffsetX").Should().HaveExactValue(r1.Zero.X); appForm.MeasurementControl("zeroOffsetY").Should().HaveExactValue(r1.Zero.Y); var lb = appForm.ListBox("reticleItems"); lb.Should().Exist(); lb.Should().HaveItemsCount(r1.Elements.Count + r1.BulletDropCompensator.Count); lb.Should().HaveIndexSelected(-1); //wrong reticle, take it from control!!! foreach (var element in appForm.Reticle.Elements) { lb.Should().HaveItemMatching <object>(lbi => ReferenceEquals(lbi, element)); } foreach (var element in appForm.Reticle.BulletDropCompensator) { lb.Should().HaveItemMatching <object>(lbi => ReferenceEquals(lbi, element)); } }
public void Parameters_Preview_Then_Close() { MilDotReticle mildot = new MilDotReticle(); ReticlePath path = new ReticlePath() { LineWidth = AngularUnit.MOA.New(0.1), Color = "black", Fill = true }; EditPathForm form = new EditPathForm(path, mildot); form.MeasurementControl("measurementWidth").Should().HaveValue(path.LineWidth.Value); form.ComboBox("comboBoxColor").Should().HaveText(path.Color); form.CheckBox("checkBoxFill").Should().BeChecked(); form.MeasurementControl("measurementWidth").Value = AngularUnit.MOA.New(21); form.ComboBox("comboBoxColor").Text = "aqua"; form.CheckBox("checkBoxFill").Checked = false; path.LineWidth.Should().NotBe(AngularUnit.MOA.New(21)); path.Color.Should().NotBe("aqua"); path.Fill.Should().NotBeFalse(); form.Save(); path.LineWidth.Should().Be(AngularUnit.MOA.New(21)); path.Color.Should().Be("aqua"); path.Fill.Should().BeFalse(); form.Close(); form.EditPathForm_FormClosed(this, new FormClosedEventArgs(CloseReason.UserClosing)); form.Dispose(); path.LineWidth.Should().Be(AngularUnit.MOA.New(0.1)); path.Color.Should().Be("black"); path.Fill.Should().BeTrue(); }