Completed rename from RainmeterEditor to RainmeterStudio

This commit is contained in:
2014-07-26 10:12:56 +03:00
parent f1b984768a
commit 6eec29a3a7
117 changed files with 10407 additions and 6247 deletions

View 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 RainmeterStudio.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();
}
}
}

View File

@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RainmeterStudio.Business;
using RainmeterStudio.UI.Dialogs;
using RainmeterStudio.Model.Events;
using RainmeterStudio.Model;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Imaging;
namespace RainmeterStudio.UI.Controller
{
public class DocumentController
{
#region Commands
public Command DocumentCreateCommand { get; private set; }
#endregion
public event EventHandler<DocumentOpenedEventArgs> DocumentOpened
{
add
{
DocumentManager.Instance.DocumentOpened += value;
}
remove
{
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 CreateWindow(DocumentFormat defaultFormat = null, string defaultPath = "")
{
// Show dialog
var dialog = new CreateDocumentDialog()
{
Owner = OwnerWindow,
SelectedFormat = defaultFormat,
SelectedPath = defaultPath
};
bool? res = dialog.ShowDialog();
if (!res.HasValue || !res.Value)
return;
var format = dialog.SelectedFormat;
var path = dialog.SelectedPath;
// Call manager
DocumentManager.Instance.Create(format, path);
}
public void Create(DocumentFormat format, string path)
{
// Call manager
DocumentManager.Instance.Create(format, path);
}
}
}

View File

@ -0,0 +1,64 @@
<Window x:Class="RainmeterStudio.UI.Dialogs.CreateDocumentDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Create..." Height="250" Width="400"
WindowStartupLocation="CenterOwner"
WindowStyle="ToolWindow" ShowInTaskbar="False">
<Grid Background="WhiteSmoke">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListView Name="listFormats" Grid.Row="0">
<ListView.ItemTemplate>
<DataTemplate>
<DockPanel>
<Image DockPanel.Dock="Left" Source="{Binding Icon}"
Width="32" Height="32" Margin="2"
Stretch="Uniform" VerticalAlignment="Top" />
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<TextBlock Text="{Binding Name}" FontWeight="Bold" />
<TextBlock Text="{Binding Description}" />
</StackPanel>
</DockPanel>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock FontWeight="Bold" FontSize="13pt" Text="{Binding Name}" />
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
</ListView>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0">Path:</TextBlock>
<TextBox Name="textPath" Grid.Row="0" Grid.Column="1"></TextBox>
<Button Grid.Row="0" Grid.Column="2">...</Button>
</Grid>
<StackPanel Grid.Row="2" Orientation="Horizontal"
HorizontalAlignment="Right">
<Button Name="buttonCreate" Click="buttonCreate_Click" IsDefault="True">Create</Button>
<Button Name="buttonCancel" Click="buttonCancel_Click" IsCancel="True">Cancel</Button>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using RainmeterStudio.Business;
using RainmeterStudio.Model;
namespace RainmeterStudio.UI.Dialogs
{
/// <summary>
/// Interaction logic for CreateDocumentDialog.xaml
/// </summary>
public partial class CreateDocumentDialog : Window
{
/// <summary>
/// Gets or sets the currently selected file format
/// </summary>
public DocumentFormat SelectedFormat
{
get
{
return listFormats.SelectedItem as DocumentFormat;
}
set
{
listFormats.SelectedItem = value;
}
}
/// <summary>
/// Gets or sets the path
/// </summary>
public string SelectedPath
{
get
{
return textPath.Text;
}
set
{
textPath.Text = value;
}
}
/// <summary>
/// Creates a new instance of CreateDocumentDialog
/// </summary>
public CreateDocumentDialog()
{
InitializeComponent();
PopulateFormats();
Validate();
}
private void PopulateFormats()
{
listFormats.ItemsSource = DocumentManager.Instance.DocumentFormats;
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(listFormats.ItemsSource);
view.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
}
private void buttonCreate_Click(object sender, RoutedEventArgs e)
{
DialogResult = true;
Close();
}
private void buttonCancel_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
Close();
}
private void Validate()
{
bool res = true;
res &= !String.IsNullOrWhiteSpace(textPath.Text);
res &= (listFormats.SelectedItem != null);
buttonCreate.IsEnabled = res;
}
}
}

View File

@ -0,0 +1,116 @@
<Window x:Class="RainmeterStudio.UI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:RainmeterStudio.UI"
xmlns:ad="clr-namespace:Xceed.Wpf.AvalonDock;assembly=Xceed.Wpf.AvalonDock"
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" />
<!-- Menu bar -->
<RowDefinition Height="Auto" />
<!-- Toolbar -->
<RowDefinition />
<!-- Dock area -->
<RowDefinition Height="Auto" />
<!-- Status bar -->
</Grid.RowDefinitions>
<!-- Menu bar -->
<Menu Grid.Row="0" Grid.ColumnSpan="10">
<MenuItem Header="_File">
<MenuItem Header="_New">
<MenuItem DataContext="{Binding DocumentCreateCommand}"
Command="{Binding}" Header="{Binding DisplayText}" ToolTip="{Binding Tooltip}"
InputGestureText="{Binding ShortcutText}">
<MenuItem.Icon>
<Image Source="{Binding Icon}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="_Project..." Command="{Binding DocumentCreateCommand}">
<MenuItem.Icon>
<Image Source="/Resources/Icons/project_star_16.png" />
</MenuItem.Icon>
</MenuItem>
</MenuItem>
<MenuItem Header="_Open..." />
<Separator />
<MenuItem Header="_Close" />
<MenuItem Header="E_xit" />
</MenuItem>
<MenuItem Header="_Edit" />
<MenuItem Header="_Help" />
</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 />
<Button DataContext="{Binding DocumentCreateCommand}"
Command="{Binding}" ToolTip="{Binding Tooltip}">
<Image Source="{Binding Icon}" />
</Button>
</ToolBar>
</ToolBarTray>
<!-- Grid splitter -->
<GridSplitter Grid.Row="2" Grid.Column="1"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<!-- Document panel -->
<ad:DockingManager
x:Name="dockingManager"
Grid.Row="2">
<adlayout:LayoutRoot>
<adlayout:LayoutRoot.LeftSide>
<adlayout:LayoutAnchorSide>
<adlayout:LayoutAnchorGroup>
<adlayout:LayoutAnchorable Title="Toolbox" />
</adlayout:LayoutAnchorGroup>
</adlayout:LayoutAnchorSide>
</adlayout:LayoutRoot.LeftSide>
<adlayout:LayoutPanel Orientation="Horizontal">
<adlayout:LayoutDocumentPane x:Name="documentPane" />
<adlayout:LayoutAnchorablePaneGroup DockWidth="150" Orientation="Vertical">
<adlayout:LayoutAnchorablePane>
<adlayout:LayoutAnchorable Title="Skins">
<ui:SkinsPanel />
</adlayout:LayoutAnchorable>
<adlayout:LayoutAnchorable Title="Outline" />
</adlayout:LayoutAnchorablePane>
<adlayout:LayoutAnchorablePane>
<adlayout:LayoutAnchorable Title="Properties" />
</adlayout:LayoutAnchorablePane>
</adlayout:LayoutAnchorablePaneGroup>
</adlayout:LayoutPanel>
</adlayout:LayoutRoot>
</ad:DockingManager>
<!-- Status bar -->
<StatusBar Grid.Row="3" Grid.ColumnSpan="10">
<ProgressBar Name="statusProgress"
Width="64" Height="8"
IsIndeterminate="True"
Visibility="Collapsed" />
<TextBlock Name="statusMessage">Ready</TextBlock>
</StatusBar>
</Grid>
</Window>

View File

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using RainmeterStudio.Model.Events;
using RainmeterStudio.UI.Controller;
using Xceed.Wpf.AvalonDock.Layout;
namespace RainmeterStudio.UI
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private DocumentController documentController;
public Command DocumentCreateCommand { get { return documentController.DocumentCreateCommand; } }
public MainWindow()
{
InitializeComponent();
this.DataContext = this;
documentController = new DocumentController();
documentController.OwnerWindow = this;
documentController.DocumentOpened += documentController_DocumentOpened;
AddKeyBinding(documentController.DocumentCreateCommand);
}
private void AddKeyBinding(Command c)
{
if (c.Shortcut != null)
InputBindings.Add(new KeyBinding(c, c.Shortcut));
}
void documentController_DocumentOpened(object sender, DocumentOpenedEventArgs e)
{
// Spawn a new window
LayoutDocument document = new LayoutDocument();
document.Content = e.Editor.EditorUI;
document.Title = e.Editor.Title;
document.Closing += document_Closing;
documentPane.Children.Add(document);
documentPane.SelectedContentIndex = documentPane.IndexOf(document);
}
void document_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
switch (MessageBox.Show("Are you sure?", "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question))
{
case MessageBoxResult.Yes:
break;
case MessageBoxResult.No:
break;
default:
e.Cancel = true;
return;
}
}
}
}

View File

@ -0,0 +1,16 @@
<UserControl x:Class="RainmeterStudio.UI.SkinsPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TreeView>
<TreeViewItem Header="Sample item">
<TreeViewItem Header="Sample subitem" />
</TreeViewItem>
<TreeViewItem Header="Sample item 2" />
</TreeView>
</Grid>
</UserControl>

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using RainmeterStudio.Interop;
using RainmeterStudio.Storage;
namespace RainmeterStudio.UI
{
/// <summary>
/// Interaction logic for SkinsPanel.xaml
/// </summary>
public partial class SkinsPanel : UserControl
{
public SkinsPanel()
{
InitializeComponent();
//var x = Rainmeter.Instance.Handle;
}
}
}

View File

@ -0,0 +1,55 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="Button">
<Setter Property="Margin" Value="1" />
<Setter Property="Padding" Value="6,1,6,1" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="_border"
BorderBrush="Gray"
BorderThickness="1"
CornerRadius="2"
Padding="{TemplateBinding Padding}">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#eeee" Offset="0" />
<GradientStop Color="#cccc" Offset="1" />
</LinearGradientBrush>
</Border.Background>
<ContentPresenter Name="_content" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="_border" Property="Background" >
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#eeee" Offset="0" />
<GradientStop Color="#dddd" Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="_border" Property="Background" >
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#dddd" Offset="0" />
<GradientStop Color="#bbbb" Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="_content" Property="Opacity" Value=".5" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View File

@ -0,0 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ButtonStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>