override internal ICutViewState visitPaste2Normal(PasteState pasteState) { var normalState = new NormalState(); normalState.Operation = "Select a node to cut"; normalState.HiddenStatus = "Choices"; normalState.selectedItem = pasteState.selectedItem; normalState.StateText = "Selected: " + normalState.selectedItem.Name; return(normalState); }
override internal ICutViewState visitCut2Paste(CutState cutState) { if (cutState.selectedItem.Name.Equals(cutState.cutFrom)) { cutState.StateText = "Selected: " + cutState.selectedItem.Name; return(cutState); } var pasteState = new PasteState(); pasteState.selectedItem = cutState.selectedItem; pasteState.operation = cutState.operation; pasteState.pasteTo = cutState.selectedItem.Name; if (cutState.fromParent != null) { var foundFrom = cutState.fromParent.TreeItems.First(t => t.Name.Equals(cutState.cutFrom)); if (foundFrom == null) { cutState.StateText = "Error! From " + cutState.cutFrom + " to " + pasteState.pasteTo; return(cutState); } else { var checkParent = pasteState.selectedItem.parent; bool checkCyclic = false; while (checkParent != null) { if (foundFrom.Name.Equals(checkParent.Name)) { checkCyclic = true; break; } checkParent = checkParent.parent; } if (checkCyclic) { cutState.StateText = "Cyclic Reference! From " + cutState.cutFrom + " to " + pasteState.pasteTo; return(cutState); } cutState.fromParent.TreeItems.Remove(foundFrom); pasteState.selectedItem.TreeItems.Add(foundFrom); foundFrom.parent = cutState.selectedItem; pasteState.Operation = "Done! From " + cutState.cutFrom + " to " + pasteState.pasteTo; } } else { cutState.StateText = "Error! From " + cutState.cutFrom + " to " + pasteState.pasteTo; return(cutState); } pasteState.StateText = "Selected: " + pasteState.selectedItem.Name; return(pasteState); }
internal abstract A visitPaste2Normal(PasteState pasteState);