static XplatUI() { // Compose name with current domain id because on Win32 we register class name // and name must be unique to process. If we load MWF into multiple appdomains // and try to register same class name we fail. default_class_name = "SWFClass" + System.Threading.Thread.GetDomainID().ToString(); if (RunningOnUnix) { //if (Environment.GetEnvironmentVariable ("not_supported_MONO_MWF_USE_NEW_X11_BACKEND") != null) { // driver=XplatUIX11_new.GetInstance (); //} else if (Environment.GetEnvironmentVariable("MONO_MWF_MAC_FORCE_X11") != null) { driver = XplatUIX11.GetInstance(); } else { IntPtr buf = Marshal.AllocHGlobal(8192); // This is a hacktastic way of getting sysname from uname () if (uname(buf) != 0) { // WTF: We cannot run uname driver = XplatUIX11.GetInstance(); } else { string os = Marshal.PtrToStringAnsi(buf); if (os == "Darwin") { driver = XplatUICarbon.GetInstance(); } else { driver = XplatUIX11.GetInstance(); } } Marshal.FreeHGlobal(buf); } } else { driver = XplatUIWin32.GetInstance(); } driver.InitializeDriver(); // Initialize things that need to be done after the driver is ready DataFormats.GetFormat(0); #if NET_2_0 // Signal that the Application loop can be run. // This allows UIA to initialize a11y support for MWF // before the main loop begins. Application.FirePreRun(); #endif }
public void VisualStyleRendererDrawBackgroundExcludingArea(IntPtr theme, IDeviceContext dc, int part, int state, Rectangle_ bounds, Rectangle_ excludedArea) { XplatUIWin32.RECT bounds_rect = XplatUIWin32.RECT.FromRectangle(bounds); IntPtr hdc = dc.GetHdc(); XplatUIWin32.Win32ExcludeClipRect(hdc, excludedArea.Left, excludedArea.Top, excludedArea.Right, excludedArea.Bottom); UXTheme.DrawThemeBackground(theme, hdc, part, state, ref bounds_rect, IntPtr.Zero); IntPtr hrgn = XplatUIWin32.Win32CreateRectRgn(excludedArea.Left, excludedArea.Top, excludedArea.Right, excludedArea.Bottom); XplatUIWin32.Win32ExtSelectClipRgn(hdc, hrgn, (int)ClipCombineMode.RGN_OR); XplatUIWin32.Win32DeleteObject(hrgn); dc.ReleaseHdc(); }
static XplatUI() { #if XAMARINMAC driver = XplatUICocoa.GetInstance(); #else driver = XplatUIWin32.GetInstance(); #endif driver.InitializeDriver(); // Initialize things that need to be done after the driver is ready DataFormats.GetFormat(0); // Signal that the Application loop can be run. // This allows UIA to initialize a11y support for MWF // before the main loop begins. Application.FirePreRun(); }
internal static uint GetData(IntPtr this_, ref FORMATETC pformatetcIn, IntPtr pmedium) { int index; index = FindFormat(pformatetcIn); if (index != -1) { medium.tymed = TYMED.TYMED_HGLOBAL; medium.hHandle = XplatUIWin32.DupGlobalMem(((STGMEDIUM)DragMediums[index]).hHandle); medium.pUnkForRelease = IntPtr.Zero; try { Marshal.StructureToPtr(medium, pmedium, false); } catch (Exception e) { Console.WriteLine("Error: {0}", e.Message); } return(S_OK); } return(DV_E_FORMATETC); }
private static bool AddFormatAndMedium(ClipboardFormats cfFormat, object data) { STGMEDIUM medium; FORMATETC format; IntPtr hmem; IntPtr hmem_ptr; byte[] b; switch (cfFormat) { case ClipboardFormats.CF_TEXT: { b = XplatUIWin32.StringToAnsi((string)data); hmem = XplatUIWin32.CopyToMoveableMemory(b); break; } case ClipboardFormats.CF_UNICODETEXT: { b = XplatUIWin32.StringToUnicode((string)data); hmem = XplatUIWin32.CopyToMoveableMemory(b); break; } case ClipboardFormats.CF_HDROP: { IEnumerator e; StringBuilder sb; long hmem_string_ptr; IntPtr string_buffer; int string_buffer_size; sb = new StringBuilder(); // Make sure object is enumerable; otherwise if ((data is string) || !(data is IEnumerable)) { sb.Append(data.ToString()); sb.Append('\0'); sb.Append('\0'); } else { e = ((IEnumerable)data).GetEnumerator(); while (e.MoveNext()) { sb.Append(e.Current.ToString()); sb.Append('\0'); } sb.Append('\0'); } string_buffer = Marshal.StringToHGlobalUni(sb.ToString()); string_buffer_size = (int)XplatUIWin32.Win32GlobalSize(string_buffer); // Write DROPFILES structure hmem = XplatUIWin32.Win32GlobalAlloc(XplatUIWin32.GAllocFlags.GMEM_MOVEABLE | XplatUIWin32.GAllocFlags.GMEM_DDESHARE, 0x14 + string_buffer_size); hmem_ptr = XplatUIWin32.Win32GlobalLock(hmem); Marshal.WriteInt32(hmem_ptr, 0x14); // pFiles Marshal.WriteInt32(hmem_ptr, 1 * Marshal.SizeOf(typeof(uint)), 0); // point.x Marshal.WriteInt32(hmem_ptr, 2 * Marshal.SizeOf(typeof(uint)), 0); // point.y Marshal.WriteInt32(hmem_ptr, 3 * Marshal.SizeOf(typeof(uint)), 0); // fNc Marshal.WriteInt32(hmem_ptr, 4 * Marshal.SizeOf(typeof(uint)), 1); // fWide hmem_string_ptr = (long)hmem_ptr; hmem_string_ptr += 0x14; XplatUIWin32.Win32CopyMemory(new IntPtr(hmem_string_ptr), string_buffer, string_buffer_size); Marshal.FreeHGlobal(string_buffer); XplatUIWin32.Win32GlobalUnlock(hmem_ptr); break; } case ClipboardFormats.CF_DIB: { b = XplatUIWin32.ImageToDIB((Image)data); hmem = XplatUIWin32.CopyToMoveableMemory(b); break; } default: { hmem = IntPtr.Zero; break; } } if (hmem != IntPtr.Zero) { medium = new STGMEDIUM(); medium.tymed = TYMED.TYMED_HGLOBAL; medium.hHandle = hmem; medium.pUnkForRelease = IntPtr.Zero; DragMediums.Add(medium); format = new FORMATETC(); format.ptd = IntPtr.Zero; format.dwAspect = DVASPECT.DVASPECT_CONTENT; format.lindex = -1; format.tymed = TYMED.TYMED_HGLOBAL; format.cfFormat = cfFormat; DragFormats.Add(format); return(true); } return(false); }