public override void WriteGroupCodes() { int flags; WriteGroupCodeValue(10, X0.ToString().Trim()); WriteGroupCodeValue(20, Y0.ToString().Trim()); WriteGroupCodeValue(30, Z0.ToString().Trim()); WriteGroupCodeValue(11, X1.ToString().Trim()); WriteGroupCodeValue(21, Y1.ToString().Trim()); WriteGroupCodeValue(31, Z1.ToString().Trim()); WriteGroupCodeValue(12, X2.ToString().Trim()); WriteGroupCodeValue(22, Y2.ToString().Trim()); WriteGroupCodeValue(32, Z2.ToString().Trim()); WriteGroupCodeValue(13, X3.ToString().Trim()); WriteGroupCodeValue(23, Y3.ToString().Trim()); WriteGroupCodeValue(33, Z3.ToString().Trim()); flags = 0; if(Edge1Invisible) flags += 1; if(Edge2Invisible) flags += 2; if(Edge3Invisible) flags += 4; if(Edge4Invisible) flags += 8; WriteGroupCodeValue(70, flags.ToString().Trim()); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = 41; hashCode = hashCode * 59 + Type.GetHashCode(); hashCode = hashCode * 59 + Barcode1DSymbology.GetHashCode(); if (Data != null) { hashCode = hashCode * 59 + Data.GetHashCode(); } hashCode = hashCode * 59 + X1.GetHashCode(); hashCode = hashCode * 59 + X2.GetHashCode(); hashCode = hashCode * 59 + X3.GetHashCode(); hashCode = hashCode * 59 + X4.GetHashCode(); hashCode = hashCode * 59 + Y1.GetHashCode(); hashCode = hashCode * 59 + Y2.GetHashCode(); hashCode = hashCode * 59 + Y3.GetHashCode(); hashCode = hashCode * 59 + Y4.GetHashCode(); hashCode = hashCode * 59 + BboxLeftInches.GetHashCode(); hashCode = hashCode * 59 + BboxTopInches.GetHashCode(); hashCode = hashCode * 59 + BboxWidthInches.GetHashCode(); hashCode = hashCode * 59 + BboxHeightInches.GetHashCode(); hashCode = hashCode * 59 + PageNumber.GetHashCode(); hashCode = hashCode * 59 + PagePixelWidth.GetHashCode(); hashCode = hashCode * 59 + PagePixelHeight.GetHashCode(); hashCode = hashCode * 59 + PageHorizontalResolution.GetHashCode(); hashCode = hashCode * 59 + PageVerticalResolution.GetHashCode(); return(hashCode); } }
public static void SaveLog(int itemIndex, string runResult) { //创建文件夹 if (!Directory.Exists(logDir)) { Directory.CreateDirectory(logDir); } var lineVals = new List <string> { DateTime.Now.ToString("HH:mm:ss"), X1.ToString("f3"), X2.ToString("f3"), Y1.ToString("f3"), Y2.ToString("f3"), angle.ToString("f3"), runResult, itemIndex.ToString(), " ", X1_pixel.ToString("f3"), X2_pixel.ToString("f3"), Y1_pixel.ToString("f3"), Y2_pixel.ToString("f3"), angleUncalib.ToString("f3") }; var line = string.Join(",", lineVals); try { csvFile = dataLogger.WriteLine(line); } catch { MessageBox.Show("请关闭所有CCD软件产生的文档"); } removeOutdatedFiles(logDir); }
public override IEnumerable <SvgAttribute> GetAttributes() { var baseAttributes = base.GetAttributes(); if (baseAttributes != null) { foreach (var attr in baseAttributes) { yield return(attr); } } var ci = CultureInfo.InvariantCulture; yield return(new SvgAttribute("x1", "0", () => X1.ToString(ci), v => X1 = SvgAttribute.ParseFloatAttribute(v) )); yield return(new SvgAttribute("y1", "0", () => Y1.ToString(ci), v => Y1 = SvgAttribute.ParseFloatAttribute(v) )); yield return(new SvgAttribute("x2", "0", () => X2.ToString(ci), v => X2 = SvgAttribute.ParseFloatAttribute(v) )); yield return(new SvgAttribute("y2", "0", () => Y2.ToString(ci), v => Y2 = SvgAttribute.ParseFloatAttribute(v) )); yield return(new SvgAttribute("stroke-width", () => StrokeWidth.ToString(ci), v => StrokeWidth = SvgAttribute.ParseFloatAttribute(v) )); yield return(new SvgAttribute("stroke", () => Stroke == Color.Empty ? "none" : ColorTranslator.ToSvg(Stroke), v => Stroke = SvgAttribute.ParseColorAttribute(v, Stroke.A) )); yield return(new SvgAttribute("stroke-opacity", "1", () => ((double)Stroke.A / 255).ToString(ci), v => Stroke = SvgAttribute.ParseOpacityAttribute(v, Stroke) )); yield return(new SvgAttribute("stroke-dashoffset", () => StrokeDashOffset.ToString(ci), v => StrokeDashOffset = SvgAttribute.ParseFloatAttribute(v) )); yield return(new SvgAttribute("stroke-dasharray", () => DashArrayToString(), v => StrokeDashArray = SvgAttribute.ParseFloatArray(v) )); }
/// <summary> /// Return a string representation of this object. /// </summary> public override String ToString() { return(String.Format("Line2D: X1={0}, Y1={1}, X2={2}, Y2={3}", X1.ToString(), Y1.ToString(), X2.ToString(), Y2.ToString())); }
public override int GetHashCode() { var hashCode = 268039418; hashCode = hashCode * -1521134295 + X1.GetHashCode(); hashCode = hashCode * -1521134295 + Y1.GetHashCode(); hashCode = hashCode * -1521134295 + X2.GetHashCode(); hashCode = hashCode * -1521134295 + Y2.GetHashCode(); return(hashCode); }
public override int GetHashCode() { int prime = 37; int hash = 1; hash = prime * hash + X1.GetHashCode(); hash = prime * hash + X2.GetHashCode(); hash = prime * hash + X3.GetHashCode(); hash = prime * hash + Y1.GetHashCode(); hash = prime * hash + Y2.GetHashCode(); return(prime * hash + Y3.GetHashCode()); }
public override int GetHashCode() { var prime = 37; var hash = 1; hash = prime * hash + X1.GetHashCode(); hash = prime * hash + Y1.GetHashCode(); hash = prime * hash + X2.GetHashCode(); hash = prime * hash + Y2.GetHashCode(); hash = prime * hash + X3.GetHashCode(); hash = prime * hash + Y3.GetHashCode(); return(hash); }
// Searching of open key. private void button1_Click(object sender, EventArgs e) { // Assigning values to variables. P = Convert.ToUInt64(textBox1.Text); // P - prime number. P is bigger than the biggest number of the message. G = Convert.ToUInt64(textBox2.Text); // Q<P. X1 = Convert.ToUInt64(textBox3.Text); X2 = Convert.ToUInt64(textBox6.Text); // Calculation of open keys. Y1 = OpenKey(P, G, X1); Y2 = OpenKey(P, G, X2); // Showing results. textBox4.Text = Y1.ToString(); textBox7.Text = Y2.ToString(); }
public override void WriteGroupCodes() { WriteGroupCodeValue(10, X0.ToString().Trim()); WriteGroupCodeValue(20, Y0.ToString().Trim()); WriteGroupCodeValue(30, Z0.ToString().Trim()); WriteGroupCodeValue(11, X1.ToString().Trim()); WriteGroupCodeValue(21, Y1.ToString().Trim()); WriteGroupCodeValue(31, Z1.ToString().Trim()); WriteGroupCodeValue(12, X2.ToString().Trim()); WriteGroupCodeValue(22, Y2.ToString().Trim()); WriteGroupCodeValue(32, Z2.ToString().Trim()); WriteGroupCodeValue(13, X3.ToString().Trim()); WriteGroupCodeValue(23, Y3.ToString().Trim()); WriteGroupCodeValue(33, Z3.ToString().Trim()); }
public int CompareTo(VectorPoint other) { int result = X1.CompareTo(other.X1); if (result == 0) { result = Y1.CompareTo(other.Y1); } else if (result == 0) { result = X2.CompareTo(other.X2); } else if (result == 0) { result = Y2.CompareTo(other.Y2); } return(result); }
public bool Equals(Garage other) { if (other == null) { return(false); } return(Type.Equals(other.Type) && State.Equals(other.State) && Field02h.Equals(other.Field02h) && ClosingWithoutTargetVehicle.Equals(other.ClosingWithoutTargetVehicle) && Deactivated.Equals(other.Deactivated) && ResprayHappened.Equals(other.ResprayHappened) && TargetModelIndex.Equals(other.TargetModelIndex) && Door1Pointer.Equals(other.Door1Pointer) && Door2Pointer.Equals(other.Door2Pointer) && Door1Handle.Equals(other.Door1Handle) && Door2Handle.Equals(other.Door2Handle) && IsDoor1Dummy.Equals(other.IsDoor1Dummy) && IsDoor2Dummy.Equals(other.IsDoor2Dummy) && RecreateDoorOnNextRefresh.Equals(other.RecreateDoorOnNextRefresh) && RotatingDoor.Equals(other.RotatingDoor) && CameraFollowsPlayer.Equals(other.CameraFollowsPlayer) && X1.Equals(other.X1) && X2.Equals(other.X2) && Y1.Equals(other.Y1) && Y2.Equals(other.Y2) && Z1.Equals(other.Z1) && Z2.Equals(other.Z2) && DoorOpenOffset.Equals(other.DoorOpenOffset) && DoorOpenMax.Equals(other.DoorOpenMax) && Door1X.Equals(other.Door1X) && Door1Y.Equals(other.Door1Y) && Door2X.Equals(other.Door2X) && Door2Y.Equals(other.Door2Y) && Door1Z.Equals(other.Door1Z) && Door2Z.Equals(other.Door2Z) && Timer.Equals(other.Timer) && CollectedCarsState.Equals(other.CollectedCarsState) && TargetCarPointer.Equals(other.TargetCarPointer) && Field96h.Equals(other.Field96h) && StoredCar.Equals(other.StoredCar)); }
bool WriteFromGRDECL(string file) { try { using (StreamWriter sw = new StreamWriter(file, true)) { sw.WriteLine(string.Empty); sw.WriteLine(grdecl_kw_mapaxes); sw.WriteLine(X1.ToString() + " " + Y1.ToString() + " " + X2.ToString() + " " + Y2.ToString() + " " + X3.ToString() + " " + Y3.ToString() + " /"); } } catch (Exception) { return(false); } return(true); }
public bool Equals(Garage other) { if (other == null) { return(false); } return(Type.Equals(other.Type) && State.Equals(other.State) && MaxCarsAllowed.Equals(other.MaxCarsAllowed) && ClosingWithoutTargetVehicle.Equals(other.ClosingWithoutTargetVehicle) && Deactivated.Equals(other.Deactivated) && ResprayHappened.Equals(other.ResprayHappened) && Door1Pointer.Equals(other.Door1Pointer) && Door2Pointer.Equals(other.Door2Pointer) && Door1Handle.Equals(other.Door1Handle) && Door2Handle.Equals(other.Door2Handle) && IsDoor1Dummy.Equals(other.IsDoor1Dummy) && IsDoor2Dummy.Equals(other.IsDoor2Dummy) && RecreateDoorOnNextRefresh.Equals(other.RecreateDoorOnNextRefresh) && RotatingDoor.Equals(other.RotatingDoor) && CameraFollowsPlayer.Equals(other.CameraFollowsPlayer) && Position.Equals(other.Position) && Rotation.Equals(other.Rotation) && CeilingZ.Equals(other.CeilingZ) && DoorRelated1.Equals(other.DoorRelated1) && DoorRelated2.Equals(other.DoorRelated2) && X1.Equals(other.X1) && X2.Equals(other.X2) && Y1.Equals(other.Y1) && Y2.Equals(other.Y2) && DoorOpenOffset.Equals(other.DoorOpenOffset) && DoorOpenMax.Equals(other.DoorOpenMax) && Door1X.Equals(other.Door1X) && Door1Y.Equals(other.Door1Y) && Door2X.Equals(other.Door2X) && Door2Y.Equals(other.Door2Y) && Door1Z.Equals(other.Door1Z) && Door2Z.Equals(other.Door2Z) && Timer.Equals(other.Timer)); }
protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; ele.TryPathTo("Point1/X", true, out subEle); subEle.Value = X1.ToString(); ele.TryPathTo("Point1/Y", true, out subEle); subEle.Value = Y1.ToString(); ele.TryPathTo("Point1/Z", true, out subEle); subEle.Value = Z1.ToString(); ele.TryPathTo("Point2/X", true, out subEle); subEle.Value = X2.ToString(); ele.TryPathTo("Point2/Y", true, out subEle); subEle.Value = Y2.ToString(); ele.TryPathTo("Point2/Z", true, out subEle); subEle.Value = Z2.ToString(); }
/// <summary> /// Return the HashCode of this object. /// </summary> /// <returns>The HashCode of this object.</returns> public override Int32 GetHashCode() { return(X1.GetHashCode() ^ 1 + Y1.GetHashCode() ^ 2 + X2.GetHashCode() ^ 3 + Y2.GetHashCode()); }
/// <summary> /// Base class for two-dimensional graphs. /// </summary> /// <param name="X">X-axis</param> /// <param name="Y">Y-axis</param> /// <param name="PlotCallback">Callback method that performs the plotting.</param> /// <param name="ShowZeroX">If the y-axis (x=0) should always be shown.</param> /// <param name="ShowZeroY">If the x-axis (y=0) should always be shown.</param> /// <param name="Node">Node creating the graph.</param> /// <param name="Parameters">Graph-specific parameters.</param> public Graph2D(IVector X, IVector Y, DrawCallback PlotCallback, bool ShowZeroX, bool ShowZeroY, ScriptNode Node, params object[] Parameters) : base() { if (X is Interval XI) { X = new DoubleVector(XI.GetArray()); } if (Y is Interval YI) { Y = new DoubleVector(YI.GetArray()); } int i, c = X.Dimension; bool HasNull = false; IElement ex, ey; if (c != Y.Dimension) { throw new ScriptException("X and Y series must be equally large."); } for (i = 0; i < c; i++) { ex = X.GetElement(i); ey = Y.GetElement(i); if (ex.AssociatedObjectValue is null || ey.AssociatedObjectValue is null) { HasNull = true; break; } } this.showZeroX = ShowZeroX; this.showZeroY = ShowZeroY; this.minX = Min.CalcMin(X, null); this.maxX = Max.CalcMax(X, null); if (this.showZeroX && this.minX is AbelianGroup Gx) { List <IElement> Elements = new List <IElement> { this.minX, Gx.Zero }; this.minX = Min.CalcMin(X.Encapsulate(Elements, null) as IVector, null); Elements = new List <IElement> { this.maxX, Gx.Zero }; this.maxX = Max.CalcMax(X.Encapsulate(Elements, null) as IVector, null); } this.minY = Min.CalcMin(Y, null); this.maxY = Max.CalcMax(Y, null); if (this.showZeroY && this.minY is AbelianGroup Gy) { List <IElement> Elements = new List <IElement> { this.minY, Gy.Zero }; this.minY = Min.CalcMin(Y.Encapsulate(Elements, null) as IVector, null); Elements = new List <IElement> { this.maxY, Gy.Zero }; this.maxY = Max.CalcMax(Y.Encapsulate(Elements, null) as IVector, null); } if (HasNull) { LinkedList <IElement> X2 = new LinkedList <IElement>(); LinkedList <IElement> Y2 = new LinkedList <IElement>(); this.axisTypeX = null; this.axisTypeY = null; for (i = 0; i < c; i++) { ex = X.GetElement(i); ey = Y.GetElement(i); if (ex.AssociatedObjectValue is null || ey.AssociatedObjectValue is null) { if (X2.First != null) { this.AddSegment(X, Y, X2, Y2, Node, PlotCallback, Parameters); X2 = new LinkedList <IElement>(); Y2 = new LinkedList <IElement>(); } } else { X2.AddLast(ex); Y2.AddLast(ey); } }
public override int GetHashCode() { return(X1.GetHashCode() + X2.GetHashCode() + X3.GetHashCode() + Y1.GetHashCode() + Y2.GetHashCode() + Y3.GetHashCode()); }
private void button_OK_Click(object sender, EventArgs e) { try { FN1 = Filename1.Text; FN2 = Filename2.Text; FN3 = Filename3.Text; FN4 = Filename4.Text; FN5 = Filename5.Text; if ((FN1.Length < 2) && (FN2.Length < 2) && (FN3.Length < 2) && (FN4.Length < 2) && (FN5.Length < 2)) { throw new FormatException(); } m_SS = SS.Text; if ((m_SS.Length < 1) || (m_SS.Length > 1)) { throw new FormatException(); } m_PN = int.Parse(PN.Text); if (m_PN <= 0) { throw new FormatException(); } if (X1.Text.Length < 1) { throw new FormatException(); } if (X2.Text.Length < 1) { throw new FormatException(); } if (Y1.Text.Length < 1) { throw new FormatException(); } if (Y2.Text.Length < 1) { throw new FormatException(); } if (Z1.Text.Length < 1) { throw new FormatException(); } if (Z2.Text.Length < 1) { throw new FormatException(); } minX = int.Parse(X1.Text); maxX = int.Parse(X2.Text); minY = int.Parse(Y1.Text); maxY = int.Parse(Y2.Text); minZ = int.Parse(Z1.Text); maxZ = int.Parse(Z2.Text); if (minX > maxX) { int buff = minX; minX = maxX; maxX = buff; } if (minY > maxY) { int buff = minY; minY = maxY; maxY = buff; } if (minZ > maxZ) { int buff = minZ; minZ = maxZ; maxZ = buff; } DialogResult = DialogResult.OK; } catch (FormatException) { if (FN1.Length < 2) { MessageBox.Show("FileName1 = ?"); Filename1.Text = ""; Filename1.Focus(); } if ((m_SS.Length < 1) || (m_SS.Length > 1)) { MessageBox.Show("Separation Character = ?"); SS.Text = ""; SS.Focus(); } if (m_PN <= 0) { MessageBox.Show("Draw a Point for Every = ?"); PN.Text = ""; PN.Focus(); } if (X1.Text.Length < 1) { MessageBox.Show("Limit1 - X = ?"); X1.Text = ""; X1.Focus(); } if (X2.Text.Length < 1) { MessageBox.Show("Limit2 - X = ?"); X2.Text = ""; X2.Focus(); } if (Y1.Text.Length < 1) { MessageBox.Show("Limit1 - Y = ?"); Y1.Text = ""; Y1.Focus(); } if (Y2.Text.Length < 1) { MessageBox.Show("Limit2 - Y = ?"); Y2.Text = ""; Y2.Focus(); } if (Z1.Text.Length < 1) { MessageBox.Show("Limit1 - Z = ?"); Z1.Text = ""; Z1.Focus(); } if (Z2.Text.Length < 1) { MessageBox.Show("Limit2 - Z = ?"); Z2.Text = ""; Z2.Focus(); } } }
/// <summary> /// Base class for two-dimensional graphs. /// </summary> /// <param name="X">X-axis</param> /// <param name="Y">Y-axis</param> /// <param name="PlotCallback">Callback method that performs the plotting.</param> /// <param name="ShowZeroX">If the y-axis (x=0) should always be shown.</param> /// <param name="ShowZeroY">If the x-axis (y=0) should always be shown.</param> /// <param name="Node">Node creating the graph.</param> /// <param name="Parameters">Graph-specific parameters.</param> public Graph2D(IVector X, IVector Y, DrawCallback PlotCallback, bool ShowZeroX, bool ShowZeroY, ScriptNode Node, params object[] Parameters) : base() { int i, c = X.Dimension; bool HasNull = false; IElement ex, ey; if (c != Y.Dimension) { throw new ScriptException("X and Y series must be equally large."); } if (X is Interval XI) { X = new DoubleVector(XI.GetArray()); } if (Y is Interval YI) { Y = new DoubleVector(YI.GetArray()); } for (i = 0; i < c; i++) { ex = X.GetElement(i); ey = Y.GetElement(i); if (ex.AssociatedObjectValue == null || ey.AssociatedObjectValue == null) { HasNull = true; break; } } this.showZeroX = ShowZeroX; this.showZeroY = ShowZeroY; this.minX = Min.CalcMin(X, null); this.maxX = Max.CalcMax(X, null); this.minY = Min.CalcMin(Y, null); this.maxY = Max.CalcMax(Y, null); if (HasNull) { LinkedList <IElement> X2 = new LinkedList <IElement>(); LinkedList <IElement> Y2 = new LinkedList <IElement>(); this.axisTypeX = null; this.axisTypeY = null; for (i = 0; i < c; i++) { ex = X.GetElement(i); ey = Y.GetElement(i); if (ex.AssociatedObjectValue == null || ey.AssociatedObjectValue == null) { if (X2.First != null) { this.AddSegment(X, Y, X2, Y2, Node, PlotCallback, Parameters); X2 = new LinkedList <IElement>(); Y2 = new LinkedList <IElement>(); } } else { X2.AddLast(ex); Y2.AddLast(ey); } } if (X2.First != null) { this.AddSegment(X, Y, X2, Y2, Node, PlotCallback, Parameters); } } else { this.axisTypeX = X.GetType(); this.axisTypeY = Y.GetType(); if (c > 0) { this.x.AddLast(X); this.y.AddLast(Y); this.callbacks.AddLast(PlotCallback); this.parameters.AddLast(Parameters); } } IElement Zero = null; if (ShowZeroX && c > 0 && this.minX.AssociatedSet is IAbelianGroup AG) { Zero = AG.AdditiveIdentity; this.minX = Min.CalcMin(new ObjectVector(this.minX, Zero), null); this.maxX = Max.CalcMax(new ObjectVector(this.maxX, Zero), null); } if (ShowZeroY && c > 0 && this.minY.AssociatedSet is IAbelianGroup AG2) { Zero = AG2.AdditiveIdentity; this.minY = Min.CalcMin(new ObjectVector(this.minY, Zero), null); this.maxY = Max.CalcMax(new ObjectVector(this.maxY, Zero), null); } }
/// <summary> /// /// </summary> protected override void CreateChildControls() { bool isInUpdatePanel = this.IsInUpdatePanel; //Page p = (Page)System.Web.HttpContext.Current.Handler; //ScriptManager m = ScriptManager.GetCurrent(p); ClientScriptManager cs = Page.ClientScript; if (this.IncludeJQuery) { if (string.IsNullOrEmpty(this.ScriptPath)) { this.ScriptPath = "/scripts/"; } if (isInUpdatePanel) { if (!cs.IsClientScriptIncludeRegistered(this.GetType(), "jquery")) { ScriptManager.RegisterClientScriptInclude(this, this.GetType() , "jquery", ResolveClientUrl(this.ScriptPath + "jquery.js")); } if (!cs.IsClientScriptIncludeRegistered(this.GetType(), "jqueryCrop")) { ScriptManager.RegisterClientScriptInclude(this, this.GetType() , "jqueryCrop", ResolveClientUrl(this.ScriptPath + "jquery.jcrop.js")); } } else { if (!cs.IsClientScriptIncludeRegistered(this.GetType(), "jquery")) { cs.RegisterClientScriptInclude(this.GetType() , "jquery", ResolveClientUrl(this.ScriptPath + "jquery.js")); } if (!cs.IsClientScriptIncludeRegistered(this.GetType(), "jqueryCrop")) { cs.RegisterClientScriptInclude(this.GetType() , "jqueryCrop", ResolveClientUrl(this.ScriptPath + "jquery.jcrop.js")); } } } else { // load it from google ajax library. Faster way and less annoying! /*if(!cs.IsClientScriptIncludeRegistered("jquery")) * cs.RegisterClientScriptInclude("jquery" * , "http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"); */ string jquery = "\r\n<script src=\"" + cs.GetWebResourceUrl(this.GetType(), "CS.Web.UI.jquery.js") + "\" type=\"text/javascript\"></script>\r\n"; string cropJS = "\r\n<script src=\"" + cs.GetWebResourceUrl(this.GetType(), "CS.Web.UI.jquery.jcrop.js") + "\" type=\"text/javascript\"></script>\r\n"; if (isInUpdatePanel) { if (!cs.IsClientScriptBlockRegistered("jquery")) { cs.RegisterClientScriptBlock(this.GetType(), "jquery", jquery, false); } if (!cs.IsClientScriptBlockRegistered("cropJS")) { cs.RegisterClientScriptBlock(this.GetType(), "cropJS", cropJS, false); } } else { if (!cs.IsClientScriptBlockRegistered("jquery")) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "jquery", jquery, false); } if (!cs.IsClientScriptBlockRegistered("cropJS")) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "cropJS", cropJS, false); } } } string cropCss = "<link href=\"" + cs.GetWebResourceUrl(this.GetType(), "CS.Web.UI.jquery.jcrop.css") + "\" type=\"text/css\" rel=\"stylesheet\" />\r\n"; //if (!Page.Header.Controls.Add(new LiteralControl(("cropCss")) // cs.RegisterStartupScript(this.GetType(), "cropCss", cropCss, false); if (!cs.IsClientScriptBlockRegistered("cropJS")) { Page.Header.Controls.Add(new LiteralControl(cropCss)); } //bool cropInitScriptAdded = cs.IsClientScriptBlockRegistered("cropInit"); if (true) { System.Web.UI.WebControls.Image image = (System.Web.UI.WebControls.Image)Parent.FindControl(cropimage); ViewState["ImageUrl"] = image.ImageUrl; //System.Drawing.Image img = // System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath( image.ImageUrl)); //check if we set canvas size if (this.CanvasHeight > 0 | this.CanvasWidth > 0) { string folder = HttpContext.Current.Server.MapPath("~/"); GetRawSize(folder + image.ImageUrl); double rratio = (double)rawHeight / rawWidth; //raw image ratio double cratio; //canvas ratio if (this.CanvasHeight == 0) { cratio = rratio; this.CanvasHeight = Convert.ToInt32(this.CanvasWidth * rratio); } else if (this.CanvasWidth == 0) { cratio = rratio; this.CanvasWidth = Convert.ToInt32(this.CanvasHeight / rratio); } else { cratio = (double)CanvasHeight / CanvasWidth; } if (rratio > cratio) {//we have to fit height if (rawHeight > CanvasHeight) { resizefact = (double)CanvasHeight / rawHeight; image.Height = CanvasHeight; image.Width = Convert.ToInt32(rawWidth * resizefact); } } else { //we have to fit width if (rawWidth > CanvasWidth) { resizefact = (double)CanvasWidth / rawWidth; image.Width = CanvasWidth; image.Height = Convert.ToInt32(rawHeight * resizefact); } } ViewState["canvasRatio"] = resizefact; } StringBuilder sb = new StringBuilder(); sb.Append("<script>$(function(){ "); string showPreviewScript = ""; showPreviewScript = ", onChange: __showPreview" + ", onSelect: __showPreview"; sb.Append("$('#" + image.ClientID + "').Jcrop({" + "setSelect: [" + X.ToString() + "," + Y.ToString() + "," + X2.ToString() + ", " + Y2.ToString() + "]" + showPreviewScript); if (!string.IsNullOrEmpty(this.Ratio)) { sb.Append(", aspectRatio: " + this.Ratio); } if (!string.IsNullOrEmpty(this.MaxSize)) { sb.Append(", maxSize: [" + this.MaxSize + "]"); } if (!string.IsNullOrEmpty(this.MinSize)) { sb.Append(", minSize: [" + this.MinSize + "]"); } sb.Append("});"); sb.Append("});"); string script = @"function __showPreview(coords){ try{ $('#_x').val(coords.x); $('#_y').val(coords.y); $('#_w').val(coords.w); $('#_h').val(coords.h); var rx = {1} / coords.w; var ry = {2} / coords.h; $('#{0}').css({ width: Math.round(rx * {3}) + 'px', height: Math.round(ry * {4}) + 'px', marginLeft: '-' + Math.round(rx * coords.x) + 'px', marginTop: '-' + Math.round(ry * coords.y) + 'px' }); } catch(e){} } "; GetRawSize(image.ImageUrl); script = script.Replace("{0}", this.PreviewImageID); script = script.Replace("{1}", rawWidth.ToString()); script = script.Replace("{2}", rawHeight.ToString()); script = script.Replace("{3}", rawWidth.ToString()); script = script.Replace("{4}", rawHeight.ToString()); sb.Append(script); //sb.Append(string.Format(script.ToString(),this.PreviewImageID)); //if (EnablePreview) //{ // sb.Append("\r\n function __showPreview22(coords){ \r\n" + // "var rx = 100 / coords.w; \r\n" + // "var ry = 100 / coords.h; \r\n" + // "$('#preview').css({" + // " width: Math.round(rx * " + img.Width + ") + 'px', \r\n" + // " height: Math.round(ry * " + img.Height + ") + 'px', \r\n" + // " marginLeft: '-' + Math.round(rx * coords.x) + 'px', \r\n" + // " marginTop: '-' + Math.round(ry * coords.y) + 'px' \r\n" + // "}); try {__showDebug(coords); } catch(e) {}}\r\n\r\n"); //} /*sb.Append(@"function __showDebug(coords){ * try{ * $('#wci_xt').val(coords.x); * $('#wci_yt').val(coords.y); * $('#wci_wt').val(coords.w); * $('#wci_ht').val(coords.h); * } * catch(e){} * }"); * */ sb.Append(@"</script>"); if (isInUpdatePanel) { ScriptManager.RegisterClientScriptBlock(this, this.GetType() , "cropInit" , sb.ToString(), false); //ScriptManager.RegisterStartupScript(this, this.GetType(), "alertbabam", "alert('test');", true); ScriptManager.RegisterHiddenField(this, "_x", X.ToString()); ScriptManager.RegisterHiddenField(this, "_y", Y.ToString()); ScriptManager.RegisterHiddenField(this, "_w", W.ToString()); ScriptManager.RegisterHiddenField(this, "_h", H.ToString()); } else { cs.RegisterClientScriptBlock(this.GetType() , "cropInit" , sb.ToString(), false); cs.RegisterHiddenField("_x", X.ToString()); cs.RegisterHiddenField("_y", Y.ToString()); cs.RegisterHiddenField("_w", W.ToString()); cs.RegisterHiddenField("_h", H.ToString()); } image.Dispose(); //img.Dispose(); } base.CreateChildControls(); //HttpContext.Current.Response.Write("ssss"); }
public bool IntersectsWith(Line other) { if (this == other) { return(true); } double mx = X2 - X1; double my = Y2 - Y1; double rmx = other.X2 - other.X1; double rmy = other.Y2 - other.Y1; double dx = other.X1 - X1; double dy = Y1 - other.Y1; double d = (mx * rmy - my * rmx); double n = (mx * dy + my * dx) / d; double q = (rmx * dy + rmy * dx) / d; if (n > 0 && n < 1 && q > 0 && q < 1) { return(true); } //if (other.X1 == 0 && other.Y1 == 0 && other.X2 == 1 && other.Y2 == 0 && X1 == 3 && Y1 == 0 && X2 == 0 && Y2 == 0) // System.Diagnostics.Debugger.Break(); // check if they have the same gradient if ((Y2 - Y1) * (other.X2 - other.X1) != (other.Y2 - other.Y1) * (X2 - X1)) { return(false); } // check if (X1, Y1) lies on the other line if ((other.Y1 - Y1) * (other.X2 - other.X1) == (other.Y2 - other.Y1) * (other.X1 - X1) && X1.IsBetween(other.X1, other.X2) && Y1.IsBetween(other.Y1, other.Y2)) { return(true); } // check if (X2, Y2) lies on the other line if ((other.Y1 - Y2) * (other.X2 - other.X1) == (other.Y2 - other.Y1) * (other.X1 - X2) && X2.IsBetween(other.X1, other.X2) && Y2.IsBetween(other.Y1, other.Y2)) { return(true); } // check if other’s (X1, Y1) lies on this line if ((Y1 - other.Y1) * (X2 - X1) == (Y2 - Y1) * (X1 - other.X1) && other.X1.IsBetween(X1, X2) && other.Y1.IsBetween(Y1, Y2)) { return(true); } // check if other’s (other.X2, other.Y2) lies on other.line if ((Y1 - other.Y2) * (X2 - X1) == (Y2 - Y1) * (X1 - other.X2) && other.X2.IsBetween(X1, X2) && other.Y2.IsBetween(Y1, Y2)) { return(true); } return(false); }
/// <summary> /// Checks whether to render the annotation with respect to size or co - ordinate units. /// </summary> /// <returns>Returns a value indicating whether to render the annotation with respect to size or co - ordinate units.</returns> private bool IsRenderSize() { return(X2 == null || (X2.GetType() == typeof(double) && double.IsNaN((double)X2)) || Y2 == null || (Y2.GetType() == typeof(double) && double.IsNaN((double)Y2))); }
public static bool IsAsmensKodasGood(string asmensKodas) { if (String.IsNullOrEmpty(asmensKodas)) { return(false); } else { asmensKodas = WhiteSpaceRemove(asmensKodas); if (CheckIfForeigner(asmensKodas)) { return(true); } if (!CheckIfNumerable(asmensKodas)) { return(false); } else { int L, Y1, Y2, M1, M2, D1, D2, X1, X2, X3, K = 0; L = int.Parse(asmensKodas[0].ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); Y1 = int.Parse(asmensKodas[1].ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); Y2 = int.Parse(asmensKodas[2].ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); M1 = int.Parse(asmensKodas[3].ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); M2 = int.Parse(asmensKodas[4].ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); D1 = int.Parse(asmensKodas[5].ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); D2 = int.Parse(asmensKodas[6].ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); X1 = int.Parse(asmensKodas[7].ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); X2 = int.Parse(asmensKodas[8].ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); X3 = int.Parse(asmensKodas[9].ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); K = int.Parse(asmensKodas[10].ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); // Tikrinamas pirmas skaitmuo ar yra nuo 1 iki 6 if (L == 0) { return(false); } else if (L == 7) { return(false); } else if (L == 8) { return(false); } else if (L == 9) { return(false); } // Tikrina datas else if (int.Parse(Y1.ToString(CultureInfo.InvariantCulture) + Y2.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture) < 00 || int.Parse(Y1.ToString(CultureInfo.InvariantCulture) + Y2.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture) > 99) { return(false); } else if (int.Parse(M1.ToString(CultureInfo.InvariantCulture) + M2.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture) < 01 || int.Parse(M1.ToString(CultureInfo.InvariantCulture) + M2.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture) > 12) { return(false); } else if (int.Parse(D1.ToString(CultureInfo.InvariantCulture) + D2.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture) < 01 || int.Parse(D1.ToString(CultureInfo.InvariantCulture) + D2.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture) > 31) { return(false); } // Tikrina kontroline suma else { int S = 0, Liekana = 0; S = L * 1 + Y1 * 2 + Y2 * 3 + M1 * 4 + M2 * 5 + D1 * 6 + D2 * 7 + X1 * 8 + X2 * 9 + X3 * 1; Liekana = S % 11; if (Liekana != 10 && Liekana == K) { return(true); } else if (Liekana == 10) { S = 0; S = L * 3 + Y1 * 4 + Y2 * 5 + M1 * 6 + M2 * 7 + D1 * 8 + D2 * 9 + X1 * 1 + X2 * 2 + X3 * 3; Liekana = S % 11; if (Liekana != 10 && Liekana == K) { return(true); } else if (Liekana == 10 && K == 0) { return(true); } else { return(false); } } else { return(false); } } } } }
/// <summary> /// /// </summary> protected override void CreateChildControls() { //Add the jquery/jcrop includes AddFileReferences(); System.Web.UI.WebControls.Image image = Parent.FindControl(this.Image) as System.Web.UI.WebControls.Image; string url = image.ImageUrl; string resolvedUrl = url.StartsWith("~") ? ResolveUrl(url) : url; ViewState["ImageUrl"] = resolvedUrl; //image - '<img />' tag ID, DOM, or jquery reference //settings - object /* * settings = {keepAspectRatio:false, * keepAspectRatioCheckbox: '#id' or reference, * aspectRatio: null or value, * minSize: [w,h], * maxSize: [w,h], * previewDiv: '#id' or reference or null, * previewWidth: (previewDiv original width, or 100), * previewHeight: (previewDiv original height, or 100), * boxWidth: null or value, * boxHeight: null or value, * setSelect: [x1,y1,x2,y2], * updateLinks: "#id1, #id2" or null, * updateFields: "#id1, #id2" or null, * updateImages: "#id1, #id2" or null */ NameValueCollection s = new NameValueCollection(); if (!string.IsNullOrEmpty(this.FixedAspectRatioCheckboxID)) { Control c = Parent.FindControl(FixedAspectRatioCheckboxID); if (c != null) { s["keepAspectRatioCheckbox"] = "'#" + c.ClientID + "'"; } } s["keepAspectRatio"] = FixedAspectRatio.ToString().ToLower(); if (!string.IsNullOrEmpty(this.Ratio)) { s["aspectRatio"] = Ratio; } //If the image URL is a virtual path within the application, and ServerSideResize=true, then use URL resizing; otherwise, use boxWidth/boxHeight if (CanvasHeight > 0 | CanvasWidth > 0) { if (!url.StartsWith("http", StringComparison.OrdinalIgnoreCase) && this.ServerSizeResize) { NameValueCollection max = new NameValueCollection(); if (CanvasHeight > 0) { max["maxheight"] = CanvasHeight.ToString(); } if (CanvasWidth > 0) { max["maxwidth"] = CanvasWidth.ToString(); } url = ImageResizer.Util.PathUtils.MergeOverwriteQueryString(url, max); image.ImageUrl = url; } else { if (CanvasHeight > 0) { s["boxHeight"] = CanvasHeight.ToString(); } if (CanvasWidth > 0) { s["boxWidth"] = CanvasWidth.ToString(); } } } //If there has been a crop rectangle specified, use it if (W > 0 || H > 0) { s["setSelect"] = "[" + X.ToString() + "," + Y.ToString() + "," + X2.ToString() + ", " + Y2.ToString() + "]"; } if (!string.IsNullOrEmpty(this.MaxSize)) { s["maxSize"] = "[" + this.MaxSize + "]"; } if (!string.IsNullOrEmpty(this.MinSize)) { s["minSize"] = "[" + this.MinSize + "]"; } if (this.PreviewWidth > 0) { s["previewWidth"] = this.PreviewWidth.ToString(); } if (this.PreviewHeight > 0) { s["previewHeight"] = this.PreviewHeight.ToString(); } if (!string.IsNullOrEmpty(this.PreviewImageID)) { Control c = Parent.FindControl(PreviewImageID); if (c != null) { s["previewDiv"] = "'#" + c.ClientID + "'"; } } s["updateFields"] = "'#" + HiddenFieldClientId + "'"; StringBuilder sb = new StringBuilder(); sb.AppendLine("<script>$(function(){ "); sb.AppendLine("webcropimage('#" + image.ClientID + "', {"); foreach (string key in s) { sb.AppendLine(key + ": " + s[key] + ","); } sb.Append("});});"); sb.Append(@"</script>"); if (isInUpdatePanel) { ScriptManager.RegisterClientScriptBlock(this, this.GetType() , "cropInit" + this.ClientID , sb.ToString(), false); ScriptManager.RegisterHiddenField(this, HiddenFieldClientId, resolvedUrl); } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType() , "cropInit" + this.ClientID , sb.ToString(), false); Page.ClientScript.RegisterHiddenField(HiddenFieldClientId, resolvedUrl); } base.CreateChildControls(); }
public string ToString(string format, IFormatProvider provider) { return($"X1={X1.ToString(format, provider)} Y1={Y1.ToString(format, provider)} X2={X2.ToString(format, provider)} Y2={Y2.ToString(format, provider)}"); }
/// <summary> /// Returns true if BarcodeInfo instances are equal /// </summary> /// <param name="input">Instance of BarcodeInfo to be compared</param> /// <returns>Boolean</returns> public bool Equals(BarcodeInfo input) { if (input == null) { return(false); } return (( Type == input.Type || Type.Equals(input.Type) ) && ( Barcode1DSymbology == input.Barcode1DSymbology || Barcode1DSymbology.Equals(input.Barcode1DSymbology) ) && ( Data == input.Data || (Data != null && Data.Equals(input.Data)) ) && ( X1 == input.X1 || X1.Equals(input.X1) ) && ( X2 == input.X2 || X2.Equals(input.X2) ) && ( X3 == input.X3 || X3.Equals(input.X3) ) && ( X4 == input.X4 || X4.Equals(input.X4) ) && ( Y1 == input.Y1 || Y1.Equals(input.Y1) ) && ( Y2 == input.Y2 || Y2.Equals(input.Y2) ) && ( Y3 == input.Y3 || Y3.Equals(input.Y3) ) && ( Y4 == input.Y4 || Y4.Equals(input.Y4) ) && ( BboxLeftInches == input.BboxLeftInches || BboxLeftInches.Equals(input.BboxLeftInches) ) && ( BboxTopInches == input.BboxTopInches || BboxTopInches.Equals(input.BboxTopInches) ) && ( BboxWidthInches == input.BboxWidthInches || BboxWidthInches.Equals(input.BboxWidthInches) ) && ( BboxHeightInches == input.BboxHeightInches || BboxHeightInches.Equals(input.BboxHeightInches) ) && ( PageNumber == input.PageNumber || PageNumber.Equals(input.PageNumber) ) && ( PagePixelWidth == input.PagePixelWidth || PagePixelWidth.Equals(input.PagePixelWidth) ) && ( PagePixelHeight == input.PagePixelHeight || PagePixelHeight.Equals(input.PagePixelHeight) ) && ( PageHorizontalResolution == input.PageHorizontalResolution || PageHorizontalResolution.Equals(input.PageHorizontalResolution) ) && ( PageVerticalResolution == input.PageVerticalResolution || PageVerticalResolution.Equals(input.PageVerticalResolution) )); }