87 lines
2.5 KiB
C#
87 lines
2.5 KiB
C#
using _20230724_MBJC_upperpc.Common;
|
|
using _20230724_MBJC_upperpc.Models;
|
|
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(); }
|
|
}
|
|
|
|
|
|
private BeaconModel beacon = new BeaconModel
|
|
{
|
|
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,
|
|
Position_Pitch_Angle = -90,
|
|
Position_Heading_Angle = 90,
|
|
BasicSite_Heading = 0,
|
|
BasicSite_JD = 119.2683f,
|
|
BasicSite_WD = 29.3586f,
|
|
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);
|
|
}
|
|
|
|
public void DoNavChanged(object obj)
|
|
{
|
|
|
|
if (Title_Name == obj.ToString())
|
|
return;
|
|
Title_Name = obj.ToString();
|
|
|
|
//切换页面之前清理一下内存
|
|
tools.ClearMemory(this);
|
|
|
|
Type type = Type.GetType("_20230724_MBJC_upperpc.Views." + Title_Name);
|
|
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes);
|
|
FrameworkElement page = (FrameworkElement)cti.Invoke(null);
|
|
this.PageContent = page;
|
|
}
|
|
|
|
}
|
|
}
|