public TextEditingAction(SDL.SDL_TextEditingEvent e) { unsafe { Text = SDLUtil.NullTerminatedUTF8String(new IntPtr(e.text)); } CursorPos = e.start; SelectionLen = e.length; }
private static void AssertNotEquals(string testName, object o1, object o2) { assertCount++; if (Equals(o1, o2)) { failures++; Console.WriteLine("!! Failure: " + testName + " - " + SDLUtil.Format(o1) + " equals " + SDLUtil.Format(o2)); } }
private static bool IsCoercible(System.Type type) { if (!SDLUtil.IsCoercible(type) && !type.IsEnum) { return(ReflectionHelper.IsNullable(type)); } else { return(true); } }
static void Main(string[] args) { SDLApp app = new SDLApp(true); SystemInfo info = new SystemInfo(); Console.WriteLine("CPU Cache size: {0} | Ram Size: {1} | CPU features: {2}", info.CPUCacheSize, info.RAMSizeMB, info.ProcessorFeatures); Console.WriteLine("DPI: Horizontal: {0} | Vertical: {1} | Diagonal: {2}", info.HorizontalDPI, info.VerticalDPI, info.DiagonalDPI); Console.WriteLine("Current video driver: {0} | All video drivers: {1}", info.CurrentVideoDriver, string.Join(" ", info.InstalledVideoDrivers)); Console.WriteLine("Power left (percentage): {0} (seconds): {1}", info.PowerLeftPercentage, info.PowerLeftSeconds); Console.WriteLine("Current clipboard text: {0}", SDLUtil.GetClipboard()); Console.WriteLine("Type name of debug window to launch"); string windowName = Console.ReadLine(); switch (windowName) { case "events": { app.RegisterWindow(new TestWindow1()); break; } case "fps": { app.RegisterWindow(new TestWindow2()); break; } case "mixer": { app.RegisterWindow(new TestWindow3()); break; } case "graphics": { app.RegisterWindow(new TestWindow4()); break; } default: { Console.WriteLine("Press enter to launch 3 debug messageboxes"); Console.ReadLine(); MessageBox.ShowMessageBox(MessageBoxFlags.Info, "Info", "This should be info box"); int s = MessageBox.ShowMessageBoxEx(MessageBoxFlags.Warning, "Warning", "This should be warning box", new string[] { "0", "1", "2" }); Console.WriteLine("Button pressed: {0}", s); MessageBox.ShowMessageBox(MessageBoxFlags.Error, "Error", "This should be error box"); break; } } app.RunWindowLoop(); app.Dispose(); }
private static object TryCoerce(object value, out bool simpleType) { value = SDLUtil.TryCoerce(value, out simpleType); if (!simpleType) { System.Type type = value.GetType(); if (value is Enum) { value = (object)Util.GetName(type, value); simpleType = true; } else if (ReflectionHelper.IsNullable(type)) { value = SDLUtil.TryCoerce(ReflectionHelper.GetValue(type.GetProperty("Value"), value), out simpleType); } } return(value); }