20230724_MBJC_upperpc/ViewModels/MainViewModel.cs

102 lines
3.0 KiB
C#
Raw Normal View History

2023-12-18 09:31:28 +00:00
using _20230724_MBJC_upperpc.Common;
using _20230724_MBJC_upperpc.Models;
2023-12-23 03:35:57 +00:00
using _20230724_MBJC_upperpc.Views;
2023-12-18 09:31:28 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Intrinsics.X86;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace _20230724_MBJC_upperpc.ViewModels
{
public class MainViewModel : NotifyBase
{
#region
/// <summary>
/// 主界面标签切换事件
/// </summary>
public CommandBase NavChangedCommand { get; set; }
string Title_Name = ""; //设置当前显示的标题 1 浮标 2 接驳盒 3 系统控制 4 日志记录
#endregion
private FrameworkElement _pageContent;
public FrameworkElement PageContent
{
get { return _pageContent; }
set { _pageContent = value; this.DoNotify(); }
}
2023-12-23 03:35:57 +00:00
2023-12-18 09:31:28 +00:00
private BeaconModel beacon = new BeaconModel
{
2023-12-20 09:58:16 +00:00
ID = 6,
Datetime = DateTime.Now,
Position_Distance = 450.6589f,
Propagationtime = 2.6f,
Beacon_JD = 112.9635f,
Beacon_WD = 31.5665f,
Beacon_Depth = 49.58f,
Beacon_Roll_Angle = 90,
Beacon_Pitch_Angle = 0,
Beacon_Heading_Angle = 0,
Temp = 24.5f,
2023-12-18 09:31:28 +00:00
Position_Pitch_Angle = -90,
Position_Heading_Angle = 90,
BasicSite_Heading = 0,
BasicSite_JD = 119.2683f,
2023-12-20 09:58:16 +00:00
BasicSite_WD = 29.3586f,
2023-12-18 09:31:28 +00:00
BasicSite_Depth = 4f,
};
public BeaconModel Beacon
{
get { return beacon; }
set { beacon = value; this.DoNotify(); }
}
public MainViewModel()
{
this.NavChangedCommand = new CommandBase();
this.NavChangedCommand.DoExcute = new Action<object>(DoNavChanged);
this.NavChangedCommand.DoCanExcute = new Func<object, bool>((o) => true);
2023-12-23 03:35:57 +00:00
DoNavChanged("FirstPageView");
2023-12-18 09:31:28 +00:00
}
public void DoNavChanged(object obj)
{
if (Title_Name == obj.ToString())
return;
Title_Name = obj.ToString();
2023-12-23 03:35:57 +00:00
if (Title_Name != "FirstPageView" && Title_Name != "BuoyPlatformView")
{
Title_Name = "AnchorPointView";
}
2023-12-18 09:31:28 +00:00
//切换页面之前清理一下内存
tools.ClearMemory(this);
2023-12-23 03:35:57 +00:00
//首先提示加载界面
Type type = Type.GetType("_20230724_MBJC_upperpc.Views.ProgressView");
2023-12-18 09:31:28 +00:00
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes);
FrameworkElement page = (FrameworkElement)cti.Invoke(null);
this.PageContent = page;
2023-12-23 03:35:57 +00:00
type = Type.GetType("_20230724_MBJC_upperpc.Views." + Title_Name);
cti = type.GetConstructor(System.Type.EmptyTypes);
page = (FrameworkElement)cti.Invoke(null);
this.PageContent = page;
2023-12-18 09:31:28 +00:00
}
}
}