making braille object re-build correctly
issue: MatterHackers/MCCentral#4958 Braille crashes when change letter
This commit is contained in:
parent
c82923b779
commit
82e053be25
2 changed files with 13 additions and 15 deletions
|
|
@ -29,7 +29,6 @@ either expressed or implied, of the FreeBSD Project.
|
|||
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Agg.VertexSource;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
|
|
@ -45,32 +44,32 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
}
|
||||
|
||||
public static BrailleCardObject3D Create()
|
||||
public static async Task<BrailleCardObject3D> Create()
|
||||
{
|
||||
var item = new BrailleCardObject3D();
|
||||
|
||||
item.Rebuild();
|
||||
await item.Rebuild();
|
||||
return item;
|
||||
}
|
||||
|
||||
public override bool CanFlatten => true;
|
||||
|
||||
public char Letter { get; set; } = 'a';
|
||||
|
||||
public double BaseHeight { get; set; } = 4;
|
||||
|
||||
public override void OnInvalidate(InvalidateArgs invalidateType)
|
||||
public override async void OnInvalidate(InvalidateArgs invalidateType)
|
||||
{
|
||||
if (invalidateType.InvalidateType.HasFlag(InvalidateType.Properties)
|
||||
&& invalidateType.Source == this)
|
||||
{
|
||||
Rebuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnInvalidate(invalidateType);
|
||||
await Rebuild();
|
||||
}
|
||||
|
||||
base.OnInvalidate(invalidateType);
|
||||
}
|
||||
|
||||
override public Task Rebuild()
|
||||
override public async Task Rebuild()
|
||||
{
|
||||
using (RebuildLock())
|
||||
{
|
||||
|
|
@ -86,7 +85,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
TextToEncode = Letter.ToString(),
|
||||
BaseHeight = BaseHeight,
|
||||
};
|
||||
brailleLetter.Rebuild();
|
||||
await brailleLetter.Rebuild();
|
||||
this.Children.Add(brailleLetter);
|
||||
|
||||
var textObject = new TextObject3D()
|
||||
|
|
@ -97,7 +96,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
Height = BaseHeight
|
||||
};
|
||||
|
||||
textObject.Invalidate(InvalidateType.Properties);
|
||||
await textObject.Rebuild();
|
||||
IObject3D letterObject = new RotateObject3D(textObject, MathHelper.Tau / 4);
|
||||
letterObject = new AlignObject3D(letterObject, FaceAlign.Bottom | FaceAlign.Front, brailleLetter, FaceAlign.Top | FaceAlign.Front, 0, 0, 3.5);
|
||||
letterObject = new SetCenterObject3D(letterObject, brailleLetter.GetCenter(), true, false, false);
|
||||
|
|
@ -126,7 +125,6 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
}
|
||||
|
||||
Invalidate(InvalidateType.Children);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -85,12 +85,12 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
static TypeFace typeFace = TypeFace.LoadFrom(AggContext.StaticData.ReadAllText(Path.Combine("Fonts", "Braille.svg")));
|
||||
|
||||
public override void OnInvalidate(InvalidateArgs invalidateType)
|
||||
public override async void OnInvalidate(InvalidateArgs invalidateType)
|
||||
{
|
||||
if (invalidateType.InvalidateType.HasFlag(InvalidateType.Properties)
|
||||
&& invalidateType.Source == this)
|
||||
{
|
||||
Rebuild();
|
||||
await Rebuild();
|
||||
}
|
||||
|
||||
base.OnInvalidate(invalidateType);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue