/// <inheritdoc /> public override void Do(DocumentEditorContext context) { var caret = (TextCaret)CursorHandle.GetCaret(context); caret = caret.DeleteText(1); context.Selection.Replace(caret); }
/// <inheritdoc /> public override void Undo(DocumentEditorContext context) { var caret = (TextCaret)CursorHandle.GetCaret(context); caret = caret.InsertText(OriginalText); context.Selection.Replace(caret); }
public void Close() { if (handle != null) { handle.Close(); handle = null; } }
/// <summary> /// Closes cursor and frees all resources. /// </summary> public void Dispose() { if (_cursorHandle == null) { return; } _cursorHandle.Dispose(); _cursorHandle = null; _cursorResult = null; }
/// <summary> /// Replaces the specified system cursor with the given cursor. The cursor will /// be destroyed and as such must not be loaded from a resource. Use CopyCursor /// on cursors loaded from resources before calling this method. /// </summary> public static void SetSystemCursor(CursorHandle cursor, SystemCursor id) { if (!Imports.SetSystemCursor(cursor, id)) { throw Errors.GetIoExceptionForLastError(); } // SetSystemCursor destroys passed in cursors cursor.SetHandleAsInvalid(); }
public static CursorHandle LoadCursor(CursorId id) { CursorHandle handle = Imports.LoadCursorW(ModuleInstance.Null, (IntPtr)id); if (handle.IsInvalid) { throw Errors.GetIoExceptionForLastError(); } return(handle); }
internal Cursor(MessageQueue queue) { int status = SafeNativeMethods.MQCreateCursor(queue.MQInfo.ReadHandle, out var result); if (MessageQueue.IsFatalError(status)) { throw new MessageQueueException(status); } this.handle = result; }
public static CursorHandle CopyCursor(CursorHandle cursor) { CursorHandle copy = Imports.CopyCursor(cursor); if (copy.IsInvalid) { throw Errors.GetIoExceptionForLastError(); } return(copy); }
internal Cursor(MessageQueue queue) { CursorHandle handle; int num = SafeNativeMethods.MQCreateCursor(queue.MQInfo.ReadHandle, out handle); if (MessageQueue.IsFatalError(num)) { throw new MessageQueueException(num); } this.handle = handle; }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Size: cxClient = lParam.LowWord; cyClient = lParam.HighWord; CursorHandle hCursor = Windows.SetCursor(CursorId.Wait); Windows.ShowCursor(true); hRgnClip.Dispose(); Span <RegionHandle> hRgnTemp = stackalloc RegionHandle[6]; hRgnTemp[0] = Gdi.CreateEllipticRegion(Rectangle.FromLTRB(0, cyClient / 3, cxClient / 2, 2 * cyClient / 3)); hRgnTemp[1] = Gdi.CreateEllipticRegion(Rectangle.FromLTRB(cxClient / 2, cyClient / 3, cxClient, 2 * cyClient / 3)); hRgnTemp[2] = Gdi.CreateEllipticRegion(Rectangle.FromLTRB(cxClient / 3, 0, 2 * cxClient / 3, cyClient / 2)); hRgnTemp[3] = Gdi.CreateEllipticRegion(Rectangle.FromLTRB(cxClient / 3, cyClient / 2, 2 * cxClient / 3, cyClient)); hRgnTemp[4] = Gdi.CreateRectangleRegion(Rectangle.FromLTRB(0, 0, 1, 1)); hRgnTemp[5] = Gdi.CreateRectangleRegion(Rectangle.FromLTRB(0, 0, 1, 1)); hRgnClip = Gdi.CreateRectangleRegion(Rectangle.FromLTRB(0, 0, 1, 1)); hRgnTemp[4].CombineRegion(hRgnTemp[0], hRgnTemp[1], CombineRegionMode.Or); hRgnTemp[5].CombineRegion(hRgnTemp[2], hRgnTemp[3], CombineRegionMode.Or); hRgnClip.CombineRegion(hRgnTemp[4], hRgnTemp[5], CombineRegionMode.Xor); for (int i = 0; i < 6; i++) { hRgnTemp[i].Dispose(); } Windows.SetCursor(hCursor); Windows.ShowCursor(false); return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { dc.SetViewportOrigin(new Point(cxClient / 2, cyClient / 2)); dc.SelectClippingRegion(hRgnClip); double fRadius = Hypotenuse(cxClient / 2.0, cyClient / 2.0); for (double fAngle = 0.0; fAngle < TWO_PI; fAngle += TWO_PI / 360) { dc.MoveTo(default); dc.LineTo(new Point( (int)(fRadius * Math.Cos(fAngle) + 0.5), (int)(-fRadius * Math.Sin(fAngle) + 0.5))); } }
public unsafe DirectXWindowClass( string className = default, ModuleInstance moduleInstance = default, ClassStyle classStyle = ClassStyle.HorizontalRedraw | ClassStyle.VerticalRedraw, IconHandle icon = default, IconHandle smallIcon = default, CursorHandle cursor = default, string menuName = null, int menuId = 0, int classExtraBytes = 0, int windowExtraBytes = 0) : base(className, moduleInstance, classStyle, BrushHandle.NoBrush, icon, smallIcon, cursor, menuName, menuId, classExtraBytes, windowExtraBytes) { }
internal unsafe Cursor(CursorHandle cursorHandle, QueryFunctions.CursorResultDelegate cursorResult, int count, JsonSerializer serializer) : base(cursorHandle, cursorResult, count) { Serializer = serializer; }
public static CursorHandle SetCursor(CursorHandle cursor) { return(Imports.SetCursor(cursor)); }
public static extern SharedCursorHandle SetCursor( CursorHandle hCursor);
internal unsafe CursorBase(CursorHandle cursorHandle, QueryFunctions.CursorResultDelegate cursorResult, int count) { _cursorHandle = cursorHandle; _cursorResult = cursorResult; _count = count; }
public void test_Transactions() { MQConnection con = null; try { con = connectToServer(address, null, null); addAllGroups(con); addAllUsers(con); addAllQueues(con); QueueHandle handle = new QueueHandle(); ErrorCode ec = con.OpenQueue(TEST_QUEUE[0], handle); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to open queue: " + TEST_QUEUE[0]); sendMessages(con, handle, 10, 0); ec = con.BeginTransaction(); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to BeginTransaction:" + ec); CursorHandle cur = new CursorHandle(); ec = con.OpenCursor(handle, cur); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to OpenCursor:" + ec); ec = con.AdvanceCursor(handle, cur); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to AdvanceCursor:" + ec); ec = con.AdvanceCursor(handle, cur); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to AdvanceCursor:" + ec); QueueMessage msg = new QueueMessage(); ec = con.RetrieveCursor(handle, true, cur, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to RetrieveCursor:" + ec); string txt = (new StreamReader(msg.Stream)).ReadLine(); Assert.IsTrue(txt.Equals("2"), "Incorrect Message: " + txt + " should be 2"); msg = new QueueMessage(); ec = con.RetrieveCursor(handle, true, cur, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to RetrieveCursor:" + ec); txt = (new StreamReader(msg.Stream)).ReadLine(); Assert.IsTrue(txt.Equals("3"), "Incorrect Message: " + txt + " should be 3"); msg = new QueueMessage(); ec = con.Retrieve(handle, true, 0, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to RetrieveCursor:" + ec); txt = (new StreamReader(msg.Stream)).ReadLine(); Assert.IsTrue(txt.Equals("0"), "Incorrect Message: " + txt + " should be 0"); int[] ids = { 1, 4, 5, 6, 7, 8, 9 }; for (int x = 0; x < ids.Length; x++) { msg = new QueueMessage(); ec = con.Retrieve(handle, true, 0, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to RetrieveCursor:" + ec); txt = (new StreamReader(msg.Stream)).ReadLine(); Console.WriteLine("txt: " + txt); Assert.IsTrue(int.Parse(txt) == ids[x], "Incorrect Message: " + txt + " should be " + ids[x]); } ec = con.RollbackTransaction(); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to RollbackTransaction:" + ec); for (int x = 0; x < 8; x++) { msg = new QueueMessage(); ec = con.Retrieve(handle, true, 0, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to RetrieveCursor:" + ec); txt = (new StreamReader(msg.Stream)).ReadLine(); Assert.IsTrue(int.Parse(txt) == x, "Incorrect Message: " + txt + " should be " + x); } ec = con.CommitTransaction(); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to CommitTransaction:" + ec); for (int x = 0; x < 2; x++) { msg = new QueueMessage(); ec = con.Retrieve(handle, true, 0, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to RetrieveCursor:" + ec); txt = (new StreamReader(msg.Stream)).ReadLine(); Assert.IsTrue(int.Parse(txt) == x + 8, "Incorrect Message: " + txt + " should be " + (x + 8)); } ec = con.RollbackTransaction(); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to RollbackTransaction:" + ec); ec = con.EndTransaction(); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to RollbackTransaction:" + ec); for (int x = 0; x < 2; x++) { msg = new QueueMessage(); ec = con.Retrieve(handle, true, 0, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to RetrieveCursor:" + ec); txt = (new StreamReader(msg.Stream)).ReadLine(); Assert.IsTrue(int.Parse(txt) == x + 8, "Incorrect Message: " + txt + " should be " + (x + 8)); } msg = new QueueMessage(); ec = con.Retrieve(handle, true, 0, msg); Assert.IsTrue(ec == ErrorCode.EC_NOMOREMESSAGES, "Able to RetrieveCursor:" + ec); ec = con.CloseQueue(handle); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unble to CloseQueue:" + ec); } finally { if (con != null) { con.Close(); } } }
public void test_PeekID_PeekFront_OpenCursor_PeekCursor_SeekID_RetrieveCursor_AdvanceCursor_TestCurosr_CloseCursor_RetrieveID() { MQConnection con = null; try { con = connectToServer(address, null, null); addAllGroups(con); addAllUsers(con); addAllQueues(con); QueueHandle handle = new QueueHandle(); ErrorCode ec = con.OpenQueue(TEST_QUEUE[0], handle); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to open queue: " + TEST_QUEUE[0]); sendMessages(con, handle, 5, 0); QueueMessage msg = new QueueMessage(); StreamWriter sw = new StreamWriter(msg.Stream); sw.WriteLine(SPECIAL_MESSAGE); sw.Close(); byte[] b = { 0, 0, 0, 0, 0, 0, 0, 0 }; UUID uuid = new UUID(new Guid(123456789, 4321, 1234, b)); msg.ReciptID = uuid; //msg.ReciptID = ((UUID)uuid.Clone()); ec = con.Enqueue(handle, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to write special message"); sendMessages(con, handle, 5, 5); msg = new QueueMessage(); ec = con.PeekID(handle, true, uuid, 0, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to PeekID:" + ec); string txt = (new StreamReader(msg.Stream)).ReadLine(); Console.WriteLine("txt:\t\t\t" + txt); Console.WriteLine("uuid:\t\t\t" + (Guid)uuid); Console.WriteLine("msg.ReceiptID:\t" + (Guid)msg.ReciptID); Console.WriteLine("txt.Equals(SPECIAL_MESSAGE): " + txt.Equals(SPECIAL_MESSAGE)); Console.WriteLine("uuid.Equals(msg.ReceiptID)): " + uuid.Equals(msg.ReciptID)); Assert.IsTrue(txt.Equals(SPECIAL_MESSAGE) && uuid.Equals(msg.ReciptID), "Incorrect PeekID Message: " + (Guid)msg.ReciptID); msg = new QueueMessage(); ec = con.PeekFront(handle, true, 0, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to PeekFront"); txt = (new StreamReader(msg.Stream)).ReadLine(); Assert.IsTrue(txt.Equals("0"), "Incorrect PeekFront Message: body=" + txt); CursorHandle cur = new CursorHandle(); ec = con.OpenCursor(handle, cur); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to OpenCursor"); ec = con.SeekID(handle, uuid, 0, cur); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to SeekID"); msg = new QueueMessage(); ec = con.PeekCursor(handle, true, cur, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to PeekCursor"); txt = (new StreamReader(msg.Stream)).ReadLine(); Assert.IsTrue(txt.Equals(SPECIAL_MESSAGE) && uuid.Equals(msg.ReciptID), "Incorrect PeekCursor Message: " + msg.ReciptID); ec = con.AdvanceCursor(handle, cur); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to AdvanceCursor"); msg = new QueueMessage(); ec = con.PeekCursor(handle, true, cur, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to PeekCursor (after advance)"); txt = (new StreamReader(msg.Stream)).ReadLine(); Assert.IsTrue(txt.Equals("5"), "Incorrect PeekCursor (after advance) Message: " + msg.ReciptID); msg = new QueueMessage(); ec = con.RetrieveCursor(handle, true, cur, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to RetrieveCursor"); txt = (new StreamReader(msg.Stream)).ReadLine(); Assert.IsTrue(txt.Equals("5"), "Incorrect PeekCursor (after RetrieveCursor) Message: " + msg.ReciptID); ec = con.TestCursor(handle, cur); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to test Cursor, ec: " + ec); ec = con.CloseCursor(handle, cur); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to CloseCursor, ec: " + ec); msg = new QueueMessage(); ec = con.RetrieveID(handle, true, uuid, 0, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to RetrieveID"); txt = (new StreamReader(msg.Stream)).ReadLine(); Assert.IsTrue(txt.Equals(SPECIAL_MESSAGE) && uuid.Equals(msg.ReciptID), "Incorrect RetrieveID Message: " + msg.ReciptID); int[] bodies = { 0, 1, 2, 3, 4, 6, 7, 8, 9 }; // 5 was retrieved above. for (int x = 0; x < bodies.Length; x++) { msg = new QueueMessage(); ec = con.Retrieve(handle, true, 0, msg); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to retrieve message: " + x); txt = (new StreamReader(msg.Stream)).ReadLine(); Console.WriteLine("txt: " + txt); Assert.IsTrue(int.Parse(txt) == bodies[x], "Incorrect message: " + txt); } ec = con.CloseQueue(handle); Assert.IsTrue(ec == ErrorCode.EC_NOERROR, "Unable to Close queue"); } finally { if (con != null) { con.Close(); } } }
static LRESULT WindowProcedure(WindowHandle window, WindowMessage message, WPARAM wParam, LPARAM lParam) { switch (message) { case WindowMessage.Size: cxClient = lParam.LowWord; cyClient = lParam.HighWord; CursorHandle hCursor = Windows.SetCursor(CursorId.Wait); Windows.ShowCursor(true); hRgnClip?.Dispose(); RegionHandle[] hRgnTemp = new RegionHandle[6]; hRgnTemp[0] = Windows.CreateEllipticRegion(0, cyClient / 3, cxClient / 2, 2 * cyClient / 3); hRgnTemp[1] = Windows.CreateEllipticRegion(cxClient / 2, cyClient / 3, cxClient, 2 * cyClient / 3); hRgnTemp[2] = Windows.CreateEllipticRegion(cxClient / 3, 0, 2 * cxClient / 3, cyClient / 2); hRgnTemp[3] = Windows.CreateEllipticRegion(cxClient / 3, cyClient / 2, 2 * cxClient / 3, cyClient); hRgnTemp[4] = Windows.CreateRectangleRegion(0, 0, 1, 1); hRgnTemp[5] = Windows.CreateRectangleRegion(0, 0, 1, 1); hRgnClip = Windows.CreateRectangleRegion(0, 0, 1, 1); hRgnTemp[4].CombineRegion(hRgnTemp[0], hRgnTemp[1], CombineRegionMode.Or); hRgnTemp[5].CombineRegion(hRgnTemp[2], hRgnTemp[3], CombineRegionMode.Or); hRgnClip.CombineRegion(hRgnTemp[4], hRgnTemp[5], CombineRegionMode.Xor); for (int i = 0; i < 6; i++) { hRgnTemp[i]?.Dispose(); } Windows.SetCursor(hCursor); Windows.ShowCursor(false); return(0); case WindowMessage.Paint: using (DeviceContext dc = window.BeginPaint()) { dc.SetViewportOrigin(cxClient / 2, cyClient / 2); dc.SelectClippingRegion(hRgnClip); double fRadius = Hypotenuse(cxClient / 2.0, cyClient / 2.0); for (double fAngle = 0.0; fAngle < TWO_PI; fAngle += TWO_PI / 360) { dc.MoveTo(0, 0); dc.LineTo( (int)(fRadius * Math.Cos(fAngle) + 0.5), (int)(-fRadius * Math.Sin(fAngle) + 0.5)); } } return(0); case WindowMessage.Destroy: hRgnClip?.Dispose(); Windows.PostQuitMessage(0); return(0); } return(Windows.DefaultWindowProcedure(window, message, wParam, lParam)); }
public static extern CursorHandle CopyCursor( CursorHandle pcur);
public static extern bool SetSystemCursor( CursorHandle hcur, SystemCursor id);