private void GDIPathSegmentTypeHasChanged() { GDIPathSegmentTypeName segmentName = _GDI.Paths[_selectedPathIndex.Value].Segments[_selectedSegmentIndex.Value].SegmentType; _GDI.Paths[_selectedPathIndex.Value].Segments[_selectedSegmentIndex.Value] = GetGDIPathSegmentInstance(segmentName); switch (segmentName) { case GDIPathSegmentTypeName.Arc: gdiControlGrid.SelectedObject = (Arc)_GDI.Paths[_selectedPathIndex.Value].Segments[_selectedSegmentIndex.Value]; break; case GDIPathSegmentTypeName.CubicBezier: gdiControlGrid.SelectedObject = (CubicBezier)_GDI.Paths[_selectedPathIndex.Value].Segments[_selectedSegmentIndex.Value]; break; case GDIPathSegmentTypeName.Lines: gdiControlGrid.SelectedObject = (Lines)_GDI.Paths[_selectedPathIndex.Value].Segments[_selectedSegmentIndex.Value]; break; case GDIPathSegmentTypeName.Polygon: gdiControlGrid.SelectedObject = (Polygon)_GDI.Paths[_selectedPathIndex.Value].Segments[_selectedSegmentIndex.Value]; break; } }
private static NSegment GetGDIPathSegmentInstance(GDIPathSegmentTypeName segmentName) { string typeName = "NShapeCreator." + Enum.GetName(typeof(GDIPathSegmentTypeName), segmentName); return((NSegment)Assembly.GetExecutingAssembly().CreateInstance(typeName)); }