mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	Work on resource and settings managers, added some documentation.
This commit is contained in:
		@@ -1,10 +1,8 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Windows.Input;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using RainmeterStudio.UI.Controller;
 | 
			
		||||
using RainmeterStudio.Business;
 | 
			
		||||
using RainmeterStudio.Core.Utils;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.UI
 | 
			
		||||
{
 | 
			
		||||
@@ -26,9 +24,6 @@ namespace RainmeterStudio.UI
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Name { get; set; }
 | 
			
		||||
 | 
			
		||||
        #region Display text property
 | 
			
		||||
        private string _displayText = null;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the display text of the command
 | 
			
		||||
        /// </summary>
 | 
			
		||||
@@ -36,22 +31,10 @@ namespace RainmeterStudio.UI
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_displayText == null)
 | 
			
		||||
                    return Resources.Strings.ResourceManager.GetString(Name + "_DisplayText");
 | 
			
		||||
 | 
			
		||||
                return _displayText;
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _displayText = value;
 | 
			
		||||
                return ResourceProvider.GetString("Command_" + Name + "_DisplayText");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region ToolTip property
 | 
			
		||||
        private string _toolTip = null;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the tooltip
 | 
			
		||||
        /// </summary>
 | 
			
		||||
@@ -59,20 +42,9 @@ namespace RainmeterStudio.UI
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_toolTip == null)
 | 
			
		||||
                    return Resources.Strings.ResourceManager.GetString(Name + "_ToolTip");
 | 
			
		||||
 | 
			
		||||
                return _toolTip;
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _toolTip = value;
 | 
			
		||||
                return ResourceProvider.GetString("Command_" + Name + "_ToolTip");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Icon property
 | 
			
		||||
        private ImageSource _icon = null;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the command's icon
 | 
			
		||||
@@ -81,21 +53,9 @@ namespace RainmeterStudio.UI
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_icon == null)
 | 
			
		||||
                    return IconProvider.GetIcon(Name);
 | 
			
		||||
 | 
			
		||||
                return _icon;
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _icon = value;
 | 
			
		||||
                return ResourceProvider.GetImage("Command_" + Name + "_Icon");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Keyboard shortcut property
 | 
			
		||||
 | 
			
		||||
        private KeyGesture _shortcut;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the keyboard shortcut of this command
 | 
			
		||||
@@ -104,17 +64,8 @@ namespace RainmeterStudio.UI
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_shortcut == null)
 | 
			
		||||
                {
 | 
			
		||||
                    string str = SettingsProvider.GetSetting<string>(Name + "_Shortcut");
 | 
			
		||||
                    return GetKeyGestureFromString(str);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                return _shortcut;
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _shortcut = value;
 | 
			
		||||
                string str = SettingsProvider.GetSetting<string>("Command_" + Name + "_Shortcut");
 | 
			
		||||
                return InputHelper.GetKeyGesture(str);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -125,73 +76,20 @@ namespace RainmeterStudio.UI
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                // Safety check
 | 
			
		||||
                if (Shortcut == null)
 | 
			
		||||
                    return null;
 | 
			
		||||
 | 
			
		||||
                // Build string
 | 
			
		||||
                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;
 | 
			
		||||
                return SettingsProvider.GetSetting<string>("Command_" + Name + "_Shortcut");
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                Shortcut = GetKeyGestureFromString(value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private KeyGesture GetKeyGestureFromString(string k)
 | 
			
		||||
        {
 | 
			
		||||
            // Safety check
 | 
			
		||||
            if (k == null)
 | 
			
		||||
                return null;
 | 
			
		||||
 | 
			
		||||
            // Variables
 | 
			
		||||
            ModifierKeys mods = ModifierKeys.None;
 | 
			
		||||
            Key key = Key.None;
 | 
			
		||||
 | 
			
		||||
            // Parse each field
 | 
			
		||||
            foreach (var field in k.Split('+'))
 | 
			
		||||
            {
 | 
			
		||||
                // Trim surrounding white space
 | 
			
		||||
                string trimmed = field.Trim();
 | 
			
		||||
 | 
			
		||||
                // Parse
 | 
			
		||||
                if (trimmed.Equals("Win", StringComparison.InvariantCultureIgnoreCase))
 | 
			
		||||
                    mods |= ModifierKeys.Windows;
 | 
			
		||||
                if (trimmed.Equals("Ctrl", StringComparison.InvariantCultureIgnoreCase))
 | 
			
		||||
                    mods |= ModifierKeys.Control;
 | 
			
		||||
                if (trimmed.Equals("Alt", StringComparison.InvariantCultureIgnoreCase))
 | 
			
		||||
                    mods |= ModifierKeys.Alt;
 | 
			
		||||
                if (trimmed.Equals("Shift", StringComparison.InvariantCultureIgnoreCase))
 | 
			
		||||
                    mods |= ModifierKeys.Shift;
 | 
			
		||||
                else Enum.TryParse<Key>(field, out key);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return new KeyGesture(key, mods);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Event triggered when the command execution status changes
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public event EventHandler CanExecuteChanged;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Triggers the can execute changed event
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public void NotifyCanExecuteChanged()
 | 
			
		||||
        {
 | 
			
		||||
            if (CanExecuteChanged != null)
 | 
			
		||||
@@ -252,7 +150,7 @@ namespace RainmeterStudio.UI
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static class UIElementExtensions
 | 
			
		||||
    public static partial class UIElementExtensions
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a keyboard shortcut to an UI element
 | 
			
		||||
 
 | 
			
		||||
@@ -66,7 +66,7 @@ namespace RainmeterStudio.UI.Controller
 | 
			
		||||
            var dialog = new CreateDocumentDialog(this)
 | 
			
		||||
            {
 | 
			
		||||
                Owner = OwnerWindow,
 | 
			
		||||
                SelectedTemplate = defaultFormat,
 | 
			
		||||
                SelectedTemplate = new DocumentTemplateViewModel(defaultFormat),
 | 
			
		||||
                SelectedPath = defaultPath
 | 
			
		||||
            };
 | 
			
		||||
            bool? res = dialog.ShowDialog();
 | 
			
		||||
@@ -78,7 +78,7 @@ namespace RainmeterStudio.UI.Controller
 | 
			
		||||
            var path = dialog.SelectedPath;
 | 
			
		||||
 | 
			
		||||
            // Call manager
 | 
			
		||||
            DocumentManager.Create(format);
 | 
			
		||||
            DocumentManager.Create(format.Template);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void Create(DocumentTemplate format)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,9 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Windows.Data;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using System.Windows.Media.Imaging;
 | 
			
		||||
using RainmeterStudio.Business;
 | 
			
		||||
using RainmeterStudio.Core.Model;
 | 
			
		||||
using RainmeterStudio.Resources;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.UI.Controller
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,49 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.UI.Controller
 | 
			
		||||
{
 | 
			
		||||
    public static class SettingsProvider
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Attempts to retrieve the setting of type T, where T is class
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">Any class type</typeparam>
 | 
			
		||||
        /// <param name="name">Name of setting</param>
 | 
			
		||||
        /// <returns>Retrieved setting, or null if not found</returns>
 | 
			
		||||
        public static T GetSetting<T> (string name) where T : class
 | 
			
		||||
        {
 | 
			
		||||
            var property = Properties.Settings.Default.Properties
 | 
			
		||||
                .OfType<SettingsProperty>()
 | 
			
		||||
                .FirstOrDefault(x => String.Equals(x.Name, name));
 | 
			
		||||
                
 | 
			
		||||
            return (property == null) ? null : (property.DefaultValue as T);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Attempts to retrieve the setting of type T
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">Any type</typeparam>
 | 
			
		||||
        /// <param name="name">Name of setting</param>
 | 
			
		||||
        /// <param name="value">Output value</param>
 | 
			
		||||
        /// <returns>True if attempt was successful</returns>
 | 
			
		||||
        public static bool TryGetSetting<T>(string name, out T value)
 | 
			
		||||
        {
 | 
			
		||||
            var property = Properties.Settings.Default.Properties.OfType<SettingsProperty>().FirstOrDefault(x => x.Name.Equals(name));
 | 
			
		||||
 | 
			
		||||
            if (property != null)
 | 
			
		||||
            {
 | 
			
		||||
                value = (T)property.DefaultValue;
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                value = default(T);
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,31 +1,21 @@
 | 
			
		||||
<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"
 | 
			
		||||
        xmlns:r="clr-namespace:RainmeterStudio.Resources"
 | 
			
		||||
        Title="{x:Static r:Strings.CreateDocumentDialog_Title}" Height="250" Width="400"
 | 
			
		||||
        WindowStartupLocation="CenterOwner"
 | 
			
		||||
        WindowStyle="ToolWindow" ShowInTaskbar="False"
 | 
			
		||||
        Background="WhiteSmoke" >
 | 
			
		||||
    
 | 
			
		||||
    <Grid Margin="2px">
 | 
			
		||||
        <Grid.ColumnDefinitions>
 | 
			
		||||
            <ColumnDefinition Width="2*" />
 | 
			
		||||
            <ColumnDefinition Width="2" />
 | 
			
		||||
            <ColumnDefinition Width="3*" />
 | 
			
		||||
        </Grid.ColumnDefinitions>
 | 
			
		||||
        
 | 
			
		||||
    <Grid Margin="2px">        
 | 
			
		||||
        <Grid.RowDefinitions>
 | 
			
		||||
            <RowDefinition />
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
            <RowDefinition Height="Auto" />
 | 
			
		||||
        </Grid.RowDefinitions>
 | 
			
		||||
 | 
			
		||||
        <ListView Name="listCategories" Grid.Row="0" Grid.Column="0"
 | 
			
		||||
                  SelectionChanged="listCategories_SelectionChanged"
 | 
			
		||||
                  Margin="1px"/>
 | 
			
		||||
        
 | 
			
		||||
        <GridSplitter Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
 | 
			
		||||
        
 | 
			
		||||
        <ListView Name="listFormats" Grid.Row="0" Grid.Column="2" Margin="1px">
 | 
			
		||||
        <ListView Name="listTemplates" Grid.Row="0" Margin="1px"
 | 
			
		||||
                  SelectionChanged="listFormats_SelectionChanged">
 | 
			
		||||
            <ListView.ItemTemplate>
 | 
			
		||||
                <DataTemplate>
 | 
			
		||||
                    <DockPanel>
 | 
			
		||||
@@ -41,7 +31,7 @@
 | 
			
		||||
            </ListView.ItemTemplate>
 | 
			
		||||
        </ListView>
 | 
			
		||||
        
 | 
			
		||||
        <Grid Grid.Row="1" Grid.ColumnSpan="3">
 | 
			
		||||
        <Grid Grid.Row="1">
 | 
			
		||||
            <Grid.RowDefinitions>
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
                <RowDefinition />
 | 
			
		||||
@@ -52,13 +42,16 @@
 | 
			
		||||
                <ColumnDefinition Width="Auto" />
 | 
			
		||||
            </Grid.ColumnDefinitions>
 | 
			
		||||
 | 
			
		||||
            <TextBlock Grid.Row="0">Path:</TextBlock>
 | 
			
		||||
            <TextBlock Grid.Row="0" Text="{x:Static r:Strings.CreateDocumentDialog_Name}" />
 | 
			
		||||
            <TextBox Name="textPath" Grid.Row="0" Grid.Column="1" Margin="1px"></TextBox>
 | 
			
		||||
            <Button Grid.Row="0" Grid.Column="2">...</Button>
 | 
			
		||||
 | 
			
		||||
            <TextBlock Grid.Row="1">Path:</TextBlock>
 | 
			
		||||
            <TextBox Name="textPath1" Grid.Row="1" Grid.Column="1" Margin="1px"></TextBox>
 | 
			
		||||
            <Button Grid.Row="1" Grid.Column="2">...</Button>
 | 
			
		||||
            
 | 
			
		||||
        </Grid>
 | 
			
		||||
 | 
			
		||||
        <StackPanel Grid.Row="2" Grid.ColumnSpan="3" Orientation="Horizontal"
 | 
			
		||||
        <StackPanel Grid.Row="2" Orientation="Horizontal"
 | 
			
		||||
                    HorizontalAlignment="Right">
 | 
			
		||||
            <Button Name="buttonCreate" Click="buttonCreate_Click" IsDefault="True" Margin="1px">Create</Button>
 | 
			
		||||
            <Button Name="buttonCancel" Click="buttonCancel_Click" IsCancel="True" Margin="1px">Cancel</Button>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,19 +1,9 @@
 | 
			
		||||
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.Core.Documents;
 | 
			
		||||
using RainmeterStudio.UI.Controller;
 | 
			
		||||
using RainmeterStudio.UI.ViewModel;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.UI.Dialogs
 | 
			
		||||
{
 | 
			
		||||
@@ -27,15 +17,15 @@ namespace RainmeterStudio.UI.Dialogs
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the currently selected file format
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public DocumentTemplate SelectedTemplate
 | 
			
		||||
        public DocumentTemplateViewModel SelectedTemplate
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return listFormats.SelectedItem as DocumentTemplate;
 | 
			
		||||
                return listTemplates.SelectedItem as DocumentTemplateViewModel;
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                listFormats.SelectedItem = value;
 | 
			
		||||
                listTemplates.SelectedItem = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -62,29 +52,13 @@ namespace RainmeterStudio.UI.Dialogs
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
            _documentController = docCtrl;
 | 
			
		||||
 | 
			
		||||
            PopulateCategories();
 | 
			
		||||
            RepopulateFormats();
 | 
			
		||||
            PopulateFormats();
 | 
			
		||||
            Validate();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void PopulateCategories()
 | 
			
		||||
        private void PopulateFormats()
 | 
			
		||||
        {
 | 
			
		||||
            listCategories.ItemsSource = _documentController.DocumentTemplates
 | 
			
		||||
                .Select(template => template.Category)
 | 
			
		||||
                .Where(cat => cat != null)
 | 
			
		||||
                .Distinct()
 | 
			
		||||
                .Concat(new[] { "All" });
 | 
			
		||||
 | 
			
		||||
            listCategories.SelectedIndex = listCategories.Items.Count - 1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void RepopulateFormats()
 | 
			
		||||
        {
 | 
			
		||||
            if (Object.Equals(listCategories.SelectedItem, "All"))
 | 
			
		||||
                listFormats.ItemsSource = _documentController.DocumentTemplates;
 | 
			
		||||
 | 
			
		||||
            else
 | 
			
		||||
                listFormats.ItemsSource = _documentController.DocumentTemplates.Where(x => Object.Equals(x.Category, listCategories.SelectedItem));
 | 
			
		||||
            listTemplates.ItemsSource = _documentController.DocumentTemplates;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void buttonCreate_Click(object sender, RoutedEventArgs e)
 | 
			
		||||
@@ -102,15 +76,17 @@ namespace RainmeterStudio.UI.Dialogs
 | 
			
		||||
        private void Validate()
 | 
			
		||||
        {
 | 
			
		||||
            bool res = true;
 | 
			
		||||
 | 
			
		||||
            res &= !String.IsNullOrWhiteSpace(textPath.Text);
 | 
			
		||||
            res &= (listFormats.SelectedItem != null);
 | 
			
		||||
            res &= !textPath.Text.Intersect(System.IO.Path.GetInvalidFileNameChars()).Any();
 | 
			
		||||
            res &= (listTemplates.SelectedItem != null);
 | 
			
		||||
 | 
			
		||||
            buttonCreate.IsEnabled = res;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void listCategories_SelectionChanged(object sender, SelectionChangedEventArgs e)
 | 
			
		||||
        private void listFormats_SelectionChanged(object sender, SelectionChangedEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            RepopulateFormats();
 | 
			
		||||
            Validate();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 | 
			
		||||
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
        xmlns:r="clr-namespace:RainmeterStudio.Resources"
 | 
			
		||||
        Title="{x:Static r:Strings.ProjectCreateDialog_Title}" Height="320" Width="480"
 | 
			
		||||
        Title="{x:Static r:Strings.CreateProjectDialog_Title}" Height="320" Width="480"
 | 
			
		||||
        WindowStartupLocation="CenterOwner"
 | 
			
		||||
        WindowStyle="ToolWindow" ShowInTaskbar="False">
 | 
			
		||||
 | 
			
		||||
@@ -55,31 +55,31 @@
 | 
			
		||||
            </Grid.ColumnDefinitions>
 | 
			
		||||
 | 
			
		||||
            <!-- Name -->
 | 
			
		||||
            <TextBlock Grid.Row="0" Text="{x:Static r:Strings.ProjectCreateDialog_Name}" />
 | 
			
		||||
            <TextBlock Grid.Row="0" Text="{x:Static r:Strings.CreateProjectDialog_Name}" />
 | 
			
		||||
 | 
			
		||||
            <TextBox Name="textName" 
 | 
			
		||||
                     Grid.Row="0" Grid.Column="1"
 | 
			
		||||
                     TextChanged="textName_TextChanged"/>
 | 
			
		||||
            
 | 
			
		||||
            <!-- Location -->
 | 
			
		||||
            <TextBlock Grid.Row="1" Text="{x:Static r:Strings.ProjectCreateDialog_Location}" />
 | 
			
		||||
            <TextBlock Grid.Row="1" Text="{x:Static r:Strings.CreateProjectDialog_Location}" />
 | 
			
		||||
            <ComboBox Name="textLocation" IsEditable="True"
 | 
			
		||||
                      Grid.Row="1" Grid.Column="1" />
 | 
			
		||||
            <Button Grid.Row="1" Grid.Column="2" Content="{x:Static r:Strings.Dialog_Browse}"/>
 | 
			
		||||
            <CheckBox Name="checkLocationDefault" 
 | 
			
		||||
                      Grid.Row="1" Grid.Column="3" 
 | 
			
		||||
                      Content="{x:Static r:Strings.ProjectCreateDialog_LocationDefault}" 
 | 
			
		||||
                      Content="{x:Static r:Strings.CreateProjectDialog_LocationDefault}" 
 | 
			
		||||
                      VerticalAlignment="Center"/>
 | 
			
		||||
 | 
			
		||||
            <!-- Path -->
 | 
			
		||||
            <TextBlock Grid.Row="2" Text="{x:Static r:Strings.ProjectCreateDialog_Path}"/>
 | 
			
		||||
            <TextBlock Grid.Row="2" Text="{x:Static r:Strings.CreateProjectDialog_Path}"/>
 | 
			
		||||
            <ComboBox Name="textPath" 
 | 
			
		||||
                      IsEditable="True"
 | 
			
		||||
                     Grid.Row="2" Grid.Column="1" />
 | 
			
		||||
            <Button Grid.Row="2" Grid.Column="2" Content="{x:Static r:Strings.Dialog_Browse}" />
 | 
			
		||||
            <CheckBox Name="checkCreateDirectory" 
 | 
			
		||||
                      Grid.Row="2" Grid.Column="3" 
 | 
			
		||||
                      Content="{x:Static r:Strings.ProjectCreateDialog_PathCreateFolder}"
 | 
			
		||||
                      Content="{x:Static r:Strings.CreateProjectDialog_PathCreateFolder}"
 | 
			
		||||
                      IsChecked="True"
 | 
			
		||||
                      Checked="checkCreateDirectory_CheckChanged"
 | 
			
		||||
                      Unchecked="checkCreateDirectory_CheckChanged"
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,15 @@
 | 
			
		||||
        xmlns:ad="clr-namespace:Xceed.Wpf.AvalonDock;assembly=Xceed.Wpf.AvalonDock"
 | 
			
		||||
        xmlns:adlayout="clr-namespace:Xceed.Wpf.AvalonDock.Layout;assembly=Xceed.Wpf.AvalonDock"
 | 
			
		||||
        xmlns:r="clr-namespace:RainmeterStudio.Resources"
 | 
			
		||||
        Title="Rainmeter Studio" Height="600" Width="800"
 | 
			
		||||
        xmlns:p="clr-namespace:RainmeterStudio.Properties"
 | 
			
		||||
        
 | 
			
		||||
        Title="{x:Static r:Strings.MainWindow_Title}" 
 | 
			
		||||
        Height="{Binding Source={x:Static p:Settings.Default}, Path=MainWindow_Height, Mode=TwoWay}"
 | 
			
		||||
        Width="{Binding Source={x:Static p:Settings.Default}, Path=MainWindow_Width, Mode=TwoWay}"
 | 
			
		||||
        WindowState="{Binding Source={x:Static p:Settings.Default}, Path=MainWindow_WindowState, 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}"
 | 
			
		||||
        
 | 
			
		||||
        ResizeMode="CanResizeWithGrip" >
 | 
			
		||||
 | 
			
		||||
    <Grid>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,6 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using System.Windows.Media;
 | 
			
		||||
using RainmeterStudio.Business;
 | 
			
		||||
using RainmeterStudio.Core.Documents;
 | 
			
		||||
using RainmeterStudio.UI.Controller;
 | 
			
		||||
 | 
			
		||||
namespace RainmeterStudio.UI.ViewModel
 | 
			
		||||
{
 | 
			
		||||
@@ -20,34 +16,17 @@ namespace RainmeterStudio.UI.ViewModel
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Name { get { return Template.Name; } }
 | 
			
		||||
 | 
			
		||||
        #region Icon property
 | 
			
		||||
 | 
			
		||||
        private ImageSource _icon = null;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the icon of this document template
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public virtual ImageSource Icon
 | 
			
		||||
        public ImageSource Icon
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_icon == null)
 | 
			
		||||
                    return IconProvider.GetIcon("Template_" + Name);
 | 
			
		||||
 | 
			
		||||
                return _icon;
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _icon = value;
 | 
			
		||||
                return ResourceProvider.GetImage("Template_" + Name + "_Icon");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Display text property
 | 
			
		||||
 | 
			
		||||
        private string _displayText = null;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the display text
 | 
			
		||||
        /// </summary>
 | 
			
		||||
@@ -55,23 +34,10 @@ namespace RainmeterStudio.UI.ViewModel
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_displayText == null)
 | 
			
		||||
                    return Resources.Strings.ResourceManager.GetString("Template_" + Name + "_DisplayText");
 | 
			
		||||
 | 
			
		||||
                return _displayText;
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _displayText = value;
 | 
			
		||||
                return ResourceProvider.GetString("Template_" + Name + "_DisplayText");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Description property
 | 
			
		||||
 | 
			
		||||
        private string _description = null;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the description of this document template
 | 
			
		||||
        /// </summary>
 | 
			
		||||
@@ -79,43 +45,10 @@ namespace RainmeterStudio.UI.ViewModel
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_description == null)
 | 
			
		||||
                    return Resources.Strings.ResourceManager.GetString("Template_" + Name + "_Description");
 | 
			
		||||
 | 
			
		||||
                return _description;
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _description = value;
 | 
			
		||||
                return ResourceProvider.GetString("Template_" + Name + "_Description");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region Category property
 | 
			
		||||
 | 
			
		||||
        private string _category = null;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets or sets the category of this template
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public string Category
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (_category == null)
 | 
			
		||||
                    return Resources.Strings.ResourceManager.GetString("Template_" + Name + "_Category");
 | 
			
		||||
 | 
			
		||||
                return _category;
 | 
			
		||||
            }
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                _category = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initializes the document template view model
 | 
			
		||||
        /// </summary>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user