mirror of
https://github.com/BlossomiShymae/Needlework.Net.git
synced 2025-12-06 18:20:47 +01:00
30 lines
842 B
C#
30 lines
842 B
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
using Needlework.Net.Desktop.Messages;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
|
|
namespace Needlework.Net.Desktop.ViewModels
|
|
{
|
|
public partial class OopsiesWindowViewModel(string text) : ObservableObject
|
|
{
|
|
public string Text { get; } = text;
|
|
|
|
[RelayCommand]
|
|
private void OpenDefaultEditor()
|
|
{
|
|
var temp = Path.GetTempFileName().Replace(".tmp", ".json");
|
|
File.WriteAllText(temp, Text);
|
|
Process.Start("explorer", "\"" + temp + "\"");
|
|
CloseDialog();
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void CloseDialog()
|
|
{
|
|
WeakReferenceMessenger.Default.Send(new OopsiesWindowCanceledMessage(null));
|
|
}
|
|
}
|
|
}
|