using FeMM.Common.Models;
using FeMM.Grasshopper.DataTypes.FeMM;
using FeMM.Grasshopper.Helpers;
using Grasshopper.Kernel;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace FeMM.Grasshopper.Components.Parameters
{
public class CoordinateSystemParam : GH_PersistentParam<GH_FunctionDefinition>
{
private bool _isCheckedLocal = false;
private bool _isCheckedGlobal = false;
public CoordinateSystemParam()
: base("CoordinateSystem", "CS", "The model coordinate system", CategoryNameConstants.CATEGORY_FEMM, CategoryNameConstants.SUBCATEGORY_PARAMETERS)
{
}
protected override GH_GetterResult Prompt_Plural(ref List<GH_FunctionDefinition> values)
{
return GH_GetterResult.cancel;
}
protected override GH_GetterResult Prompt_Singular(ref GH_FunctionDefinition value)
{
return GH_GetterResult.success;
}
public override bool AppendMenuItems(ToolStripDropDown menu)
{
Menu_AppendObjectNameEx(menu);
Menu_AppendWireDisplay(menu);
Menu_AppendDisconnectWires(menu);
Menu_AppendSeparator(menu);
Menu_AppendItem(menu, "Local", (s, e) =>
{
_isCheckedGlobal = false;
_isCheckedLocal = true;
PersistentData.Clear();
SetPersistentData(new GH_FunctionDefinition(CoordinateSystemModel.Local));
AppendMenuItems(menu);
ExpireSolution(true);
},
true, _isCheckedLocal);
Menu_AppendItem(menu, "Global", (s, e) => {
_isCheckedGlobal = true;
_isCheckedLocal = false;
PersistentData.Clear();
SetPersistentData(new GH_FunctionDefinition(CoordinateSystemModel.Global));
AppendMenuItems(menu);
ExpireSolution(true);
},
true, _isCheckedGlobal);
Menu_AppendSeparator(menu);
Menu_AppendDestroyPersistent(menu);
Menu_AppendInternaliseData(menu);
return true;
}
public override GH_Exposure Exposure => GH_Exposure.secondary;
protected override Bitmap Icon => Properties.Resources.CoordinateSystemParamIcon;
public override Guid ComponentGuid => new("6A7AD660-29B0-4CBB-AF29-7F5CE72F1CF3");
}
}