/// <summary> /// 修改计量单位 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateUnits(MeasureUnits model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update MeasureUnits set "); strSql.Append("UnitCode=@UnitCode,"); strSql.Append("UnitName=@UnitName"); strSql.Append(" where UnitID=@UnitID "); SqlParameter[] parameters = { new SqlParameter("@UnitCode", SqlDbType.VarChar, 30), new SqlParameter("@UnitName", SqlDbType.VarChar, 1024), new SqlParameter("@UnitID", SqlDbType.VarChar, 36) }; parameters[0].Value = model.UnitCode; parameters[1].Value = model.UnitName; parameters[2].Value = model.UnitID; int rows = DBAccess.ExecuteNonQuery(DB.Type, DB.ConnectionString, CommandType.Text, strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public static double GetDistance(DataTable PointList, MeasureUnits units) { double latitudeA = 0, longitudeA = 0, latitudeB = 0, longitudeB = 0, FinalRes = 0; for (int i = 0; i < PointList.Rows.Count - 1; i++) { latitudeA = Convert.ToDouble(PointList.Rows[i]["Latitude"].ToString()); longitudeA = Convert.ToDouble(PointList.Rows[i]["Longitude"].ToString()); latitudeB = Convert.ToDouble(PointList.Rows[i + 1]["Latitude"].ToString()); longitudeB = Convert.ToDouble(PointList.Rows[i + 1]["Longitude"].ToString()); if (latitudeA <= -90 || latitudeA >= 90 || longitudeA <= -180 || longitudeA >= 180 || latitudeB <= -90 && latitudeB >= 90 || longitudeB <= -180 || longitudeB >= 180) { throw new ArgumentException(String.Format("Invalid value point coordinates. Points A({0},{1}) B({2},{3}) ", latitudeA, longitudeA, latitudeB, longitudeB)); } double R = (units == MeasureUnits.Miles) ? 3960 : 6371; double dLat = toRadian(latitudeB - latitudeA); double dLon = toRadian(longitudeB - longitudeA); double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) + Math.Cos(toRadian(latitudeA)) * Math.Cos(toRadian(latitudeB)) * Math.Sin(dLon / 2) * Math.Sin(dLon / 2); double c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a))); double d = R * c; FinalRes += d; } return(FinalRes); }
//inches, cm, mm, pixels private void UpdateSize() { switch (projectWidthProperty.SelectedIndex) { case 0: ProjectWidth = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectWidth, currentMeasureUnit, MeasureUnits.inch), 2); ProjectHeight = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectHeight, currentMeasureUnit, MeasureUnits.inch), 2); currentMeasureUnit = MeasureUnits.inch; break; case 1: ProjectWidth = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectWidth, currentMeasureUnit, MeasureUnits.cm), 2); ProjectHeight = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectHeight, currentMeasureUnit, MeasureUnits.cm), 2); currentMeasureUnit = MeasureUnits.cm; break; case 2: ProjectWidth = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectWidth, currentMeasureUnit, MeasureUnits.mm), 2); ProjectHeight = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectHeight, currentMeasureUnit, MeasureUnits.mm), 2); currentMeasureUnit = MeasureUnits.mm; break; case 3: ProjectWidth = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectWidth, currentMeasureUnit, MeasureUnits.pixel), 0); ProjectHeight = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectHeight, currentMeasureUnit, MeasureUnits.pixel), 0); currentMeasureUnit = MeasureUnits.pixel; break; } }
private void InitializeGoods() { Goods = new ObservableCollection <Good>(); MeasureUnit measureUnit = MeasureUnits.First(x => x.Id == 2); Goods.Add(new Good() { Id = 1, Code = "1", Name = "Nokia N900 32GB internal storage", BarCode = "4155474899", MeasureUnitId = measureUnit.Id, MeasureUnit = measureUnit }); Goods.Add(new Good() { Id = 2, Code = "2", Name = "Nokia N91 4gb", BarCode = "2346767", MeasureUnitId = measureUnit.Id, MeasureUnit = measureUnit }); Goods.Add(new Good() { Id = 3, Code = "3", Name = "Nokia N82", BarCode = "98654", MeasureUnitId = measureUnit.Id, MeasureUnit = measureUnit }); }
// <summary> /// Inserts the Node in the diagram at given location /// </summary> /// <param name="nNodeIndex">index of the node</param> /// <param name="ptLocation">Location of the node</param> /// <returns></returns> private Node InsertNode(Node node, PointF ptLocation) { m_list = new ArrayList(); // Perform Matrix transformation MeasureUnits units = MeasureUnits.Pixel; SizeF szPinOffset = ((IUnitIndependent)node).GetPinPointOffset(units); ptLocation.X += szPinOffset.Width; ptLocation.Y += szPinOffset.Height; ((IUnitIndependent)node).SetPinPoint(ptLocation, units); //Append the nodes to the drawing area this.diagram1.Model.AppendChild(node); if (node.Name.StartsWith("M")) { this.managers.Add(node); //Adds tag information for nodes managerCount = managerCount + 1; int managerCode = managerCount + 100; m_list.AddRange(new string[] { managerCode.ToString(), projectName[managerCount] }); node.Tag = m_list; } else { this.employees.Add(node); //Adds tag information for nodes employeeCount = employeeCount + 1; int employeeCode = employeeCount + 1000; m_list.AddRange(new string[] { employeeCode.ToString(), employeeName[employeeCount], designation[employeeCount] }); node.Tag = m_list; } return(node); }
/// <summary> /// This will do conversion between units /// </summary> /// <param name="value"></param> /// <param name="sourceUnit"></param> /// <param name="resultingUnit"></param> /// <returns></returns> public float ConvertUnit(float value, MeasureUnits sourceUnit, MeasureUnits resultingUnit) { Initialize(this.resolution, this.resolutionMeasure); float rate = conversionTable[sourceUnit][resultingUnit]; return((float)Math.Round((double)(value * rate), 3)); }
private void InitializeRectangle(System.Drawing.RectangleF rectBounds, MeasureUnits measureUnits) { this.Labels.Add(lblRowText); lblRowText.FontStyle.Family = "Arial"; lblRowText.FontStyle.Size = 8; lblRowText.OffsetX = 55; lblRowText.OffsetY = 5; }
public void SetRulersUnit(MeasureUnits unit) { Ruler tmpRuler = (Ruler)topRuler; tmpRuler.MeasureUnit = unit; tmpRuler = (Ruler)leftRuler; tmpRuler.MeasureUnit = unit; tmpRuler = (Ruler)guideRuler; tmpRuler.MeasureUnit = unit; RefreshView(); }
/// <summary> /// Inserts the node /// </summary> /// <param name="node">Node</param> /// <param name="ptPinPoint">Node's Location</param> /// <returns>returns the node</returns> private Node InsertNode(Node node, PointF ptPinPoint) { MeasureUnits units = MeasureUnits.Pixel; SizeF szPinOffset = ((IUnitIndependent)node).GetPinPointOffset(units); ptPinPoint.X += szPinOffset.Width; ptPinPoint.Y += szPinOffset.Height; ((IUnitIndependent)node).SetPinPoint(ptPinPoint, units); node.EnableCentralPort = true; this.diagram1.Model.AppendChild(node); return(node); }
private string GetUnits(MeasureUnits units) { switch (units) { case MeasureUnits.Celsium: return "metric"; case MeasureUnits.Fahrenheit: return "imperial"; default: return "metric"; } }
/// <summary> /// Inserts the node into the diagram at given location /// </summary> /// <param name="node">Node</param> /// <param name="ptLocation">Node's Location</param> /// <returns></returns> private Node InsertNode(Node node, PointF ptLocation) { MeasureUnits units = MeasureUnits.Pixel; SizeF szPinOffset = ((IUnitIndependent)node).GetPinPointOffset(units); ptLocation.X += szPinOffset.Width; ptLocation.Y += szPinOffset.Height; ((IUnitIndependent)node).SetPinPoint(ptLocation, units); this.diagram1.Model.AppendChild(node); return(node); }
public List <ShippingOption> GetShippingOptions() { try { _weight = MeasureUnits.ConvertWeight(ShoppingCart.TotalShippingWeight, MeasureUnits.WeightUnit.Kilogramm, MeasureUnits.WeightUnit.Pound); _isDomenic = CountryToIso2.ToUpper().Trim() == "US"; return(GetShippingOption()); } catch (Exception ex) { Debug.LogError(ex); return(new List <ShippingOption>()); } }
/// <summary> /// Calculates the approximate birds-flight distance between this coordinate and the coordinate in the parameter /// </summary> /// <param name="coordinate">The coordinate.</param> /// <param name="units">The units to measure in</param> /// <returns></returns> public double DistanceFrom(Coordinate coordinate, MeasureUnits units) { double earthRadius = (units == MeasureUnits.Miles) ? 3960 : 6371; double dLat = Deg2Rad(coordinate.Latitude - Latitude); double dLon = Deg2Rad(coordinate.Longitude - Longitude); double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) + Math.Cos(Deg2Rad(Latitude)) * Math.Cos(Deg2Rad(coordinate.Latitude)) * Math.Sin(dLon / 2) * Math.Sin(dLon / 2); double c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a))); double d = earthRadius * c; return d; }
public string UnitToString(MeasureUnits unit) { switch (unit) { case MeasureUnits.point: return("pt"); case MeasureUnits.mm: return("mm"); case MeasureUnits.cm: return("cm"); case MeasureUnits.inch: return("in"); case MeasureUnits.pixel: return("px"); default: return(""); } }
/// <summary> /// Returns the distance in miles or kilometers of any two /// latitude / longitude points. (Haversine formula) /// </summary> public static double Distance(double latitudeA, double longitudeA, double latitudeB, double longitudeB, MeasureUnits units, int decimalPoints = 2) { if (latitudeA <= -90 || latitudeA >= 90 || longitudeA <= -180 || longitudeA >= 180 || latitudeB <= -90 && latitudeB >= 90 || longitudeB <= -180 || longitudeB >= 180) { throw new ArgumentException( $"Invalid value point coordinates. Points A({latitudeA},{longitudeA}) B({latitudeB},{longitudeB}) "); } double R = (units == MeasureUnits.Miles) ? 3960 : 6371; var dLat = ToRadian(latitudeB - latitudeA); var dLon = ToRadian(longitudeB - longitudeA); var a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) + Math.Cos(ToRadian(latitudeA)) * Math.Cos(ToRadian(latitudeB)) * Math.Sin(dLon / 2) * Math.Sin(dLon / 2); var c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a))); var d = R * c; return Math.Round(d, decimalPoints); }
/// <summary> /// Insert the node into the diagram /// </summary> /// <param name="node">Node</param> /// <param name="ptLocation">Node's location</param> /// <returns></returns> private Node InsertNode(Node node, PointF ptLocation) { MeasureUnits units = MeasureUnits.Pixel; SizeF szPinOffset = ((IUnitIndependent)node).GetPinPointOffset(units); ptLocation.X += szPinOffset.Width; ptLocation.Y += szPinOffset.Height; ((IUnitIndependent)node).SetPinPoint(ptLocation, units); if (node.Name == "ClockHead" && node is Group) { if (((Group)node).Nodes[0] is FilledPath) { ((FilledPath)((Group)node).Nodes[0]).FillStyle.Color = ColorTranslator.FromHtml("#FF119EDA"); } if (((Group)node).Nodes[1] is FilledPath) { ((FilledPath)((Group)node).Nodes[1]).FillStyle.Color = ColorTranslator.FromHtml("#FF96D3ED"); } } if (node.Name == "CenterPiece" && node is Group) { if (((Group)node).Nodes[0] is FilledPath) { ((FilledPath)((Group)node).Nodes[0]).FillStyle.Color = ColorTranslator.FromHtml("#FF96D3ED"); } if (((Group)node).Nodes[1] is FilledPath) { ((FilledPath)((Group)node).Nodes[1]).FillStyle.Color = ColorTranslator.FromHtml("#FF119EDA"); } } if (node.Name == "Seconds") { if (node is FilledPath) { ((FilledPath)node).FillStyle.Color = ColorTranslator.FromHtml("#FF119EDA"); } } this.diagram1.Model.AppendChild(node); return(node); }
/// <summary> /// 添加计量单位 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddUnits(MeasureUnits model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into MeasureUnits("); strSql.Append("UnitID,UnitCode,UnitName)"); strSql.Append(" values ("); strSql.Append("@UnitID,@UnitCode,@UnitName)"); SqlParameter[] parameters = { new SqlParameter("@UnitID", SqlDbType.VarChar, 36), new SqlParameter("@UnitCode", SqlDbType.VarChar, 30), new SqlParameter("@UnitName", SqlDbType.VarChar, 1024) }; parameters[0].Value = model.UnitID; parameters[1].Value = model.UnitCode; parameters[2].Value = model.UnitName; return(DBAccess.ExecuteNonQuery(DB.Type, DB.ConnectionString, CommandType.Text, strSql.ToString(), parameters)); }
/// <summary> /// 获取计量单位List /// </summary> /// <returns></returns> public IList <MeasureUnits> GetMeasureUnitsList() { try { StringBuilder strSql = new StringBuilder(); strSql.Append(" select * from MeasureUnits "); IList <MeasureUnits> list = new List <MeasureUnits>(); DataSet ds = DBAccess.ExecuteDataset(DB.Type, DB.ConnectionString, CommandType.Text, strSql.ToString(), null); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { MeasureUnits unit = new MeasureUnits(); if (dr["UnitID"] != null && dr["UnitID"].ToString() != "") { unit.UnitID = dr["UnitID"].ToString(); } if (dr["UnitCode"] != null && dr["UnitCode"].ToString() != "") { unit.UnitCode = dr["UnitCode"].ToString(); } if (dr["UnitName"] != null && dr["UnitName"].ToString() != "") { unit.UnitName = dr["UnitName"].ToString(); } list.Add(unit); } } return(list); } catch (Exception ex) { throw ex; } finally { // } }
private void InitializeRectangle(System.Drawing.RectangleF rectBounds, MeasureUnits measureUnits) { this.Labels.Add(lblClassName); lblClassName.FontStyle.Family = "Arial"; lblClassName.FontStyle.Size = 8; lblClassName.FontStyle.Bold = true; lblClassName.OffsetX = 10; lblClassName.OffsetY = 5; this.Labels.Add(lblClassType); lblClassType.FontStyle.Family = "Arial"; lblClassType.FontStyle.Size = 8; lblClassType.OffsetX = 10; lblClassType.OffsetY = 25; this.Labels.Add(lblObjectType); lblObjectType.FontStyle.Family = "Arial"; lblObjectType.FontStyle.Size = 7; lblObjectType.OffsetX = 10; lblObjectType.OffsetY = 45; this.LineStyle.LineWidth = 0; }
/// <summary> /// Returns the distance in miles or kilometers of any two /// latitude / longitude points. (Haversine formula) /// </summary> public static double Distance(double latitudeA, double longitudeA, double latitudeB, double longitudeB, MeasureUnits units) { if (latitudeA <= -90 || latitudeA >= 90 || longitudeA <= -180 || longitudeA >= 180 || latitudeB <= -90 && latitudeB >= 90 || longitudeB <= -180 || longitudeB >= 180) { throw new ArgumentException(String.Format("Invalid value point coordinates. Points A({0},{1}) B({2},{3}) ", latitudeA, longitudeA, latitudeB, longitudeB)); } double R = (units == MeasureUnits.Miles) ? 3960 : 6371; double dLat = toRadian(latitudeB - latitudeA); double dLon = toRadian(longitudeB - longitudeA); double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) + Math.Cos(toRadian(latitudeA)) * Math.Cos(toRadian(latitudeB)) * Math.Sin(dLon / 2) * Math.Sin(dLon / 2); double c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a))); double d = R * c; return d; }
/// <summary> /// Insert Node into the diagram /// </summary> /// <param name="node">Node</param> /// <param name="ptPinPoint">Node's Location</param> /// <param name="layer">Layer</param> /// <returns>returns the node</returns> private Node InsertNode(Node node, PointF ptPinPoint, Layer layer) { MeasureUnits units = MeasureUnits.Pixel; SizeF szPinOffset = ((IUnitIndependent)node).GetPinPointOffset(units); ptPinPoint.X += szPinOffset.Width; ptPinPoint.Y += szPinOffset.Height; ((IUnitIndependent)node).SetPinPoint(ptPinPoint, units); node.EnableCentralPort = true; node.ShadowStyle.Visible = false; this.diagram1.Model.AppendChild(node); if (layer != null) { layer.Nodes.Add(node); node.Layers.Add(layer); } return(node); }
/// <summary> /// 获取计量单位模型 /// </summary> /// <param name="UnitID"></param> /// <returns></returns> public MeasureUnits GetModel(string UnitID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 UnitID,UnitCode,UnitName from MeasureUnits "); strSql.Append(" where UnitID=@UnitID "); SqlParameter[] parameters = { new SqlParameter("@UnitID", SqlDbType.VarChar, 36) }; parameters[0].Value = UnitID; MeasureUnits model = new MeasureUnits(); DataSet ds = DBAccess.ExecuteDataset(DB.Type, DB.ConnectionString, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["UnitID"] != null && ds.Tables[0].Rows[0]["UnitID"].ToString() != "") { model.UnitID = ds.Tables[0].Rows[0]["UnitID"].ToString(); } if (ds.Tables[0].Rows[0]["UnitCode"] != null && ds.Tables[0].Rows[0]["UnitCode"].ToString() != "") { model.UnitCode = ds.Tables[0].Rows[0]["UnitCode"].ToString(); } if (ds.Tables[0].Rows[0]["UnitName"] != null && ds.Tables[0].Rows[0]["UnitName"].ToString() != "") { model.UnitName = ds.Tables[0].Rows[0]["UnitName"].ToString(); } return(model); } else { return(null); } }
private bool CheckNewPinOffset(SizeF szPinOffset, MeasureUnits unit) { SizeF pinOffset = this.BoundsInfo.GetPinOffset(unit); bool flag = pinOffset != szPinOffset; if (!flag && (szPinOffset.Width <= 0f)) { flag = false; } if (!flag && (szPinOffset.Height <= 0f)) { flag = false; } if (flag && (pinOffset.Width != szPinOffset.Width)) { flag = EditStyle.CanMoveX(this); } if (flag && (pinOffset.Height != szPinOffset.Height)) { flag = EditStyle.CanMoveY(this); } if (flag) { PointF pinPoint = this.BoundsInfo.GetPinPoint(unit); SizeF size = this.BoundsInfo.GetSize(unit); float fAngle = Geometry.ConvertToFullCircle(this.RotationAngle); Matrix matrix = this.GetTransformations(pinPoint, szPinOffset, fAngle); this.AppendFlipTransforms(matrix, pinPoint, this.FlipX, this.FlipY); flag = this.CheckConstrainingRegion(matrix, pinPoint, size); } return flag; }
public decimal GetRate(decimal weight, MeasureUnits.WeightUnit unit) { return(GetRate(MeasureUnits.ConvertWeight(weight, unit, MeasureUnits.WeightUnit.Kilogramm))); }
/// <summary> /// Returns the distance in miles or kilometers of any two /// latitude / longitude points. (Haversine formula) /// </summary> public static double GetDistance(double latitudeA, double longitudeA, double latitudeB, double longitudeB, MeasureUnits units) { if (latitudeA <= -90 || latitudeA >= 90 || longitudeA <= -180 || longitudeA >= 180 || latitudeB <= -90 && latitudeB >= 90 || longitudeB <= -180 || longitudeB >= 180) { throw new ArgumentException(String.Format("Invalid value point coordinates. Points A({0},{1}) B({2},{3}) ", latitudeA, longitudeA, latitudeB, longitudeB)); } double R = (units == MeasureUnits.Miles) ? 3960 : 6371; double dLat = toRadian(latitudeB - latitudeA); double dLon = toRadian(longitudeB - longitudeA); double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) + Math.Cos(toRadian(latitudeA)) * Math.Cos(toRadian(latitudeB)) * Math.Sin(dLon / 2) * Math.Sin(dLon / 2); double c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a))); double d = R * c; return(d); }
// Letter, Legal, Tabloid, 640x480, 800x600, 1024x768, A4, A3, B5, B4, B3 private void projectSizeProperty_SelectedIndexChanged(object sender, EventArgs e) { customEnabled = false; switch (projectSizeProperty.SelectedIndex) { case 1: projectWidthProperty.SelectedIndex = 0; projectHeightProperty.SelectedIndex = 0; currentMeasureUnit = MeasureUnits.inch; ProjectWidth = 8.5F; ProjectHeight = 11.0F; break; case 2: projectWidthProperty.SelectedIndex = 0; projectHeightProperty.SelectedIndex = 0; currentMeasureUnit = MeasureUnits.inch; ProjectWidth = 8.5F; ProjectHeight = 14.0F; break; case 3: projectWidthProperty.SelectedIndex = 0; projectHeightProperty.SelectedIndex = 0; currentMeasureUnit = MeasureUnits.inch; ProjectWidth = 11.0F; ProjectHeight = 17.0F; break; case 4: projectWidthProperty.SelectedIndex = 3; projectHeightProperty.SelectedIndex = 3; currentMeasureUnit = MeasureUnits.pixel; ProjectWidth = 640.0F; ProjectHeight = 480.0F; break; case 5: projectWidthProperty.SelectedIndex = 3; projectHeightProperty.SelectedIndex = 3; currentMeasureUnit = MeasureUnits.pixel; ProjectWidth = 800.0F; ProjectHeight = 600.0F; break; case 6: projectWidthProperty.SelectedIndex = 3; projectHeightProperty.SelectedIndex = 3; currentMeasureUnit = MeasureUnits.pixel; ProjectWidth = 1024.0F; ProjectHeight = 768.0F; break; case 7: projectWidthProperty.SelectedIndex = 2; projectHeightProperty.SelectedIndex = 2; currentMeasureUnit = MeasureUnits.mm; ProjectWidth = 210.0F; ProjectHeight = 297.0F; break; case 8: projectWidthProperty.SelectedIndex = 2; projectHeightProperty.SelectedIndex = 2; currentMeasureUnit = MeasureUnits.mm; ProjectWidth = 297.0F; ProjectHeight = 420.0F; break; case 9: projectWidthProperty.SelectedIndex = 2; projectHeightProperty.SelectedIndex = 2; currentMeasureUnit = MeasureUnits.mm; ProjectWidth = 176.0F; ProjectHeight = 250.0F; break; case 10: projectWidthProperty.SelectedIndex = 2; projectHeightProperty.SelectedIndex = 2; currentMeasureUnit = MeasureUnits.mm; ProjectWidth = 250.0F; ProjectHeight = 353.0F; break; case 11: projectWidthProperty.SelectedIndex = 2; projectHeightProperty.SelectedIndex = 2; currentMeasureUnit = MeasureUnits.mm; ProjectWidth = 353.0F; ProjectHeight = 500.0F; break; } }
public static double Distance(GeoLocation from, GeoLocation to, MeasureUnits units, int decimalPoints = 2) { return(Distance(from.Latitude, from.Longitude, to.Latitude, to.Longitude, units, decimalPoints)); }
public static double Distance(GeoPoint from, GeoPoint to, MeasureUnits units, int decimalPoints = 2) { return Distance(from.Latitude, from.Longitude, to.Latitude, to.Longitude, units, decimalPoints); }
SizeF IUnitIndependent.GetPinPointOffset(MeasureUnits unit) { return this.BoundsInfo.GetPinOffset(unit); }
RectangleF IUnitIndependent.GetBoundingRectangle(MeasureUnits unit, bool bRelativeToModel) { if (bRelativeToModel) { RectangleF pathBounds = this.GetPathBounds(); PointF[] pts = new PointF[] { pathBounds.Location, new PointF(pathBounds.X + pathBounds.Width, pathBounds.Y), new PointF(pathBounds.Right, pathBounds.Bottom), new PointF(pathBounds.X, pathBounds.Y + pathBounds.Height) }; HandlesHitTesting.GetParentsTransformations(this, true).TransformPoints(pts); return Geometry.CreateRect(pts); } return MeasureUnitsConverter.FromPixels(this.BoundingRect, unit); }
/// <summary> /// This will do conversion between units /// </summary> /// <param name="value"></param> /// <param name="sourceUnit"></param> /// <param name="resultingUnit"></param> /// <returns></returns> public float ConvertUnit(float value, MeasureUnits sourceUnit, MeasureUnits resultingUnit) { Initialize(this.resolution, this.resolutionMeasure); float rate = conversionTable[sourceUnit][resultingUnit]; return (float)Math.Round((double)(value*rate), 3); }
private void UpdateGridOptions() { if((gridInterval != AppOptions.Instance.GridInterval) || (this.subdivisions != AppOptions.Instance.GridSubdivisions)) { gridInterval = AppOptions.Instance.GridInterval; subdivisions = AppOptions.Instance.GridSubdivisions; MakeAllLines(); } majorLinePen.Color = AppOptions.Instance.GridColor; minorLinePen.Color = AppOptions.Instance.GridColor; switch (AppOptions.Instance.GridLineStyle) { case 0: LineStyle = System.Drawing.Drawing2D.DashStyle.Solid; break; case 1: LineStyle = System.Drawing.Drawing2D.DashStyle.Dash; break; case 2: LineStyle = System.Drawing.Drawing2D.DashStyle.Dot; break; } switch (AppOptions.Instance.GridUnit) { case 0: Unit = MeasureUnits.inch; break; case 1: Unit = MeasureUnits.cm; break; case 2: Unit = MeasureUnits.mm; break; case 3: Unit = MeasureUnits.pixel; break; } }
public string UnitToString(MeasureUnits unit) { switch (unit) { case MeasureUnits.point: return "pt"; case MeasureUnits.mm: return "mm"; case MeasureUnits.cm: return "cm"; case MeasureUnits.inch: return "in"; case MeasureUnits.pixel: return "px"; default: return ""; } }
/// <summary> /// 添加计量单位 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddUnits(MeasureUnits model) { return(iMeasureUnitsDAL.AddUnits(model)); }
private RateRequest CreateRateRequest(RateService rate) { RateRequest rateRequest = new RateRequest(); UPSSecurity upss = new UPSSecurity(); UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken(); upssSvcAccessToken.AccessLicenseNumber = AccessKey; upss.ServiceAccessToken = upssSvcAccessToken; UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken(); upssUsrNameToken.Username = UserName; upssUsrNameToken.Password = Password; upss.UsernameToken = upssUsrNameToken; rate.UPSSecurityValue = upss; RequestType request = new RequestType(); String[] requestOption = { "Shop" }; request.RequestOption = requestOption; rateRequest.Request = request; ShipmentType shipment = new ShipmentType(); ShipperType shipper = new ShipperType(); //shipper.ShipperNumber = "ISUS01"; AddressType shipperAddress = new AddressType(); String[] addressLine = { "Shipper\'s address line" }; shipperAddress.AddressLine = addressLine; shipperAddress.City = "Shipper\'s city"; shipperAddress.PostalCode = PostalCodeFrom; //shipperAddress.StateProvinceCode = UpsItem.CountryCode; shipperAddress.CountryCode = CountryCodeFrom; shipperAddress.AddressLine = addressLine; shipper.Address = shipperAddress; shipment.Shipper = shipper; ShipFromType shipFrom = new ShipFromType(); AddressType shipFromAddress = new AddressType(); shipFromAddress.AddressLine = addressLine; shipFromAddress.City = "ShipFrom city"; shipFromAddress.PostalCode = PostalCodeFrom; //shipFromAddress.StateProvinceCode = "GA"; shipFromAddress.CountryCode = CountryCodeFrom; shipFrom.Address = shipFromAddress; shipment.ShipFrom = shipFrom; ShipToType shipTo = new ShipToType(); ShipToAddressType shipToAddress = new ShipToAddressType(); String[] addressLine1 = { AddressTo }; shipToAddress.AddressLine = addressLine1; shipToAddress.City = CityTo; shipToAddress.PostalCode = PostalCodeTo; shipToAddress.StateProvinceCode = StateTo; shipToAddress.CountryCode = CountryCodeTo; shipTo.Address = shipToAddress; shipment.ShipTo = shipTo; //CodeDescriptionType service = new CodeDescriptionType(); //service.Code = "02"; //shipment.Service = service; float weight = MeasureUnits.ConvertWeight(ShoppingCart.TotalShippingWeight, MeasureUnits.WeightUnit.Kilogramm, MeasureUnits.WeightUnit.Pound); var data = new List <PackageType>(); if (!IsPackageTooHeavy(weight)) { PackageType package = new PackageType(); PackageWeightType packageWeight = new PackageWeightType(); packageWeight.Weight = weight.ToString("F3").Replace(',', '.'); CodeDescriptionType uom = new CodeDescriptionType(); uom.Code = "LBS"; uom.Description = "Pounds"; packageWeight.UnitOfMeasurement = uom; package.PackageWeight = packageWeight; CodeDescriptionType packType = new CodeDescriptionType(); packType.Code = "02"; package.PackagingType = packType; data.Add(package); } else { int totalPackages = 1; int totalPackagesWeights = 1; if (IsPackageTooHeavy(weight)) { totalPackagesWeights = SQLDataHelper.GetInt(Math.Ceiling(weight / MaxPackageWeight)); } totalPackages = totalPackagesWeights; if (totalPackages == 0) { totalPackages = 1; } float weight2 = weight / totalPackages; if (weight2 < 1) { weight2 = 1; } for (int i = 0; i < totalPackages; i++) { PackageType package = new PackageType(); PackageWeightType packageWeight = new PackageWeightType(); packageWeight.Weight = weight2.ToString("F3"); CodeDescriptionType uom = new CodeDescriptionType(); uom.Code = "LBS"; uom.Description = "Pounds"; packageWeight.UnitOfMeasurement = uom; package.PackageWeight = packageWeight; CodeDescriptionType packType = new CodeDescriptionType(); packType.Code = GetPackagingTypeCode(PackagingType); package.PackagingType = packType; data.Add(package); } } PackageType[] pkgArray = data.ToArray(); shipment.Package = pkgArray; rateRequest.Shipment = shipment; CodeDescriptionType pckup = new CodeDescriptionType() { Code = GetPickupTypeCode(PickupType) }; rateRequest.PickupType = pckup; CodeDescriptionType ccustomer = new CodeDescriptionType() { Code = GetCustomerClassificationCode(CustomerType) }; rateRequest.CustomerClassification = ccustomer; System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); return(rateRequest); }
public float GetRate(float weight, MeasureUnits.WeightUnit unit) { return(GetRate(MeasureUnits.ConvertWeight(weight, unit, MeasureUnits.WeightUnit.Kilogramm))); }
SizeF IUnitIndependent.GetSize(MeasureUnits unit) { return this.BoundsInfo.GetSize(unit); }
public static double convertToMiKM(double amt, MeasureUnits units) { double R = (units == MeasureUnits.Miles) ? 3960 : 6371; double d = R * amt; return d; }
void IUnitIndependent.SetPinPoint(PointF ptValue, MeasureUnits unit) { this.SetPinPoint(ptValue, unit); }
/// <summary> /// Returns the distance in miles or kilometers of any two /// latitude / longitude points. (Haversine formula) /// </summary> public static double Distance(double latitudeA, double longitudeA, double latitudeB, double longitudeB, MeasureUnits units, int decimalPoints = 2) { if (latitudeA <= -90 || latitudeA >= 90 || longitudeA <= -180 || longitudeA >= 180 || latitudeB <= -90 && latitudeB >= 90 || longitudeB <= -180 || longitudeB >= 180) { throw new ArgumentException( $"Invalid value point coordinates. Points A({latitudeA},{longitudeA}) B({latitudeB},{longitudeB}) "); } double R = (units == MeasureUnits.Miles) ? 3960 : 6371; var dLat = ToRadian(latitudeB - latitudeA); var dLon = ToRadian(longitudeB - longitudeA); var a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) + Math.Cos(ToRadian(latitudeA)) * Math.Cos(ToRadian(latitudeB)) * Math.Sin(dLon / 2) * Math.Sin(dLon / 2); var c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a))); var d = R * c; return(Math.Round(d, decimalPoints)); }
void IUnitIndependent.SetPinPointOffset(SizeF szValue, MeasureUnits unit) { if (this.CheckNewPinOffset(szValue, unit)) { this.BoundsInfo.SetPinOffset(szValue, unit); this.UpdateBoundingRectangle(); } }
void IUnitIndependent.SetSize(SizeF szValue, MeasureUnits unit) { if (this.CheckNewSize(szValue, unit)) { this.BoundsInfo.SetSize(szValue, unit); this.UpdateBoundingRectangle(); if (this.Parent != null) { this.Parent.UpdateCompositeBounds(); } } }
//inches, cm, mm, pixels private void UpdateSize() { switch (projectWidthProperty.SelectedIndex) { case 0: ProjectWidth = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectWidth, currentMeasureUnit, MeasureUnits.inch),2); ProjectHeight = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectHeight, currentMeasureUnit, MeasureUnits.inch),2); currentMeasureUnit = MeasureUnits.inch; break; case 1: ProjectWidth = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectWidth, currentMeasureUnit, MeasureUnits.cm),2); ProjectHeight = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectHeight, currentMeasureUnit, MeasureUnits.cm),2); currentMeasureUnit = MeasureUnits.cm; break; case 2: ProjectWidth = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectWidth, currentMeasureUnit, MeasureUnits.mm),2); ProjectHeight = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectHeight, currentMeasureUnit, MeasureUnits.mm), 2); currentMeasureUnit = MeasureUnits.mm; break; case 3: ProjectWidth = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectWidth, currentMeasureUnit, MeasureUnits.pixel),0); ProjectHeight = (float)System.Math.Round(UnitsManager.Instance.ConvertUnit(ProjectHeight, currentMeasureUnit, MeasureUnits.pixel),0); currentMeasureUnit = MeasureUnits.pixel; break; } }
// https://sentinel2.luxoft.com/sen/issues/browse/PMEDIAINFOVISDEV-733 protected override void SetPinPoint(PointF ptValue, MeasureUnits unit) { SizeF size = this.BoundsInfo.GetSize(unit); SizeF offset = this.BoundsInfo.GetPinOffset(unit); if (ptValue.X - offset.Width < -size.Width) ptValue.X = -size.Width + offset.Width; if (ptValue.Y - offset.Height < -size.Height) ptValue.Y = -size.Height + offset.Height; Syncfusion.Windows.Forms.Diagram.Model model = this.Root; if (model != null) { size = MeasureUnitsConverter.Convert(model.LogicalSize, model.MeasurementUnits, unit); if (ptValue.X - offset.Width > size.Width) ptValue.X = size.Width + offset.Width; if (ptValue.Y - offset.Height > size.Height) ptValue.Y = size.Height + offset.Height; } base.SetPinPoint(ptValue, unit); }
/// <summary> /// 修改计量单位 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateUnits(MeasureUnits model) { return(iMeasureUnitsDAL.UpdateUnits(model)); }
private bool CheckNewSize(SizeF szSize, MeasureUnits unit) { SizeF size = this.BoundsInfo.GetSize(unit); bool flag = size != szSize; if (!flag && (szSize.Width <= 0f)) { flag = false; } if (!flag && (szSize.Height <= 0f)) { flag = false; } if (flag && (size.Height != szSize.Height)) { flag = EditStyle.CanChangeHeight(this); } if (flag && (size.Width != szSize.Width)) { flag = EditStyle.CanChangeWidth(this); } if (flag) { PointF pinPoint = this.BoundsInfo.GetPinPoint(unit); SizeF pinOffset = this.BoundsInfo.GetPinOffset(unit); SizeF ef3 = this.BoundsInfo.GetSize(unit); float fAngle = Geometry.ConvertToFullCircle(this.RotationAngle); float num2 = (ef3.Width != 0f) ? (pinOffset.Width / ef3.Width) : 1f; float num3 = (ef3.Height != 0f) ? (pinOffset.Height / ef3.Height) : 1f; SizeF szPinOffset = new SizeF(szSize.Width * num2, szSize.Height * num3); Matrix matrix = this.GetTransformations(pinPoint, szPinOffset, fAngle); this.AppendFlipTransforms(matrix, pinPoint, this.FlipX, this.FlipY); flag = this.CheckConstrainingRegion(matrix, pinPoint, szSize); } return flag; }