public static Image GenerateGifByDegree(Double degree) { string strDegree = Convert.ToInt32((degree % 360 + 360) % 360).ToString(); if (!Directory.Exists(GifPath)) { Directory.CreateDirectory(GifPath); } String outputFilePath = GifPath + "ArrowBack" + strDegree + ".gif"; if (!File.Exists(outputFilePath)) { String[] imageFilePaths = new String[] { JpgPath + "ArrowBack0.JPG", JpgPath + "ArrowBack1.JPG", JpgPath + "ArrowBack2.JPG", JpgPath + "ArrowBack3.JPG" }; AnimatedGifEncoder gifEncoder = new AnimatedGifEncoder(); gifEncoder.Start(outputFilePath); gifEncoder.SetDelay(GifInterval); //-1:no repeat,0:always repeat gifEncoder.SetRepeat(0); for (int i = 0, count = imageFilePaths.Length; i < count; i++) { gifEncoder.AddFrame(DrawUtility.Rotate(Image.FromFile(imageFilePaths[i]), degree)); } gifEncoder.Finish(); } return(Image.FromFile(outputFilePath)); }
/// <summary> /// </summary> public static void DrawEnd(EndButton btnEnd) { if (btnEnd != null) { using (GraphicsPath path1 = new GraphicsPath()) { path1.AddEllipse(0, 0, btnEnd.Radius * 2, btnEnd.Radius * 2); // path1.AddEllipse(btnEnd.Radius / 2, btnEnd.Radius / 2, btnEnd.Radius, btnEnd.Radius); btnEnd.Region = new Region(path1); } btnEnd.Size = new Size(btnEnd.Radius * 2, btnEnd.Radius * 2); Point arrowPoint = DrawUtility.GetCyclePoint(100, 0, btnEnd.InArrowDegree); btnEnd.Left = btnEnd.InPoint.X + arrowPoint.X * btnEnd.Radius / 100 - btnEnd.Radius; btnEnd.Top = btnEnd.InPoint.Y + arrowPoint.Y * btnEnd.Radius / 100 - btnEnd.Radius; } }
/// <summary> /// </summary> public static void DrawProcess(ProcessButton btnProcess) { if (btnProcess != null) { GraphicsPath path1 = new GraphicsPath(); //path1.AddRectangle(DrawUtility.GetNormalRecangle(0, 0)); //control1.BackColor = SystemColors.Control; path1 = CreateRoundedRectanglePath(DrawUtility.GetNormalRecangle(0, 0), a * 2); btnProcess.Size = new Size(Convert.ToInt16((ah + rw - 5) * 1.2 * a), Convert.ToInt16(8 * 1.2 * a)); btnProcess.Region = new Region(path1); double degree = (btnProcess.InArrowDegree % 360 + 360) % 360; if (degree <= 45 || degree > 315) { //接触点为矩形按钮的左侧中点 btnProcess.Left = btnProcess.InPoint.X; btnProcess.Top = btnProcess.InPoint.Y - btnProcess.Height / 2; } else if (degree > 45 && degree <= 135) { //接触点为矩形按钮的上侧中点 btnProcess.Left = btnProcess.InPoint.X - btnProcess.Width / 2; btnProcess.Top = btnProcess.InPoint.Y; } else if (degree > 135 && degree <= 225) { //接触点为矩形按钮的右侧中点 btnProcess.Left = btnProcess.InPoint.X - btnProcess.Width; btnProcess.Top = btnProcess.InPoint.Y - btnProcess.Height / 2; } else if (degree > 225 && degree <= 315) { //接触点为矩形按钮的下侧中点 btnProcess.Left = btnProcess.InPoint.X - btnProcess.Width / 2; btnProcess.Top = btnProcess.InPoint.Y - btnProcess.Height; } } }