-
-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve ThemedMessageBox with wrapping logic and default system icons.
Move Eto.IO.SystemIcons to Eto.Drawing, and add Information, Warning, Error, and Question icons.
- Loading branch information
Showing
31 changed files
with
1,093 additions
and
596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Eto.GtkSharp.Drawing; | ||
|
||
public class SystemIconsHandler : SystemIcons.IHandler | ||
{ | ||
#region ISystemIcons Members | ||
|
||
public Icon GetFileIcon(string fileName, SystemIconSize size) | ||
{ | ||
return null; | ||
} | ||
|
||
public Icon Get(SystemIconType type, SystemIconSize size) | ||
{ | ||
return null; | ||
} | ||
|
||
#endregion | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Eto.Mac.Drawing; | ||
|
||
namespace Eto.Mac.Drawing; | ||
|
||
public class SystemIconsHandler : SystemIcons.IHandler | ||
{ | ||
|
||
public Icon GetFileIcon(string fileName, SystemIconSize size) | ||
{ | ||
var ws = new NSWorkspace(); | ||
var image = ws.IconForFileType(Path.GetExtension(fileName)); | ||
return WithSize(new Icon(new IconHandler(image)), size); | ||
} | ||
|
||
public Icon Get(SystemIconType type, SystemIconSize size) | ||
{ | ||
var icon = type switch | ||
{ | ||
SystemIconType.OpenDirectory => new Icon(new IconHandler(NSImage.ImageNamed(NSImageName.Folder))), | ||
SystemIconType.CloseDirectory => new Icon(new IconHandler(NSImage.ImageNamed(NSImageName.Folder))), | ||
SystemIconType.Question => GetResourceIcon("GenericQuestionMarkIcon.icns"), | ||
SystemIconType.Error => GetResourceIcon("AlertStopIcon.icns"), | ||
SystemIconType.Information => GetResourceIcon("AlertNoteIcon.icns"), | ||
SystemIconType.Warning => new Icon(new IconHandler(NSImage.ImageNamed(NSImageName.Caution))), | ||
_ => throw new NotSupportedException(), | ||
}; | ||
|
||
return WithSize(icon, size); | ||
} | ||
|
||
private static Icon WithSize(Icon icon, SystemIconSize size) | ||
{ | ||
var pixels = size switch | ||
{ | ||
SystemIconSize.Large => 32, | ||
SystemIconSize.Small => 16, | ||
_ => throw new NotSupportedException() | ||
}; | ||
|
||
return icon.WithSize(pixels, pixels); | ||
} | ||
|
||
private static Icon GetResourceIcon(string name) | ||
{ | ||
const string basePath = "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources"; | ||
var path = Path.Combine(basePath, name); | ||
if (File.Exists(path)) | ||
{ | ||
return new Icon(path); | ||
} | ||
return null; | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.