mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Fixed project item icons, and new document bug
This commit is contained in:
parent
0090059531
commit
22baf7f6a5
@ -201,6 +201,9 @@ namespace RainmeterStudio.Core.Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the target kind
|
||||||
|
/// </summary>
|
||||||
[XmlAttribute("targetKind")]
|
[XmlAttribute("targetKind")]
|
||||||
public ReferenceTargetKind TargetKind
|
public ReferenceTargetKind TargetKind
|
||||||
{
|
{
|
||||||
@ -297,8 +300,8 @@ namespace RainmeterStudio.Core.Model
|
|||||||
throw new ArgumentException("Reference must be removed from its current parent first.");
|
throw new ArgumentException("Reference must be removed from its current parent first.");
|
||||||
|
|
||||||
// Add and parent
|
// Add and parent
|
||||||
reference.Parent = this;
|
|
||||||
_children.Add(reference.Name, reference);
|
_children.Add(reference.Name, reference);
|
||||||
|
reference.Parent = this;
|
||||||
|
|
||||||
// Trigger event
|
// Trigger event
|
||||||
if (CollectionChanged != null)
|
if (CollectionChanged != null)
|
||||||
|
@ -158,10 +158,10 @@
|
|||||||
<value>icons\16\folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>icons\16\folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ProjectItemNone" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="ProjectItemNone" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>icons\16\file_generic.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>icons\16\page_white_delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ProjectItemUnknown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="ProjectItemUnknown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>icons\16\page_white_delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>icons\16\file_generic.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ProjectItem_rsproj" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="ProjectItem_rsproj" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>icons\16\project.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>icons\16\project.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
@ -168,7 +168,7 @@ namespace RainmeterStudio.UI.Controller
|
|||||||
if (!Directory.Exists(folder))
|
if (!Directory.Exists(folder))
|
||||||
folder = Path.GetDirectoryName(folder);
|
folder = Path.GetDirectoryName(folder);
|
||||||
|
|
||||||
var reference = new Reference(name, Path.Combine(folder, name));
|
var reference = new Reference(name, Path.Combine(folder, name), Reference.ReferenceTargetKind.File);
|
||||||
editor.AttachedDocument.Reference = reference;
|
editor.AttachedDocument.Reference = reference;
|
||||||
|
|
||||||
// Save document
|
// Save document
|
||||||
@ -176,6 +176,7 @@ namespace RainmeterStudio.UI.Controller
|
|||||||
|
|
||||||
// Add to parent
|
// Add to parent
|
||||||
OwnerWindow.ProjectPanel.ActiveItem.Add(reference);
|
OwnerWindow.ProjectPanel.ActiveItem.Add(reference);
|
||||||
|
ProjectManager.SaveActiveProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@ -48,6 +49,7 @@ namespace RainmeterStudio.UI
|
|||||||
this.AddKeyBinding(DocumentController.DocumentSaveCommand);
|
this.AddKeyBinding(DocumentController.DocumentSaveCommand);
|
||||||
this.AddKeyBinding(DocumentController.DocumentCloseCommand);
|
this.AddKeyBinding(DocumentController.DocumentCloseCommand);
|
||||||
this.AddKeyBinding(ProjectController.ProjectCreateCommand);
|
this.AddKeyBinding(ProjectController.ProjectCreateCommand);
|
||||||
|
this.AddKeyBinding(ProjectController.ProjectOpenCommand);
|
||||||
|
|
||||||
// Subscribe to events
|
// Subscribe to events
|
||||||
DocumentController.DocumentOpened += documentController_DocumentOpened;
|
DocumentController.DocumentOpened += documentController_DocumentOpened;
|
||||||
@ -75,11 +77,51 @@ namespace RainmeterStudio.UI
|
|||||||
documentPane.Children.Add(document);
|
documentPane.Children.Add(document);
|
||||||
documentPane.SelectedContentIndex = documentPane.IndexOf(document);
|
documentPane.SelectedContentIndex = documentPane.IndexOf(document);
|
||||||
|
|
||||||
e.Document.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler((obj, args) =>
|
e.Document.PropertyChanged += Document_PropertyChanged;
|
||||||
|
if (e.Document.Reference != null)
|
||||||
|
e.Document.Reference.PropertyChanged += Reference_PropertyChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Document_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
IDocument document = (IDocument)sender;
|
||||||
|
|
||||||
|
// Find document object and update document title
|
||||||
|
foreach (var pair in _openedDocuments)
|
||||||
{
|
{
|
||||||
// Update document title
|
if (pair.Value.AttachedDocument == document)
|
||||||
document.Title = GetDocumentTitle(e.Document);
|
{
|
||||||
});
|
pair.Key.Title = GetDocumentTitle(document);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the reference changed, subscribe to reference changes as well
|
||||||
|
if (e.PropertyName == "Reference" && document.Reference != null)
|
||||||
|
{
|
||||||
|
document.Reference.PropertyChanged += Reference_PropertyChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reference_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
Reference reference = (Reference)sender;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
// Find documents with this reference and update document title
|
||||||
|
foreach (var pair in _openedDocuments)
|
||||||
|
{
|
||||||
|
if (pair.Value.AttachedDocument.Reference == reference)
|
||||||
|
{
|
||||||
|
pair.Key.Title = GetDocumentTitle(pair.Value.AttachedDocument);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No document found? Unsubscribe
|
||||||
|
if (found == false)
|
||||||
|
{
|
||||||
|
reference.PropertyChanged -= Reference_PropertyChanged;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetDocumentTitle(IDocument document)
|
private string GetDocumentTitle(IDocument document)
|
||||||
@ -87,7 +129,11 @@ namespace RainmeterStudio.UI
|
|||||||
string documentName;
|
string documentName;
|
||||||
|
|
||||||
// Get title
|
// Get title
|
||||||
if (ProjectController.ActiveProject == null || !ProjectController.ActiveProject.Contains(document.Reference))
|
if (document.Reference == null)
|
||||||
|
{
|
||||||
|
documentName = "New document";
|
||||||
|
}
|
||||||
|
else if (ProjectController.ActiveProject == null || !ProjectController.ActiveProject.Contains(document.Reference))
|
||||||
{
|
{
|
||||||
documentName = document.Reference.StoragePath ?? "New document";
|
documentName = document.Reference.StoragePath ?? "New document";
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,10 @@ namespace RainmeterStudio.UI.Panels
|
|||||||
|
|
||||||
private void Refresh()
|
private void Refresh()
|
||||||
{
|
{
|
||||||
|
// Clear current items
|
||||||
|
treeProjectItems.Items.Clear();
|
||||||
|
|
||||||
|
// No project
|
||||||
if (Controller == null || Controller.ActiveProject == null)
|
if (Controller == null || Controller.ActiveProject == null)
|
||||||
{
|
{
|
||||||
this.IsEnabled = false;
|
this.IsEnabled = false;
|
||||||
@ -137,7 +141,6 @@ namespace RainmeterStudio.UI.Panels
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add tree to tree view
|
// Add tree to tree view
|
||||||
treeProjectItems.Items.Clear();
|
|
||||||
treeProjectItems.Items.Add(new ReferenceViewModel(refTree));
|
treeProjectItems.Items.Add(new ReferenceViewModel(refTree));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user