Work on project, document managers, controllers and UI

This commit is contained in:
Tiberiu Chibici 2014-09-08 21:31:47 +03:00
parent e338ae31ca
commit fd166fe814
19 changed files with 698 additions and 148 deletions

View File

@ -36,6 +36,8 @@ namespace RainmeterStudio.Business
#endregion #endregion
#region Constructor
/// <summary> /// <summary>
/// Initializes the project manager /// Initializes the project manager
/// </summary> /// </summary>
@ -46,6 +48,10 @@ namespace RainmeterStudio.Business
ActiveProject = null; ActiveProject = null;
} }
#endregion
#region Project operations
/// <summary> /// <summary>
/// Creates a new project /// Creates a new project
/// </summary> /// </summary>
@ -115,6 +121,10 @@ namespace RainmeterStudio.Business
ActiveProjectChanged(this, new EventArgs()); ActiveProjectChanged(this, new EventArgs());
} }
#endregion
#region Document templates
/// <summary> /// <summary>
/// Registers a project template /// Registers a project template
/// </summary> /// </summary>
@ -128,5 +138,7 @@ namespace RainmeterStudio.Business
/// Gets a list of existing project templates /// Gets a list of existing project templates
/// </summary> /// </summary>
public IEnumerable<IProjectTemplate> ProjectTemplates { get { return _projectTemplates; } } public IEnumerable<IProjectTemplate> ProjectTemplates { get { return _projectTemplates; } }
#endregion
} }
} }

View File

@ -27,12 +27,12 @@ namespace RainmeterStudio.Properties {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+Shift+N")] [global::System.Configuration.DefaultSettingValueAttribute("Ctrl+Shift+N")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public string Command_ProjectCreateCommand_Shortcut { public string Command_ProjectCreate_Shortcut {
get { get {
return ((string)(this["Command_ProjectCreateCommand_Shortcut"])); return ((string)(this["Command_ProjectCreate_Shortcut"]));
} }
set { set {
this["Command_ProjectCreateCommand_Shortcut"] = value; this["Command_ProjectCreate_Shortcut"] = value;
} }
} }
@ -40,12 +40,12 @@ namespace RainmeterStudio.Properties {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("F5")] [global::System.Configuration.DefaultSettingValueAttribute("F5")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public string Command_ProjectPanel_RefreshCommand_Shortcut { public string Command_ProjectPanel_Refresh_Shortcut {
get { get {
return ((string)(this["Command_ProjectPanel_RefreshCommand_Shortcut"])); return ((string)(this["Command_ProjectPanel_Refresh_Shortcut"]));
} }
set { 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.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+N")] [global::System.Configuration.DefaultSettingValueAttribute("Ctrl+N")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public string Command_DocumentCreateCommand_Shortcut { public string Command_DocumentCreate_Shortcut {
get { get {
return ((string)(this["Command_DocumentCreateCommand_Shortcut"])); return ((string)(this["Command_DocumentCreate_Shortcut"]));
} }
set { set {
this["Command_DocumentCreateCommand_Shortcut"] = value; this["Command_DocumentCreate_Shortcut"] = value;
} }
} }
@ -66,12 +66,12 @@ namespace RainmeterStudio.Properties {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+Shift+O")] [global::System.Configuration.DefaultSettingValueAttribute("Ctrl+Shift+O")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public string Command_ProjectOpenCommand_Shortcut { public string Command_ProjectOpen_Shortcut {
get { get {
return ((string)(this["Command_ProjectOpenCommand_Shortcut"])); return ((string)(this["Command_ProjectOpen_Shortcut"]));
} }
set { set {
this["Command_ProjectOpenCommand_Shortcut"] = value; this["Command_ProjectOpen_Shortcut"] = value;
} }
} }
@ -79,12 +79,12 @@ namespace RainmeterStudio.Properties {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+W")] [global::System.Configuration.DefaultSettingValueAttribute("Ctrl+W")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public string Command_DocumentCloseCommand_Shortcut { public string Command_DocumentClose_Shortcut {
get { get {
return ((string)(this["Command_DocumentCloseCommand_Shortcut"])); return ((string)(this["Command_DocumentClose_Shortcut"]));
} }
set { set {
this["Command_DocumentCloseCommand_Shortcut"] = value; this["Command_DocumentClose_Shortcut"] = value;
} }
} }
@ -183,5 +183,31 @@ namespace RainmeterStudio.Properties {
this["CreateProjectDialog_CreateDirectoryCheckbox"] = value; 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;
}
}
} }
} }

View File

@ -2,19 +2,19 @@
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="RainmeterStudio.Properties" GeneratedClassName="Settings"> <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="RainmeterStudio.Properties" GeneratedClassName="Settings">
<Profiles /> <Profiles />
<Settings> <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> <Value Profile="(Default)">Ctrl+Shift+N</Value>
</Setting> </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> <Value Profile="(Default)">F5</Value>
</Setting> </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> <Value Profile="(Default)">Ctrl+N</Value>
</Setting> </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> <Value Profile="(Default)">Ctrl+Shift+O</Value>
</Setting> </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> <Value Profile="(Default)">Ctrl+W</Value>
</Setting> </Setting>
<Setting Name="MainWindow_Width" Type="System.Double" Scope="User"> <Setting Name="MainWindow_Width" Type="System.Double" Scope="User">
@ -41,5 +41,11 @@
<Setting Name="CreateProjectDialog_CreateDirectoryCheckbox" Type="System.Boolean" Scope="User"> <Setting Name="CreateProjectDialog_CreateDirectoryCheckbox" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>
</Setting> </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> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -238,6 +238,16 @@
<ItemGroup> <ItemGroup>
<None Include="Resources\Icons\32\project_empty.png" /> <None Include="Resources\Icons\32\project_empty.png" />
</ItemGroup> </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" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -63,9 +63,9 @@ namespace RainmeterStudio.Resources {
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap Command_DocumentCreateCommand_Icon { internal static System.Drawing.Bitmap Command_DocumentClose_Icon {
get { get {
object obj = ResourceManager.GetObject("Command_DocumentCreateCommand_Icon", resourceCulture); object obj = ResourceManager.GetObject("Command_DocumentClose_Icon", resourceCulture);
return ((System.Drawing.Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
} }
} }
@ -73,9 +73,9 @@ namespace RainmeterStudio.Resources {
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap Command_ProjectCreateCommand_Icon { internal static System.Drawing.Bitmap Command_DocumentCreate_Icon {
get { get {
object obj = ResourceManager.GetObject("Command_ProjectCreateCommand_Icon", resourceCulture); object obj = ResourceManager.GetObject("Command_DocumentCreate_Icon", resourceCulture);
return ((System.Drawing.Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
} }
} }
@ -83,9 +83,49 @@ namespace RainmeterStudio.Resources {
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap Command_ProjectOpenCommand_Icon { internal static System.Drawing.Bitmap Command_DocumentOpen_Icon {
get { 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)); return ((System.Drawing.Bitmap)(obj));
} }
} }

View File

@ -118,13 +118,25 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <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> <value>icons\16\page_white_star.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </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> <value>icons\16\project_star.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </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> <value>icons\16\folder_project.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="Command_ProjectPanel_CollapseAllCommand_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="Command_ProjectPanel_CollapseAllCommand_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 B

View File

@ -90,72 +90,180 @@ namespace RainmeterStudio.Resources {
/// <summary> /// <summary>
/// Looks up a localized string similar to _Close. /// Looks up a localized string similar to _Close.
/// </summary> /// </summary>
public static string Command_DocumentCloseCommand_DisplayText { public static string Command_DocumentClose_DisplayText {
get { get {
return ResourceManager.GetString("Command_DocumentCloseCommand_DisplayText", resourceCulture); return ResourceManager.GetString("Command_DocumentClose_DisplayText", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Close active document. /// Looks up a localized string similar to Close active document.
/// </summary> /// </summary>
public static string Command_DocumentCloseCommand_ToolTip { public static string Command_DocumentClose_ToolTip {
get { get {
return ResourceManager.GetString("Command_DocumentCloseCommand_ToolTip", resourceCulture); return ResourceManager.GetString("Command_DocumentClose_ToolTip", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to _File.... /// Looks up a localized string similar to _File....
/// </summary> /// </summary>
public static string Command_DocumentCreateCommand_DisplayText { public static string Command_DocumentCreate_DisplayText {
get { get {
return ResourceManager.GetString("Command_DocumentCreateCommand_DisplayText", resourceCulture); return ResourceManager.GetString("Command_DocumentCreate_DisplayText", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Create a new file. /// Looks up a localized string similar to Create a new file.
/// </summary> /// </summary>
public static string Command_DocumentCreateCommand_ToolTip { public static string Command_DocumentCreate_ToolTip {
get { 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> /// <summary>
/// Looks up a localized string similar to _Project.... /// Looks up a localized string similar to _Project....
/// </summary> /// </summary>
public static string Command_ProjectCreateCommand_DisplayText { public static string Command_ProjectCreate_DisplayText {
get { get {
return ResourceManager.GetString("Command_ProjectCreateCommand_DisplayText", resourceCulture); return ResourceManager.GetString("Command_ProjectCreate_DisplayText", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Create a new project. /// Looks up a localized string similar to Create a new project.
/// </summary> /// </summary>
public static string Command_ProjectCreateCommand_ToolTip { public static string Command_ProjectCreate_ToolTip {
get { get {
return ResourceManager.GetString("Command_ProjectCreateCommand_ToolTip", resourceCulture); return ResourceManager.GetString("Command_ProjectCreate_ToolTip", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to _Project.... /// Looks up a localized string similar to _Project....
/// </summary> /// </summary>
public static string Command_ProjectOpenCommand_DisplayText { public static string Command_ProjectOpen_DisplayText {
get { get {
return ResourceManager.GetString("Command_ProjectOpenCommand_DisplayText", resourceCulture); return ResourceManager.GetString("Command_ProjectOpen_DisplayText", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Open existing project. /// Looks up a localized string similar to Open existing project.
/// </summary> /// </summary>
public static string Command_ProjectOpenCommand_ToolTip { public static string Command_ProjectOpen_ToolTip {
get { get {
return ResourceManager.GetString("Command_ProjectOpenCommand_ToolTip", resourceCulture); return ResourceManager.GetString("Command_ProjectOpen_ToolTip", resourceCulture);
} }
} }
@ -367,7 +475,7 @@ namespace RainmeterStudio.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Do_n&apos;t save. /// Looks up a localized string similar to Don&apos;t save.
/// </summary> /// </summary>
public static string Dialog_DoNotSave { public static string Dialog_DoNotSave {
get { 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> /// <summary>
/// Looks up a localized string similar to Open project.... /// Looks up a localized string similar to Open project....
/// </summary> /// </summary>
@ -412,7 +529,7 @@ namespace RainmeterStudio.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to _Save. /// Looks up a localized string similar to Save.
/// </summary> /// </summary>
public static string Dialog_Save { public static string Dialog_Save {
get { 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> /// <summary>
/// Looks up a localized string similar to _File. /// Looks up a localized string similar to _File.
/// </summary> /// </summary>

View File

@ -147,16 +147,16 @@
<data name="Dialog_OpenProject_Title" xml:space="preserve"> <data name="Dialog_OpenProject_Title" xml:space="preserve">
<value>Open project...</value> <value>Open project...</value>
</data> </data>
<data name="Command_DocumentCloseCommand_DisplayText" xml:space="preserve"> <data name="Command_DocumentClose_DisplayText" xml:space="preserve">
<value>_Close</value> <value>_Close</value>
</data> </data>
<data name="Command_DocumentCloseCommand_ToolTip" xml:space="preserve"> <data name="Command_DocumentClose_ToolTip" xml:space="preserve">
<value>Close active document</value> <value>Close active document</value>
</data> </data>
<data name="Command_DocumentCreateCommand_DisplayText" xml:space="preserve"> <data name="Command_DocumentCreate_DisplayText" xml:space="preserve">
<value>_File...</value> <value>_File...</value>
</data> </data>
<data name="Command_DocumentCreateCommand_ToolTip" xml:space="preserve"> <data name="Command_DocumentCreate_ToolTip" xml:space="preserve">
<value>Create a new file</value> <value>Create a new file</value>
</data> </data>
<data name="MainWindow_File" xml:space="preserve"> <data name="MainWindow_File" xml:space="preserve">
@ -168,10 +168,10 @@
<data name="MainWindow_File_Open" xml:space="preserve"> <data name="MainWindow_File_Open" xml:space="preserve">
<value>_Open</value> <value>_Open</value>
</data> </data>
<data name="Command_ProjectCreateCommand_DisplayText" xml:space="preserve"> <data name="Command_ProjectCreate_DisplayText" xml:space="preserve">
<value>_Project...</value> <value>_Project...</value>
</data> </data>
<data name="Command_ProjectCreateCommand_ToolTip" xml:space="preserve"> <data name="Command_ProjectCreate_ToolTip" xml:space="preserve">
<value>Create a new project</value> <value>Create a new project</value>
</data> </data>
<data name="CreateProjectDialog_Location" xml:space="preserve"> <data name="CreateProjectDialog_Location" xml:space="preserve">
@ -192,10 +192,10 @@
<data name="CreateProjectDialog_Title" xml:space="preserve"> <data name="CreateProjectDialog_Title" xml:space="preserve">
<value>Create project</value> <value>Create project</value>
</data> </data>
<data name="Command_ProjectOpenCommand_DisplayText" xml:space="preserve"> <data name="Command_ProjectOpen_DisplayText" xml:space="preserve">
<value>_Project...</value> <value>_Project...</value>
</data> </data>
<data name="Command_ProjectOpenCommand_ToolTip" xml:space="preserve"> <data name="Command_ProjectOpen_ToolTip" xml:space="preserve">
<value>Open existing project</value> <value>Open existing project</value>
</data> </data>
<data name="Command_ProjectPanel_CollapseAllCommand_DisplayText" xml:space="preserve"> <data name="Command_ProjectPanel_CollapseAllCommand_DisplayText" xml:space="preserve">
@ -250,9 +250,51 @@
<value>Unsaved changes</value> <value>Unsaved changes</value>
</data> </data>
<data name="Dialog_DoNotSave" xml:space="preserve"> <data name="Dialog_DoNotSave" xml:space="preserve">
<value>Do_n't save</value> <value>Don't save</value>
</data> </data>
<data name="Dialog_Save" xml:space="preserve"> <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> <value>_Save</value>
</data> </data>
<data name="Command_DocumentSave_ToolTip" xml:space="preserve">
<value>Save the current document</value>
</data>
</root> </root>

View File

@ -9,6 +9,8 @@ using RainmeterStudio.UI.Dialogs;
using RainmeterStudio.UI.ViewModel; using RainmeterStudio.UI.ViewModel;
using RainmeterStudio.Core.Model; using RainmeterStudio.Core.Model;
using System.IO; using System.IO;
using Microsoft.Win32;
using RainmeterStudio.Core.Utils;
namespace RainmeterStudio.UI.Controller namespace RainmeterStudio.UI.Controller
{ {
@ -34,10 +36,20 @@ namespace RainmeterStudio.UI.Controller
public Command DocumentOpenCommand { get; private set; } 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 #endregion
#region Events
/// <summary> /// <summary>
/// Triggered when a document is opened /// Triggered when a document is opened
/// </summary> /// </summary>
@ -56,15 +68,77 @@ namespace RainmeterStudio.UI.Controller
remove { DocumentManager.DocumentClosed -= value; } 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; } 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) public DocumentController(DocumentManager documentManager, ProjectManager projectManager)
{ {
DocumentManager = documentManager; DocumentManager = documentManager;
ProjectManager = projectManager; ProjectManager = projectManager;
DocumentCreateCommand = new Command("DocumentCreateCommand", () => Create(), () => ProjectManager.ActiveProject != null); DocumentCreateCommand = new Command("DocumentCreate", Create, () => ProjectManager.ActiveProject != null);
ProjectManager.ActiveProjectChanged += new EventHandler((obj, e) => DocumentCreateCommand.NotifyCanExecuteChanged()); 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 #region Document operations
@ -105,23 +179,105 @@ namespace RainmeterStudio.UI.Controller
} }
/// <summary> /// <summary>
/// Saves the document opened in specified editor /// Shows an 'open document' dialog, and opens a document
/// </summary> /// </summary>
/// <param name="editor">Editor</param> public void Open()
public void Save(IDocumentEditor editor)
{ {
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; return;
} }
// TODO
}
public void SaveAs(IDocumentEditor editor)
{
// TODO
} }
/// <summary> /// <summary>
@ -135,17 +291,13 @@ namespace RainmeterStudio.UI.Controller
// Show the 'are you sure' prompt if necesary // Show the 'are you sure' prompt if necesary
if (editor.AttachedDocument.IsDirty) if (editor.AttachedDocument.IsDirty)
{ {
bool? res = CloseUnsavedDialog.ShowDialog(OwnerWindow, editor.AttachedDocument); switch(CloseUnsavedDialog.ShowDialog(OwnerWindow, editor.AttachedDocument))
if (res.HasValue)
{
// Save
if (res.Value)
{
Save(editor);
}
}
else
{ {
case CloseUnsavedDialogResult.Save:
Save();
break;
case CloseUnsavedDialogResult.Cancel:
return false; return false;
} }
} }
@ -155,6 +307,56 @@ namespace RainmeterStudio.UI.Controller
return true; 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 #endregion
/// <summary> /// <summary>

View File

@ -82,10 +82,21 @@ namespace RainmeterStudio.UI.Controller
#region Commands #region Commands
/// <summary>
/// Create project command
/// </summary>
public Command ProjectCreateCommand { get; private set; } public Command ProjectCreateCommand { get; private set; }
/// <summary>
/// Open project command
/// </summary>
public Command ProjectOpenCommand { get; private set; } public Command ProjectOpenCommand { get; private set; }
/// <summary>
/// Close project command
/// </summary>
public Command ProjectCloseCommand { get; private set; }
#endregion #endregion
/// <summary> /// <summary>
@ -96,8 +107,11 @@ namespace RainmeterStudio.UI.Controller
{ {
Manager = manager; Manager = manager;
ProjectCreateCommand = new Command("ProjectCreateCommand", () => CreateProject()); // Initialize commands
ProjectOpenCommand = new Command("ProjectOpenCommand", () => OpenProject()); 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> /// <summary>
@ -126,7 +140,7 @@ namespace RainmeterStudio.UI.Controller
/// Displays an 'open file' dialog and opens an existing project /// Displays an 'open file' dialog and opens an existing project
/// </summary> /// </summary>
/// <param name="path"></param> /// <param name="path"></param>
public void OpenProject(string path = null) public void OpenProject()
{ {
// Open dialog // Open dialog
OpenFileDialog dialog = new OpenFileDialog(); OpenFileDialog dialog = new OpenFileDialog();
@ -151,6 +165,7 @@ namespace RainmeterStudio.UI.Controller
/// </summary> /// </summary>
public void CloseProject() public void CloseProject()
{ {
Manager.Close();
} }
} }
} }

View File

@ -17,15 +17,14 @@
<TextBlock Grid.Row="0" Text="{x:Static r:Strings.CloseUnsavedDialog_Message }" <TextBlock Grid.Row="0" Text="{x:Static r:Strings.CloseUnsavedDialog_Message }"
Margin="4"/> Margin="4"/>
<ScrollViewer Grid.Row="1" <ListBox Name="listUnsavedDocuments" Grid.Row="1" Padding="3"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" IsEnabled="False" >
ScrollViewer.VerticalScrollBarVisibility="Auto"> <ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Name="textFiles" <TextBlock Text="{Binding Reference.Name}" />
Margin="4" Padding="4" </DataTemplate>
Background="White"/> </ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
<TextBlock Grid.Row="2" Text="{x:Static r:Strings.CloseUnsavedDialog_Question }" <TextBlock Grid.Row="2" Text="{x:Static r:Strings.CloseUnsavedDialog_Question }"
Margin="4"/> Margin="4"/>

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
@ -11,9 +12,18 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
using RainmeterStudio.Core.Model; using RainmeterStudio.Core.Model;
using RainmeterStudio.Core.Utils;
namespace RainmeterStudio.UI.Dialogs namespace RainmeterStudio.UI.Dialogs
{ {
public enum CloseUnsavedDialogResult
{
Unset,
Save,
DoNotSave,
Cancel
}
/// <summary> /// <summary>
/// Interaction logic for CloseUnsavedDialog.xaml /// Interaction logic for CloseUnsavedDialog.xaml
/// </summary> /// </summary>
@ -24,10 +34,11 @@ namespace RainmeterStudio.UI.Dialogs
/// </summary> /// </summary>
/// <param name="unsavedDocuments">List of unsaved documents</param> /// <param name="unsavedDocuments">List of unsaved documents</param>
/// <returns>Dialog result</returns> /// <returns>Dialog result</returns>
public static bool? ShowDialog(IEnumerable<IDocument> unsavedDocuments) public static CloseUnsavedDialogResult ShowDialog(IEnumerable<IDocument> unsavedDocuments)
{ {
var dialog = new CloseUnsavedDialog(unsavedDocuments); var dialog = new CloseUnsavedDialog(unsavedDocuments);
return dialog.ShowDialog(); dialog.ShowDialog();
return dialog.SaveDialogResult;
} }
/// <summary> /// <summary>
@ -36,11 +47,11 @@ namespace RainmeterStudio.UI.Dialogs
/// <param name="owner">Owner window</param> /// <param name="owner">Owner window</param>
/// <param name="unsavedDocuments">List of unsaved documents</param> /// <param name="unsavedDocuments">List of unsaved documents</param>
/// <returns>Dialog result</returns> /// <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); var dialog = new CloseUnsavedDialog(unsavedDocuments);
dialog.Owner = owner; dialog.ShowDialog();
return dialog.ShowDialog(); return dialog.SaveDialogResult;
} }
/// <summary> /// <summary>
@ -49,13 +60,18 @@ namespace RainmeterStudio.UI.Dialogs
/// <param name="owner">Owner window</param> /// <param name="owner">Owner window</param>
/// <param name="unsavedDocuments">List of unsaved documents</param> /// <param name="unsavedDocuments">List of unsaved documents</param>
/// <returns>Dialog result</returns> /// <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); var dialog = new CloseUnsavedDialog(unsavedDocuments);
dialog.Owner = owner; dialog.ShowDialog();
return dialog.ShowDialog(); return dialog.SaveDialogResult;
} }
/// <summary>
/// Gets the 'close unsaved' dialog result
/// </summary>
public CloseUnsavedDialogResult SaveDialogResult { get; private set; }
/// <summary> /// <summary>
/// Initializes the dialog /// Initializes the dialog
/// </summary> /// </summary>
@ -64,39 +80,25 @@ namespace RainmeterStudio.UI.Dialogs
{ {
InitializeComponent(); InitializeComponent();
textFiles.Inlines.AddRange(unsavedDocuments.SelectMany(GetInlines)); SaveDialogResult = CloseUnsavedDialogResult.Unset;
} unsavedDocuments.ForEach(d => listUnsavedDocuments.Items.Add(d));
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
};
} }
private void buttonSave_Click(object sender, RoutedEventArgs e) private void buttonSave_Click(object sender, RoutedEventArgs e)
{ {
DialogResult = true; SaveDialogResult = CloseUnsavedDialogResult.Save;
Close(); Close();
} }
private void buttonDoNotSave_Click(object sender, RoutedEventArgs e) private void buttonDoNotSave_Click(object sender, RoutedEventArgs e)
{ {
DialogResult = false; SaveDialogResult = CloseUnsavedDialogResult.DoNotSave;
Close(); Close();
} }
private void buttonCancel_Click(object sender, RoutedEventArgs e) private void buttonCancel_Click(object sender, RoutedEventArgs e)
{ {
DialogResult = null; SaveDialogResult = CloseUnsavedDialogResult.Cancel;
Close(); Close();
} }
} }

View File

@ -14,7 +14,8 @@
Left="{Binding Source={x:Static p:Settings.Default}, Path=MainWindow_Left, Mode=TwoWay}" 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}" Top="{Binding Source={x:Static p:Settings.Default}, Path=MainWindow_Top, Mode=TwoWay}"
ResizeMode="CanResizeWithGrip" > ResizeMode="CanResizeWithGrip"
Closing="Window_Closing">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@ -47,16 +48,58 @@
</MenuItem> </MenuItem>
<Separator /> <Separator />
<MenuItem Header="{x:Static r:Strings.MainWindow_File_Open}"> <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}" <MenuItem DataContext="{Binding ProjectController.ProjectOpenCommand}"
Style="{StaticResource CommandMenuItemStyle}"> Style="{StaticResource CommandMenuItemStyle}">
<MenuItem.Icon> <MenuItem.Icon>
<Image Source="{Binding Icon}" /> <Image Source="{Binding Icon}" />
</MenuItem.Icon> </MenuItem.Icon>
</MenuItem> </MenuItem>
<Separator />
</MenuItem> </MenuItem>
<Separator /> <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 Header="E_xit" />
</MenuItem> </MenuItem>
<MenuItem Header="_Edit" /> <MenuItem Header="_Edit" />

View File

@ -44,8 +44,11 @@ namespace RainmeterStudio.UI
ProjectController = projCtrl; ProjectController = projCtrl;
// Add key bindings // Add key bindings
this.AddKeyBinding(ProjectController.ProjectCreateCommand);
this.AddKeyBinding(DocumentController.DocumentCreateCommand); this.AddKeyBinding(DocumentController.DocumentCreateCommand);
this.AddKeyBinding(DocumentController.DocumentOpenCommand);
this.AddKeyBinding(DocumentController.DocumentSaveCommand);
this.AddKeyBinding(DocumentController.DocumentCloseCommand);
this.AddKeyBinding(ProjectController.ProjectCreateCommand);
// Subscribe to events // Subscribe to events
DocumentController.DocumentOpened += documentController_DocumentOpened; DocumentController.DocumentOpened += documentController_DocumentOpened;
@ -63,17 +66,21 @@ namespace RainmeterStudio.UI
document.Content = e.Editor.EditorUI; document.Content = e.Editor.EditorUI;
document.Closing += document_Closing; document.Closing += document_Closing;
document.Closed += document_Closed; document.Closed += document_Closed;
document.IsActiveChanged += new EventHandler((sender2, e2) =>
{
if (document.IsActive)
DocumentController.ActiveDocumentEditor = e.Editor;
});
documentPane.Children.Add(document); documentPane.Children.Add(document);
documentPane.SelectedContentIndex = documentPane.IndexOf(document); documentPane.SelectedContentIndex = documentPane.IndexOf(document);
e.Document.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler((obj, args) => e.Document.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler((obj, args) =>
{ {
string documentName; string documentName;
// Get title // 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"; documentName = e.Document.Reference.StoragePath ?? "New document";
} }
@ -96,25 +103,27 @@ namespace RainmeterStudio.UI
void document_Closed(object sender, EventArgs e) void document_Closed(object sender, EventArgs e)
{ {
var layoutDocument = (LayoutDocument)sender; var layoutDocument = (LayoutDocument)sender;
} }
void document_Closing(object sender, System.ComponentModel.CancelEventArgs e) void document_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{ {
// Get editor
var document = (LayoutDocument)sender;
var editor = _openedDocuments[document];
// Try to close active document
switch (MessageBox.Show("Are you sure?", "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question)) 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; e.Cancel = true;
return;
} }
} }
} }

View File

@ -7,19 +7,19 @@
</configSections> </configSections>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup><userSettings> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup><userSettings>
<RainmeterStudio.Properties.Settings> <RainmeterStudio.Properties.Settings>
<setting name="Command_ProjectCreateCommand_Shortcut" serializeAs="String"> <setting name="Command_ProjectCreate_Shortcut" serializeAs="String">
<value>Ctrl+Shift+N</value> <value>Ctrl+Shift+N</value>
</setting> </setting>
<setting name="Command_ProjectPanel_RefreshCommand_Shortcut" serializeAs="String"> <setting name="Command_ProjectPanel_Refresh_Shortcut" serializeAs="String">
<value>F5</value> <value>F5</value>
</setting> </setting>
<setting name="Command_DocumentCreateCommand_Shortcut" serializeAs="String"> <setting name="Command_DocumentCreate_Shortcut" serializeAs="String">
<value>Ctrl+N</value> <value>Ctrl+N</value>
</setting> </setting>
<setting name="Command_ProjectOpenCommand_Shortcut" serializeAs="String"> <setting name="Command_ProjectOpen_Shortcut" serializeAs="String">
<value>Ctrl+Shift+O</value> <value>Ctrl+Shift+O</value>
</setting> </setting>
<setting name="Command_DocumentCloseCommand_Shortcut" serializeAs="String"> <setting name="Command_DocumentClose_Shortcut" serializeAs="String">
<value>Ctrl+W</value> <value>Ctrl+W</value>
</setting> </setting>
<setting name="MainWindow_Width" serializeAs="String"> <setting name="MainWindow_Width" serializeAs="String">
@ -38,14 +38,20 @@
<value>10</value> <value>10</value>
</setting> </setting>
<setting name="CreateProjectDialog_RecentLocations" serializeAs="String"> <setting name="CreateProjectDialog_RecentLocations" serializeAs="String">
<value/> <value />
</setting> </setting>
<setting name="Project_SavedLocation" serializeAs="String"> <setting name="Project_SavedLocation" serializeAs="String">
<value/> <value />
</setting> </setting>
<setting name="CreateProjectDialog_CreateDirectoryCheckbox" serializeAs="String"> <setting name="CreateProjectDialog_CreateDirectoryCheckbox" serializeAs="String">
<value>True</value> <value>True</value>
</setting> </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> </RainmeterStudio.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>