Closed Brent-bai closed 7 months ago
Found another problem: Two ControlGroup altered by dependecy options, controled by two icon button; The ControlGroup does changed when I click each buttons; but input values of disabled ControlGruop remained, when I change it back, it would cause unexpected result (because it will do something when all the input is difined). It seems just hide but not disabled. Because when I switch to another control group, the input focus remains in the previous control group. In the CustomControlDependantHandler, I add the "source.Dispose();", it would not work. Do you have any ideas? Thank you!
I have add a reset() method to ControlGroup to reset the remained value or selection to default, but the input focus problem still existed. I noted the IControl resource code have the focus() method, but not finished. Would it be the answer in the future? Is there a method to get the IPropertyManagerPage2 of SW Api?
I use reflection to get the IPropertyManagerPage2, but found the control id is changed everytime. 😂
Sorry, a bit confused with the last issue with ControlGroup. Do you have code snippet for that?
[sorry, gif is deleted for privacy] This gif will explain the problem. The CustomControlDependantHandler5 should disable the controlgroup. But it still enabled, just hidden.
//DependantHandler
public class CustomControlDependantHandler5 : IDependencyHandler
{
public void UpdateState(IXApplication app, IControl source, IControl[] dependencies)
{
var res = (bool)dependencies.First().GetValue();
source.Enabled = res;
source.Visible = res;
}
}
//ControlGruop
[Title("-FourCorner")]
[DependentOn(typeof(CustomControlDependantHandler5), nameof(isFourCornerPoints))]
public PointsFromFourCornerControlsGroup? pointsFromFourCornerControlsGroup { get; set; }
[Title("-OneCorner")]
[DependentOn(typeof(CustomControlDependantHandler5), nameof(isOneCornerPoints))]
public PointsFromOneCornerControlGroup? pointsFromOneCornerControlsGroup { get; set; }
//Icon Toggle Button
private bool _isFourCornerPoints;
[DependentOn(typeof(CustomControlDependantHandler3), nameof(holeReferenceType))]
[BitmapToggleButton(typeof(Resource1), nameof(Resource1.FourCornerPoint), BitmapEffect_e.None | BitmapEffect_e.Transparent, 32, 32)]
[ControlTag(nameof(isFourCornerPoints))]
[ControlOptions(left: 0, top: 0)]
public bool isFourCornerPoints
{
get => _isFourCornerPoints;
set
{
if (_isFourCornerPoints != value)
{
_isFourCornerPoints = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(isFourCornerPoints)));
if (value)
{
isOneCornerPoints = false;
}
else
{
if (pointsFromFourCornerControlsGroup!=null) pointsFromFourCornerControlsGroup.Reset();
}
}
}
}
By the way, may the property "IsEditing" of ISwSketch2D be public? So I can get the actived sketch.
Ah, I see, thank you. The issue here is that IPropertyManagerPageGroup does not have an Enabled property in SW API and it is not considered as control (unless I missing this). in xCAD group is also a control so it has this property derived, but implementation is empty: https://github.com/xarial/xcad/blob/dev/src/SolidWorks/UI/PropertyPage/Toolkit/Controls/PropertyManagerPageGroupControl.cs#L44-L46. I think it should throw NotSupported exception