UI changes, added commands
@ -29,7 +29,7 @@ namespace RainmeterEditor.Documents.Text
|
||||
Category = Resources.Strings.Category_Utility,
|
||||
DefaultExtension = ".txt",
|
||||
Description = Resources.Strings.DocumentFormat_TextFile_Description,
|
||||
Icon = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Resources/Icons/text-x-generic-32.png", UriKind.RelativeOrAbsolute)),
|
||||
Icon = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Resources/Icons/text_file_32.png", UriKind.RelativeOrAbsolute)),
|
||||
Factory = this
|
||||
};
|
||||
}
|
||||
|
@ -98,6 +98,7 @@
|
||||
</Compile>
|
||||
<Compile Include="Model\IDocumentStorage.cs" />
|
||||
<Compile Include="Storage\SkinDirectory.cs" />
|
||||
<Compile Include="UI\Command.cs" />
|
||||
<Compile Include="UI\Dialogs\CreateDocumentDialog.xaml.cs">
|
||||
<DependentUpon>CreateDocumentDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -175,14 +176,28 @@
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Icons\page_white_text.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Icons\text-x-generic-32.png" />
|
||||
<Resource Include="Resources\Icons\text_file_32.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<SplashScreen Include="Resources\splash.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Icons\arrow_left_16.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Icons\arrow_right_16.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Icons\arrow_backward_16.png" />
|
||||
<Resource Include="Resources\Icons\arrow_forward_16.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Icons\page_white_star_16.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\Icons\project_16.png" />
|
||||
<Resource Include="Resources\Icons\project_star_16.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.
|
||||
|
BIN
RainmeterEditor/Resources/Icons/arrow_backward_16.png
Normal file
After Width: | Height: | Size: 343 B |
BIN
RainmeterEditor/Resources/Icons/arrow_forward_16.png
Normal file
After Width: | Height: | Size: 375 B |
BIN
RainmeterEditor/Resources/Icons/arrow_left_16.png
Normal file
After Width: | Height: | Size: 345 B |
BIN
RainmeterEditor/Resources/Icons/arrow_right_16.png
Normal file
After Width: | Height: | Size: 349 B |
BIN
RainmeterEditor/Resources/Icons/page_white_star_16.png
Normal file
After Width: | Height: | Size: 565 B |
Before Width: | Height: | Size: 342 B |
BIN
RainmeterEditor/Resources/Icons/project_16.png
Normal file
After Width: | Height: | Size: 724 B |
BIN
RainmeterEditor/Resources/Icons/project_star_16.png
Normal file
After Width: | Height: | Size: 742 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
18
RainmeterEditor/Resources/Strings.Designer.cs
generated
@ -69,6 +69,24 @@ namespace RainmeterEditor.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to New file....
|
||||
/// </summary>
|
||||
internal static string DocumentCreateCommand_DisplayText {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentCreateCommand_DisplayText", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Creates a new file.
|
||||
/// </summary>
|
||||
internal static string DocumentCreateCommand_ToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentCreateCommand_ToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Text Editor.
|
||||
/// </summary>
|
||||
|
@ -120,6 +120,12 @@
|
||||
<data name="Category_Utility" xml:space="preserve">
|
||||
<value>Utility</value>
|
||||
</data>
|
||||
<data name="DocumentCreateCommand_DisplayText" xml:space="preserve">
|
||||
<value>New file...</value>
|
||||
</data>
|
||||
<data name="DocumentCreateCommand_ToolTip" xml:space="preserve">
|
||||
<value>Creates a new file</value>
|
||||
</data>
|
||||
<data name="DocumentEditor_Text_Name" xml:space="preserve">
|
||||
<value>Text Editor</value>
|
||||
</data>
|
||||
|
88
RainmeterEditor/UI/Command.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace RainmeterEditor.UI
|
||||
{
|
||||
public class Command : ICommand
|
||||
{
|
||||
#region Private members
|
||||
|
||||
private Action<object> _execute;
|
||||
private Func<object, bool> _canExecute;
|
||||
private Action _executeNoParam;
|
||||
private Func<bool> _canExecuteNoParam;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
public string Name { get; set; }
|
||||
public string DisplayText { get; set; }
|
||||
public string Tooltip { get; set; }
|
||||
public ImageSource Icon { get; set; }
|
||||
public KeyGesture Shortcut { get; set; }
|
||||
|
||||
public string ShortcutText
|
||||
{
|
||||
get
|
||||
{
|
||||
string text = String.Empty;
|
||||
|
||||
if ((Shortcut.Modifiers & ModifierKeys.Windows) != 0)
|
||||
text += "Win+";
|
||||
|
||||
if ((Shortcut.Modifiers & ModifierKeys.Control) != 0)
|
||||
text += "Ctrl+";
|
||||
|
||||
if ((Shortcut.Modifiers & ModifierKeys.Alt) != 0)
|
||||
text += "Alt+";
|
||||
|
||||
if ((Shortcut.Modifiers & ModifierKeys.Shift) != 0)
|
||||
text += "Shift+";
|
||||
|
||||
text += Enum.GetName(typeof(Key), Shortcut.Key);
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public Command(string name = null, Action<object> execute = null, Func<object, bool> canExecute = null)
|
||||
{
|
||||
Name = name;
|
||||
_execute = execute;
|
||||
_canExecute = canExecute;
|
||||
}
|
||||
|
||||
public Command(string name = null, Action execute = null, Func<bool> canExecute = null)
|
||||
{
|
||||
Name = name;
|
||||
_executeNoParam = execute;
|
||||
_canExecuteNoParam = canExecute;
|
||||
}
|
||||
|
||||
public virtual bool CanExecute(object parameter)
|
||||
{
|
||||
if (_canExecute != null)
|
||||
return _canExecute(parameter);
|
||||
else if (_canExecuteNoParam != null)
|
||||
return _canExecuteNoParam();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Execute(object parameter)
|
||||
{
|
||||
if (_execute != null)
|
||||
_execute(parameter);
|
||||
else if (_executeNoParam != null)
|
||||
_executeNoParam();
|
||||
}
|
||||
}
|
||||
}
|
@ -7,11 +7,19 @@ using RainmeterEditor.UI.Dialogs;
|
||||
using RainmeterEditor.Model.Events;
|
||||
using RainmeterEditor.Model;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace RainmeterEditor.UI.Controller
|
||||
{
|
||||
public class DocumentController
|
||||
{
|
||||
#region Commands
|
||||
|
||||
public Command DocumentCreateCommand { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public event EventHandler<DocumentOpenedEventArgs> DocumentOpened
|
||||
{
|
||||
add
|
||||
@ -23,19 +31,27 @@ namespace RainmeterEditor.UI.Controller
|
||||
DocumentManager.Instance.DocumentOpened -= value;
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler DocumentClosed;
|
||||
|
||||
public Window OwnerWindow { get; set; }
|
||||
|
||||
public DocumentController()
|
||||
{
|
||||
DocumentCreateCommand = new Command("DocumentCreateCommand", () => CreateWindow())
|
||||
{
|
||||
DisplayText = Resources.Strings.DocumentCreateCommand_DisplayText,
|
||||
Tooltip = Resources.Strings.DocumentCreateCommand_ToolTip,
|
||||
Icon = new BitmapImage(new Uri("/Resources/Icons/page_white_star_16.png", UriKind.RelativeOrAbsolute)),
|
||||
Shortcut = new KeyGesture(Key.N, ModifierKeys.Control)
|
||||
};
|
||||
}
|
||||
|
||||
public void Create(Window parent = null, DocumentFormat defaultFormat = null, string defaultPath = "")
|
||||
public void CreateWindow(DocumentFormat defaultFormat = null, string defaultPath = "")
|
||||
{
|
||||
// Show dialog
|
||||
var dialog = new CreateDocumentDialog()
|
||||
{
|
||||
Owner = parent,
|
||||
Owner = OwnerWindow,
|
||||
SelectedFormat = defaultFormat,
|
||||
SelectedPath = defaultPath
|
||||
};
|
||||
@ -56,5 +72,6 @@ namespace RainmeterEditor.UI.Controller
|
||||
// Call manager
|
||||
DocumentManager.Instance.Create(format, path);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Window x:Class="RainmeterEditor.MainWindow"
|
||||
<Window x:Class="RainmeterEditor.UI.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="clr-namespace:RainmeterEditor.UI"
|
||||
@ -6,6 +6,11 @@
|
||||
xmlns:adlayout="clr-namespace:Xceed.Wpf.AvalonDock.Layout;assembly=Xceed.Wpf.AvalonDock"
|
||||
Title="Rainmeter Studio" Height="350" Width="525"
|
||||
ResizeMode="CanResizeWithGrip" >
|
||||
|
||||
<Window.Resources>
|
||||
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
@ -21,7 +26,23 @@
|
||||
<!-- Menu bar -->
|
||||
<Menu Grid.Row="0" Grid.ColumnSpan="10">
|
||||
<MenuItem Header="_File">
|
||||
<MenuItem Header="_New Item..." Click="File_New_Click"/>
|
||||
<MenuItem Header="_New">
|
||||
<MenuItem Header="_File..."
|
||||
DataContext="{DynamicResource DocumentCreateCommand}"
|
||||
Command="{Binding}"
|
||||
ToolTip="{Binding Tooltip}"
|
||||
InputGestureText="{Binding ShortcutText}">
|
||||
<MenuItem.Icon>
|
||||
<Image DataContext="{DynamicResource DocumentCreateCommand}"
|
||||
Source="{Binding Icon}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Project..." Command="{DynamicResource CreateFileCommand}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="/Resources/Icons/project_star_16.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Open..." />
|
||||
<Separator />
|
||||
<MenuItem Header="_Close" />
|
||||
@ -32,6 +53,17 @@
|
||||
</Menu>
|
||||
|
||||
<!-- Toolbar -->
|
||||
<ToolBarTray Grid.Row="1">
|
||||
<ToolBar>
|
||||
<Button Name="buttonBackward" ToolTip="Navigate backward">
|
||||
<Image Width="16" Height="16" Source="/Resources/Icons/arrow_backward_16.png" />
|
||||
</Button>
|
||||
<Button Name="buttonForward" ToolTip="Navigate forward">
|
||||
<Image Width="16" Height="16" Source="/Resources/Icons/arrow_forward_16.png" />
|
||||
</Button>
|
||||
<Separator />
|
||||
</ToolBar>
|
||||
</ToolBarTray>
|
||||
|
||||
<!-- Grid splitter -->
|
||||
<GridSplitter Grid.Row="2" Grid.Column="1"
|
||||
|
@ -15,20 +15,38 @@ using RainmeterEditor.Model.Events;
|
||||
using RainmeterEditor.UI.Controller;
|
||||
using Xceed.Wpf.AvalonDock.Layout;
|
||||
|
||||
namespace RainmeterEditor
|
||||
namespace RainmeterEditor.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
DocumentController documentController = new DocumentController();
|
||||
private DocumentController documentController;
|
||||
|
||||
private IEnumerable<Command> Commands
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return documentController.DocumentCreateCommand;
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
documentController = new DocumentController();
|
||||
documentController.OwnerWindow = this;
|
||||
documentController.DocumentOpened += documentController_DocumentOpened;
|
||||
|
||||
foreach (var c in Commands)
|
||||
{
|
||||
Resources.Add(c.Name, c);
|
||||
|
||||
if (c.Shortcut != null)
|
||||
InputBindings.Add(new KeyBinding(c, c.Shortcut));
|
||||
}
|
||||
}
|
||||
|
||||
void documentController_DocumentOpened(object sender, DocumentOpenedEventArgs e)
|
||||
@ -58,10 +76,5 @@ namespace RainmeterEditor
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void File_New_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
documentController.Create(this);
|
||||
}
|
||||
}
|
||||
}
|