/// <summary> /// The draw internal. /// </summary> /// <param name="graphics"> /// The graphics. /// </param> /// <param name="coordinateConverter"> /// The coordinate converter. /// </param> /// <param name="renderMode"> /// The render mode. /// </param> private void DrawInternal( Graphics graphics, IBasicCoordinateConverter coordinateConverter, PaneRenderMode renderMode) { graphics = ArgumentValidator.CheckNotNull(graphics, "graphics"); coordinateConverter = ArgumentValidator.CheckNotNull(coordinateConverter, "coordinateConverter"); var smoothingMode = graphics.SmoothingMode; graphics.SmoothingMode = SmoothingMode.AntiAlias; this.pen.Width = this.Selected && renderMode == PaneRenderMode.Quality ? 2f : 1f; for (int i = 0; i < (Data.XArray.Length - 1); i++) { double x = Data.XArray[i]; double y = Data.YArray[i]; double x1 = Data.XArray[i + 1]; double y1 = Data.YArray[i + 1]; graphics.DrawLine( this.pen, coordinateConverter.PhysicalToControl( this.ActiveTransformationHandler.Transform(x, y)), coordinateConverter.PhysicalToControl( this.ActiveTransformationHandler.Transform(x1, y1)) ); } graphics.SmoothingMode = smoothingMode; }
public TICGraphObject(ITICData data, Color graphColor) { Data = ArgumentValidator.CheckNotNull(data, "data"); this.TransformationHandler.DataBoundingBox = new BoundingBox2D( this.Data.XArray.Min(), this.Data.YArray.Min(), this.Data.XArray.Max(), this.Data.YArray.Max()); this.Color = graphColor; }
/// <summary> /// The select. /// </summary> /// <param name="paneManager"> /// The pane manager. /// </param> /// <param name="selectionBuffer"> /// The selection buffer. /// </param> /// <returns> /// The <see cref="SelectionElement"/>. /// </returns> protected override SelectionElement Select(IPaneManager paneManager, ISelectionBuffer selectionBuffer) { paneManager = ArgumentValidator.CheckNotNull(paneManager, "paneManager"); selectionBuffer = ArgumentValidator.CheckNotNull(selectionBuffer, "selectionBuffer"); selectionBuffer.Clear(); this.DrawInternal( selectionBuffer.SelectionGraphics, paneManager.CoordinateConverter, paneManager.RenderMode); if (selectionBuffer.ContainsHit()) { var selectionElement = new SelectionElement(this); this.OnObjectSelected(selectionElement, paneManager, selectionBuffer); return(selectionElement); } return(null); }
/// <summary> /// /// </summary> /// <param name="paneManager"></param> /// <param name="graphics"></param> protected override void Draw(IPaneManager paneManager, Graphics graphics) { paneManager = ArgumentValidator.CheckNotNull <IPaneManager>(paneManager, "paneManager"); graphics = ArgumentValidator.CheckNotNull <Graphics>(graphics, "graphics"); if (!base.UsePersistentMode) { this.DrawSignal(graphics, paneManager.RenderingLoadManager, paneManager.CoordinateConverter, paneManager.RenderMode, paneManager.RenderTarget); } //else //{ // if (this.persistentLayer.Update(paneManager.CoordinateConverter, paneManager.RenderMode)) // { // this.DrawSignal(this.persistentLayer.Graphics, paneManager.RenderingLoadManager, paneManager.CoordinateConverter, paneManager.RenderMode, paneManager.RenderTarget); // } // graphics.DrawImage(this.persistentLayer.Bitmap, paneManager.CoordinateConverter.MinPixelX, paneManager.CoordinateConverter.MinPixelY, this.persistentLayer.Bitmap.Width, this.persistentLayer.Bitmap.Height); // } }
public string Sign(string content, string charset, string privateKey) { try { ArgumentValidator.CheckNotNull(content, "待签名内容不可为Null"); ArgumentValidator.CheckArgument(!String.IsNullOrEmpty(privateKey), "私钥不可为空"); if (String.IsNullOrEmpty(charset)) { charset = DEFAULT_CHARSET; } return(DoSign(content, charset, privateKey)); } catch (Exception ex) { String errorMessage = GetAsymmetricType() + "签名遭遇异常,请检查私钥格式是否正确。" + ex.Message + " content=" + content + ",charset=" + charset + ",privateKeySize=" + privateKey.Length; Console.WriteLine(errorMessage); throw new AopException(errorMessage, ex); } }
public string Encrypt(string plainText, string charset, string publicKey) { try { ArgumentValidator.CheckNotNull(plainText, "密文不可为Null"); ArgumentValidator.CheckArgument(!String.IsNullOrEmpty(publicKey), "公钥不可为空"); if (String.IsNullOrEmpty(charset)) { charset = DEFAULT_CHARSET; } return(DoEncrypt(plainText, charset, publicKey)); } catch (Exception ex) { String errorMessage = GetAsymmetricType() + "非对称解密遭遇异常,请检查公钥格式是否正确。" + ex.Message + " plainText=" + plainText + ",charset=" + charset + ",publicKey=" + publicKey; Console.WriteLine(errorMessage); throw new AopException(errorMessage, ex); } }
public string Decrypt(string cipherTextBase64, string charset, string privateKey) { try { ArgumentValidator.CheckNotNull(cipherTextBase64, "密文不可为Null"); ArgumentValidator.CheckArgument(!String.IsNullOrEmpty(privateKey), "私钥不可为空"); if (String.IsNullOrEmpty(charset)) { charset = DEFAULT_CHARSET; } return(DoDecrypt(cipherTextBase64, charset, privateKey)); } catch (Exception ex) { String errorMessage = GetAsymmetricType() + "非对称解密遭遇异常,请检查私钥格式是否正确。" + ex.Message + " cipherTextBase64=" + cipherTextBase64 + ",charset=" + charset + ",privateKeySize=" + privateKey.Length; Console.WriteLine(errorMessage); throw new AopException(errorMessage, ex); } }
public bool Verify(string content, string charset, string publicKey, string sign) { try { ArgumentValidator.CheckNotNull(content, "待验签内容不可为Null"); ArgumentValidator.CheckArgument(!String.IsNullOrEmpty(publicKey), "公钥不可为空"); ArgumentValidator.CheckArgument(!String.IsNullOrEmpty(sign), "签名串不可为空"); if (String.IsNullOrEmpty(charset)) { charset = DEFAULT_CHARSET; } return(DoVerify(content, charset, publicKey, sign)); } catch (Exception ex) { String errorMessage = GetAsymmetricType() + "验签遭遇异常,请检查公钥格式是否正确。" + ex.Message + " content=" + content + ",charset=" + charset + ",publicKey=" + publicKey + ",sign=" + sign; Console.WriteLine(errorMessage); throw new AopException(errorMessage, ex); } }
public T CertificateExecute <T>(IAopRequest <T> request, string accessToken, string appAuthToken, String targetAppId) where T : AopResponse { ArgumentValidator.CheckNotNull(certEnvironment, "检测到证书相关参数未初始化,非证书模式下请改为调用Execute。"); if (string.IsNullOrEmpty(this.charset)) { this.charset = "utf-8"; } string apiVersion = null; if (!string.IsNullOrEmpty(request.GetApiVersion())) { apiVersion = request.GetApiVersion(); } else { apiVersion = Version; } // 添加协议级请求参数 AopDictionary txtParams = new AopDictionary(request.GetParameters()); // 序列化BizModel txtParams = SerializeBizModel(txtParams, request); txtParams.Add(AlipayConstants.METHOD, request.GetApiName()); txtParams.Add(AlipayConstants.VERSION, apiVersion); txtParams.Add(AlipayConstants.ALIPAY_SDK, SDK_VERSION); txtParams.Add(AlipayConstants.APP_ID, appId); txtParams.Add(AlipayConstants.FORMAT, format); txtParams.Add(AlipayConstants.TIMESTAMP, DateTime.Now); txtParams.Add(AlipayConstants.ACCESS_TOKEN, accessToken); txtParams.Add(AlipayConstants.SIGN_TYPE, signType); txtParams.Add(AlipayConstants.TERMINAL_TYPE, request.GetTerminalType()); txtParams.Add(AlipayConstants.TERMINAL_INFO, request.GetTerminalInfo()); txtParams.Add(AlipayConstants.PROD_CODE, request.GetProdCode()); txtParams.Add(AlipayConstants.CHARSET, charset); txtParams.Add(AlipayConstants.APP_CERT_SN, certEnvironment.AppCertSN); txtParams.Add(AlipayConstants.ALIPAY_ROOT_CERT_SN, certEnvironment.RootCertSN); if (!string.IsNullOrEmpty(request.GetNotifyUrl())) { txtParams.Add(AlipayConstants.NOTIFY_URL, request.GetNotifyUrl()); } if (!string.IsNullOrEmpty(appAuthToken)) { txtParams.Add(AlipayConstants.APP_AUTH_TOKEN, appAuthToken); } if (!string.IsNullOrEmpty(targetAppId)) { txtParams.Add(AlipayConstants.TARGET_APP_ID, targetAppId); } if (request.GetNeedEncrypt()) { if (string.IsNullOrEmpty(txtParams[AlipayConstants.BIZ_CONTENT])) { throw new AopException("api request Fail ! The reason: encrypt request is not supported!"); } if (string.IsNullOrEmpty(this.encyptKey) || string.IsNullOrEmpty(this.encyptType)) { throw new AopException("encryptType or encryptKey must not null!"); } if (!"AES".Equals(this.encyptType)) { throw new AopException("api only support Aes!"); } string encryptContent = AopUtils.AesEncrypt(this.encyptKey, txtParams[AlipayConstants.BIZ_CONTENT], this.charset); txtParams.Remove(AlipayConstants.BIZ_CONTENT); txtParams.Add(AlipayConstants.BIZ_CONTENT, encryptContent); txtParams.Add(AlipayConstants.ENCRYPT_TYPE, this.encyptType); } // 添加签名参数 txtParams.Add(AlipayConstants.SIGN, AopUtils.SignAopRequest(txtParams, privateKeyPem, charset, this.keyFromFile, signType)); // 是否需要上传文件 string body; if (request is IAopUploadRequest <T> ) { IAopUploadRequest <T> uRequest = (IAopUploadRequest <T>)request; IDictionary <string, FileItem> fileParams = AopUtils.CleanupDictionary(uRequest.GetFileParameters()); body = webUtils.DoPost(this.serverUrl + "?" + AlipayConstants.CHARSET + "=" + this.charset, txtParams, fileParams, this.charset); } else { body = webUtils.DoPost(this.serverUrl + "?" + AlipayConstants.CHARSET + "=" + this.charset, txtParams, this.charset); } T rsp; IAopParser <T> parser; if ("xml".Equals(format)) { parser = new AopXmlParser <T>(); rsp = parser.Parse(body, charset); } else { parser = new AopJsonParser <T>(); rsp = parser.Parse(body, charset); } ResponseParseItem item = ParseRespItem(request, body, parser, this.encyptKey, this.encyptType, charset); rsp = parser.Parse(item.RealContent, charset); CheckResponseCertSign(request, item.RespContent, rsp.IsError, parser); return(rsp); }
/// <summary> /// /// </summary> /// <param name="graphics"></param> /// <param name="renderingLoadManager"></param> /// <param name="coordinateConverter"></param> /// <param name="renderMode"></param> /// <param name="renderTarget"></param> private void DrawSignal(Graphics graphics, IRenderingLoadManager renderingLoadManager, IBasicCoordinateConverter coordinateConverter, PaneRenderMode renderMode, RenderTarget renderTarget) { graphics = ArgumentValidator.CheckNotNull <Graphics>(graphics, "graphics"); coordinateConverter = ArgumentValidator.CheckNotNull <IBasicCoordinateConverter>(coordinateConverter, "coordinateConverter"); if ((renderingLoadManager == null) || (!renderingLoadManager.RenderingLoadIsExceeded || (this.Selected || this.AssociatedInjectionIsSelected))) { SmoothingMode smoothingMode = graphics.SmoothingMode; graphics.SmoothingMode = SmoothingMode.AntiAlias; //Pen pen = (!this.Selected || ((renderMode != PaneRenderMode.Quality) || (renderTarget != RenderTarget.Screen))) ? new Pen(this.DisplaySettings.Color) : new Pen(this.DisplaySettings.Color); Color color = DisplaySettings.Color; Color displayColor = Color.FromArgb(color.R, color.G, color.B); Pen pen = new Pen(displayColor); DisplaySettings.Color = displayColor; Color fillColor = Color.FromArgb(color.A, color.R + 3 * (255 - color.R) / 4, color.G + 3 * (255 - color.G) / 4, color.B + 3 * (255 - color.B) / 4); Pen fillPen = new Pen(fillColor); double num = base.ActiveTransformationHandler.InverseTransformX(coordinateConverter.ControlToPhysicalX(2)) - base.ActiveTransformationHandler.InverseTransformX(coordinateConverter.ControlToPhysicalX(1)); int num2 = 1; IEquidistantDataEx signal = this.SignalData as IEquidistantDataEx; if (signal != null) { num2 = (int)(num / signal.XStep); } int num3 = Math.Max(coordinateConverter.MinPixelX, coordinateConverter.PhysicalToControlX(base.ActiveTransformationHandler.TransformX(this.SignalData.XMin))); int num4 = Math.Min(coordinateConverter.MaxPixelX, coordinateConverter.PhysicalToControlX(base.ActiveTransformationHandler.TransformX(this.SignalData.XMax))); if (num2 > 3) { for (int i = num3; i < num4; i++) { double num6 = base.ActiveTransformationHandler.InverseTransformX(coordinateConverter.ControlToPhysicalX(i)); Range range = CommonDataExtensions.GetValueRange(this.SignalData, (double)(num6 - (0.5 * num)), (double)(num6 + (0.5 * num))); double num7 = base.ActiveTransformationHandler.InverseTransformX(coordinateConverter.ControlToPhysicalX((int)(i + 1))); Range range2 = CommonDataExtensions.GetValueRange(this.SignalData, (double)(num7 - (0.5 * num)), (double)(num7 + (0.5 * num))); int num8 = coordinateConverter.PhysicalToControlY(base.ActiveTransformationHandler.TransformY(range.Min)); int num9 = coordinateConverter.PhysicalToControlY(base.ActiveTransformationHandler.TransformY(range.Max)); int num10 = coordinateConverter.PhysicalToControlY(base.ActiveTransformationHandler.TransformY(range2.Min)); int num11 = coordinateConverter.PhysicalToControlY(base.ActiveTransformationHandler.TransformY(range2.Max)); graphics.DrawLine(pen, i, num8, i + 1, num11); graphics.DrawLine(pen, i, num9, i + 1, num10); } } else { List <Point> plotPoints = new List <Point>(); int num13 = Math.Min(this.SignalData.GetNextIndex(base.ActiveTransformationHandler.InverseTransformX(coordinateConverter.MaxPhysicalX)), this.SignalData.Count - 1); for (int i = Math.Max(this.SignalData.GetPrevIndex(base.ActiveTransformationHandler.InverseTransformX(coordinateConverter.MinPhysicalX)), 0) + 1; i <= num13; i++) { Point point = coordinateConverter.PhysicalToControl(base.ActiveTransformationHandler.Transform(this.SignalData.GetXValue(i - 1), this.SignalData.GetValue((int)(i - 1)))); Point point2 = coordinateConverter.PhysicalToControl(base.ActiveTransformationHandler.Transform(this.SignalData.GetXValue(i), this.SignalData.GetValue(i))); Point xPoint = coordinateConverter.PhysicalToControl(base.ActiveTransformationHandler.Transform(this.SignalData.GetXValue(i), 0)); if (((point.Y >= coordinateConverter.MinPixelY) || (point2.Y >= coordinateConverter.MinPixelY)) && (((point.Y <= coordinateConverter.MaxPixelY) || (point2.Y <= coordinateConverter.MaxPixelY)) && (((point.X >= coordinateConverter.MinPixelX) || (point2.X >= coordinateConverter.MinPixelX)) && (((point.X <= coordinateConverter.MaxPixelX) || (point2.X <= coordinateConverter.MaxPixelX)) && (IsPointValid(point) && IsPointValid(point2)))))) { try { pen.Width = 3; graphics.DrawLine(pen, point, point2); //graphics.DrawLine(pen, point, xPoint); //graphics.DrawLine(pen, point2, xPoint); plotPoints.Add(point); plotPoints.Add(point2); } catch (OverflowException exception) { object[] args = new object[] { exception.Message }; TraceLog.Warning(string.Format(CultureInfo.InvariantCulture, "There was an overflow exception in the graph object.\nException Message = {0}", args)); } int xMin = int.MaxValue; int xMax = int.MinValue; foreach (Point p in plotPoints) { int x = p.X; if (x < xMin) { xMin = x; } if (x > xMax) { xMax = x; } } Point start = new Point(xMin, coordinateConverter.PhysicalToControlY(0)); Point end = new Point(xMax, coordinateConverter.PhysicalToControlY(0)); List <Point> plotPoints1 = new List <Point>(); plotPoints1.Add(start); foreach (Point p in plotPoints) { plotPoints1.Add(p); } plotPoints1.Add(end); plotPoints1.Add(start); graphics.FillPolygon(fillPen.Brush, plotPoints1.ToArray()); } } } graphics.SmoothingMode = smoothingMode; } }
/// <summary> /// The draw zoom overview. /// </summary> /// <param name="paneManager"> /// The pane manager. /// </param> /// <param name="graphics"> /// The graphics. /// </param> protected override void DrawZoomOverview(IPaneManager paneManager, Graphics graphics) { paneManager = ArgumentValidator.CheckNotNull(paneManager, "paneManager"); this.DrawInternal(graphics, paneManager.ZoomOverviewInfo.CoordinateConverter, paneManager.RenderMode); }