初始化上传
This commit is contained in:
50
常用工具集/Base/DelegateCommand.cs
Normal file
50
常用工具集/Base/DelegateCommand.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace 常用工具集.Base
|
||||
{
|
||||
public class DelegateCommand : ICommand
|
||||
{
|
||||
public Action<object> ExecuteCommand = null;
|
||||
public Func<object, bool> CanExecuteCommand = null;
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
|
||||
public DelegateCommand()
|
||||
{
|
||||
}
|
||||
|
||||
public DelegateCommand(Action<object> Command)
|
||||
{
|
||||
ExecuteCommand = Command;
|
||||
}
|
||||
|
||||
public bool CanExecute(object paramter)
|
||||
{
|
||||
if (CanExecuteCommand != null)
|
||||
{
|
||||
return CanExecuteCommand(paramter);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(object paramter)
|
||||
{
|
||||
if (ExecuteCommand != null)
|
||||
ExecuteCommand(paramter);
|
||||
}
|
||||
|
||||
public void RaiseCanExecuteChanged()
|
||||
{
|
||||
if (CanExecuteChanged != null)
|
||||
CanExecuteChanged(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
51
常用工具集/Base/GlobalValues.cs
Normal file
51
常用工具集/Base/GlobalValues.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Notifications;
|
||||
using Avalonia.Input.Platform;
|
||||
using Avalonia.Platform.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace 常用工具集.Base
|
||||
{
|
||||
internal class GlobalValues
|
||||
{
|
||||
public static Ursa.Controls.WindowNotificationManager? NotificationManager { get; set; }
|
||||
public static Window MainWindow { get; internal set; }
|
||||
public static IStorageProvider StorageProvider { get; internal set; }
|
||||
public static IClipboard Clipboard { get; internal set; }
|
||||
|
||||
public static void ShowNotification(string title, string message, NotificationType type)
|
||||
{
|
||||
if (NotificationManager != null)
|
||||
{
|
||||
NotificationManager?.Show(new Notification(title, message), showIcon: true, showClose: false, type: type);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Error(string message)
|
||||
{
|
||||
if (NotificationManager != null)
|
||||
{
|
||||
NotificationManager?.Show(message, NotificationType.Error, TimeSpan.FromSeconds(1), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Warning(string message)
|
||||
{
|
||||
if (NotificationManager != null)
|
||||
{
|
||||
NotificationManager?.Show(message, NotificationType.Warning, TimeSpan.FromSeconds(1), true, false);
|
||||
}
|
||||
}
|
||||
public static void Success(string message)
|
||||
{
|
||||
if (NotificationManager != null)
|
||||
{
|
||||
NotificationManager?.Show(message, NotificationType.Success, TimeSpan.FromSeconds(1), true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
常用工具集/Base/ViewModelBase.cs
Normal file
19
常用工具集/Base/ViewModelBase.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace 常用工具集.Base
|
||||
{
|
||||
public class ViewModelBase : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public void NotifyPropertyChanged([CallerMemberName] string propertyname = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyname));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user