115 lines
3.9 KiB
C#
115 lines
3.9 KiB
C#
using Aurora.Api.Manager;
|
|
using Aurora.Api;
|
|
using Aurora.View;
|
|
using Aurora;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Media.Media3D;
|
|
using WeldingCommon.Models;
|
|
using System.Reactive.Linq;
|
|
|
|
namespace WeldingCommon.Views
|
|
{
|
|
public class UCModelEditorViewModel : NotifyPropertyChangedBase, IModelViewModel
|
|
{
|
|
public readonly Logger Log = new Logger("UCModelEditorViewModel");
|
|
|
|
public IAuroraEnvironment _AuroraEnv;
|
|
public readonly IRecipeManager _RecipeManager;
|
|
public readonly IModelManager _ModelManager;
|
|
|
|
private string _EditingSubMenu = "EquipmentSpecific";
|
|
public bool IsEditingEquipmentSpecific {
|
|
get => _EditingSubMenu == "EquipmentSpecific";
|
|
set {
|
|
if (value) {
|
|
SetProperty(ref _EditingSubMenu, "EquipmentSpecific");
|
|
}
|
|
NotifyPropertyChanged("IsEditingTeachingRun"); // 다른 variable 에 notify 해 줌.
|
|
}
|
|
}
|
|
public bool IsEditingTeachingRun {
|
|
get => _EditingSubMenu == "TeachingRun";
|
|
set {
|
|
if (value) {
|
|
SetProperty(ref _EditingSubMenu, "TeachingRun");
|
|
}
|
|
NotifyPropertyChanged("IsEditingEquipmentSpecific");
|
|
}
|
|
}
|
|
|
|
private EquipmentSpecificModel _EditingEquipmentSpecificModel;
|
|
public EquipmentSpecificModel EditingEquipmentSpecificModel { get => _EditingEquipmentSpecificModel; set => SetProperty(ref _EditingEquipmentSpecificModel, value); }
|
|
|
|
private string _EditingEquipmentSpecificModelName;
|
|
public string EditingEquipmentSpecificModelName { get => _EditingEquipmentSpecificModelName; set => SetProperty(ref _EditingEquipmentSpecificModelName, value); }
|
|
|
|
public UCModelEditorViewModel(IAuroraEnvironment aurora)
|
|
{
|
|
_AuroraEnv = aurora;
|
|
_RecipeManager = _AuroraEnv.RecipeManager;
|
|
_ModelManager = _AuroraEnv.ModelManager;
|
|
|
|
OnModelChanged();
|
|
|
|
Observable.Merge(
|
|
_AuroraEnv.EventObservable.AsObservable(AuroraSysEvent.SYS_MODEL_ENTRY_CHAGNED),
|
|
_AuroraEnv.EventObservable.AsObservable(AuroraSysEvent.SYS_MODEL_ITEM_CHANGED)
|
|
).ObserveOnDispatcher()
|
|
.Subscribe(x => OnModelChanged(EditingEquipmentSpecificModelName));
|
|
}
|
|
|
|
public void OnChanged(string modelName)
|
|
{
|
|
OnModelChanged(modelName);
|
|
}
|
|
|
|
public void Reloaded(string modelName)
|
|
{
|
|
//throw new NotImplementedException();
|
|
}
|
|
|
|
public void OnModelChanged(string modelName = null)
|
|
{
|
|
if (modelName == null) {
|
|
modelName = _RecipeManager.ActivatedModelName();
|
|
|
|
if (modelName == null) {
|
|
// 아직 ModelManager(Model) 준비되지 않은 상태. 일단 skip
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (modelName != EditingEquipmentSpecificModelName) {
|
|
Log.D($"OnModelChanged : {EditingEquipmentSpecificModelName} -> {modelName}");
|
|
}
|
|
EditingEquipmentSpecificModelName = modelName;
|
|
|
|
var model = _ModelManager?.ModelItem(EditingEquipmentSpecificModelName, CommonModelIds.EquipmentSpecificModel) as EquipmentSpecificModel;
|
|
if (model != null) {
|
|
EditingEquipmentSpecificModel = model;
|
|
}
|
|
}
|
|
|
|
public bool CanRename(string oldName, string newName, out string errMsg)
|
|
{
|
|
errMsg = "";
|
|
return true;
|
|
}
|
|
|
|
public bool PreSaved(string modelName)
|
|
{
|
|
//throw new NotImplementedException();
|
|
return true;
|
|
}
|
|
|
|
public void OnSaved(string modelName)
|
|
{
|
|
//throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|