mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Work on project, document managers, controllers and UI
This commit is contained in:
parent
e338ae31ca
commit
fd166fe814
@ -36,6 +36,8 @@ namespace RainmeterStudio.Business
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the project manager
|
||||
/// </summary>
|
||||
@ -46,6 +48,10 @@ namespace RainmeterStudio.Business
|
||||
ActiveProject = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Project operations
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new project
|
||||
/// </summary>
|
||||
@ -115,6 +121,10 @@ namespace RainmeterStudio.Business
|
||||
ActiveProjectChanged(this, new EventArgs());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Document templates
|
||||
|
||||
/// <summary>
|
||||
/// Registers a project template
|
||||
/// </summary>
|
||||
@ -128,5 +138,7 @@ namespace RainmeterStudio.Business
|
||||
/// Gets a list of existing project templates
|
||||
/// </summary>
|
||||
public IEnumerable<IProjectTemplate> ProjectTemplates { get { return _projectTemplates; } }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
56
RainmeterStudio/Properties/Settings.Designer.cs
generated
56
RainmeterStudio/Properties/Settings.Designer.cs
generated
@ -27,12 +27,12 @@ namespace RainmeterStudio.Properties {
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+Shift+N")]
|
||||
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
|
||||
public string Command_ProjectCreateCommand_Shortcut {
|
||||
public string Command_ProjectCreate_Shortcut {
|
||||
get {
|
||||
return ((string)(this["Command_ProjectCreateCommand_Shortcut"]));
|
||||
return ((string)(this["Command_ProjectCreate_Shortcut"]));
|
||||
}
|
||||
set {
|
||||
this["Command_ProjectCreateCommand_Shortcut"] = value;
|
||||
this["Command_ProjectCreate_Shortcut"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,12 +40,12 @@ namespace RainmeterStudio.Properties {
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("F5")]
|
||||
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
|
||||
public string Command_ProjectPanel_RefreshCommand_Shortcut {
|
||||
public string Command_ProjectPanel_Refresh_Shortcut {
|
||||
get {
|
||||
return ((string)(this["Command_ProjectPanel_RefreshCommand_Shortcut"]));
|
||||
return ((string)(this["Command_ProjectPanel_Refresh_Shortcut"]));
|
||||
}
|
||||
set {
|
||||
this["Command_ProjectPanel_RefreshCommand_Shortcut"] = value;
|
||||
this["Command_ProjectPanel_Refresh_Shortcut"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,12 +53,12 @@ namespace RainmeterStudio.Properties {
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+N")]
|
||||
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
|
||||
public string Command_DocumentCreateCommand_Shortcut {
|
||||
public string Command_DocumentCreate_Shortcut {
|
||||
get {
|
||||
return ((string)(this["Command_DocumentCreateCommand_Shortcut"]));
|
||||
return ((string)(this["Command_DocumentCreate_Shortcut"]));
|
||||
}
|
||||
set {
|
||||
this["Command_DocumentCreateCommand_Shortcut"] = value;
|
||||
this["Command_DocumentCreate_Shortcut"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,12 +66,12 @@ namespace RainmeterStudio.Properties {
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+Shift+O")]
|
||||
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
|
||||
public string Command_ProjectOpenCommand_Shortcut {
|
||||
public string Command_ProjectOpen_Shortcut {
|
||||
get {
|
||||
return ((string)(this["Command_ProjectOpenCommand_Shortcut"]));
|
||||
return ((string)(this["Command_ProjectOpen_Shortcut"]));
|
||||
}
|
||||
set {
|
||||
this["Command_ProjectOpenCommand_Shortcut"] = value;
|
||||
this["Command_ProjectOpen_Shortcut"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,12 +79,12 @@ namespace RainmeterStudio.Properties {
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+W")]
|
||||
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
|
||||
public string Command_DocumentCloseCommand_Shortcut {
|
||||
public string Command_DocumentClose_Shortcut {
|
||||
get {
|
||||
return ((string)(this["Command_DocumentCloseCommand_Shortcut"]));
|
||||
return ((string)(this["Command_DocumentClose_Shortcut"]));
|
||||
}
|
||||
set {
|
||||
this["Command_DocumentCloseCommand_Shortcut"] = value;
|
||||
this["Command_DocumentClose_Shortcut"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,5 +183,31 @@ namespace RainmeterStudio.Properties {
|
||||
this["CreateProjectDialog_CreateDirectoryCheckbox"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+O")]
|
||||
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
|
||||
public string Command_DocumentOpen_Shortcut {
|
||||
get {
|
||||
return ((string)(this["Command_DocumentOpen_Shortcut"]));
|
||||
}
|
||||
set {
|
||||
this["Command_DocumentOpen_Shortcut"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+S")]
|
||||
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
|
||||
public string Command_DocumentSave_Shortcut {
|
||||
get {
|
||||
return ((string)(this["Command_DocumentSave_Shortcut"]));
|
||||
}
|
||||
set {
|
||||
this["Command_DocumentSave_Shortcut"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,19 +2,19 @@
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="RainmeterStudio.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="Command_ProjectCreateCommand_Shortcut" Roaming="true" Type="System.String" Scope="User">
|
||||
<Setting Name="Command_ProjectCreate_Shortcut" Roaming="true" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">Ctrl+Shift+N</Value>
|
||||
</Setting>
|
||||
<Setting Name="Command_ProjectPanel_RefreshCommand_Shortcut" Roaming="true" Type="System.String" Scope="User">
|
||||
<Setting Name="Command_ProjectPanel_Refresh_Shortcut" Roaming="true" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">F5</Value>
|
||||
</Setting>
|
||||
<Setting Name="Command_DocumentCreateCommand_Shortcut" Roaming="true" Type="System.String" Scope="User">
|
||||
<Setting Name="Command_DocumentCreate_Shortcut" Roaming="true" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">Ctrl+N</Value>
|
||||
</Setting>
|
||||
<Setting Name="Command_ProjectOpenCommand_Shortcut" Roaming="true" Type="System.String" Scope="User">
|
||||
<Setting Name="Command_ProjectOpen_Shortcut" Roaming="true" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">Ctrl+Shift+O</Value>
|
||||
</Setting>
|
||||
<Setting Name="Command_DocumentCloseCommand_Shortcut" Roaming="true" Type="System.String" Scope="User">
|
||||
<Setting Name="Command_DocumentClose_Shortcut" Roaming="true" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">Ctrl+W</Value>
|
||||
</Setting>
|
||||
<Setting Name="MainWindow_Width" Type="System.Double" Scope="User">
|
||||
@ -41,5 +41,11 @@
|
||||
<Setting Name="CreateProjectDialog_CreateDirectoryCheckbox" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="Command_DocumentOpen_Shortcut" Roaming="true" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">Ctrl+O</Value>
|
||||
</Setting>
|
||||
<Setting Name="Command_DocumentSave_Shortcut" Roaming="true" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">Ctrl+S</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
@ -238,6 +238,16 @@
|
||||
<ItemGroup>
|
||||
<None Include="Resources\Icons\32\project_empty.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Icons\16\window-close.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Icons\16\folder_page_white.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Icons\16\disk.png" />
|
||||
<Resource Include="Resources\Icons\16\disk_multiple.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
52
RainmeterStudio/Resources/Icons.Designer.cs
generated
52
RainmeterStudio/Resources/Icons.Designer.cs
generated
@ -63,9 +63,9 @@ namespace RainmeterStudio.Resources {
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Command_DocumentCreateCommand_Icon {
|
||||
internal static System.Drawing.Bitmap Command_DocumentClose_Icon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Command_DocumentCreateCommand_Icon", resourceCulture);
|
||||
object obj = ResourceManager.GetObject("Command_DocumentClose_Icon", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
@ -73,9 +73,9 @@ namespace RainmeterStudio.Resources {
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Command_ProjectCreateCommand_Icon {
|
||||
internal static System.Drawing.Bitmap Command_DocumentCreate_Icon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Command_ProjectCreateCommand_Icon", resourceCulture);
|
||||
object obj = ResourceManager.GetObject("Command_DocumentCreate_Icon", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
@ -83,9 +83,49 @@ namespace RainmeterStudio.Resources {
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Command_ProjectOpenCommand_Icon {
|
||||
internal static System.Drawing.Bitmap Command_DocumentOpen_Icon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Command_ProjectOpenCommand_Icon", resourceCulture);
|
||||
object obj = ResourceManager.GetObject("Command_DocumentOpen_Icon", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Command_DocumentSave_Icon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Command_DocumentSave_Icon", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Command_DocumentSaveAll_Icon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Command_DocumentSaveAll_Icon", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Command_ProjectCreate_Icon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Command_ProjectCreate_Icon", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Command_ProjectOpen_Icon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Command_ProjectOpen_Icon", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
@ -118,13 +118,25 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="Command_DocumentCreateCommand_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<data name="Command_DocumentClose_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>icons\16\window-close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Command_DocumentCreate_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>icons\16\page_white_star.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Command_ProjectCreateCommand_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<data name="Command_DocumentOpen_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>icons\16\folder_page_white.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Command_DocumentSaveAll_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>icons\16\disk_multiple.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Command_DocumentSave_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>icons\16\disk.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Command_ProjectCreate_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>icons\16\project_star.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Command_ProjectOpenCommand_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<data name="Command_ProjectOpen_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>icons\16\folder_project.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Command_ProjectPanel_CollapseAllCommand_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
|
BIN
RainmeterStudio/Resources/Icons/16/disk.png
Normal file
BIN
RainmeterStudio/Resources/Icons/16/disk.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 620 B |
BIN
RainmeterStudio/Resources/Icons/16/disk_multiple.png
Normal file
BIN
RainmeterStudio/Resources/Icons/16/disk_multiple.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 691 B |
BIN
RainmeterStudio/Resources/Icons/16/folder_page_white.png
Normal file
BIN
RainmeterStudio/Resources/Icons/16/folder_page_white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 639 B |
BIN
RainmeterStudio/Resources/Icons/16/window-close.png
Normal file
BIN
RainmeterStudio/Resources/Icons/16/window-close.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 505 B |
162
RainmeterStudio/Resources/Strings.Designer.cs
generated
162
RainmeterStudio/Resources/Strings.Designer.cs
generated
@ -90,72 +90,180 @@ namespace RainmeterStudio.Resources {
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Close.
|
||||
/// </summary>
|
||||
public static string Command_DocumentCloseCommand_DisplayText {
|
||||
public static string Command_DocumentClose_DisplayText {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentCloseCommand_DisplayText", resourceCulture);
|
||||
return ResourceManager.GetString("Command_DocumentClose_DisplayText", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Close active document.
|
||||
/// </summary>
|
||||
public static string Command_DocumentCloseCommand_ToolTip {
|
||||
public static string Command_DocumentClose_ToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentCloseCommand_ToolTip", resourceCulture);
|
||||
return ResourceManager.GetString("Command_DocumentClose_ToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _File....
|
||||
/// </summary>
|
||||
public static string Command_DocumentCreateCommand_DisplayText {
|
||||
public static string Command_DocumentCreate_DisplayText {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentCreateCommand_DisplayText", resourceCulture);
|
||||
return ResourceManager.GetString("Command_DocumentCreate_DisplayText", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Create a new file.
|
||||
/// </summary>
|
||||
public static string Command_DocumentCreateCommand_ToolTip {
|
||||
public static string Command_DocumentCreate_ToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentCreateCommand_ToolTip", resourceCulture);
|
||||
return ResourceManager.GetString("Command_DocumentCreate_ToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _File....
|
||||
/// </summary>
|
||||
public static string Command_DocumentOpen_DisplayText {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentOpen_DisplayText", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open a file.
|
||||
/// </summary>
|
||||
public static string Command_DocumentOpen_ToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentOpen_ToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Save.
|
||||
/// </summary>
|
||||
public static string Command_DocumentSave_DisplayText {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentSave_DisplayText", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Save the current document.
|
||||
/// </summary>
|
||||
public static string Command_DocumentSave_ToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentSave_ToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Save a _Copy....
|
||||
/// </summary>
|
||||
public static string Command_DocumentSaveACopy_DisplayText {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentSaveACopy_DisplayText", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Saves a copy of the current document.
|
||||
/// </summary>
|
||||
public static string Command_DocumentSaveACopy_ToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentSaveACopy_ToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Save All.
|
||||
/// </summary>
|
||||
public static string Command_DocumentSaveAll_DisplayText {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentSaveAll_DisplayText", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Save all the opened documents.
|
||||
/// </summary>
|
||||
public static string Command_DocumentSaveAll_ToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentSaveAll_ToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Save _As....
|
||||
/// </summary>
|
||||
public static string Command_DocumentSaveAs_DisplayText {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentSaveAs_DisplayText", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Save the current document to another file.
|
||||
/// </summary>
|
||||
public static string Command_DocumentSaveAs_ToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_DocumentSaveAs_ToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Close Project.
|
||||
/// </summary>
|
||||
public static string Command_ProjectClose_DisplayText {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_ProjectClose_DisplayText", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Close currently opened project.
|
||||
/// </summary>
|
||||
public static string Command_ProjectClose_ToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_ProjectClose_ToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Project....
|
||||
/// </summary>
|
||||
public static string Command_ProjectCreateCommand_DisplayText {
|
||||
public static string Command_ProjectCreate_DisplayText {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_ProjectCreateCommand_DisplayText", resourceCulture);
|
||||
return ResourceManager.GetString("Command_ProjectCreate_DisplayText", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Create a new project.
|
||||
/// </summary>
|
||||
public static string Command_ProjectCreateCommand_ToolTip {
|
||||
public static string Command_ProjectCreate_ToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_ProjectCreateCommand_ToolTip", resourceCulture);
|
||||
return ResourceManager.GetString("Command_ProjectCreate_ToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Project....
|
||||
/// </summary>
|
||||
public static string Command_ProjectOpenCommand_DisplayText {
|
||||
public static string Command_ProjectOpen_DisplayText {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_ProjectOpenCommand_DisplayText", resourceCulture);
|
||||
return ResourceManager.GetString("Command_ProjectOpen_DisplayText", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open existing project.
|
||||
/// </summary>
|
||||
public static string Command_ProjectOpenCommand_ToolTip {
|
||||
public static string Command_ProjectOpen_ToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("Command_ProjectOpenCommand_ToolTip", resourceCulture);
|
||||
return ResourceManager.GetString("Command_ProjectOpen_ToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,7 +475,7 @@ namespace RainmeterStudio.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Do_n't save.
|
||||
/// Looks up a localized string similar to Don't save.
|
||||
/// </summary>
|
||||
public static string Dialog_DoNotSave {
|
||||
get {
|
||||
@ -402,6 +510,15 @@ namespace RainmeterStudio.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open document.
|
||||
/// </summary>
|
||||
public static string Dialog_OpenDocument_Title {
|
||||
get {
|
||||
return ResourceManager.GetString("Dialog_OpenDocument_Title", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open project....
|
||||
/// </summary>
|
||||
@ -412,7 +529,7 @@ namespace RainmeterStudio.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Save.
|
||||
/// Looks up a localized string similar to Save.
|
||||
/// </summary>
|
||||
public static string Dialog_Save {
|
||||
get {
|
||||
@ -420,6 +537,15 @@ namespace RainmeterStudio.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Save document.
|
||||
/// </summary>
|
||||
public static string Dialog_SaveDocument_Title {
|
||||
get {
|
||||
return ResourceManager.GetString("Dialog_SaveDocument_Title", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _File.
|
||||
/// </summary>
|
||||
|
@ -147,16 +147,16 @@
|
||||
<data name="Dialog_OpenProject_Title" xml:space="preserve">
|
||||
<value>Open project...</value>
|
||||
</data>
|
||||
<data name="Command_DocumentCloseCommand_DisplayText" xml:space="preserve">
|
||||
<data name="Command_DocumentClose_DisplayText" xml:space="preserve">
|
||||
<value>_Close</value>
|
||||
</data>
|
||||
<data name="Command_DocumentCloseCommand_ToolTip" xml:space="preserve">
|
||||
<data name="Command_DocumentClose_ToolTip" xml:space="preserve">
|
||||
<value>Close active document</value>
|
||||
</data>
|
||||
<data name="Command_DocumentCreateCommand_DisplayText" xml:space="preserve">
|
||||
<data name="Command_DocumentCreate_DisplayText" xml:space="preserve">
|
||||
<value>_File...</value>
|
||||
</data>
|
||||
<data name="Command_DocumentCreateCommand_ToolTip" xml:space="preserve">
|
||||
<data name="Command_DocumentCreate_ToolTip" xml:space="preserve">
|
||||
<value>Create a new file</value>
|
||||
</data>
|
||||
<data name="MainWindow_File" xml:space="preserve">
|
||||
@ -168,10 +168,10 @@
|
||||
<data name="MainWindow_File_Open" xml:space="preserve">
|
||||
<value>_Open</value>
|
||||
</data>
|
||||
<data name="Command_ProjectCreateCommand_DisplayText" xml:space="preserve">
|
||||
<data name="Command_ProjectCreate_DisplayText" xml:space="preserve">
|
||||
<value>_Project...</value>
|
||||
</data>
|
||||
<data name="Command_ProjectCreateCommand_ToolTip" xml:space="preserve">
|
||||
<data name="Command_ProjectCreate_ToolTip" xml:space="preserve">
|
||||
<value>Create a new project</value>
|
||||
</data>
|
||||
<data name="CreateProjectDialog_Location" xml:space="preserve">
|
||||
@ -192,10 +192,10 @@
|
||||
<data name="CreateProjectDialog_Title" xml:space="preserve">
|
||||
<value>Create project</value>
|
||||
</data>
|
||||
<data name="Command_ProjectOpenCommand_DisplayText" xml:space="preserve">
|
||||
<data name="Command_ProjectOpen_DisplayText" xml:space="preserve">
|
||||
<value>_Project...</value>
|
||||
</data>
|
||||
<data name="Command_ProjectOpenCommand_ToolTip" xml:space="preserve">
|
||||
<data name="Command_ProjectOpen_ToolTip" xml:space="preserve">
|
||||
<value>Open existing project</value>
|
||||
</data>
|
||||
<data name="Command_ProjectPanel_CollapseAllCommand_DisplayText" xml:space="preserve">
|
||||
@ -250,9 +250,51 @@
|
||||
<value>Unsaved changes</value>
|
||||
</data>
|
||||
<data name="Dialog_DoNotSave" xml:space="preserve">
|
||||
<value>Do_n't save</value>
|
||||
<value>Don't save</value>
|
||||
</data>
|
||||
<data name="Dialog_Save" xml:space="preserve">
|
||||
<value>Save</value>
|
||||
</data>
|
||||
<data name="Command_ProjectClose_DisplayText" xml:space="preserve">
|
||||
<value>Close Project</value>
|
||||
</data>
|
||||
<data name="Command_ProjectClose_ToolTip" xml:space="preserve">
|
||||
<value>Close currently opened project</value>
|
||||
</data>
|
||||
<data name="Dialog_OpenDocument_Title" xml:space="preserve">
|
||||
<value>Open document</value>
|
||||
</data>
|
||||
<data name="Dialog_SaveDocument_Title" xml:space="preserve">
|
||||
<value>Save document</value>
|
||||
</data>
|
||||
<data name="Command_DocumentOpen_DisplayText" xml:space="preserve">
|
||||
<value>_File...</value>
|
||||
</data>
|
||||
<data name="Command_DocumentOpen_ToolTip" xml:space="preserve">
|
||||
<value>Open a file</value>
|
||||
</data>
|
||||
<data name="Command_DocumentSaveACopy_DisplayText" xml:space="preserve">
|
||||
<value>Save a _Copy...</value>
|
||||
</data>
|
||||
<data name="Command_DocumentSaveACopy_ToolTip" xml:space="preserve">
|
||||
<value>Saves a copy of the current document</value>
|
||||
</data>
|
||||
<data name="Command_DocumentSaveAll_DisplayText" xml:space="preserve">
|
||||
<value>Save All</value>
|
||||
</data>
|
||||
<data name="Command_DocumentSaveAll_ToolTip" xml:space="preserve">
|
||||
<value>Save all the opened documents</value>
|
||||
</data>
|
||||
<data name="Command_DocumentSaveAs_DisplayText" xml:space="preserve">
|
||||
<value>Save _As...</value>
|
||||
</data>
|
||||
<data name="Command_DocumentSaveAs_ToolTip" xml:space="preserve">
|
||||
<value>Save the current document to another file</value>
|
||||
</data>
|
||||
<data name="Command_DocumentSave_DisplayText" xml:space="preserve">
|
||||
<value>_Save</value>
|
||||
</data>
|
||||
<data name="Command_DocumentSave_ToolTip" xml:space="preserve">
|
||||
<value>Save the current document</value>
|
||||
</data>
|
||||
</root>
|
@ -9,6 +9,8 @@ using RainmeterStudio.UI.Dialogs;
|
||||
using RainmeterStudio.UI.ViewModel;
|
||||
using RainmeterStudio.Core.Model;
|
||||
using System.IO;
|
||||
using Microsoft.Win32;
|
||||
using RainmeterStudio.Core.Utils;
|
||||
|
||||
namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
@ -34,10 +36,20 @@ namespace RainmeterStudio.UI.Controller
|
||||
|
||||
public Command DocumentOpenCommand { get; private set; }
|
||||
|
||||
public Command DocumentSaveCommand { get; private set; }
|
||||
|
||||
public Command DocumentSaveAsCommand { get; private set; }
|
||||
|
||||
public Command DocumentSaveACopyCommand { get; private set; }
|
||||
|
||||
public Command DocumentSaveAllCommand { get; private set; }
|
||||
|
||||
public Command DocumentCloseCommand { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when a document is opened
|
||||
/// </summary>
|
||||
@ -56,15 +68,77 @@ namespace RainmeterStudio.UI.Controller
|
||||
remove { DocumentManager.DocumentClosed -= value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when the active document editor changes.
|
||||
/// </summary>
|
||||
public event EventHandler ActiveDocumentEditorChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
private IDocumentEditor _activeDocumentEditor = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the active document editor.
|
||||
/// This must be set by the main window when active document changes.
|
||||
/// </summary>
|
||||
public IDocumentEditor ActiveDocumentEditor
|
||||
{
|
||||
get
|
||||
{
|
||||
return _activeDocumentEditor;
|
||||
}
|
||||
set
|
||||
{
|
||||
_activeDocumentEditor = value;
|
||||
|
||||
if (ActiveDocumentEditorChanged != null)
|
||||
ActiveDocumentEditorChanged(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindow OwnerWindow { get; set; }
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a document controller
|
||||
/// </summary>
|
||||
/// <param name="documentManager"></param>
|
||||
/// <param name="projectManager"></param>
|
||||
public DocumentController(DocumentManager documentManager, ProjectManager projectManager)
|
||||
{
|
||||
DocumentManager = documentManager;
|
||||
ProjectManager = projectManager;
|
||||
|
||||
DocumentCreateCommand = new Command("DocumentCreateCommand", () => Create(), () => ProjectManager.ActiveProject != null);
|
||||
ProjectManager.ActiveProjectChanged += new EventHandler((obj, e) => DocumentCreateCommand.NotifyCanExecuteChanged());
|
||||
DocumentCreateCommand = new Command("DocumentCreate", Create, () => ProjectManager.ActiveProject != null);
|
||||
DocumentOpenCommand = new Command("DocumentOpen", Open);
|
||||
DocumentSaveCommand = new Command("DocumentSave", () => Save(), HasActiveDocumentEditor);
|
||||
DocumentSaveAsCommand = new Command("DocumentSaveAs", () => SaveAs(), HasActiveDocumentEditor);
|
||||
DocumentSaveACopyCommand = new Command("DocumentSaveACopy", () => SaveACopy(), HasActiveDocumentEditor);
|
||||
DocumentSaveAllCommand = new Command("DocumentSaveAll", SaveAll, () => ProjectManager.ActiveProject != null);
|
||||
DocumentCloseCommand = new Command("DocumentClose", () => Close(), HasActiveDocumentEditor);
|
||||
|
||||
ProjectManager.ActiveProjectChanged += new EventHandler((obj, e) =>
|
||||
{
|
||||
DocumentCreateCommand.NotifyCanExecuteChanged();
|
||||
DocumentSaveAllCommand.NotifyCanExecuteChanged();
|
||||
});
|
||||
|
||||
ActiveDocumentEditorChanged += new EventHandler((obj, e) =>
|
||||
{
|
||||
DocumentSaveCommand.NotifyCanExecuteChanged();
|
||||
DocumentSaveAsCommand.NotifyCanExecuteChanged();
|
||||
DocumentSaveACopyCommand.NotifyCanExecuteChanged();
|
||||
DocumentCloseCommand.NotifyCanExecuteChanged();
|
||||
});
|
||||
}
|
||||
|
||||
private bool HasActiveDocumentEditor()
|
||||
{
|
||||
return ActiveDocumentEditor != null;
|
||||
}
|
||||
|
||||
#region Document operations
|
||||
@ -105,23 +179,105 @@ namespace RainmeterStudio.UI.Controller
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the document opened in specified editor
|
||||
/// Shows an 'open document' dialog, and opens a document
|
||||
/// </summary>
|
||||
/// <param name="editor">Editor</param>
|
||||
public void Save(IDocumentEditor editor)
|
||||
public void Open()
|
||||
{
|
||||
if (!editor.AttachedDocument.Reference.IsOnStorage())
|
||||
// Show open dialog
|
||||
OpenFileDialog dialog = new OpenFileDialog();
|
||||
dialog.Title = Resources.Strings.Dialog_OpenDocument_Title;
|
||||
dialog.Filter = Resources.Strings.Dialog_FileType_AllFiles + "|*.*";
|
||||
dialog.InitialDirectory = Properties.Settings.Default.Project_SavedLocation;
|
||||
|
||||
bool? res = dialog.ShowDialog();
|
||||
if (res.HasValue && res.Value)
|
||||
{
|
||||
SaveAs(editor);
|
||||
// Open file
|
||||
DocumentManager.Open(dialog.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the active document
|
||||
/// </summary>
|
||||
public bool Save()
|
||||
{
|
||||
return Save(ActiveDocumentEditor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the active document
|
||||
/// </summary>
|
||||
public bool Save(IDocumentEditor editor)
|
||||
{
|
||||
if (editor.AttachedDocument.Reference.IsOnStorage())
|
||||
{
|
||||
DocumentManager.Save(editor.AttachedDocument);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SaveAs(editor);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a 'save as' dialog, and saves active document
|
||||
/// </summary>
|
||||
public bool SaveAs()
|
||||
{
|
||||
return SaveAs(ActiveDocumentEditor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a 'save as' dialog, and saves active document
|
||||
/// </summary>
|
||||
public bool SaveAs(IDocumentEditor editor)
|
||||
{
|
||||
// Show save dialog
|
||||
SaveFileDialog dialog = new SaveFileDialog();
|
||||
dialog.Title = Resources.Strings.Dialog_SaveDocument_Title;
|
||||
dialog.Filter = Resources.Strings.Dialog_FileType_AllFiles + "|*.*";
|
||||
dialog.FileName = editor.AttachedDocument.Reference.StoragePath;
|
||||
|
||||
bool? res = dialog.ShowDialog();
|
||||
if (res.HasValue && res.Value)
|
||||
{
|
||||
DocumentManager.SaveAs(dialog.FileName, editor.AttachedDocument);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a 'save' dialog, and saves a copy of the active document
|
||||
/// </summary>
|
||||
public void SaveACopy()
|
||||
{
|
||||
// Show save dialog
|
||||
SaveFileDialog dialog = new SaveFileDialog();
|
||||
dialog.Title = Resources.Strings.Dialog_SaveDocument_Title;
|
||||
dialog.Filter = Resources.Strings.Dialog_FileType_AllFiles + "|*.*";
|
||||
dialog.FileName = ActiveDocumentEditor.AttachedDocument.Reference.StoragePath;
|
||||
|
||||
bool? res = dialog.ShowDialog();
|
||||
if (res.HasValue && res.Value)
|
||||
{
|
||||
DocumentManager.SaveACopy(dialog.FileName, ActiveDocumentEditor.AttachedDocument);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves all opened documents
|
||||
/// </summary>
|
||||
public void SaveAll()
|
||||
{
|
||||
foreach (var editor in DocumentManager.Editors)
|
||||
{
|
||||
if (!Save(editor))
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
public void SaveAs(IDocumentEditor editor)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -135,17 +291,13 @@ namespace RainmeterStudio.UI.Controller
|
||||
// Show the 'are you sure' prompt if necesary
|
||||
if (editor.AttachedDocument.IsDirty)
|
||||
{
|
||||
bool? res = CloseUnsavedDialog.ShowDialog(OwnerWindow, editor.AttachedDocument);
|
||||
if (res.HasValue)
|
||||
{
|
||||
// Save
|
||||
if (res.Value)
|
||||
{
|
||||
Save(editor);
|
||||
}
|
||||
}
|
||||
else
|
||||
switch(CloseUnsavedDialog.ShowDialog(OwnerWindow, editor.AttachedDocument))
|
||||
{
|
||||
case CloseUnsavedDialogResult.Save:
|
||||
Save();
|
||||
break;
|
||||
|
||||
case CloseUnsavedDialogResult.Cancel:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -155,6 +307,56 @@ namespace RainmeterStudio.UI.Controller
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the active document.
|
||||
/// </summary>
|
||||
/// <returns>True if closed successfully</returns>
|
||||
/// <remarks>Shows the 'are you sure' prompt if there are unsaved edits.</remarks>
|
||||
public bool Close()
|
||||
{
|
||||
// Show the 'are you sure' prompt if necesary
|
||||
if (Close(ActiveDocumentEditor))
|
||||
{
|
||||
ActiveDocumentEditor = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes all the opened documents
|
||||
/// </summary>
|
||||
/// <returns>True if closed successfully, false if user hit 'cancel'.</returns>
|
||||
public bool CloseAll()
|
||||
{
|
||||
// Get dirty documents
|
||||
var unsaved = DocumentManager.Editors
|
||||
.Select(editor => editor.AttachedDocument)
|
||||
.Where(document => document.IsDirty);
|
||||
|
||||
// There are unsaved documents? Display save dialog
|
||||
if (unsaved.Any())
|
||||
{
|
||||
switch (CloseUnsavedDialog.ShowDialog(OwnerWindow, unsaved))
|
||||
{
|
||||
case CloseUnsavedDialogResult.Save:
|
||||
SaveAll();
|
||||
break;
|
||||
|
||||
case CloseUnsavedDialogResult.Cancel:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Close all documents
|
||||
// To array is used because DocumentManager.Editors is modified when closing a document.
|
||||
DocumentManager.Editors.ToArray().ForEach(DocumentManager.Close);
|
||||
|
||||
// Done
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
@ -82,10 +82,21 @@ namespace RainmeterStudio.UI.Controller
|
||||
|
||||
#region Commands
|
||||
|
||||
/// <summary>
|
||||
/// Create project command
|
||||
/// </summary>
|
||||
public Command ProjectCreateCommand { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Open project command
|
||||
/// </summary>
|
||||
public Command ProjectOpenCommand { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Close project command
|
||||
/// </summary>
|
||||
public Command ProjectCloseCommand { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
@ -96,8 +107,11 @@ namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
Manager = manager;
|
||||
|
||||
ProjectCreateCommand = new Command("ProjectCreateCommand", () => CreateProject());
|
||||
ProjectOpenCommand = new Command("ProjectOpenCommand", () => OpenProject());
|
||||
// Initialize commands
|
||||
ProjectCreateCommand = new Command("ProjectCreate", CreateProject);
|
||||
ProjectOpenCommand = new Command("ProjectOpen", OpenProject);
|
||||
ProjectCloseCommand = new Command("ProjectClose", CloseProject, () => ActiveProject != null);
|
||||
ActiveProjectChanged += new EventHandler((sender, e) => ProjectCloseCommand.NotifyCanExecuteChanged());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -126,7 +140,7 @@ namespace RainmeterStudio.UI.Controller
|
||||
/// Displays an 'open file' dialog and opens an existing project
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
public void OpenProject(string path = null)
|
||||
public void OpenProject()
|
||||
{
|
||||
// Open dialog
|
||||
OpenFileDialog dialog = new OpenFileDialog();
|
||||
@ -151,6 +165,7 @@ namespace RainmeterStudio.UI.Controller
|
||||
/// </summary>
|
||||
public void CloseProject()
|
||||
{
|
||||
Manager.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,15 +17,14 @@
|
||||
<TextBlock Grid.Row="0" Text="{x:Static r:Strings.CloseUnsavedDialog_Message }"
|
||||
Margin="4"/>
|
||||
|
||||
<ScrollViewer Grid.Row="1"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||
|
||||
<TextBlock Name="textFiles"
|
||||
Margin="4" Padding="4"
|
||||
Background="White"/>
|
||||
|
||||
</ScrollViewer>
|
||||
<ListBox Name="listUnsavedDocuments" Grid.Row="1" Padding="3"
|
||||
IsEnabled="False" >
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Reference.Name}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<TextBlock Grid.Row="2" Text="{x:Static r:Strings.CloseUnsavedDialog_Question }"
|
||||
Margin="4"/>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
@ -11,9 +12,18 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using RainmeterStudio.Core.Model;
|
||||
using RainmeterStudio.Core.Utils;
|
||||
|
||||
namespace RainmeterStudio.UI.Dialogs
|
||||
{
|
||||
public enum CloseUnsavedDialogResult
|
||||
{
|
||||
Unset,
|
||||
Save,
|
||||
DoNotSave,
|
||||
Cancel
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for CloseUnsavedDialog.xaml
|
||||
/// </summary>
|
||||
@ -24,10 +34,11 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
/// </summary>
|
||||
/// <param name="unsavedDocuments">List of unsaved documents</param>
|
||||
/// <returns>Dialog result</returns>
|
||||
public static bool? ShowDialog(IEnumerable<IDocument> unsavedDocuments)
|
||||
public static CloseUnsavedDialogResult ShowDialog(IEnumerable<IDocument> unsavedDocuments)
|
||||
{
|
||||
var dialog = new CloseUnsavedDialog(unsavedDocuments);
|
||||
return dialog.ShowDialog();
|
||||
dialog.ShowDialog();
|
||||
return dialog.SaveDialogResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -36,11 +47,11 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
/// <param name="owner">Owner window</param>
|
||||
/// <param name="unsavedDocuments">List of unsaved documents</param>
|
||||
/// <returns>Dialog result</returns>
|
||||
public static bool? ShowDialog(Window owner, IEnumerable<IDocument> unsavedDocuments)
|
||||
public static CloseUnsavedDialogResult ShowDialog(Window owner, IEnumerable<IDocument> unsavedDocuments)
|
||||
{
|
||||
var dialog = new CloseUnsavedDialog(unsavedDocuments);
|
||||
dialog.Owner = owner;
|
||||
return dialog.ShowDialog();
|
||||
dialog.ShowDialog();
|
||||
return dialog.SaveDialogResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -49,13 +60,18 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
/// <param name="owner">Owner window</param>
|
||||
/// <param name="unsavedDocuments">List of unsaved documents</param>
|
||||
/// <returns>Dialog result</returns>
|
||||
public static bool? ShowDialog(Window owner, params IDocument[] unsavedDocuments)
|
||||
public static CloseUnsavedDialogResult ShowDialog(Window owner, params IDocument[] unsavedDocuments)
|
||||
{
|
||||
var dialog = new CloseUnsavedDialog(unsavedDocuments);
|
||||
dialog.Owner = owner;
|
||||
return dialog.ShowDialog();
|
||||
dialog.ShowDialog();
|
||||
return dialog.SaveDialogResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the 'close unsaved' dialog result
|
||||
/// </summary>
|
||||
public CloseUnsavedDialogResult SaveDialogResult { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the dialog
|
||||
/// </summary>
|
||||
@ -64,39 +80,25 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
textFiles.Inlines.AddRange(unsavedDocuments.SelectMany(GetInlines));
|
||||
}
|
||||
|
||||
private IEnumerable<Inline> GetInlines(IDocument doc)
|
||||
{
|
||||
var folder = System.IO.Path.GetDirectoryName(doc.Reference.StoragePath);
|
||||
|
||||
yield return new Run(folder)
|
||||
{
|
||||
Foreground = Brushes.DarkGray
|
||||
};
|
||||
|
||||
yield return new Run(doc.Reference.Name)
|
||||
{
|
||||
FontWeight = FontWeights.Bold
|
||||
};
|
||||
SaveDialogResult = CloseUnsavedDialogResult.Unset;
|
||||
unsavedDocuments.ForEach(d => listUnsavedDocuments.Items.Add(d));
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = true;
|
||||
SaveDialogResult = CloseUnsavedDialogResult.Save;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void buttonDoNotSave_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = false;
|
||||
SaveDialogResult = CloseUnsavedDialogResult.DoNotSave;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = null;
|
||||
SaveDialogResult = CloseUnsavedDialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,8 @@
|
||||
Left="{Binding Source={x:Static p:Settings.Default}, Path=MainWindow_Left, Mode=TwoWay}"
|
||||
Top="{Binding Source={x:Static p:Settings.Default}, Path=MainWindow_Top, Mode=TwoWay}"
|
||||
|
||||
ResizeMode="CanResizeWithGrip" >
|
||||
ResizeMode="CanResizeWithGrip"
|
||||
Closing="Window_Closing">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@ -47,16 +48,58 @@
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="{x:Static r:Strings.MainWindow_File_Open}">
|
||||
<MenuItem DataContext="{Binding DocumentController.DocumentOpenCommand}"
|
||||
Style="{StaticResource CommandMenuItemStyle}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{Binding Icon}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem DataContext="{Binding ProjectController.ProjectOpenCommand}"
|
||||
Style="{StaticResource CommandMenuItemStyle}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{Binding Icon}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="_Close" />
|
||||
<MenuItem DataContext="{Binding DocumentController.DocumentSaveCommand}"
|
||||
Style="{StaticResource CommandMenuItemStyle}" >
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{Binding Icon}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem DataContext="{Binding DocumentController.DocumentSaveAsCommand}"
|
||||
Style="{StaticResource CommandMenuItemStyle}" >
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{Binding Icon}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem DataContext="{Binding DocumentController.DocumentSaveACopyCommand}"
|
||||
Style="{StaticResource CommandMenuItemStyle}" >
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{Binding Icon}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem DataContext="{Binding DocumentController.DocumentSaveAllCommand}"
|
||||
Style="{StaticResource CommandMenuItemStyle}" >
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{Binding Icon}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem DataContext="{Binding DocumentController.DocumentCloseCommand}"
|
||||
Style="{StaticResource CommandMenuItemStyle}" >
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{Binding Icon}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem DataContext="{Binding ProjectController.ProjectCloseCommand}"
|
||||
Style="{StaticResource CommandMenuItemStyle}" >
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{Binding Icon}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="E_xit" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Edit" />
|
||||
|
@ -44,8 +44,11 @@ namespace RainmeterStudio.UI
|
||||
ProjectController = projCtrl;
|
||||
|
||||
// Add key bindings
|
||||
this.AddKeyBinding(ProjectController.ProjectCreateCommand);
|
||||
this.AddKeyBinding(DocumentController.DocumentCreateCommand);
|
||||
this.AddKeyBinding(DocumentController.DocumentOpenCommand);
|
||||
this.AddKeyBinding(DocumentController.DocumentSaveCommand);
|
||||
this.AddKeyBinding(DocumentController.DocumentCloseCommand);
|
||||
this.AddKeyBinding(ProjectController.ProjectCreateCommand);
|
||||
|
||||
// Subscribe to events
|
||||
DocumentController.DocumentOpened += documentController_DocumentOpened;
|
||||
@ -63,17 +66,21 @@ namespace RainmeterStudio.UI
|
||||
document.Content = e.Editor.EditorUI;
|
||||
document.Closing += document_Closing;
|
||||
document.Closed += document_Closed;
|
||||
document.IsActiveChanged += new EventHandler((sender2, e2) =>
|
||||
{
|
||||
if (document.IsActive)
|
||||
DocumentController.ActiveDocumentEditor = e.Editor;
|
||||
});
|
||||
|
||||
documentPane.Children.Add(document);
|
||||
documentPane.SelectedContentIndex = documentPane.IndexOf(document);
|
||||
|
||||
|
||||
e.Document.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler((obj, args) =>
|
||||
{
|
||||
string documentName;
|
||||
|
||||
// Get title
|
||||
if (!ProjectController.ActiveProject.Contains(e.Document.Reference))
|
||||
if (ProjectController.ActiveProject == null || !ProjectController.ActiveProject.Contains(e.Document.Reference))
|
||||
{
|
||||
documentName = e.Document.Reference.StoragePath ?? "New document";
|
||||
}
|
||||
@ -96,25 +103,27 @@ namespace RainmeterStudio.UI
|
||||
void document_Closed(object sender, EventArgs e)
|
||||
{
|
||||
var layoutDocument = (LayoutDocument)sender;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void document_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
// Get editor
|
||||
var document = (LayoutDocument)sender;
|
||||
var editor = _openedDocuments[document];
|
||||
|
||||
|
||||
switch (MessageBox.Show("Are you sure?", "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question))
|
||||
// Try to close active document
|
||||
if (!DocumentController.Close(editor))
|
||||
{
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
// Try to close
|
||||
if (!DocumentController.CloseAll())
|
||||
{
|
||||
case MessageBoxResult.Yes:
|
||||
break;
|
||||
|
||||
case MessageBoxResult.No:
|
||||
break;
|
||||
|
||||
default:
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,19 +7,19 @@
|
||||
</configSections>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup><userSettings>
|
||||
<RainmeterStudio.Properties.Settings>
|
||||
<setting name="Command_ProjectCreateCommand_Shortcut" serializeAs="String">
|
||||
<setting name="Command_ProjectCreate_Shortcut" serializeAs="String">
|
||||
<value>Ctrl+Shift+N</value>
|
||||
</setting>
|
||||
<setting name="Command_ProjectPanel_RefreshCommand_Shortcut" serializeAs="String">
|
||||
<setting name="Command_ProjectPanel_Refresh_Shortcut" serializeAs="String">
|
||||
<value>F5</value>
|
||||
</setting>
|
||||
<setting name="Command_DocumentCreateCommand_Shortcut" serializeAs="String">
|
||||
<setting name="Command_DocumentCreate_Shortcut" serializeAs="String">
|
||||
<value>Ctrl+N</value>
|
||||
</setting>
|
||||
<setting name="Command_ProjectOpenCommand_Shortcut" serializeAs="String">
|
||||
<setting name="Command_ProjectOpen_Shortcut" serializeAs="String">
|
||||
<value>Ctrl+Shift+O</value>
|
||||
</setting>
|
||||
<setting name="Command_DocumentCloseCommand_Shortcut" serializeAs="String">
|
||||
<setting name="Command_DocumentClose_Shortcut" serializeAs="String">
|
||||
<value>Ctrl+W</value>
|
||||
</setting>
|
||||
<setting name="MainWindow_Width" serializeAs="String">
|
||||
@ -46,6 +46,12 @@
|
||||
<setting name="CreateProjectDialog_CreateDirectoryCheckbox" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="Command_DocumentOpen_Shortcut" serializeAs="String">
|
||||
<value>Ctrl+O</value>
|
||||
</setting>
|
||||
<setting name="Command_DocumentSave_Shortcut" serializeAs="String">
|
||||
<value>Ctrl+S</value>
|
||||
</setting>
|
||||
</RainmeterStudio.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
|
Loading…
Reference in New Issue
Block a user