public override bool duplicateElement(DataControl dataControl) { if (!(dataControl is ActiveAreaDataControl)) { return(false); } ActiveArea newElement = (ActiveArea)(((ActiveArea)(dataControl.getContent())).Clone()); string id; int i = 1; do { id = getDefaultId(0) + i; i++; } while (!controller.isElementIdValid(id, false)); newElement.setId(id); activeAreasList.Add(newElement); activeAreasDataControlList.Add(new ActiveAreaDataControl(sceneDataControl, newElement)); controller.IdentifierSummary.addId <ActiveArea>(id); Controller.Instance.updateVarFlagSummary(); Controller.Instance.DataModified(); return(true); }
public override string renameElement(string name) { bool elementRenamed = false; string oldSceneId = activeArea.getId(); string references = controller.countIdentifierReferences(oldSceneId).ToString(); // Ask for confirmation if (name != null || controller.showStrictConfirmDialog(TC.get("Operation.RenameSceneTitle"), TC.get("Operation.RenameElementWarning", new string[] { oldSceneId, references }))) { // Show a dialog asking for the new scene id string newSceneId = name; if (name == null) { newSceneId = controller.showInputDialog(TC.get("Operation.RenameSceneTitle"), TC.get("Operation.RenameSceneMessage"), oldSceneId); } // If some value was typed and the identifiers are different if (newSceneId != null && !newSceneId.Equals(oldSceneId) && controller.isElementIdValid(newSceneId)) { activeArea.setId(newSceneId); controller.replaceIdentifierReferences(oldSceneId, newSceneId); controller.getIdentifierSummary().deleteActiveAreaId(oldSceneId); controller.getIdentifierSummary().addActiveAreaId(newSceneId); //controller.dataModified( ); elementRenamed = true; } } if (elementRenamed) { return(oldSceneId); } return(null); }
public object Clone() { ActiveArea aa = (ActiveArea)base.Clone(); //can not be two identical id string id = aa.getId() + "-" + (new System.Random().Next(1000).ToString()); aa.setId(id); aa.conditions = (conditions != null ? (Conditions)conditions.Clone() : null); aa.height = height; aa.width = width; aa.x = x; aa.y = y; aa.influenceArea = (influenceArea != null ? (InfluenceArea)influenceArea.Clone() : null); aa.rectangular = rectangular; aa.Vector2s = (Vector2s != null ? new List <Vector2>() : null); foreach (Vector2 p in Vector2s) { aa.Vector2s.Add(new Vector2(p.x, p.y)); } return(aa); }