using PdmSwPlugin.Common.CustomHandler;
|
using PdmSwPlugin.PropertySetting.Interface;
|
using PdmSwPlugin.PropertySetting.Panel.Attr;
|
using SolidWorks.Interop.sldworks;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Reflection;
|
using System.Runtime.CompilerServices;
|
using System.Windows.Controls;
|
|
namespace PdmSwPlugin.PropertySetting.Panel
|
{
|
/// <summary>
|
/// DrwPanel.xaml 的交互逻辑
|
/// </summary>
|
public partial class DefaultPanel : UserControl, IPropertyOpt, INotifyPropertyChanged
|
{
|
#region 不能公用的东西,真有你的啊C#
|
public event PropertyChangedEventHandler PropertyChanged;
|
public void RaisePropertyChanged(string name)
|
{
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
}
|
|
public void RaiseAndSetIfChanged<T>(ref T old, T @new, [CallerMemberName] string propertyName = null)
|
{
|
old = @new;
|
if (propertyName != null)
|
{
|
RaisePropertyChanged(propertyName);
|
var attr = this.GetType().GetProperty(propertyName)?.GetCustomAttribute<PropertySettingAttr>();
|
if (attr == null)
|
{
|
return;
|
}
|
if (attr.NeedSave)
|
{
|
UpdateProperty?.Invoke(this, attr.Name, @new);
|
}
|
}
|
}
|
#endregion
|
|
private string _message;
|
|
public string message
|
{
|
get => _message;
|
set => RaiseAndSetIfChanged(ref _message, value);
|
}
|
|
public DefaultPanel()
|
{
|
DataContext = this;
|
InitializeComponent();
|
}
|
|
private ModelDoc2 doc;
|
|
public event PanelPropertyChanged UpdateProperty;
|
|
public bool ClearAllProperties(out string ErrMsg)
|
{
|
ErrMsg = null;
|
return true;
|
}
|
|
public Dictionary<string, string> GetAllProperties()
|
{
|
return null;
|
}
|
|
public object GetPropertyValue(string propertyName)
|
{
|
return null;
|
}
|
|
public bool SetProperties(ModelDoc2 doc, object properties, bool docChange, out string errMsg)
|
{
|
errMsg = null;
|
message = properties.ToString();
|
return true;
|
}
|
|
public bool SaveDoc(ref int err, ref int warn){
|
return true;
|
}
|
|
public bool SetSettings(object settings)
|
{
|
return true;
|
}
|
|
public bool UpdateSingleProperty(string name, string value)
|
{
|
return true;
|
}
|
|
public bool GetDocChanged()
|
{
|
return false;
|
}
|
|
public bool ResetProperty(out string errMsg)
|
{
|
return SetProperties(doc, message, false, out errMsg);
|
}
|
}
|
}
|