Ejemplo n.º 1
0
        public void Parameter_takes_precedence_over_registered_service()
        {
            Container.Register(Component.For <CompA>(),
                               Component.For <CompB>().DependsOn(Dependency.OnValue <string>("some string")),
                               Component.For <CompC>().Instance(new CompC(0)));

            var c2   = new CompC(42);
            var args = new Arguments().AddTyped(c2);
            var b    = Container.Resolve <CompB>(args);

            Assert.AreSame(c2, b.Compc);
        }
Ejemplo n.º 2
0
		public CompB(CompC compC)
		{
		}
Ejemplo n.º 3
0
        private void cmdCalculate_Click(object sender, EventArgs e)
        {
            LatLong();
            string CString = txtCourse.Text + '°';

            if (Conversion.Val(txtCourse.Text) >= 0d & Conversion.Val(txtCourse.Text) < 90d)
            {
                CourseAngle = Conversion.Val(txtCourse.Text);
                Prefix      = CommonGlobals.g_LatN;
                Suffix      = CommonGlobals.g_LongE;
            }

            if (Conversion.Val(txtCourse.Text) >= 90d & Conversion.Val(txtCourse.Text) < 180d)
            {
                CourseAngle = 180d - Conversion.Val(txtCourse.Text);
                CString     = "180" + '°' + "-" + txtCourse.Text + '°';
                Prefix      = CommonGlobals.g_LatS;
                Suffix      = CommonGlobals.g_LongE;
            }

            if (Conversion.Val(txtCourse.Text) >= 180d & Conversion.Val(txtCourse.Text) < 270d)
            {
                CourseAngle = Conversion.Val(txtCourse.Text) - 180d;
                CString     = CString + "- 180" + '°';
                Prefix      = CommonGlobals.g_LatS;
                Suffix      = CommonGlobals.g_LongW;
            }

            if (Conversion.Val(txtCourse.Text) >= 270d & Conversion.Val(txtCourse.Text) < 360d)
            {
                CourseAngle = 360d - Conversion.Val(txtCourse.Text);
                CString     = "360" + '°' + "-" + txtCourse.Text + '°';
                Prefix      = CommonGlobals.g_LatN;
                Suffix      = CommonGlobals.g_LongW;
            }

            if (Math.Abs(L2) > 90d)
            {
                ErrorMsgBox("Distance too large.  Cannot go this far along this rhumb line.");
                return;
            }

            Distance = Conversion.Val(txtDist.Text);
            Factor   = (float)Math.Abs(Math.Cos(CourseAngle * Math.PI / 180d));
            Factor   = (float)(Convert.ToInt32(Factor * 10f + 0.5d) / 10d);
            double Cfactor = Convert.ToInt32((Math.Cos(CourseAngle * Math.PI / 180d) * 10d + 0.5d) / 10d);

            LatDiff    = Distance * Factor;
            LatDiff    = Convert.ToInt32(LatDiff * 10d + 0.5d) / 10d;
            IntLatDiff = (int)Convert.ToInt32(LatDiff + 0.5d);
            txtSailings.Clear();
            txtSailings.AppendText(g_tab + g_tab + g_tab + " Simplified Traverse Table Worksheet" + Environment.NewLine + Environment.NewLine);
            txtSailings.SelectionAlignment = HorizontalAlignment.Left;
            txtSailings.WordWrap           = true;
            txtSailings.AppendText("1." + g_tab + "Course: " + CString + "T => C = " + Prefix + " " + Math.Abs(CourseAngle).ToString() + '°' + " " + Suffix + g_tab + g_tab + "factor (C) = " + Math.Abs(Factor).ToString() + Environment.NewLine);
            Cfactor   = Factor;
            CompC     = (float)(90d - CourseAngle);
            Factor    = (float)Math.Abs(Math.Cos(CompC * Math.PI / 180d));
            Factor    = (float)(Convert.ToInt32(Factor * 10f + 0.5d) / 10d);
            Departure = (float)(Distance * Factor);
            Departure = (float)(Convert.ToInt32(Departure * 10f + 0.5d) / 10d);
            txtSailings.AppendText("2." + g_tab + "Complement C = 90" + '°' + "- C " + Environment.NewLine + "   " + g_tab + g_tab + "= 90" + '°' + "-" + CourseAngle.ToString("##0") + Environment.NewLine + "   " + g_tab + g_tab + "= " + CompC.ToString() + '°' + g_tab + g_tab + g_tab + g_tab + "factor (Comp C) = " + Factor.ToString() + Environment.NewLine);
            txtSailings.AppendText("3." + g_tab + "Diff Lat = D x factor(C) " + Environment.NewLine + "   " + g_tab + g_tab + "= " + Distance.ToString("##0.0") + " nm x " + Cfactor.ToString("#0.0") + Environment.NewLine + "   " + g_tab + g_tab + "= " + LatDiff.ToString("#0.0") + "'" + " rounded to " + IntLatDiff.ToString("#0") + "'" + Environment.NewLine);
            txtSailings.AppendText("4." + g_tab + "Departure = D x factor(Comp C) " + Environment.NewLine + "   " + g_tab + g_tab + "= " + Distance.ToString("##0.0") + " nm x " + Factor.ToString("#0.0") + Environment.NewLine + "   " + g_tab + g_tab + "= " + Math.Abs(Departure).ToString("#0.0") + " nm" + Environment.NewLine);
            string PlusMinusStr = "+";

            if (Conversion.Val(txtCourse.Text) > 90d & Conversion.Val(txtCourse.Text) < 270d)
            {
                IntLatDiff   = -IntLatDiff;
                PlusMinusStr = "-";
            }

            L2 = L1 + IntLatDiff / 60d;
            if (Math.Abs(L2) >= 85d)
            {
                ErrorMsgBox("Latitude too high for Simplified Traverse Table, a form of mid-latitude sailing.");
                return;
            }

            L2Deg = (int)Convert.ToInt32(Math.Abs(L2));
            L2Min = (Math.Abs(L2) - L2Deg) * 60d;
            L2Min = Convert.ToInt32(L2Min + 0.5d);
            if (L2Min == 60d)
            {
                L2Min = 0d;
                L2Deg = L2Deg + 1;
            }

            if (Lo2Min == 60d)
            {
                Lo2Min = 0d;
                Lo2Deg = Lo2Deg + 1;
            }

            txtSailings.AppendText("5." + g_tab + "L2 = L1 (+/-) Diff Lat" + Environment.NewLine + "   " + g_tab + g_tab + "= " + txtL1Deg.Text.ToString() + '°' + txtL1Min.Text + "'" + cboL1.Text + " " + PlusMinusStr + " " + Math.Abs(IntLatDiff).ToString("0") + "'" + Environment.NewLine + "   " + g_tab + g_tab + "= " + L2Deg.ToString("0") + '°' + Strings.Format(L2Min, "00") + "'");
            if (Math.Abs(L2) < 0.01d)
            {
                L2 = 0d;
                txtSailings.AppendText("");
            }

            if (L2 > 0d & Math.Abs(L2) > 0.01d)
            {
                txtSailings.AppendText(CommonGlobals.g_LatN);
            }

            if (L2 <0d& Math.Abs(L2)> 0.01d)
            {
                txtSailings.AppendText(CommonGlobals.g_LatS);
            }

            txtSailings.AppendText(Environment.NewLine);
            L2       = Math.Sign(L2) * (L2Deg + L2Min / 60d);
            Lm       = (L1 + L2) / 2d; // Mid-latitude
            Factor   = (float)Math.Abs(Math.Cos(Lm * Math.PI / 180d));
            Factor   = (float)(Convert.ToInt32(Factor * 10f + 0.5d) / 10d);
            LmDeg    = (int)Convert.ToInt32(Math.Abs(Lm));
            LmMin    = (float)((Math.Abs(Lm) - LmDeg) * 60d);
            LmMin    = (float)(Convert.ToInt32(LmMin * 10f + 0.5d) / 10d);
            IntLmMin = (int)Convert.ToInt32(LmMin + 0.5d);
            txtSailings.AppendText("6." + g_tab + "Mid Lat = L1 (+/-) (Diff Lat / 2) " + Environment.NewLine + "   " + g_tab + g_tab + "= " + txtL1Deg.Text.ToString() + '°' + txtL1Min.Text + "'" + cboL1.Text + " " + PlusMinusStr + " " + Math.Abs(IntLatDiff).ToString("0") + "/2'" + Environment.NewLine + "   " + g_tab + g_tab + "= " + Strings.Format(LmDeg, "0") + '°' + Strings.Format(LmMin, "00.0") + "'");
            if (Lm >= 0d)
            {
                txtSailings.AppendText(CommonGlobals.g_LatN);
            }

            if (Lm < 0d)
            {
                txtSailings.AppendText(CommonGlobals.g_LatS);
            }

            txtSailings.AppendText(" rounded to " + Strings.Format(LmDeg, "0") + '°' + Strings.Format(IntLmMin, "00") + "'");
            if (Lm >= 0d)
            {
                txtSailings.AppendText(CommonGlobals.g_LatN);
            }

            if (Lm < 0d)
            {
                txtSailings.AppendText(CommonGlobals.g_LatS);
            }

            // txtSailings.AppendText(vbNewLine)
            txtSailings.AppendText(g_tab + "factor (Mid-Lat) = " + Factor.ToString() + Environment.NewLine);
            DLo    = Convert.ToInt32(Departure / Factor * 10f + 0.5d) / 10d;
            IntDLo = (int)(Math.Sign(DLo) * Convert.ToInt32(Math.Abs(DLo) + 0.5d));
            txtSailings.AppendText("7." + g_tab + "Diff Lo = Departure / factor (Mid-Lat)" + Environment.NewLine + "   " + g_tab + g_tab + "= " + Departure.ToString("#0.0") + " / " + Factor.ToString() + Environment.NewLine + "   " + g_tab + g_tab + "= " + DLo.ToString("#0.0") + "' rounded to " + IntDLo.ToString() + "'" + Environment.NewLine);
            if (Conversion.Val(txtCourse.Text) > 0d & Conversion.Val(txtCourse.Text) < 180d)
            {
                IntDLo = -IntDLo;
            }

            PlusMinusStr = " + ";
            if (IntDLo < 0)
            {
                PlusMinusStr = " - ";
            }

            Lo2 = Lo1 + IntDLo / 60d;
            while (Lo2 >= 360d)
            {
                Lo2 = Lo2 - 360d;
            }
            // Crossing IDL
            if (Math.Abs(Lo2) > 180d)
            {
                Lo2 = -Math.Sign(Lo2) * (360d - Math.Abs(Lo2));
            }

            Lo2Deg = (int)Convert.ToInt32(Math.Abs(Lo2));
            Lo2Min = (Math.Abs(Lo2) - Lo2Deg) * 60d;
            Lo2Min = Convert.ToInt32(Lo2Min + 0.5d);
            txtSailings.AppendText("8." + g_tab + "Lo2 = Lo1 (+/-) Diff Lo" + Environment.NewLine + "   " + g_tab + g_tab + "= " + txtLo1Deg.Text + '°' + " " + txtLo1Min.Text + "'" + cboLo1.Text + " " + PlusMinusStr + Math.Abs(IntDLo).ToString() + Environment.NewLine + "   " + g_tab + g_tab + "= " + Strings.Format(Lo2Deg, "0") + '°' + Strings.Format(Lo2Min, "00") + "'");
            if (Math.Abs(Lo2) < 0.01d)
            {
                Lo2 = 0d;
                txtSailings.AppendText("");
            }

            if (Math.Abs(Lo2) > 179.999d)
            {
                txtSailings.AppendText("");
            }
            if (Lo2 > 0d & Math.Abs(Lo2) < 179.999d)
            {
                txtSailings.AppendText(CommonGlobals.g_LongW);
            }

            if (Lo2 < 0d & Math.Abs(Lo2) < 179.999d)
            {
                txtSailings.AppendText(CommonGlobals.g_LongE);
            }

            txtSailings.AppendText(Environment.NewLine);
            txtSailings.AppendText(Environment.NewLine);
            txtSailings.AppendText("Arrival Position" + g_tab + "L2: " + Strings.Format(L2Deg, "0") + '°' + Strings.Format(L2Min, "00") + "'");
            if (Math.Abs(L2) < 0.01d)
            {
                L2 = 0d;
                txtSailings.AppendText("");
            }

            if (L2 > 0d & Math.Abs(L2) > 0.01d)
            {
                txtSailings.AppendText(CommonGlobals.g_LatN);
            }

            if (L2 <0d& Math.Abs(L2)> 0.01d)
            {
                txtSailings.AppendText(CommonGlobals.g_LatS);
            }

            txtSailings.AppendText(g_tab + "Lo2: " + Strings.Format(Lo2Deg, "0") + '°' + Strings.Format(Lo2Min, "00") + "'");
            if (Math.Abs(Lo2) < 0.01d)
            {
                Lo2 = 0d;
                txtSailings.AppendText("");
            }

            if (Math.Abs(Lo2) > 179.999d)
            {
                txtSailings.AppendText("");
            }

            if (Lo2 > 0d & Math.Abs(Lo2) < 179.999d)
            {
                txtSailings.AppendText(CommonGlobals.g_LongW);
            }

            if (Lo2 < 0d & Math.Abs(Lo2) < 179.999d)
            {
                txtSailings.AppendText(CommonGlobals.g_LongE);
            }

            txtTraverseTbl.Clear();
            txtTraverseTbl.AppendText(g_tab + g_tab + g_tab + "Simplified Traverse Table" + Environment.NewLine);
            txtTraverseTbl.AppendText(Strings.Space(5) + "Angle  0" + '°' + Strings.Space(5) + "18" + '°' + Strings.Space(5) + "31" + '°' + Strings.Space(5) + "41" + '°' + Strings.Space(5) + "49" + '°' + Strings.Space(5) + "56" + '°' + Strings.Space(5) + "63" + '°' + Strings.Space(5) + "69" + '°' + Strings.Space(5) + "75" + '°' + Strings.Space(5) + "81" + '°' + Strings.Space(5) + "87" + '°' + Strings.Space(5) + "90" + '°');
            txtTraverseTbl.AppendText(Environment.NewLine);
            txtTraverseTbl.AppendText(Strings.Space(5) + "Factor" + Strings.Space(5) + "1.0" + Strings.Space(6) + "0.9" + Strings.Space(5) + "0.8" + Strings.Space(6) + "0.7" + Strings.Space(5) + "0.6" + Strings.Space(6) + "0.5" + Strings.Space(5) + "0.4" + Strings.Space(6) + "0.3" + Strings.Space(5) + "0.2" + Strings.Space(6) + "0.1" + Strings.Space(5) + "0.0");
            // if txtDist.Text = "" Then
            // txtSailings.AppendText("Distance   " & Format(Distance, "##0.0") & " nm")
            // End If
        }
Ejemplo n.º 4
0
 public CompB(CompC compC)
 {
 }