diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-10 06:03:25 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-03-10 06:03:25 +0100 |
| commit | 523a04de5252ae089e52eeaf9c8d83a5e0676731 (patch) | |
| tree | 4498dc0edfa1e5b101807bdc85061884bda3dac2 /src/Interface.cs | |
| parent | 991a840bf9bc92ddc76e9e9961706168328a211b (diff) | |
getStremFromPath made instanced for overriding in designiface, crowide wip
Diffstat (limited to 'src/Interface.cs')
| -rw-r--r-- | src/Interface.cs | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/src/Interface.cs b/src/Interface.cs index f17ac895..00a952b0 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -88,8 +88,6 @@ namespace Crow } } - loadCursors (); - FontRenderingOptions = new FontOptions (); FontRenderingOptions.Antialias = Antialias.Subpixel; FontRenderingOptions.HintMetrics = HintMetrics.On; @@ -103,6 +101,7 @@ namespace Crow public void Init () { CurrentInterface = this; + loadCursors (); loadStyling (); findAvailableTemplates (); initTooltip (); @@ -271,17 +270,17 @@ namespace Crow } } - static void loadCursors(){ + void loadCursors(){ //Load cursors - XCursor.Cross = XCursorFile.Load("#Crow.Images.Icons.Cursors.cross").Cursors[0]; - XCursor.Default = XCursorFile.Load("#Crow.Images.Icons.Cursors.arrow").Cursors[0]; - XCursor.NW = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_left_corner").Cursors[0]; - XCursor.NE = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_right_corner").Cursors[0]; - XCursor.SW = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors[0]; - XCursor.SE = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors[0]; - XCursor.H = XCursorFile.Load("#Crow.Images.Icons.Cursors.sb_h_double_arrow").Cursors[0]; - XCursor.V = XCursorFile.Load("#Crow.Images.Icons.Cursors.sb_v_double_arrow").Cursors[0]; - XCursor.Text = XCursorFile.Load("#Crow.Images.Icons.Cursors.ibeam").Cursors[0]; + XCursor.Cross = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.cross").Cursors[0]; + XCursor.Default = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.arrow").Cursors[0]; + XCursor.NW = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.top_left_corner").Cursors[0]; + XCursor.NE = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.top_right_corner").Cursors[0]; + XCursor.SW = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors[0]; + XCursor.SE = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors[0]; + XCursor.H = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.sb_h_double_arrow").Cursors[0]; + XCursor.V = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.sb_v_double_arrow").Cursors[0]; + XCursor.Text = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.ibeam").Cursors[0]; } #endregion @@ -329,7 +328,28 @@ namespace Crow /// <returns>A file or resource stream</returns> /// <param name="path">This could be a normal file path, or an embedded ressource ID /// Resource ID's must be prefixed with '#' character</param> - public static Stream GetStreamFromPath (string path) + public virtual Stream GetStreamFromPath (string path) + { + Stream stream = null; + + if (path.StartsWith ("#")) { + string resId = path.Substring (1); + //try/catch added to prevent nunit error + try { + stream = System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream (resId); + } catch{} + if (stream == null)//try to find ressource in Crow assembly + stream = System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceStream (resId); + if (stream == null) + throw new Exception ("Resource not found: " + path); + } else { + if (!File.Exists (path)) + throw new FileNotFoundException ("File not found: ", path); + stream = new FileStream (path, FileMode.Open, FileAccess.Read); + } + return stream; + } + public static Stream StaticGetStreamFromPath (string path) { Stream stream = null; |