// Nanjing thousands of miles 2005-3-17
///
// Progress information processing commission
/// summary>
/// The number of steps that have been completed param>
/// The total number of steps param>
Public Delegate Void ProgressHandler (Int CompletedStep, Int Totalstep);
///
/// universal function collection
/// summary>
Public Class Yyfcommon
{
///
// / This function does not perform errors to send data to the specified URL using the POST method.
/// summary>
/// URL string param>
/// Binary data to send param>
/// progress processing when sending data param>
/// progress processing when receiving data param>
///
Public static botty [] httppostdata
String Strurl,
Byte [] Bytsend,
ProgressHandler SendProgress,
ProgressHandler AcceptProgress
{
// send data
System.net.httpwebrequest myreq = (system.net.httpwebrequest) system.net.WebRequest.create (Strurl);
MyReq.Method = "post";
System.io.stream mystream = myreq.getRequestStream ();
Int iCount = 0;
IF (sendProgress! = null)
SendProgress (0, Bytsend.Length);
While (ICOUNT { IF (ICOUNT 1024> ByTsend.Length) { MyStream.write (Bytsend, ICOUNT, BYTSEND.LENGTH - ICOUNT); iCount = bytesend.length; } Else { MyStream.write (Bytsend, Icount, 1024); ICOUNT = 1024; } IF (sendProgress! = null) SendProgress (iCount, ByTsend.Length); } // while IF (sendProgress! = null) SendProgress (Bytsend.Length, Bytsend.Length); MyStream.close (); // Accept data System.net.httpwebresponse myres = null; myres = myreq.getResponse () as system.net.httpwebresponse; MyStream = myres.getResponsestream (); System.io.MemoryStream mybuf = new system.io.MemoryStream (1024); Byte [] bytbuf = new byte [1024]; INT contentLength = (int) myres.contentLength; INT AcceptLength = 0; an (acceptprogress! = null) Acceptprogress (0, ContentLength); While (True) { INT Ilen = MyStream.read (bytbuf, 0,1024); IF (ilen == 0) Break; Mybuf.write (bytbuf, 0, Ilen); AcceptLength = Ilen; IF (AcceptLength> ContentLength) CONTENTLENGTH = AcceptLect " an (acceptprogress! = null) Acceptprogress (AcceptLength, ContentLength); } // while an (acceptprogress! = null) Acceptprogress (AcceptLength, ContentLength); MyStream.close (); MYRES.CLOSE (); MyReq.abort (); BYTE [] BYTRETURN = mybuf.toArray (); Mybuf.close (); Return BytreTurn; } // public static Byte [] httppostdata () /// // / According to the data source parameter of the saved in a list /// summary> /// Original string param> /// tagged head string param> /// tag tail string param> /// Save all parameters list param> /// Public Static String fixvariableString (String Strtext, String strhead, String strend, System.collections.hashtable mykeys { // If the original string is invalid or there is no available parameters to exit the function IF (strText == NULL || strhead == NULL || strend == null || strHead.Length == 0 || strend.length == 0 || strText.length == 0 || mykeys == NULL || myKeys.count == 0) Return strText; INDEX = strText.indexof (strhead); // If the original string has no variable tag, exit the function IF (INDEX <0) Return strText; String strkey; INT index2; INT LastIndex = 0; System.Text.StringBuilder mystr = new system.text.stringbuilder (); DO { / / Find a sub-string with "[Content]" style // If you don't find the character pair of ["and"] "to exit the loop Index2 = Strtext.indexof (Strend, INDEX 1); IF (Index2> Index) { // If the "]" symbol appears after the "[" symbol, "[]" characters are // Find the result to ensure that "[]" characters do not appear "[" [" INT index3 = index; DO { Index = index3; Index3 = Strtext.indexof (Strhead, Index3 1); WHILE (Index3> index && index3 // Get the slave string of the character pair, the sub string is the parameter name. // If this parameter name is valid, the parameter value is output to the output result. / / Otherwise no additional processing strkey = strText.Substring (Index strhead.length, index2 - index - strhead.length); IF (myKeys.containskey) { LastIndex { MyStr.Append (Strtext.Substring (LastIndex, INDEX - LastIndex); } MyStr.Append (myKeys [strkey] as string; INDEX = Index2 Strend.Length; LastIndex = Index; } Else INDEX = Index2 Strend.Length; } Else { Break; } WHILE (INDEX> = 0 && index // Add the remaining strings after processing LastIndex MyStr.Append (Strtext.Substring (lastIndex)); Return myStr.toT7tring (); } // end of function: fixvariableString /// /// calculate the drag and drop control rectangle of the specified rectangle /// summary> /// Main rectangular area param> /// Drag and drop rectangle param> /// Drag and drop in the main rectangle inside, if false drags the rectangular valve param> /// /// The user uses a mouse drag operation to drag these 8 control points to change the position and size of the rectangular area, which can be inside the area area, /// can also be 8 in the rectangular area, the drag rectangle is 8, respectively from 0 to 7, respectively. /// /// Drag and drop rectangle /// - --─────────────── /// │ ■ 0 1 ■ 2 ■ │ /// │ │ /// │ │ /// │ │ /// │ │ /// │ ■ 7 3 ■ │ /// │ │ /// │ │ /// │ │ /// │ │ /// │ ■ 6 5 ■ 4 ■ │ /// - --─────────────── /// /// external drag rectangle /// /// ■ ■ ■ /// - ──────────────── /// │0 1 2│ /// │ │ /// │ │ /// │ │ /// │ │ /// ■ │7 3│ ■ /// │ │ /// │ │ /// │ │ /// │ │ /// │6 5 4 │ /// - ──────────────── /// ■ ■ ■ /// pre> /// remarks> /// Public static system.drawing.rectangle [] getDragRects (System.drawing.Rectangle MyRect, int DragRectsize, Bool InnerDragRect) { System.drawing.Rectangle [] DRAGRECTS = New System.drawing.Rectangle [8]; IF (InnerDragRect) { DragRects [0] = new System.Drawing.Rectangle (myRect.X, myRect.Y, DragRectSize, DragRectSize); DragRects [1] = new System.Drawing.Rectangle (myRect.X (int) ((myRect.Width - DragRectsize) / 2), MyRect.y, DragRectsize, DragRectsize; DragRects [2] = New System.drawing.Rectangle (MyRect.right - DragRectSize, MyRect.y, DragRectsize, DragRectsize); DragRects [3] = New System.drawing.Rectangle (MyRect.right - DragRectsize, MyRect.Y (int)) / 2) / 2) / 2), DragRectsize, DragRectsize; DragRects [4] = New System.drawing.Rectangle (MyRect.right - DragRectSize, MyRect.Bottom - DragRectsize, DragRectsize, DragRectsize); DragRects [5] = New System.drawing.Rectangle (MyRect.x (int)) / 2) / 2) / 2), MyRect.Bottom - DragRectSize, DragRectsize, DragRectsize DragRects [6] = New System.drawing.Rectangle (MyRect.x, MyRect.Bottom - DragRectsize, DragRectsize, DragRectsize); DragRects [7] = New System.drawing.Rectangle (MyRect.x, MyRect.Y (INT) ((MyRect.Height - DragRectsize) / 2), DragRectsize, DragRectsize; } Else { DragRects [0] = New System.drawing.Rectangle (MyRect.x - DragRectsize, MyRect.y - DragRectsize, DragRectsize, DragRectsize); DragRects [1] = New System.drawing.Rectangle (MyRect.width - DragRectsize) / 2), MyRect.Y - DragRectsize, DragRectsize, DragRectsize; DragRects [2] = New System.drawing.Rectangle (MyRect.right, MyRect.y - DragRectsize, DragRectsize, DragRectsize); DragRects [3] = New System.drawing.Rectangle (MyRect.Right, MyRect.Y (INT) ((INT) ((INT) ((INT) ((INT) ((INT) ((INT) ((INT) ((INT) ((INT) ((INT) ((INT) ((INT) ((INT) ((INT) ((INT) ((INT) ((INT) ((INT), DragRectsize, DragRectsize; DragRects [4] = new System.Drawing.Rectangle (myRect.Right, myRect.Bottom, DragRectSize, DragRectSize); DragRects [5] = new System.Drawing.Rectangle (myRect.X (int) ((myRect.Width - DragRectsize) / 2), MyRect.Bottom, DragRectsize, DragRectsize; DragRects [6] = New System.drawing.Rectangle (MyRect.x - DragRectsize, MyRect.Bottom, DragRectsize, DragRectsize); DragRects [7] = New System.drawing.Rectangle (MyRect.x - DragRectSize, MyRect.height - DragRectsize / 2) / 2), DragRectSize, DragRectsize; } Return DragRects; } /// / / / Calculate the mouse cursor position on the rectangle /// summary> /// /// The mouse setting is as follows /// Northwest - Northeast South Northeast - Southwest /// ■ ■ ■ /// - ──────────────── /// │0 1 2│ /// │ │ /// │ │ /// │ │ /// │ │ /// ■ │7 West - South 3│ ■ West - South /// │ │ /// │ │ /// │ │ /// │ │ /// │6 5 4 │ /// - ──────────────── /// ■ ■ ■ /// Northeast - Northwestern South China Northwest - Southeast /// remarks> /// Drag and drop the number of rectangles from 0 to 7 param> /// Public static system.windows.Forms.cursor getDragRectCursor (int index) { Switch (INDEX) { Case 0: Return system.windows.Forms.cursors.sizenwse; Case 1: Return System.windows.Forms.cursors.sizens; Case 2: Return system.windows.Forms.cursors.siznesw; Case 3: Return system.windows.Forms.cursors.sizewe; Case 4: Return system.windows.Forms.cursors.sizenwse; Case 5: Return System.windows.Forms.cursors.sizens; Case 6: Return system.windows.Forms.cursors.siznesw; Case 7: Return system.windows.Forms.cursors.sizewe; } Return NULL; } } /// /// Operating the system shearing board processing module, the method provided is a static function /// summary> /// /// C # language uses this class example, get plain text data from the operating system shear board // / / Judgment whether the operating system shear board saves plain text data /// if (clipboardhandler.cangetText ()) /// { / / / / Return to the obtained plain text data /// Return ClipboardHandler.getTextFromClipboard (); ///} /// // / Set plain text data to the operating system shear board /// String Strtext = "Plain text data to be set"; /// ClipboardHandler.SettextToclipboard (Strtext); /// esample> Public Class ClipboardHandler { /// / / Whether you can get text from the operating system shear board /// summary> /// Public Static Bool CangetText () { // clipboard.getdataObject May throw an Exception ... Try { System.windows.forms.idataObject data = system.windows.forms.clipboard.getdataObject (); Return Data! = Null && Data.GetdataPresent (System.Windows.Forms.DataFormats.Text); } Catch (Exception E) { Return False; } } // // /// / / / Can you set the text to the operating system shear board // /// summary> ///// // public static bool can settext () // { // Return True; //} /// // / Set text data to the operating system shear board /// summary> /// Text Data param> /// Public Static Bool SetTextToclipboard (String Strtext) { IF (Strtext! = Null && Strtext.length> 0) { Try { System.windows.Forms.DataObject DataObject = new system.windows.Forms.DataObject (); DataObject.Setdata (System.Windows.Forms.DataFormats.UnicodeText, true, strText); System.windows.Forms.clipboard.SetDataObject (DataObject, true); Return True; } Catch { } } Return False; } /// /// Get text from the operating system shear board /// summary> /// Public static string getTextFromClipboard () { Try { System.windows.forms.idataObject data = system.windows.forms.clipboard.getdataObject (); IF (data.getdatapresent (system.windows.forms.dataFormats.Unicodetext)) { String stratext = (string) data.getdata (system.windows.forms.dataFormats.Unicodetext); Return strText; } } Catch {} Return NULL; } }