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:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user