Permalink
Browse files

[Examples] Only use WinForms when supported.

  • Loading branch information...
1 parent b23d06e commit b1a31c08cc358b35e95bae58c379486b9166c3bf @thefiddler thefiddler committed Jul 18, 2014
Showing with 23 additions and 4 deletions.
  1. +23 −4 Source/Examples/OpenTK/Test/TestResolutionChanges.cs
@@ -23,16 +23,35 @@ public static void Main()
DisplayDevice dev = DisplayDevice.GetDisplay(DisplayIndex.First + i);
if (dev != null)
{
- Trace.WriteLine(dev.ToString());
- MessageBox.Show(dev.ToString());
+ Print(dev.ToString());
+
dev.ChangeResolution(dev.SelectResolution(640, 480, 32, 60.0f));
Thread.Sleep(1000);
- MessageBox.Show(dev.ToString());
+ Print(dev.ToString());
+
dev.RestoreResolution();
Thread.Sleep(1000);
- MessageBox.Show(dev.ToString());
+ Print(dev.ToString());
+ }
+ }
+ }
+
+ static void Print(string msg)
+ {
+ Trace.WriteLine(msg);
+
+ // Also display a MessageBox when running on a platform
+ // with WinForms support.
+ try
+ {
+ if (Configuration.RunningOnWindows || Configuration.RunningOnX11 || Configuration.RunningOnMacOS)
+ {
+ MessageBox.Show(msg);
}
}
+ catch
+ {
+ }
}
}
}

0 comments on commit b1a31c0

Please sign in to comment.