implement enum for types, implement OpenDialog from Dialog-API

This commit is contained in:
Gregor Biswanger
2017-10-17 05:12:35 +02:00
parent 2bace2d215
commit b28fa9465a
31 changed files with 527 additions and 38 deletions

View File

@@ -1,4 +1,6 @@
using System.ComponentModel;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
@@ -205,9 +207,10 @@ namespace ElectronNET.API.Entities
/// <summary>
/// The style of window title bar. Default is default. Possible values are:
/// 'default' | 'hidden' | 'hidden-inset' | 'hiddenInset' | 'customButtonsOnHover'
/// 'default' | 'hidden' | 'hiddenInset' | 'customButtonsOnHover'
/// </summary>
public string TitleBarStyle { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public TitleBarStyle TitleBarStyle { get; set; }
/// <summary>
/// Shows the title in the tile bar in full screen mode on macOS for all
@@ -228,7 +231,8 @@ namespace ElectronNET.API.Entities
/// appearance-based, light, dark, titlebar, selection, menu, popover, sidebar,
/// medium-light or ultra-dark.
/// </summary>
public string Vibrancy { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public Vibrancy Vibrancy { get; set; }
/// <summary>
/// Controls the behavior on macOS when option-clicking the green stoplight button

View File

@@ -0,0 +1,35 @@
namespace ElectronNET.API.Entities
{
public class DefaultFontFamily
{
/// <summary>
/// Defaults to Times New Roman.
/// </summary>
public string Standard { get; set; }
/// <summary>
/// Defaults to Times New Roman.
/// </summary>
public string Serif { get; set; }
/// <summary>
/// Defaults to Arial.
/// </summary>
public string SansSerif { get; set; }
/// <summary>
/// Defaults to Courier New.
/// </summary>
public string Monospace { get; set; }
/// <summary>
/// Defaults to Script.
/// </summary>
public string Cursive { get; set; }
/// <summary>
/// Defaults to Impact.
/// </summary>
public string Fantasy { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
namespace ElectronNET.API.Entities
{
public class FileFilter
{
public string[] Extensions { get; set; }
public string Name { get; set; }
}
}

View File

@@ -1,4 +1,6 @@
using ElectronNET.API.Entities;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API
{
@@ -7,16 +9,17 @@ namespace ElectronNET.API
/// <summary>
/// Must be set if type is custom, otherwise it should be omitted.
/// </summary>
public string Name { get; set; } = string.Empty;
public string Name { get; set; }
/// <summary>
/// Array of objects if type is tasks or custom, otherwise it should be omitted.
/// </summary>
public JumpListItem[] Items { get; set; } = new JumpListItem[0];
public JumpListItem[] Items { get; set; }
/// <summary>
/// One of the following: "tasks" | "frequent" | "recent" | "custom"
/// </summary>
public string Type { get; set; } = "tasks";
[JsonConverter(typeof(StringEnumConverter))]
public JumpListCategoryType Type { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
namespace ElectronNET.API
{
public enum JumpListCategoryType
{
tasks,
frequent,
recent,
custom
}
}

View File

@@ -1,16 +1,19 @@
namespace ElectronNET.API.Entities
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
public class JumpListItem
{
/// <summary>
/// The command line arguments when program is executed. Should only be set if type is task.
/// </summary>
public string Args { get; set; } = string.Empty;
public string Args { get; set; }
/// <summary>
/// Description of the task (displayed in a tooltip). Should only be set if type is task.
/// </summary>
public string Description { get; set; } = string.Empty;
public string Description { get; set; }
/// <summary>
/// The index of the icon in the resource file. If a resource file contains multiple
@@ -18,34 +21,35 @@
/// should be displayed for this task.If a resource file contains only one icon,
/// this property should be set to zero.
/// </summary>
public int IconIndex { get; set; } = 0;
public int IconIndex { get; set; }
/// <summary>
/// The absolute path to an icon to be displayed in a Jump List, which can be an
/// arbitrary resource file that contains an icon(e.g. .ico, .exe, .dll). You can
/// usually specify process.execPath to show the program icon.
/// </summary>
public string IconPath { get; set; } = string.Empty;
public string IconPath { get; set; }
/// <summary>
/// Path of the file to open, should only be set if type is file.
/// </summary>
public string Path { get; set; } = string.Empty;
public string Path { get; set; }
/// <summary>
/// Path of the program to execute, usually you should specify process.execPath
/// which opens the current program.Should only be set if type is task.
/// </summary>
public string Program { get; set; } = string.Empty;
public string Program { get; set; }
/// <summary>
/// The text to be displayed for the item in the Jump List. Should only be set if type is task.
/// </summary>
public string Title { get; set; } = string.Empty;
public string Title { get; set; }
/// <summary>
/// One of the following: "task" | "separator" | "file"
/// </summary>
public string Type {get; set; } = string.Empty;
[JsonConverter(typeof(StringEnumConverter))]
public JumpListItemType Type { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace ElectronNET.API.Entities
{
public enum JumpListItemType
{
task,
separator,
file
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
namespace ElectronNET.API.Entities
@@ -16,12 +17,14 @@ namespace ElectronNET.API.Entities
/// Define the action of the menu item, when specified the click property will be
/// ignored.
/// </summary>
public string Role { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public MenuRole Role { get; set; }
/// <summary>
/// Can be normal, separator, submenu, checkbox or radio.
/// </summary>
public string Type { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public MenuType Type { get; set; }
public string Label { get; set; }

View File

@@ -0,0 +1,129 @@
namespace ElectronNET.API.Entities
{
public enum MenuRole
{
undo,
redo,
cut,
copy,
paste,
pasteandmatchstyle,
selectall,
delete,
/// <summary>
/// Minimize current window
/// </summary>
minimize,
/// <summary>
/// Close current window
/// </summary>
close,
/// <summary>
/// Quit the application
/// </summary>
quit,
/// <summary>
/// Reload the current window
/// </summary>
reload,
/// <summary>
/// Reload the current window ignoring the cache.
/// </summary>
forcereload,
/// <summary>
/// Toggle developer tools in the current window
/// </summary>
toggledevtools,
/// <summary>
/// Toggle full screen mode on the current window
/// </summary>
togglefullscreen,
/// <summary>
/// Reset the focused pages zoom level to the original size
/// </summary>
resetzoom,
/// <summary>
/// Zoom in the focused page by 10%
/// </summary>
zoomin,
/// <summary>
/// Zoom out the focused page by 10%
/// </summary>
zoomout,
/// <summary>
/// Whole default “Edit” menu (Undo, Copy, etc.)
/// </summary>
editMenu,
/// <summary>
/// Whole default “Window” menu (Minimize, Close, etc.)
/// </summary>
windowMenu,
/// <summary>
/// Only macOS: Map to the orderFrontStandardAboutPanel action
/// </summary>
about,
/// <summary>
/// Only macOS: Map to the hide action
/// </summary>
hide,
/// <summary>
/// Only macOS: Map to the hideOtherApplications action
/// </summary>
hideothers,
/// <summary>
/// Only macOS: Map to the unhideAllApplications action
/// </summary>
unhide,
/// <summary>
/// Only macOS: Map to the startSpeaking action
/// </summary>
startspeaking,
/// <summary>
/// Only macOS: Map to the stopSpeaking action
/// </summary>
stopspeaking,
/// <summary>
/// Only macOS: Map to the arrangeInFront action
/// </summary>
front,
/// <summary>
/// Only macOS: Map to the performZoom action
/// </summary>
zoom,
/// <summary>
/// Only macOS: The submenu is a “Window” menu
/// </summary>
window,
/// <summary>
/// Only macOS: The submenu is a “Help” menu
/// </summary>
help,
/// <summary>
/// Only macOS: The submenu is a “Services” menu
/// </summary>
services
}
}

View File

@@ -0,0 +1,11 @@
namespace ElectronNET.API.Entities
{
public enum MenuType
{
normal,
separator,
submenu,
checkbox,
radio
}
}

View File

@@ -1,13 +1,17 @@
namespace ElectronNET.API.Entities
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
public class MessageBoxOptions
{
/// <summary>
/// Can be "none", "info", "error", "question" or "warning". On Windows, "question"
/// displays the same icon as "info", unless you set an icon using the "icon"
/// option.On macOS, both "warning" and "error" display the same warning icon.
/// option. On macOS, both "warning" and "error" display the same warning icon.
/// </summary>
public string Type { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public MessageBoxType Type { get; set; }
/// <summary>
/// Array of texts for buttons. On Windows, an empty array will result in one button

View File

@@ -0,0 +1,11 @@
namespace ElectronNET.API.Entities
{
public enum MessageBoxType
{
none,
info,
error,
question,
warning
}
}

View File

@@ -0,0 +1,21 @@
using System.ComponentModel;
namespace ElectronNET.API.Entities
{
public enum OnTopLevel
{
normal,
floating,
[Description("torn-off-menu")]
tornOffMenu,
[Description("modal-panel")]
modalPanel,
[Description("main-menu")]
mainMenu,
status,
[Description("pop-up-menu")]
popUpMenu,
[Description("screen-saver")]
screenSaver
}
}

View File

@@ -0,0 +1,45 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
public class OpenDialogOptions
{
public string Title { get; set; }
public string DefaultPath { get; set; }
/// <summary>
/// Custom label for the confirmation button, when left empty the default label will be used.
/// </summary>
public string ButtonLabel { get; set; }
/// <summary>
/// Contains which features the dialog should use. The following values are supported:
/// 'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory'
/// </summary>
[JsonProperty("properties", ItemConverterType = typeof(StringEnumConverter))]
public OpenDialogProperty[] Properties { get; set; }
/// <summary>
/// Message to display above input boxes.
/// </summary>
public string Message { get; set; }
/// <summary>
/// The filters specifies an array of file types that can be displayed or
/// selected when you want to limit the user to a specific type. For example:
/// </summary>
/// <example>
/// <code>
/// new FileFilter[]
/// {
/// new FileFiler { Name = "Images", Extensions = new string[] { "jpg", "png", "gif" } },
/// new FileFiler { Name = "Movies", Extensions = new string[] { "mkv", "avi", "mp4" } },
/// new FileFiler { Name = "Custom File Type", Extensions= new string[] {"as" } },
/// new FileFiler { Name = "All Files", Extensions= new string[] { "*" } }
/// }
/// </code>
/// </example>
public FileFilter[] Filters { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
namespace ElectronNET.API.Entities
{
public enum OpenDialogProperty
{
openFile,
openDirectory,
multiSelections,
showHiddenFiles,
createDirectory,
promptToCreate,
noResolveAliases,
treatPackageAsDirectory
}
}

View File

@@ -0,0 +1,11 @@
namespace ElectronNET.API.Entities
{
public enum ProgressBarMode
{
none,
normal,
indeterminate,
error,
paused
}
}

View File

@@ -1,10 +1,14 @@
namespace ElectronNET.API.Entities
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
public class ProgressBarOptions
{
/// <summary>
/// Mode for the progress bar. Can be 'none' | 'normal' | 'indeterminate' | 'error' | 'paused'.
/// </summary>
public string Mode { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public ProgressBarMode Mode { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
namespace ElectronNET.API.Entities
@@ -20,7 +21,8 @@ namespace ElectronNET.API.Entities
/// hidden - The button is not shown to the user.
/// noninteractive - The button is enabled but not interactive; no pressed button state is drawn.This value is intended for instances where the button is used in a notification.
/// </summary>
public string[] Flags { get; set; }
[JsonProperty("flags", ItemConverterType = typeof(StringEnumConverter))]
public ThumbarButtonFlag[] Flags { get; set; }
/// <summary>
/// The icon showing in thumbnail toolbar.

View File

@@ -0,0 +1,35 @@
namespace ElectronNET.API.Entities
{
public enum ThumbarButtonFlag
{
/// <summary>
/// The button is active and available to the user.
/// </summary>
enabled,
/// <summary>
/// The button is disabled.It is present, but has a visual state indicating it will not respond to user action.
/// </summary>
disabled,
/// <summary>
/// When the button is clicked, the thumbnail window closes immediately.
/// </summary>
dismissonclick,
/// <summary>
/// Do not draw a button border, use only the image.
/// </summary>
nobackground,
/// <summary>
/// The button is not shown to the user.
/// </summary>
hidden,
/// <summary>
/// The button is enabled but not interactive; no pressed button state is drawn.This value is intended for instances where the button is used in a notification.
/// </summary>
noninteractive
}
}

View File

@@ -0,0 +1,13 @@
using Newtonsoft.Json;
namespace ElectronNET.API.Entities
{
public enum TitleBarStyle
{
[JsonProperty("default")]
defaultStyle,
hidden,
hiddenInset,
customButtonsOnHover
}
}

View File

@@ -0,0 +1,21 @@
using Newtonsoft.Json;
namespace ElectronNET.API.Entities
{
public enum Vibrancy
{
[JsonProperty("appearance-based")]
appearanceBased,
light,
dark,
titlebar,
selection,
menu,
popover,
sidebar,
[JsonProperty("medium-light")]
mediumLight,
[JsonProperty("ultra-dark")]
ultraDark
}
}

View File

@@ -1,4 +1,7 @@
namespace ElectronNET.API.Entities
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ElectronNET.API.Entities
{
public class WebPreferences
{
@@ -121,6 +124,11 @@
/// </summary>
public string DisableBlinkFeatures { get; set; }
/// <summary>
/// Sets the default font for the font-family.
/// </summary>
public DefaultFontFamily DefaultFontFamily { get; set; }
/// <summary>
/// Defaults to 16.
/// </summary>