|
@@ -76,12 +76,16 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
|
|
IPreferences.Current.UpdateLocalPreference(PreferencesConstants.RecentlyOpened, RecentlyOpened.Select(x => x.FilePath));
|
|
IPreferences.Current.UpdateLocalPreference(PreferencesConstants.RecentlyOpened, RecentlyOpened.Select(x => x.FilePath));
|
|
}
|
|
}
|
|
|
|
|
|
- public void RemoveRecentlyOpened(object parameter)
|
|
|
|
|
|
+ [Command.Internal("PixiEditor.File.RemoveRecent")]
|
|
|
|
+ public void RemoveRecentlyOpened(string path)
|
|
{
|
|
{
|
|
- if (RecentlyOpened.Contains((string)parameter))
|
|
|
|
|
|
+ if (!RecentlyOpened.Contains(path))
|
|
{
|
|
{
|
|
- RecentlyOpened.Remove((string)parameter);
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ RecentlyOpened.Remove(path);
|
|
|
|
+ IPreferences.Current.UpdateLocalPreference(PreferencesConstants.RecentlyOpened, RecentlyOpened.Select(x => x.FilePath));
|
|
}
|
|
}
|
|
|
|
|
|
private void OpenHelloTherePopup()
|
|
private void OpenHelloTherePopup()
|
|
@@ -139,6 +143,23 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
|
|
OpenFromPath(dialog.FileName);
|
|
OpenFromPath(dialog.FileName);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [Command.Basic("PixiEditor.File.OpenFileFromClipboard", "OPEN_FILE_FROM_CLIPBOARD", "OPEN_FILE_FROM_CLIPBOARD_DESCRIPTIVE", CanExecute = "PixiEditor.Clipboard.HasImageInClipboard")]
|
|
|
|
+ public void OpenFromClipboard()
|
|
|
|
+ {
|
|
|
|
+ var images = ClipboardController.GetImagesFromClipboard();
|
|
|
|
+
|
|
|
|
+ foreach (var (name, image) in images)
|
|
|
|
+ {
|
|
|
|
+ if (name == null)
|
|
|
|
+ {
|
|
|
|
+ OpenRegularImage(image, null);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ OpenFromPath(name, false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private bool MakeExistingDocumentActiveIfOpened(string path)
|
|
private bool MakeExistingDocumentActiveIfOpened(string path)
|
|
{
|
|
{
|
|
foreach (DocumentViewModel document in Owner.DocumentManagerSubViewModel.Documents)
|
|
foreach (DocumentViewModel document in Owner.DocumentManagerSubViewModel.Documents)
|
|
@@ -155,8 +176,7 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Tries to open the passed file if it isn't already open
|
|
/// Tries to open the passed file if it isn't already open
|
|
/// </summary>
|
|
/// </summary>
|
|
- /// <param name="path"></param>
|
|
|
|
- public void OpenFromPath(string path)
|
|
|
|
|
|
+ public void OpenFromPath(string path, bool associatePath = true)
|
|
{
|
|
{
|
|
if (MakeExistingDocumentActiveIfOpened(path))
|
|
if (MakeExistingDocumentActiveIfOpened(path))
|
|
return;
|
|
return;
|
|
@@ -165,11 +185,11 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
|
|
{
|
|
{
|
|
if (path.EndsWith(".pixi"))
|
|
if (path.EndsWith(".pixi"))
|
|
{
|
|
{
|
|
- OpenDotPixi(path);
|
|
|
|
|
|
+ OpenDotPixi(path, associatePath);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- OpenRegularImage(path);
|
|
|
|
|
|
+ OpenRegularImage(path, associatePath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (RecoverableException ex)
|
|
catch (RecoverableException ex)
|
|
@@ -185,9 +205,9 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Opens a .pixi file from path, creates a document from it, and adds it to the system
|
|
/// Opens a .pixi file from path, creates a document from it, and adds it to the system
|
|
/// </summary>
|
|
/// </summary>
|
|
- private void OpenDotPixi(string path)
|
|
|
|
|
|
+ private void OpenDotPixi(string path, bool associatePath = true)
|
|
{
|
|
{
|
|
- DocumentViewModel document = Importer.ImportDocument(path);
|
|
|
|
|
|
+ DocumentViewModel document = Importer.ImportDocument(path, associatePath);
|
|
AddDocumentViewModelToTheSystem(document);
|
|
AddDocumentViewModelToTheSystem(document);
|
|
AddRecentlyOpened(document.FullFilePath);
|
|
AddRecentlyOpened(document.FullFilePath);
|
|
}
|
|
}
|
|
@@ -205,7 +225,7 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Opens a regular image file from path, creates a document from it, and adds it to the system.
|
|
/// Opens a regular image file from path, creates a document from it, and adds it to the system.
|
|
/// </summary>
|
|
/// </summary>
|
|
- private void OpenRegularImage(string path)
|
|
|
|
|
|
+ private void OpenRegularImage(string path, bool associatePath)
|
|
{
|
|
{
|
|
ImportFileDialog dialog = new ImportFileDialog();
|
|
ImportFileDialog dialog = new ImportFileDialog();
|
|
|
|
|
|
@@ -214,17 +234,57 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
|
|
dialog.FilePath = path;
|
|
dialog.FilePath = path;
|
|
}
|
|
}
|
|
|
|
|
|
- if (dialog.ShowDialog())
|
|
|
|
|
|
+ if (!dialog.ShowDialog())
|
|
{
|
|
{
|
|
- DocumentViewModel doc = NewDocument(b => b
|
|
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ DocumentViewModel doc = NewDocument(b => b
|
|
|
|
+ .WithSize(dialog.FileWidth, dialog.FileHeight)
|
|
|
|
+ .WithLayer(l => l
|
|
|
|
+ .WithName("Image")
|
|
.WithSize(dialog.FileWidth, dialog.FileHeight)
|
|
.WithSize(dialog.FileWidth, dialog.FileHeight)
|
|
- .WithLayer(l => l
|
|
|
|
- .WithName("Image")
|
|
|
|
- .WithSize(dialog.FileWidth, dialog.FileHeight)
|
|
|
|
- .WithSurface(Importer.ImportImage(dialog.FilePath, new VecI(dialog.FileWidth, dialog.FileHeight)))));
|
|
|
|
|
|
+ .WithSurface(Importer.ImportImage(dialog.FilePath, new VecI(dialog.FileWidth, dialog.FileHeight)))));
|
|
|
|
+
|
|
|
|
+ if (associatePath)
|
|
|
|
+ {
|
|
doc.FullFilePath = path;
|
|
doc.FullFilePath = path;
|
|
- AddRecentlyOpened(path);
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ AddRecentlyOpened(path);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Opens a regular image file from path, creates a document from it, and adds it to the system.
|
|
|
|
+ /// </summary>
|
|
|
|
+ private void OpenRegularImage(Surface surface, string path)
|
|
|
|
+ {
|
|
|
|
+ ImportFileDialog dialog = new ImportFileDialog( );
|
|
|
|
+
|
|
|
|
+ dialog.FileWidth = surface.Size.X;
|
|
|
|
+ dialog.FileHeight = surface.Size.Y;
|
|
|
|
+
|
|
|
|
+ if (!dialog.ShowDialog())
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ surface.ResizeNearestNeighbor(new VecI(dialog.FileWidth, dialog.FileHeight));
|
|
|
|
+
|
|
|
|
+ DocumentViewModel doc = NewDocument(b => b
|
|
|
|
+ .WithSize(dialog.FileWidth, dialog.FileHeight)
|
|
|
|
+ .WithLayer(l => l
|
|
|
|
+ .WithName("Image")
|
|
|
|
+ .WithSize(dialog.FileWidth, dialog.FileHeight)
|
|
|
|
+ .WithSurface(surface)));
|
|
|
|
+
|
|
|
|
+ if (path == null)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ doc.FullFilePath = path;
|
|
|
|
+ AddRecentlyOpened(path);
|
|
}
|
|
}
|
|
|
|
|
|
[Command.Basic("PixiEditor.File.New", "NEW_IMAGE", "CREATE_NEW_IMAGE", Key = Key.N, Modifiers = ModifierKeys.Control)]
|
|
[Command.Basic("PixiEditor.File.New", "NEW_IMAGE", "CREATE_NEW_IMAGE", Key = Key.N, Modifiers = ModifierKeys.Control)]
|