Skip to content

Commit 8a4bf0a

Browse files
Fixed ResourceAVMedia not being serialisable and also resources not being destroyed when a project is closed (causing things like file handles to stay open until closing the editor), added online/offline indicator in resource manager (red outline + red header), replaced standard message box usage with custom one (for the dark theme :D), added frame progress text block to export dialog
1 parent 2e522cf commit 8a4bf0a

20 files changed

Lines changed: 181 additions & 40 deletions

FramePFX/Actions/ActionManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Threading.Tasks;
55
using System.Windows;
66
using FramePFX.Interactivity.DataContexts;
7+
using FramePFX.Utils;
78

89
namespace FramePFX.Actions {
910
/// <summary>
@@ -143,8 +144,7 @@ private static async Task TryExecuteOrShowDialog(AnAction action, AnActionEventA
143144
await action.ExecuteAsync(e);
144145
}
145146
catch (Exception ex) {
146-
MessageBox.Show($"An exception occurred while executing '{e.ActionId ?? action.GetType().ToString()}':\n{ex.Message}", "Action execution exception");
147-
// await IoC.DialogService.ShowMessageExAsync("Action execution exception", , ex.GetToString());
147+
IoC.MessageService.ShowMessage("Action execution exception", $"An exception occurred while executing '{e.ActionId ?? action.GetType().ToString()}'", ex.GetToString());
148148
}
149149
}
150150

FramePFX/App.xaml.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ public async Task InitWPFApp() {
7070

7171
RuntimeHelpers.RunClassConstructor(typeof(UIInputManager).TypeHandle);
7272

73+
// This is where services are registered
7374
await ApplicationCore.InternalSetupNewInstance(this.splash);
75+
// Most if not all services are available below here
7476

7577
await AppLogger.Instance.FlushEntries();
7678
await this.splash.SetAction("Loading shortcuts and actions...", null);
@@ -90,11 +92,11 @@ public async Task InitWPFApp() {
9092
}
9193
}
9294
catch (Exception ex) {
93-
MessageBox.Show("Failed to read keymap file" + keymapFilePath + ":" + ex.GetToString());
95+
IoC.MessageService.ShowMessage("Keymap", "Failed to read keymap file" + keymapFilePath + ":" + ex.GetToString());
9496
}
9597
}
9698
else {
97-
MessageBox.Show("Keymap file does not exist at " + keymapFilePath);
99+
IoC.MessageService.ShowMessage("Keymap", "Keymap file does not exist at " + keymapFilePath);
98100
}
99101

100102
await this.splash.SetAction("Loading FFmpeg...", null);
@@ -103,8 +105,7 @@ public async Task InitWPFApp() {
103105
ffmpeg.avdevice_register_all();
104106
}
105107
catch (Exception e) {
106-
MessageBox.Show("The FFmpeg libraries (avcodec-60.dll, avfilter-9, and all other 6 dlls files) must be placed in the build folder which is where the EXE is, e.g. /FramePFX/bin/x64/Debug", "FFmpeg not found");
107-
throw new Exception("FFmpeg Unavailable. Copy FFmpeg DLLs into the same folder as the app's .exe", e);
108+
IoC.MessageService.ShowMessage("FFmpeg registration failed", "The FFmpeg libraries (avcodec-60.dll, avfilter-9, and all other 6 dlls files) must be placed in the build folder which is where the EXE is, e.g. /FramePFX/bin/x64/Debug", e.GetToString());
108109
}
109110
}
110111
}

FramePFX/AttachedProperties/ObservableSelectionHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@ private static void OnSourceCollectionChanged(object sender, NotifyCollectionCha
330330
}
331331

332332
if (list.TryGetException(out Exception error)) {
333-
MessageBox.Show("An exception occurred while processing selection change. " +
334-
"This may have corrupted the application in some way, so please restart.\n\n" +
335-
"See the app logs for more info", "Error");
333+
IoC.MessageService.ShowMessage("Error", "An exception occurred while processing selection change. " +
334+
"This may have corrupted the application in some way, so please restart.\n\n" +
335+
"See the app logs for more info");
336336
}
337337
}
338338
}

FramePFX/Editors/Actions/NewProjectAction.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Threading.Tasks;
22
using System.Windows;
33
using FramePFX.Actions;
4+
using FramePFX.Editors.Timelines.Effects;
5+
using FramePFX.Editors.Timelines.Tracks;
46
using FramePFX.Interactivity.DataContexts;
57
using FramePFX.Views;
68

@@ -44,7 +46,14 @@ public override Task ExecuteAsync(AnActionEventArgs e) {
4446
return Task.CompletedTask;
4547
}
4648

47-
editor.SetProject(new Project());
49+
Project project = new Project();
50+
VideoTrack track = new VideoTrack() {
51+
DisplayName = "Video Track 1"
52+
};
53+
54+
track.AddEffect(new MotionEffect());
55+
project.MainTimeline.AddTrack(track);
56+
editor.SetProject(project);
4857
return Task.CompletedTask;
4958
}
5059
}

FramePFX/Editors/Controls/Resources/Explorers/ResourceExplorerListControl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ protected override async void OnDrop(DragEventArgs e) {
162162
await ResourceDropRegistry.DropRegistry.OnDropped(currentFolder, list, effects);
163163
}
164164
else if (!await ResourceDropRegistry.DropRegistry.OnDroppedNative(currentFolder, new DataObjectWrapper(e.Data), effects)) {
165-
MessageBox.Show("Unknown dropped item. Drop files here", "Unknown data");
165+
IoC.MessageService.ShowMessage("Unknown data", "Unknown dropped item. Drop files here");
166166
// await IoC.DialogService.ShowMessageAsync("Unknown data", "Unknown dropped item. Drop files here");
167167
}
168168
}

FramePFX/Editors/Controls/Resources/Explorers/ResourceExplorerListItem.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class ResourceExplorerListItem : ContentControl {
2121
public static readonly DependencyProperty IsDroppableTargetOverProperty = DependencyProperty.Register("IsDroppableTargetOver", typeof(bool), typeof(ResourceExplorerListItem), new PropertyMetadata(BoolBox.False));
2222
public static readonly DependencyProperty IsSelectedProperty = Selector.IsSelectedProperty.AddOwner(typeof(ResourceExplorerListItem), new FrameworkPropertyMetadata(BoolBox.False, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, (d, e) => ((ResourceExplorerListItem) d).OnIsSelectedChanged((bool) e.NewValue)));
2323
public static readonly DependencyProperty DisplayNameProperty = DependencyProperty.Register("DisplayName", typeof(string), typeof(ResourceExplorerListItem), new PropertyMetadata(null));
24+
private static readonly DependencyPropertyKey IsResourceOnlinePropertyKey = DependencyProperty.RegisterReadOnly("IsResourceOnline", typeof(bool), typeof(ResourceExplorerListItem), new PropertyMetadata(BoolBox.True));
25+
public static readonly DependencyProperty IsResourceOnlineProperty = IsResourceOnlinePropertyKey.DependencyProperty;
2426

2527
public bool IsDroppableTargetOver {
2628
get => (bool) this.GetValue(IsDroppableTargetOverProperty);
@@ -29,14 +31,19 @@ public bool IsDroppableTargetOver {
2931

3032
public bool IsSelected {
3133
get => (bool) this.GetValue(IsSelectedProperty);
32-
set => this.SetValue(IsSelectedProperty, value);
34+
set => this.SetValue(IsSelectedProperty, value.Box());
3335
}
3436

3537
public string DisplayName {
3638
get => (string) this.GetValue(DisplayNameProperty);
3739
set => this.SetValue(DisplayNameProperty, value);
3840
}
3941

42+
public bool IsResourceOnline {
43+
get => (bool) this.GetValue(IsResourceOnlineProperty);
44+
private set => this.SetValue(IsResourceOnlinePropertyKey, value.Box());
45+
}
46+
4047
public BaseResource Model { get; private set; }
4148

4249
public ResourceExplorerListControl ResourceExplorerList { get; private set; }
@@ -195,8 +202,7 @@ protected override async void OnDrop(DragEventArgs e) {
195202
await ResourceDropRegistry.DropRegistry.OnDropped(folder, list, effects);
196203
}
197204
else if (!await ResourceDropRegistry.DropRegistry.OnDroppedNative(folder, new DataObjectWrapper(e.Data), effects)) {
198-
MessageBox.Show("Unknown dropped item. Drop files here", "Unknown data");
199-
// await IoC.DialogService.ShowMessageAsync("Unknown data", "Unknown dropped item. Drop files here");
205+
IoC.MessageService.ShowMessage("Unknown Data", "Unknown dropped item. Drop files here");
200206
}
201207
}
202208
finally {
@@ -258,6 +264,11 @@ public void OnAddingToList(ResourceExplorerListControl explorerList, BaseResourc
258264
public void OnAddedToList() {
259265
this.displayNameBinder.Attach(this, this.Model);
260266
this.isSelectedBinder.Attach(this, this.Model);
267+
if (this.Model is ResourceItem item) {
268+
item.OnlineStateChanged += this.UpdateIsOnlineState;
269+
this.UpdateIsOnlineState(item);
270+
}
271+
261272
ResourceExplorerListItemContent content = (ResourceExplorerListItemContent) this.Content;
262273
content.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
263274

@@ -270,6 +281,10 @@ public void OnAddedToList() {
270281
public void OnRemovingFromList() {
271282
this.displayNameBinder.Detatch();
272283
this.isSelectedBinder.Detatch();
284+
if (this.Model is ResourceItem item) {
285+
item.OnlineStateChanged -= this.UpdateIsOnlineState;
286+
}
287+
273288
ResourceExplorerListItemContent content = (ResourceExplorerListItemContent) this.Content;
274289
content.Disconnect();
275290
this.Content = null;
@@ -281,5 +296,9 @@ public void OnRemovedFromList() {
281296
this.ResourceExplorerList = null;
282297
this.Model = null;
283298
}
299+
300+
private void UpdateIsOnlineState(ResourceItem resource) {
301+
this.IsResourceOnline = resource.IsOnline;
302+
}
284303
}
285304
}

FramePFX/Editors/Controls/Resources/ResourceStyles.xaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,15 @@
109109
</DockPanel>
110110
</Border>
111111
<ControlTemplate.Triggers>
112-
<Trigger Property="IsMouseOver" Value="True">
112+
<MultiTrigger>
113+
<MultiTrigger.Conditions>
114+
<Condition Property="IsMouseOver" Value="True"/>
115+
<Condition Property="IsResourceOnline" Value="True"/>
116+
</MultiTrigger.Conditions>
113117
<Setter Property="Background" TargetName="PART_HeaderBorder" Value="{DynamicResource Item.MouseOver.Background}"/>
114118
<Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource Item.MouseOver.Border}"/>
115-
</Trigger>
119+
</MultiTrigger>
120+
116121
<Trigger Property="IsEnabled" Value="False">
117122
<Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource ABrush.Foreground.Disabled}"/>
118123
</Trigger>
@@ -138,6 +143,18 @@
138143
<Trigger Property="IsDroppableTargetOver" Value="True">
139144
<Setter Property="BorderBrush" TargetName="Bd" Value="OrangeRed"/>
140145
</Trigger>
146+
<Trigger Property="IsResourceOnline" Value="False">
147+
<Setter Property="Background" TargetName="PART_HeaderBorder" Value="Red"/>
148+
<Setter Property="BorderBrush" TargetName="Bd" Value="Red"/>
149+
</Trigger>
150+
<MultiTrigger>
151+
<MultiTrigger.Conditions>
152+
<Condition Property="IsMouseOver" Value="True"/>
153+
<Condition Property="IsResourceOnline" Value="False"/>
154+
</MultiTrigger.Conditions>
155+
<Setter Property="Background" TargetName="PART_HeaderBorder" Value="DarkRed"/>
156+
<Setter Property="BorderBrush" TargetName="Bd" Value="DarkRed"/>
157+
</MultiTrigger>
141158
</ControlTemplate.Triggers>
142159
</ControlTemplate>
143160
</Setter.Value>

FramePFX/Editors/Controls/Resources/Trees/ResourceTreeView.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ protected override async void OnDrop(DragEventArgs e) {
147147
await ResourceDropRegistry.DropRegistry.OnDropped(manager.RootContainer, list, effects);
148148
}
149149
else if (!await ResourceDropRegistry.DropRegistry.OnDroppedNative(manager.RootContainer, new DataObjectWrapper(e.Data), effects)) {
150-
MessageBox.Show("Unknown dropped item. Drop files here", "Unknown data");
151-
// await IoC.DialogService.ShowMessageAsync("Unknown data", "Unknown dropped item. Drop files here");
150+
IoC.MessageService.ShowMessage("Unknown Data", "Unknown dropped item. Drop files here");
152151
}
153152
}
154153
finally {

FramePFX/Editors/Controls/Resources/Trees/ResourceTreeViewItem.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ protected override async void OnDrop(DragEventArgs e) {
324324
await ResourceDropRegistry.DropRegistry.OnDropped(self, list, effects);
325325
}
326326
else if (!await ResourceDropRegistry.DropRegistry.OnDroppedNative(self, new DataObjectWrapper(e.Data), effects)) {
327-
MessageBox.Show("Unknown dropped item. Drop files here", "Unknown data");
328-
// await IoC.DialogService.ShowMessageAsync("Unknown data", "Unknown dropped item. Drop files here");
327+
IoC.MessageService.ShowMessage("Unknown Data", "Unknown dropped item. Drop files here");
329328
}
330329
}
331330
finally {

FramePFX/Editors/Controls/Timelines/TrackDropRegistry.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static TrackDropRegistry() {
2121
return objekt.GetData(NativeDropTypes.FileDrop) is string[] files && files.Length > 0 ? EnumDropType.Copy : EnumDropType.None;
2222
}, async (model, objekt, type, c) => {
2323
string[] files = (string[]) objekt.GetData(NativeDropTypes.FileDrop);
24-
MessageBox.Show($"Dropping files directly into the timeline is not implemented yet.\nYou dropped: {string.Join(", ", files)}", "STILL TODO");
24+
IoC.MessageService.ShowMessage("STILL TODO", $"Dropping files directly into the timeline is not implemented yet.\nYou dropped: {string.Join(", ", files)}");
2525
});
2626

2727
DropRegistry.Register<VideoTrack, ResourceItem>((track, resource, dt, ctx) => {
@@ -30,17 +30,17 @@ static TrackDropRegistry() {
3030
: EnumDropType.None;
3131
}, async (track, resource, dt, ctx) => {
3232
if (!ctx.TryGetContext(DataKeys.TrackDropFrameKey, out long frame)) {
33-
MessageBox.Show("Drag drop error: no track frame location", "Drop err");
33+
IoC.MessageService.ShowMessage("Drop err", "Drag drop error: no track frame location");
3434
return;
3535
}
3636

3737
if (!resource.IsOnline) {
38-
MessageBox.Show("Cannot add an offline resource to the timeline", "Resource Offline");
38+
IoC.MessageService.ShowMessage("Resource Offline", "Cannot add an offline resource to the timeline");
3939
return;
4040
}
4141

4242
if (resource.UniqueId == ResourceManager.EmptyId || !resource.IsRegistered()) {
43-
MessageBox.Show("This resource is not registered yet. This is a bug", "Invalid resource");
43+
IoC.MessageService.ShowMessage("Invalid resource", "This resource is not registered yet. This is a bug");
4444
return;
4545
}
4646

0 commit comments

Comments
 (0)