protected void SetValue(object model, object value, string propName) { UndoRedoPropertyItem propItem = new UndoRedoPropertyItem(); propItem.ModelObject = model; propItem.PropertyStr = propName; propItem.NewValue = value; propItem.DoCommand(); UndoRedoSystem.AddToUndoStack(propItem); }
// start void Start() { // if the name is blank. if (entityName == "") { string str = ""; const int CHAR_COUNT = 10; // uses 10 characters for the name for (int x = 0; x < CHAR_COUNT; x++) { // determines whether a number or letter is being used. int y = Random.Range(0, 2); switch (y) { case 0: // add number str += Random.Range(0, 10); break; case 1: // add letter default: str += (char)(Random.Range(65, 123)); break; } } entityName = str; } // leave them seperate // transform.name = name; // copies the transform infinitely preTransform.entity = gameObject; preTransform.type = 1; preTransform.active = gameObject.activeSelf; preTransform.position = transform.position; preTransform.rotation = transform.rotation; preTransform.localScale = transform.localScale; // object was created this iteration. UndoRedoSystem.RecordAction(preTransform); // preTransform.type = 0; // BinaryFormatter converter = new BinaryFormatter(); // MemoryStream mStream = new MemoryStream(); // // converter.Serialize(mStream, entity); // return mStream.ToArray(); // UndoRedoSystem.RecordObject(this, name); // UndoRedoSystem.RegisterCreatedObject(this, name); }
protected void SetValue(object model, object value, Action command = null, [CallerMemberName] string propName = null) { UndoRedoPropertyItem propItem = new UndoRedoPropertyItem(); propItem.ModelObject = model; propItem.PropertyStr = propName; propItem.NewValue = value; propItem.Command = command; propItem.DoCommand(); UndoRedoSystem.AddToUndoStack(propItem); }
private void RaiseKeyDown(KeyEventArgs e) { if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { if (e.Key == Key.Z) { UndoRedoSystem.Undo(); } else if (e.Key == Key.Y) { UndoRedoSystem.Redo(); } } }
public Form1() { InitializeComponent(); ActiveTool = Tool.Pencil; SetDoubleBuffered(this.levelRenderer); undoRedoSystem = new UndoRedoSystem(); undoRedoSystem.SystemChanged += UndoRedoSystemChanged; UndoRedoSystemChanged(null, EventArgs.Empty); Project = new Starbound.RealmFactory.DataModel.Project(); SetupFileReaders(); }
protected void SetValueMulti(object model, params Tuple <object, string>[] props) { UndoRedoMultiPropertyItem multiPropItem = new UndoRedoMultiPropertyItem(); foreach (Tuple <object, string> prop in props) { UndoRedoPropertyItem propItem = new UndoRedoPropertyItem(); propItem.ModelObject = model; propItem.PropertyStr = prop.Item2; propItem.NewValue = prop.Item1; multiPropItem.Properties.Add(propItem); } multiPropItem.DoCommand(); UndoRedoSystem.AddToUndoStack(multiPropItem); }
// update void Update() { // if something has changed. if (preTransform.active != gameObject.activeSelf || preTransform.position != transform.position || preTransform.rotation != transform.rotation || preTransform.localScale != transform.localScale) { UndoRedoSystem.RecordAction(preTransform); // saves new values preTransform.type = 0; // no creation or destruction this frame preTransform.active = gameObject.activeSelf; preTransform.position = transform.position; preTransform.rotation = transform.rotation; preTransform.localScale = transform.localScale; // tform = Instantiate(transform); // makes a copy of the transform } }