mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Work on project manager and project panel
This commit is contained in:
@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using RainmeterStudio.UI.Controller;
|
||||
|
||||
namespace RainmeterStudio.UI
|
||||
{
|
||||
@ -15,23 +16,102 @@ namespace RainmeterStudio.UI
|
||||
private Func<object, bool> _canExecute;
|
||||
private Action _executeNoParam;
|
||||
private Func<bool> _canExecuteNoParam;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the command
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
public string DisplayText { get; set; }
|
||||
public string Tooltip { get; set; }
|
||||
public ImageSource Icon { get; set; }
|
||||
|
||||
#region Display text property
|
||||
private string _displayText = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the display text of the command
|
||||
/// </summary>
|
||||
public string DisplayText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_displayText == null)
|
||||
return Resources.Strings.ResourceManager.GetString(Name + "_DisplayText");
|
||||
|
||||
return _displayText;
|
||||
}
|
||||
set
|
||||
{
|
||||
_displayText = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ToolTip property
|
||||
private string _toolTip = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tooltip
|
||||
/// </summary>
|
||||
public string ToolTip
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_toolTip == null)
|
||||
return Resources.Strings.ResourceManager.GetString(Name + "_ToolTip");
|
||||
|
||||
return _toolTip;
|
||||
}
|
||||
set
|
||||
{
|
||||
_toolTip = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Icon property
|
||||
private ImageSource _icon = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the command's icon
|
||||
/// </summary>
|
||||
public ImageSource Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_icon == null)
|
||||
return IconProvider.GetIcon(Name);
|
||||
|
||||
return _icon;
|
||||
}
|
||||
set
|
||||
{
|
||||
_icon = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Keyboard shortcut property
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the keyboard shortcut of this command
|
||||
/// </summary>
|
||||
public KeyGesture Shortcut { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the text representation of the keyboard shortcut
|
||||
/// </summary>
|
||||
public string ShortcutText
|
||||
{
|
||||
get
|
||||
{
|
||||
string text = String.Empty;
|
||||
|
||||
if (Shortcut == null)
|
||||
return text;
|
||||
|
||||
if ((Shortcut.Modifiers & ModifierKeys.Windows) != 0)
|
||||
text += "Win+";
|
||||
|
||||
@ -51,22 +131,45 @@ namespace RainmeterStudio.UI
|
||||
|
||||
#endregion
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
#endregion
|
||||
|
||||
public Command(string name = null, Action<object> execute = null, Func<object, bool> canExecute = null)
|
||||
#pragma warning disable 67
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
#pragma warning restore 67
|
||||
|
||||
/// <summary>
|
||||
/// Initializes this command
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the command</param>
|
||||
/// <param name="execute">Callback function to execute when the command is triggered</param>
|
||||
/// <param name="canExecute">Function that can be queried if the command can execute</param>
|
||||
public Command(string name, Action<object> execute, Func<object, bool> canExecute = null)
|
||||
{
|
||||
Name = name;
|
||||
_execute = execute;
|
||||
_canExecute = canExecute;
|
||||
}
|
||||
|
||||
public Command(string name = null, Action execute = null, Func<bool> canExecute = null)
|
||||
/// <summary>
|
||||
/// Initializes this command
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the command</param>
|
||||
/// <param name="execute">Callback function to execute when the command is triggered</param>
|
||||
/// <param name="canExecute">Function that can be queried if the command can execute</param>
|
||||
public Command(string name, Action execute, Func<bool> canExecute = null)
|
||||
{
|
||||
Name = name;
|
||||
_executeNoParam = execute;
|
||||
_canExecuteNoParam = canExecute;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function that can be queried if the command can be executed
|
||||
/// </summary>
|
||||
/// <param name="parameter">Command parameter</param>
|
||||
/// <returns>True if the function can be executed</returns>
|
||||
public virtual bool CanExecute(object parameter)
|
||||
{
|
||||
if (_canExecute != null)
|
||||
@ -77,6 +180,10 @@ namespace RainmeterStudio.UI
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the command
|
||||
/// </summary>
|
||||
/// <param name="parameter">Command parameter</param>
|
||||
public virtual void Execute(object parameter)
|
||||
{
|
||||
if (_execute != null)
|
||||
@ -85,4 +192,18 @@ namespace RainmeterStudio.UI
|
||||
_executeNoParam();
|
||||
}
|
||||
}
|
||||
|
||||
public static class UIElementExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds a keyboard shortcut to an UI element
|
||||
/// </summary>
|
||||
/// <param name="uiElement">UI element</param>
|
||||
/// <param name="command">Command</param>
|
||||
public static void AddKeyBinding(this System.Windows.UIElement uiElement, Command command)
|
||||
{
|
||||
if (command.Shortcut != null)
|
||||
uiElement.InputBindings.Add(new KeyBinding(command, command.Shortcut));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,6 @@ namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
_documentCreateCommand = new Command("DocumentCreateCommand", () => CreateWindow())
|
||||
{
|
||||
DisplayText = Resources.Strings.DocumentCreateCommand_DisplayText,
|
||||
Tooltip = Resources.Strings.DocumentCreateCommand_ToolTip,
|
||||
Icon = new BitmapImage(new Uri(Resources.Icons.DocumentCreateCommand_Icon, UriKind.RelativeOrAbsolute)),
|
||||
Shortcut = new KeyGesture(Key.N, ModifierKeys.Control)
|
||||
};
|
||||
}
|
||||
|
72
RainmeterStudio/UI/Controller/IconProvider.cs
Normal file
72
RainmeterStudio/UI/Controller/IconProvider.cs
Normal file
@ -0,0 +1,72 @@
|
||||
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.Model;
|
||||
|
||||
namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
public static class IconProvider
|
||||
{
|
||||
private static Dictionary<string, ImageSource> _loadedImages = new Dictionary<string, ImageSource>();
|
||||
|
||||
public static ImageSource GetIcon(string key)
|
||||
{
|
||||
if (!_loadedImages.ContainsKey(key))
|
||||
{
|
||||
// Try to get the icon file name
|
||||
string iconPath = Resources.Icons.ResourceManager.GetString(key);
|
||||
if (iconPath == null)
|
||||
return null;
|
||||
|
||||
// Load the image
|
||||
var uri = new Uri(iconPath, UriKind.RelativeOrAbsolute);
|
||||
_loadedImages.Add(key, new BitmapImage(uri));
|
||||
}
|
||||
return _loadedImages[key];
|
||||
}
|
||||
|
||||
public static ImageSource GetProjectItemIcon(Reference item)
|
||||
{
|
||||
// Resource name
|
||||
string key = "ProjectItem";
|
||||
|
||||
if (Directory.Exists(item.Path))
|
||||
key += "Directory";
|
||||
|
||||
else if (File.Exists(item.Path))
|
||||
key += "_" + Path.GetExtension(item.Path).Substring(1);
|
||||
|
||||
else key += "None";
|
||||
|
||||
// Get icon
|
||||
var icon = GetIcon(key);
|
||||
if (icon == null)
|
||||
return GetIcon("ProjectItemUnknown");
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
|
||||
public class IconProviderConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tree = value as Tree<Reference>;
|
||||
if (tree != null)
|
||||
{
|
||||
return IconProvider.GetProjectItemIcon(tree.Data);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -44,7 +44,7 @@ namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
get
|
||||
{
|
||||
return Manager.ActiveProjectPath;
|
||||
return Manager.ActiveProject.Path;
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,11 +78,8 @@ namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
if (_projectCreateCommand == null)
|
||||
{
|
||||
_projectCreateCommand = new Command("ProjectCreateComand", () => CreateProject())
|
||||
_projectCreateCommand = new Command("ProjectCreateCommand", () => CreateProject())
|
||||
{
|
||||
DisplayText = Resources.Strings.ProjectCreateCommand_DisplayText,
|
||||
Tooltip = Resources.Strings.ProjectCreateCommand_ToolTip,
|
||||
Icon = new BitmapImage(new Uri(Resources.Icons.ProjectCreateCommand_Icon, UriKind.RelativeOrAbsolute)),
|
||||
Shortcut = new KeyGesture(Key.N, ModifierKeys.Control | ModifierKeys.Shift)
|
||||
};
|
||||
}
|
||||
@ -123,10 +120,11 @@ namespace RainmeterStudio.UI.Controller
|
||||
if (!res.HasValue || !res.Value)
|
||||
return;
|
||||
|
||||
string selectedName = dialog.SelectedName;
|
||||
string selectedPath = dialog.SelectedPath;
|
||||
|
||||
// Call manager
|
||||
Manager.CreateProject(name, selectedPath); // TODO
|
||||
Manager.CreateProject(selectedName, selectedPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -125,10 +125,15 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// Add event handlers
|
||||
textLocation.AddHandler(TextBoxBase.TextChangedEvent, new TextChangedEventHandler(textLocation_TextChanged));
|
||||
textPath.AddHandler(TextBoxBase.TextChangedEvent, new TextChangedEventHandler(textPath_TextChanged));
|
||||
|
||||
// Set data context
|
||||
DataContext = this;
|
||||
|
||||
// Focus on name textbox
|
||||
textName.Focus();
|
||||
}
|
||||
|
||||
private void Create()
|
||||
|
@ -4,29 +4,9 @@
|
||||
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"
|
||||
Title="Rainmeter Studio" Height="600" Width="800"
|
||||
ResizeMode="CanResizeWithGrip" >
|
||||
|
||||
<Window.Resources>
|
||||
<Style x:Key="CommandMenuItemStyle" TargetType="MenuItem">
|
||||
<Setter Property="Command" Value="{Binding}" />
|
||||
<Setter Property="Header" Value="{Binding DisplayText}" />
|
||||
<Setter Property="ToolTip" Value="{Binding Tooltip}" />
|
||||
<Setter Property="InputGestureText" Value="{Binding ShortcutText}" />
|
||||
</Style>
|
||||
<Style x:Key="CommandButtonStyle" TargetType="Button">
|
||||
<Setter Property="Command" Value="{Binding}" />
|
||||
<Setter Property="ToolTip" Value="{Binding Tooltip}" />
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<Image Width="16" Height="16" Source="{Binding Icon}" />
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
@ -70,14 +50,16 @@
|
||||
<ToolBarTray Grid.Row="1">
|
||||
<ToolBar>
|
||||
<Button Name="buttonBackward" ToolTip="Navigate backward">
|
||||
<Image Width="16" Height="16" Source="/Resources/Icons/arrow_backward_16.png" />
|
||||
<Image Width="16" Height="16" Source="/Resources/Icons/16/arrow_backward.png" />
|
||||
</Button>
|
||||
<Button Name="buttonForward" ToolTip="Navigate forward">
|
||||
<Image Width="16" Height="16" Source="/Resources/Icons/arrow_forward_16.png" />
|
||||
<Image Width="16" Height="16" Source="/Resources/Icons/16/arrow_forward.png" />
|
||||
</Button>
|
||||
<Separator />
|
||||
<Button DataContext="{Binding DocumentController.DocumentCreateCommand}"
|
||||
Style="{StaticResource CommandButtonStyle}" />
|
||||
Style="{StaticResource CommandButtonStyle}">
|
||||
<Image Width="16" Height="16" Source="{Binding Icon}" />
|
||||
</Button>
|
||||
</ToolBar>
|
||||
</ToolBarTray>
|
||||
|
||||
@ -102,10 +84,10 @@
|
||||
<adlayout:LayoutPanel Orientation="Horizontal">
|
||||
<adlayout:LayoutDocumentPane x:Name="documentPane" />
|
||||
|
||||
<adlayout:LayoutAnchorablePaneGroup DockWidth="150" Orientation="Vertical">
|
||||
<adlayout:LayoutAnchorablePaneGroup DockWidth="250" Orientation="Vertical">
|
||||
<adlayout:LayoutAnchorablePane>
|
||||
<adlayout:LayoutAnchorable Title="Skins">
|
||||
<ui:SkinsPanel />
|
||||
<adlayout:LayoutAnchorable Title="Project">
|
||||
<ui:ProjectPanel x:Name="projectPanel" />
|
||||
</adlayout:LayoutAnchorable>
|
||||
<adlayout:LayoutAnchorable Title="Outline" />
|
||||
</adlayout:LayoutAnchorablePane>
|
||||
|
@ -39,19 +39,16 @@ namespace RainmeterStudio.UI
|
||||
ProjectManager projectManager = new ProjectManager(projectStorage);
|
||||
ProjectController = new Controller.ProjectController(projectManager);
|
||||
ProjectController.OwnerWindow = this;
|
||||
AddKeyBinding(ProjectController.ProjectCreateCommand);
|
||||
|
||||
this.AddKeyBinding(ProjectController.ProjectCreateCommand);
|
||||
|
||||
// Initialize document controller
|
||||
DocumentController = new DocumentController();
|
||||
DocumentController.OwnerWindow = this;
|
||||
DocumentController.DocumentOpened += documentController_DocumentOpened;
|
||||
AddKeyBinding(DocumentController.DocumentCreateCommand);
|
||||
}
|
||||
this.AddKeyBinding(DocumentController.DocumentCreateCommand);
|
||||
|
||||
private void AddKeyBinding(Command c)
|
||||
{
|
||||
if (c.Shortcut != null)
|
||||
InputBindings.Add(new KeyBinding(c, c.Shortcut));
|
||||
// Initialize panels
|
||||
projectPanel.Controller = ProjectController;
|
||||
}
|
||||
|
||||
void documentController_DocumentOpened(object sender, DocumentOpenedEventArgs e)
|
||||
|
61
RainmeterStudio/UI/ProjectPanel.xaml
Normal file
61
RainmeterStudio/UI/ProjectPanel.xaml
Normal file
@ -0,0 +1,61 @@
|
||||
<UserControl x:Class="RainmeterStudio.UI.ProjectPanel"
|
||||
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"
|
||||
xmlns:ctrl="clr-namespace:RainmeterStudio.UI.Controller"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<UserControl.Resources>
|
||||
<ctrl:IconProviderConverter x:Key="IconConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Toolbar -->
|
||||
<ToolBar Grid.Row="0" ToolBarTray.IsLocked="True">
|
||||
<Button DataContext="{Binding SyncWithActiveViewCommand}"
|
||||
Style="{StaticResource CommandButtonStyle}">
|
||||
<Image Width="16" Height="16" Source="{Binding Icon}" />
|
||||
</Button>
|
||||
<Button DataContext="{Binding RefreshCommand}"
|
||||
Style="{StaticResource CommandButtonStyle}">
|
||||
<Image Width="16" Height="16" Source="{Binding Icon}" />
|
||||
</Button>
|
||||
<Button DataContext="{Binding CollapseAllCommand}"
|
||||
Style="{StaticResource CommandAutoHideButtonStyle}">
|
||||
<Image Width="16" Height="16" Source="{Binding Icon}" />
|
||||
</Button>
|
||||
<Button DataContext="{Binding ExpandAllCommand}"
|
||||
Style="{StaticResource CommandAutoHideButtonStyle}">
|
||||
<Image Width="16" Height="16" Source="{Binding Icon}" />
|
||||
</Button>
|
||||
<ToggleButton Name="toggleShowAllFiles"
|
||||
DataContext="{Binding ShowAllFilesCommand}"
|
||||
Style="{StaticResource CommandButtonStyle}">
|
||||
<Image Width="16" Height="16" Source="{Binding Icon}" />
|
||||
</ToggleButton>
|
||||
</ToolBar>
|
||||
|
||||
<!-- Project item tree -->
|
||||
<TreeView Grid.Row="2" Name="treeProjectItems">
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type TreeViewItem}">
|
||||
<Setter Property="IsExpanded" Value="True" />
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
<TreeView.ItemTemplate>
|
||||
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
|
||||
<DockPanel LastChildFill="True">
|
||||
<Image DockPanel.Dock="Left" Width="16" Height="16" Source="{Binding Converter={StaticResource IconConverter}}" />
|
||||
<TextBlock Text="{Binding Data.Name}" />
|
||||
</DockPanel>
|
||||
</HierarchicalDataTemplate>
|
||||
</TreeView.ItemTemplate>
|
||||
</TreeView>
|
||||
</Grid>
|
||||
</UserControl>
|
177
RainmeterStudio/UI/ProjectPanel.xaml.cs
Normal file
177
RainmeterStudio/UI/ProjectPanel.xaml.cs
Normal file
@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
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.Model;
|
||||
using RainmeterStudio.Storage;
|
||||
using RainmeterStudio.UI.Controller;
|
||||
using RainmeterStudio.Utils;
|
||||
|
||||
namespace RainmeterStudio.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SkinsPanel.xaml
|
||||
/// </summary>
|
||||
public partial class ProjectPanel : UserControl
|
||||
{
|
||||
private ProjectController _controller;
|
||||
public ProjectController Controller
|
||||
{
|
||||
get
|
||||
{
|
||||
return _controller;
|
||||
}
|
||||
set
|
||||
{
|
||||
// Unsubscribe from old project
|
||||
if (_controller != null)
|
||||
{
|
||||
Controller.ActiveProjectChanged -= Controller_ActiveProjectChanged;
|
||||
}
|
||||
|
||||
// Set new project
|
||||
_controller = value;
|
||||
_controller.ActiveProjectChanged += Controller_ActiveProjectChanged;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private Command _syncWithActiveViewCommand;
|
||||
public Command SyncWithActiveViewCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_syncWithActiveViewCommand == null)
|
||||
{
|
||||
_syncWithActiveViewCommand = new Command("ProjectPanel_SyncWithActiveViewCommand", SyncWithActiveView);
|
||||
}
|
||||
return _syncWithActiveViewCommand;
|
||||
}
|
||||
}
|
||||
|
||||
private Command _refreshCommand;
|
||||
public Command RefreshCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_refreshCommand == null)
|
||||
{
|
||||
_refreshCommand = new Command("ProjectPanel_RefreshCommand", SyncWithActiveView)
|
||||
{
|
||||
Shortcut = new KeyGesture(Key.F5)
|
||||
};
|
||||
}
|
||||
return _refreshCommand;
|
||||
}
|
||||
}
|
||||
|
||||
private Command _expandAllCommand;
|
||||
public Command ExpandAllCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_expandAllCommand == null)
|
||||
{
|
||||
_expandAllCommand = new Command("ProjectPanel_ExpandAllCommand", SyncWithActiveView);
|
||||
}
|
||||
return _expandAllCommand;
|
||||
}
|
||||
}
|
||||
|
||||
private Command _collapseAllCommand;
|
||||
public Command CollapseAllCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_collapseAllCommand == null)
|
||||
{
|
||||
_collapseAllCommand = new Command("ProjectPanel_CollapseAllCommand", SyncWithActiveView);
|
||||
}
|
||||
return _collapseAllCommand;
|
||||
}
|
||||
}
|
||||
|
||||
private Command _showAllFilesCommand;
|
||||
public Command ShowAllFilesCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_showAllFilesCommand == null)
|
||||
{
|
||||
_showAllFilesCommand = new Command("ProjectPanel_ShowAllFilesCommand", SyncWithActiveView);
|
||||
}
|
||||
return _showAllFilesCommand;
|
||||
}
|
||||
}
|
||||
|
||||
public ProjectPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.DataContext = this;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void Controller_ActiveProjectChanged(object sender, EventArgs e)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private void SyncWithActiveView()
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
if (Controller == null || Controller.ActiveProject == null)
|
||||
{
|
||||
this.IsEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.IsEnabled = true;
|
||||
|
||||
// Display all files in the project directory
|
||||
if (toggleShowAllFiles.IsChecked.HasValue && toggleShowAllFiles.IsChecked.Value)
|
||||
{
|
||||
string projectFolder = System.IO.Path.GetDirectoryName(Controller.ActiveProjectPath);
|
||||
var tree = DirectoryHelper.GetFolderTree(projectFolder);
|
||||
tree.Data = Controller.ActiveProject.Root.Data;
|
||||
|
||||
treeProjectItems.Items.Clear();
|
||||
treeProjectItems.Items.Add(tree);
|
||||
}
|
||||
|
||||
// Display only the project items
|
||||
else
|
||||
{
|
||||
treeProjectItems.Items.Clear();
|
||||
treeProjectItems.Items.Add(Controller.ActiveProject.Root);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleShowAllFiles_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private void toggleShowAllFiles_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<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>
|
@ -1,31 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user