private void StreamOut(Stream data, int flags, bool includeCrLfs) { this.editStream = data; try { int num = 0; System.Windows.Forms.NativeMethods.EDITSTREAM es = new System.Windows.Forms.NativeMethods.EDITSTREAM(); if ((flags & 0x10) != 0) { num = 10; } else { num = 6; } if ((flags & 2) != 0) { num |= 0x40; } else if (includeCrLfs) { num |= 0x20; } else { num |= 0x10; } es.dwCookie = (IntPtr) num; es.pfnCallback = new System.Windows.Forms.NativeMethods.EditStreamCallback(this.EditStreamProc); if (IntPtr.Size == 8) { System.Windows.Forms.NativeMethods.EDITSTREAM64 lParam = this.ConvertToEDITSTREAM64(es); System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0x44a, flags, lParam); es.dwError = this.GetErrorValue64(lParam); } else { System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0x44a, flags, es); } if (es.dwError != 0) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("SaveTextError")); } } finally { this.editStream = null; } }
private void StreamIn(Stream data, int flags) { if ((flags & 0x8000) == 0) { System.Windows.Forms.NativeMethods.CHARRANGE lParam = new System.Windows.Forms.NativeMethods.CHARRANGE(); System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0x437, 0, lParam); } try { this.editStream = data; if ((flags & 2) != 0) { long position = this.editStream.Position; byte[] buffer = new byte[SZ_RTF_TAG.Length]; this.editStream.Read(buffer, (int) position, SZ_RTF_TAG.Length); string str = Encoding.Default.GetString(buffer); if (!SZ_RTF_TAG.Equals(str)) { throw new ArgumentException(System.Windows.Forms.SR.GetString("InvalidFileFormat")); } this.editStream.Position = position; } int num2 = 0; System.Windows.Forms.NativeMethods.EDITSTREAM es = new System.Windows.Forms.NativeMethods.EDITSTREAM(); if ((flags & 0x10) != 0) { num2 = 9; } else { num2 = 5; } if ((flags & 2) != 0) { num2 |= 0x40; } else { num2 |= 0x10; } es.dwCookie = (IntPtr) num2; es.pfnCallback = new System.Windows.Forms.NativeMethods.EditStreamCallback(this.EditStreamProc); base.SendMessage(0x435, 0, 0x7fffffff); if (IntPtr.Size == 8) { System.Windows.Forms.NativeMethods.EDITSTREAM64 editstream2 = this.ConvertToEDITSTREAM64(es); System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0x449, flags, editstream2); es.dwError = this.GetErrorValue64(editstream2); } else { System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, base.Handle), 0x449, flags, es); } this.UpdateMaxLength(); if (!this.GetProtectedError()) { if (es.dwError != 0) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("LoadTextError")); } base.SendMessage(0xb9, -1, 0); base.SendMessage(0xba, 0, 0); } } finally { this.editStream = null; } }