public Overlay ToOverlay(int maxX, int maxY, string directory) { Overlay overlay; if (!string.IsNullOrWhiteSpace(Path)) { overlay = Type == "flag" ? OverlayFactory.GetFlagInstance(Path, maxX, maxY) : OverlayFactory.GetImageInstance(Path, directory, maxX, maxY); } else { overlay = OverlayFactory.GetInstance(Type, maxX, maxY); } if (overlay == null) { return(null); } overlay.SetColor(Color); overlay.SetValues(Values); var path = overlay as OverlayPath; if (path != null) { path.StrokeColor = StrokeColor; } return(overlay); }
private void Clone(object sender, EventArgs e) { var controlToClone = (OverlayControl)sender; int index = _lstOverlays.Children.IndexOf(controlToClone); var type = controlToClone.Overlay.GetType(); var copy = OverlayFactory.GetInstance(type, 1, 1, controlToClone.Overlay.Name); for (int i = 0; i < controlToClone.Overlay.Attributes.Count; i++) { copy.Attributes[i].Value = controlToClone.Overlay.Attributes[i].Value; copy.Attributes[i].IsDiscrete = controlToClone.Overlay.Attributes[i].IsDiscrete; } copy.SetColor(controlToClone.Overlay.Color); if (type == typeof(OverlayPath) || type.IsSubclassOf(typeof(OverlayPath))) { ((OverlayPath)copy).StrokeColor = ((OverlayPath)controlToClone.Overlay).StrokeColor; } else if (type == typeof(OverlayFlag)) { ((OverlayFlag)copy).Flag = ((OverlayFlag)controlToClone.Overlay).Flag; } var gridSize = ((Ratio)_cmbGridSize.SelectedItem); copy.SetMaximum(gridSize.Width, gridSize.Height); OverlayAdd(index + 1, copy, true); }