private void InitSubEntries() { ArrayList gp = new ArrayList(); // wenn der Pfad zu viele Eckpunkte hat, gibts Probleme mit der WindowHandles for (int i = 0; i <= path.CurveCount; ++i) // mit Endpunkt { GeoPointProperty vertex = new GeoPointProperty("Path.Vertex", Frame, true); vertex.UserData.Add("Index", i); vertex.GetGeoPointEvent += new CADability.UserInterface.GeoPointProperty.GetGeoPointDelegate(OnGetVertexPoint); vertex.SetGeoPointEvent += new CADability.UserInterface.GeoPointProperty.SetGeoPointDelegate(OnSetVertexPoint); vertex.ModifyWithMouseEvent += new ModifyWithMouseDelegate(ModifyVertexWithMouse); vertex.PropertyEntryChangedStateEvent += new PropertyEntryChangedStateDelegate(OnVertexStateChanged); vertex.GeoPointChanged(); if (path.IsClosed) { vertex.PrependContextMenu = MenuResource.LoadMenuDefinition("MenuId.Path.Vertex", false, new VertexCommandHandler(this, i)); } gp.Add(vertex); } area = new DoubleProperty("Path.Area", Frame); area.ReadOnly = true; area.GetDoubleEvent += new CADability.UserInterface.DoubleProperty.GetDoubleDelegate(OnGetArea); area.Refresh(); gp.Add(area); length = new DoubleProperty("Path.Length", Frame); length.ReadOnly = true; length.GetDoubleEvent += new CADability.UserInterface.DoubleProperty.GetDoubleDelegate(OnGetLength); length.Refresh(); gp.Add(length); subEntries = (IPropertyEntry[])gp.ToArray(typeof(IPropertyEntry)); attributeProperties = path.GetAttributeProperties(Frame); }
private double OnGetArea(DoubleProperty sender) { if (hatch != null && hatch.CompoundShape != null) { return(hatch.CompoundShape.Area); } return(0.0); }
private void OnSetZ(DoubleProperty sender, double l) { GeoVector p = GlobalToLocal(GetValue()); p.z = l; InputFromSubEntries |= EInputFromSubEntries.z; SetValue(LocalToGlobal(p), true); }
private double OnGetRadius(DoubleProperty sender) { if (dimension.DimType == Dimension.EDimType.DimDiameter) { return(dimension.Radius * 2.0); } else { return(dimension.Radius); } }
private void OnSetRadius(DoubleProperty sender, double l) { if (dimension.DimType == Dimension.EDimType.DimDiameter) { dimension.Radius = l / 2.0; } else { dimension.Radius = l; } }
private double OnGetArea(DoubleProperty sender) { if (path.IsClosed && path.GetPlanarState() == PlanarState.Planar) { Plane plane = path.GetPlane(); ICurve2D cv = path.GetProjectedCurve(plane); Border bdr = new Border(cv); return(Math.Abs(bdr.Area)); // return cv.GetAreaFromPoint(cv.GetExtent().GetCenter()); } return(0); }
private double OnGetLength(DoubleProperty sender) { return(path.Length); }
private double OnGetZ(DoubleProperty sender) { GeoVector p = GlobalToLocal(GetValue()); return(p.z); }
private void Init() { // Initialisiert den gesammten Inhalt des TreeViews // danach sollte meist propertyPage.Refresh(this); aufgerufen werden subProperties = null; if (dimension.DimType == Dimension.EDimType.DimPoints || dimension.DimType == Dimension.EDimType.DimCoord) { points = new MultiGeoPointProperty(this, "Dimension.Points", this.Frame); points.ModifyWithMouseEvent += new CADability.UserInterface.MultiGeoPointProperty.ModifyWithMouseIndexDelegate(OnModifyPointWithMouse); points.PropertyEntryChangedStateEvent += new PropertyEntryChangedStateDelegate(OnPointsStateChanged); points.GeoPointSelectionChangedEvent += new CADability.UserInterface.GeoPointProperty.SelectionChangedDelegate(OnPointsSelectionChanged); direction = new GeoVectorProperty("Dimension.Direction", Frame, true); direction.GetGeoVectorEvent += new CADability.UserInterface.GeoVectorProperty.GetGeoVectorDelegate(OnGetDirection); direction.SetGeoVectorEvent += new CADability.UserInterface.GeoVectorProperty.SetGeoVectorDelegate(OnSetDirection); } if (dimension.DimType == Dimension.EDimType.DimRadius) { radiusProperty = new DoubleProperty("Dimension.Radius", Frame); radiusProperty.SetDoubleEvent += new CADability.UserInterface.DoubleProperty.SetDoubleDelegate(OnSetRadius); radiusProperty.GetDoubleEvent += new CADability.UserInterface.DoubleProperty.GetDoubleDelegate(OnGetRadius); radiusProperty.ModifyWithMouseEvent += new ModifyWithMouseDelegate(ModifyRadiusWithMouse); radiusProperty.DoubleChanged(); } if (dimension.DimType == Dimension.EDimType.DimDiameter) { radiusProperty = new DoubleProperty("Dimension.Diameter", Frame); radiusProperty.SetDoubleEvent += new CADability.UserInterface.DoubleProperty.SetDoubleDelegate(OnSetRadius); radiusProperty.GetDoubleEvent += new CADability.UserInterface.DoubleProperty.GetDoubleDelegate(OnGetRadius); radiusProperty.ModifyWithMouseEvent += new ModifyWithMouseDelegate(ModifyRadiusWithMouse); radiusProperty.DoubleChanged(); } if (dimension.DimType == Dimension.EDimType.DimDiameter || dimension.DimType == Dimension.EDimType.DimRadius || dimension.DimType == Dimension.EDimType.DimLocation || dimension.DimType == Dimension.EDimType.DimAngle) { // haben alle einen Mittelpunkt als Punkt 0 centerProperty = new GeoPointProperty("Dimension.Center", Frame, true); centerProperty.GetGeoPointEvent += new CADability.UserInterface.GeoPointProperty.GetGeoPointDelegate(OnGetCenter); centerProperty.SetGeoPointEvent += new CADability.UserInterface.GeoPointProperty.SetGeoPointDelegate(OnSetCenter); centerProperty.ModifyWithMouseEvent += new ModifyWithMouseDelegate(ModifyCenterWithMouse); } if (dimension.DimType == Dimension.EDimType.DimAngle) { // start- und Endwinkel startAngle = new GeoVectorProperty("Dimension.Startangle", Frame, true); startAngle.GetGeoVectorEvent += new CADability.UserInterface.GeoVectorProperty.GetGeoVectorDelegate(OnGetStartAngle); startAngle.SetGeoVectorEvent += new CADability.UserInterface.GeoVectorProperty.SetGeoVectorDelegate(OnSetStartAngle); startAngle.ModifyWithMouseEvent += new ModifyWithMouseDelegate(ModifyStartAngleWithMouse); startAngle.SetHotspotPosition(dimension.GetPoint(1)); endAngle = new GeoVectorProperty("Dimension.Endangle", Frame, true); endAngle.GetGeoVectorEvent += new CADability.UserInterface.GeoVectorProperty.GetGeoVectorDelegate(OnGetEndAngle); endAngle.SetGeoVectorEvent += new CADability.UserInterface.GeoVectorProperty.SetGeoVectorDelegate(OnSetEndAngle); endAngle.ModifyWithMouseEvent += new ModifyWithMouseDelegate(ModifyEndAngleWithMouse); endAngle.SetHotspotPosition(dimension.GetPoint(2)); startAngleHotSpot = new GeoVectorHotSpot(startAngle); endAngleHotSpot = new GeoVectorHotSpot(endAngle); } dimLineRef = new GeoPointProperty("Dimension.DimLineRef", Frame, true); dimLineRef.GetGeoPointEvent += new CADability.UserInterface.GeoPointProperty.GetGeoPointDelegate(OnGetDimLineRef); dimLineRef.SetGeoPointEvent += new CADability.UserInterface.GeoPointProperty.SetGeoPointDelegate(OnSetDimLineRef); dimLineRef.ModifyWithMouseEvent += new ModifyWithMouseDelegate(ModifyDimLineRef); dimLineRef.PropertyEntryChangedStateEvent += new PropertyEntryChangedStateDelegate(OnStateChanged); // die String Eingabefelder: int numprop = 1; if (dimension.DimType == Dimension.EDimType.DimPoints || dimension.DimType == Dimension.EDimType.DimCoord) { numprop = dimension.PointCount - 1; } textPosHotSpot = new DoubleHotSpot[numprop]; textPos = new DoubleProperty[numprop]; dimText = new StringProperty[numprop]; tolPlusText = new StringProperty[numprop]; tolMinusText = new StringProperty[numprop]; prefix = new StringProperty[numprop]; postfix = new StringProperty[numprop]; postfixAlt = new StringProperty[numprop]; for (int i = 0; i < numprop; ++i) { textPos[i] = new DoubleProperty("Dimension.TextPos", Frame); textPos[i].UserData.Add("Index", i); textPos[i].GetDoubleEvent += new CADability.UserInterface.DoubleProperty.GetDoubleDelegate(OnGetTextPos); textPos[i].SetDoubleEvent += new CADability.UserInterface.DoubleProperty.SetDoubleDelegate(OnSetTextPos); textPos[i].DoubleChanged(); textPos[i].ModifyWithMouseEvent += new ModifyWithMouseDelegate(ModifyTextPosWithMouse); textPos[i].PropertyEntryChangedStateEvent += new PropertyEntryChangedStateDelegate(OnStateChanged); textPosHotSpot[i] = new DoubleHotSpot(textPos[i]); textPosHotSpot[i].Position = dimension.GetTextPosCoordinate(i, Frame.ActiveView.Projection); dimText[i] = new StringProperty(dimension.GetDimText(i), "Dimension.DimText"); dimText[i].UserData.Add("Index", i); dimText[i].SetStringEvent += new CADability.UserInterface.StringProperty.SetStringDelegate(OnSetDimText); dimText[i].GetStringEvent += new CADability.UserInterface.StringProperty.GetStringDelegate(OnGetDimText); tolPlusText[i] = new StringProperty(dimension.GetTolPlusText(i), "Dimension.TolPlusText"); tolPlusText[i].UserData.Add("Index", i); tolPlusText[i].SetStringEvent += new CADability.UserInterface.StringProperty.SetStringDelegate(OnSetTolPlusText); tolPlusText[i].GetStringEvent += new CADability.UserInterface.StringProperty.GetStringDelegate(OnGetTolPlusText); tolMinusText[i] = new StringProperty(dimension.GetTolMinusText(i), "Dimension.TolMinusText"); tolMinusText[i].UserData.Add("Index", i); tolMinusText[i].SetStringEvent += new CADability.UserInterface.StringProperty.SetStringDelegate(OnSetTolMinusText); tolMinusText[i].GetStringEvent += new CADability.UserInterface.StringProperty.GetStringDelegate(OnGetTolMinusText); prefix[i] = new StringProperty(dimension.GetPrefix(i), "Dimension.Prefix"); prefix[i].UserData.Add("Index", i); prefix[i].SetStringEvent += new CADability.UserInterface.StringProperty.SetStringDelegate(OnSetPrefix); prefix[i].GetStringEvent += new CADability.UserInterface.StringProperty.GetStringDelegate(OnGetPrefix); postfix[i] = new StringProperty(dimension.GetPostfix(i), "Dimension.Postfix"); postfix[i].UserData.Add("Index", i); postfix[i].SetStringEvent += new CADability.UserInterface.StringProperty.SetStringDelegate(OnSetPostfix); postfix[i].GetStringEvent += new CADability.UserInterface.StringProperty.GetStringDelegate(OnGetPostfix); postfixAlt[i] = new StringProperty(dimension.GetPostfixAlt(i), "Dimension.PostfixAlt"); postfixAlt[i].UserData.Add("Index", i); postfixAlt[i].SetStringEvent += new CADability.UserInterface.StringProperty.SetStringDelegate(OnSetPostfixAlt); postfixAlt[i].GetStringEvent += new CADability.UserInterface.StringProperty.GetStringDelegate(OnGetPostfixAlt); } }
private void OnSetTextPos(DoubleProperty sender, double l) { int ind = (int)sender.UserData.GetData("Index"); dimension.SetTextPos(ind, l); }
private double OnGetTextPos(DoubleProperty sender) { int ind = (int)sender.UserData.GetData("Index"); return(dimension.GetTextPos(ind)); }
/// <summary> /// Constructs a hotspot to manipulate a double property /// </summary> /// <param name="doubleProperty">the property to be manipulated</param> public DoubleHotSpot(DoubleProperty doubleProperty) { this.doubleProperty = doubleProperty; }