internal void AddValueInPosition(XName name, XElement parentElement, bool addToExisting, object value, XmlSchemaDatatype datatype) { NamedContentModelEntity namedEntity = GetNamedEntity(name); if (namedEntity == null) { throw new LinqToXsdException("Name does not belong in content model. Cannot set value for child " + namedEntity.Name); } EditAction editAction = EditAction.None; XElement elementMarker = FindElementPosition(namedEntity, parentElement, addToExisting, out editAction); Debug.Assert(datatype != null); //Simple typed value add or set switch (editAction) { case EditAction.Append: parentElement.Add(new XElement(name, XTypedServices.GetXmlString(value, datatype, parentElement))); break; case EditAction.Update: Debug.Assert(elementMarker != null); elementMarker.Value = XTypedServices.GetXmlString(value, datatype, elementMarker); break; case EditAction.AddBefore: Debug.Assert(elementMarker != null); elementMarker.AddBeforeSelf(new XElement(name, XTypedServices.GetXmlString(value, datatype, elementMarker))); break; default: throw new InvalidOperationException(); } }
private void panBegan(CGPoint point) { if (!isActive) { return; } allItemsStartAndEndTime = dataSource.AllItemsStartAndEndTime(); firstPoint = point; LastPoint = point; var cell = CollectionView.CellForItem(itemIndexPath) as CalendarItemView; var topDragRect = CollectionView.ConvertRectFromView(cell.TopDragTouchArea, cell); var bottomDragRect = CollectionView.ConvertRectFromView(cell.BottomDragTouchArea, cell); if (topDragRect.Contains(point)) { action = EditAction.ChangeStartTime; } else if (bottomDragRect.Contains(point)) { action = EditAction.ChangeEndTime; } else if (cell.Frame.Contains(point)) { action = EditAction.ChangeOffset; } else { action = EditAction.None; } selectionFeedback.Prepare(); }
/// <summary> /// Runs the remove action on <see cref="Instance"/> defined by given variable. /// </summary> /// <param name="variable">The variable.</param> /// <returns>TestingAssembly.</returns> public TestingAssembly RunRemoveAction(string variable) { var editAction = EditAction.Remove(new VariableName(variable)); _editActions.Add(editAction); return(this); }
public override void Merge(EditAction action) { SplitterAction splitter = action as SplitterAction; this.splitTags = splitter.SplitTags; this.chop = splitter.Chop; }
public override void Setup(EditAction action, bool first) { var playAnimAction = action as EditActionPlayAnimation; actionText.text = action.ToString(); labelText.text = first ? "Then" : "And"; if (this.dieRenderer == null) { var design = DesignAndColor.V5_Grey; if (playAnimAction.animation != null) { design = playAnimAction.animation.defaultPreviewSettings.design; } this.dieRenderer = DiceRendererManager.Instance.CreateDiceRenderer(design, 160); if (dieRenderer != null) { dieRenderImage.texture = dieRenderer.renderTexture; } dieRenderer.SetAuto(true); } if (dieRenderer != null && playAnimAction.animation != null) { dieRenderer.SetAnimation(playAnimAction.animation); dieRenderer.Play(true); } }
public override bool CanMerge(EditAction action) { InsertAction insert = action as InsertAction; if (insert == null) { return(false); } // Don't group text pastes if (is_paste || insert.is_paste) { return(false); } // Must meet each other if (insert.index != index + chop.Length) { return(false); } // Don't group more than one line (inclusive) if (chop.Text [0] == '\n') { return(false); } // Don't group more than one word (exclusive) if (insert.chop.Text [0] == ' ' || insert.chop.Text [0] == '\t') { return(false); } return(true); }
internal void AddElementInPosition(XName name, XElement parentElement, bool addToExisting, XTypedElement xObj) { NamedContentModelEntity namedEntity = GetNamedEntity(name); if (namedEntity == null) { // See http://linqtoxsd.codeplex.com/WorkItem/View.aspx?WorkItemId=3542 throw new LinqToXsdException( "Name does not belong in content model. Cannot set value for child " + name.LocalName); } EditAction editAction = EditAction.None; XElement elementMarker = FindElementPosition(namedEntity, parentElement, addToExisting, out editAction); XElement newElement = XTypedServices.GetXElement(xObj, name); Debug.Assert(xObj != null); switch (editAction) { case EditAction.Append: parentElement.Add(newElement); break; case EditAction.Update: elementMarker.AddBeforeSelf(newElement); elementMarker.Remove(); break; case EditAction.AddBefore: elementMarker.AddBeforeSelf(newElement); break; } }
public ActionResult Save(EditAction editedAction) { ActionInCampaignRecord action; if (editedAction.Id != 0) { action = _actionRepository.Get(a => a.Id == editedAction.Id); if (action == null) { return(Index()); } } else { action = new ActionInCampaignRecord(); if (settingsPart.DefaultCampaign != null) { action.CampaignId = settingsPart.DefaultCampaign; } _actionRepository.Create(action); } action.Action = editedAction.Action; action.CampaignId = editedAction.CampaignId; action.Provider = editedAction.Provider; action.Points = editedAction.Points; return(Index()); }
public EditKommando(EditAction aktion, ElementTyp elementTyp, AnlagenElemente anlagenElemente, object value) { _aktion = aktion; _elementTyp = elementTyp; _neuerWert = value; _anlagenElemente = anlagenElemente; }
public override void Merge (EditAction action) { InsertAction insert = (InsertAction) action; chop.End = insert.Chop.End; insert.chop.Destroy (); }
public void DeleteFrame(int frameNumber) { if (Frames is null) { throw new InvalidOperationException(); } if (Frames.Count <= 1) { throw new AptEditorException(ErrorType.PlayableMustHaveAtLeastOneFrame); } // if it's last frame, switch to the previous frame first var nextFrame = frameNumber == Frames.Count - 1 ? Frames.Count - 1 : frameNumber; _manager !.PlayToFrame(nextFrame); var frameToBeRemoved = Frames[frameNumber]; var editAction = new EditAction(() => Frames.RemoveAt(frameNumber), () => Frames.Insert(frameNumber, frameToBeRemoved), "Remove frame"); _manager.AptManager !.Edit(editAction); }
/// <summary> /// Runs the edit action on <see cref="Instance"/> defined by given variable. /// </summary> /// <param name="variable">The variable.</param> /// <param name="editName">Name of the edit.</param> /// <returns>TestingAssembly.</returns> public TestingAssembly RunEditAction(string variable, string editName) { var editAction = EditAction.Edit(new VariableName(variable), editName); _editActions.Add(editAction); return(this); }
//new distribur public DistributorEditInput(string name, string description, EditAction editAction) { this.DistributorId = null; this.Name = name; this.Description = description; this.EditAction = editAction; }
public void AddUndoAction(EditAction action) { if (try_merge && undo_stack.Count > 0) { EditAction top = undo_stack.Peek(); if (top.CanMerge(action)) { // Merging object should handle freeing // action's resources, if needed. top.Merge(action); return; } } undo_stack.Push(action); // Clear the redo stack ClearActionStack(redo_stack); // Try to merge new incoming actions... try_merge = true; // Have undoable actions now if (undo_stack.Count == 1) { if (UndoChanged != null) { UndoChanged(this, new EventArgs()); } } }
void UndoRedo(Stack <EditAction> pop_from, Stack <EditAction> push_to, bool is_undo) { if (pop_from.Count > 0) { EditAction action = (EditAction)pop_from.Pop(); FreezeUndo(); if (is_undo) { action.Undo(buffer); } else { action.Redo(buffer); } ThawUndo(); push_to.Push(action); // Lock merges until a new undoable event comes in... try_merge = false; if (pop_from.Count == 0 || push_to.Count == 1) { if (UndoChanged != null) { UndoChanged(this, new EventArgs()); } } } }
public override void Merge(EditAction action) { EraseAction erase = (EraseAction)action; if (start == erase.start) { end += erase.end - erase.start; chop.End = erase.chop.End; // Delete the marks, leave the text erase.chop.Destroy(); } else { start = erase.start; Gtk.TextIter chop_start = chop.Start; chop.Buffer.InsertRange(ref chop_start, erase.chop.Start, erase.chop.End); // Delete the marks and text erase.Destroy(); } }
/// <summary> /// This method is called if the map decided that this layer should handle /// this mouse click /// </summary> /// <param name="e">the mouse event arg that describe the click</param> /// <returns>true if the view should be refreshed</returns> public override bool mouseDown(MouseEventArgs e, PointF mouseCoordInStud) { mMouseIsBetweenDownAndUpEvent = true; bool mustRefresh = false; if (e.Button == MouseButtons.Left) { // if finally we are called to handle this mouse down, // we add the cell under the mouse if the selection list is empty if ((mCurrentTextCellUnderMouse != null) && (mEditAction != EditAction.DUPLICATE_SELECTION)) { // if the selection is empty add the text cell, else check the control key state if ((mSelectedObjects.Count == 0) && (Control.ModifierKeys != BlueBrick.Properties.Settings.Default.MouseMultipleSelectionKey)) { addObjectInSelection(mCurrentTextCellUnderMouse); } mustRefresh = true; } // record the initial position of the mouse mMouseDownInitialPosition = mouseCoordInStud; mMouseDownLastPosition = mouseCoordInStud; mMouseHasMoved = false; } else if (e.Button == MouseButtons.Right) { // cancel button down if (mEditAction == EditAction.DUPLICATE_SELECTION) { // undo the duplicate action and clear it if (mLastDuplicateAction != null) { mLastDuplicateAction.undo(); } mLastDuplicateAction = null; } else if (mEditAction == EditAction.MOVE_SELECTION) { // compute the delta mouve of the mouse PointF deltaMove = new PointF(mouseCoordInStud.X - mMouseDownInitialPosition.X, mouseCoordInStud.Y - mMouseDownInitialPosition.Y); if ((deltaMove.X != 0) || (deltaMove.Y != 0)) { // reset the initial position to each text foreach (LayerText.TextCell cell in mSelectedObjects) { cell.Position = new PointF(cell.Position.X - deltaMove.X, cell.Position.Y - deltaMove.Y); } // reset the bounding rectangle this.updateBoundingSelectionRectangle(); } } mEditAction = EditAction.NONE; mCurrentTextCellUnderMouse = null; mustRefresh = true; } return(mustRefresh); }
public override void Merge(EditAction action) { InsertAction insert = (InsertAction)action; chop.End = insert.Chop.End; insert.chop.Destroy(); }
public LinkNode(int x, int y, EditAction action, LinkNode previous) { X = x; Y = y; Action = action; Previous = previous; Count = previous.Count + 1; }
public void RemoveGeometry(int key) { var uKey = (uint)key; var oldGeometry = Geometries[uKey]; var edit = new EditAction(() => Geometries.Remove(uKey), () => Geometries.Add(uKey, oldGeometry)); Manager.Edit(edit); }
public void AddGeometry(int key) { var uKey = (uint)key; var newGeometry = GetGeometry(string.Empty); var edit = new EditAction(() => Geometries.Add(uKey, newGeometry), () => Geometries.Remove(uKey)); Manager.Edit(edit); }
public static void SaveState(EditAction action, List <FrameInfo> frames, List <int> removeList, List <int> alterList) { if (action != EditAction.RemoveAndAlter) { throw new ArgumentException("Parameters different than RemoveAndAlter are not supported.", nameof(action)); } if (!ShouldSaveState()) { return; } var savedFrames = new List <FrameInfo>(); var currentFolder = CreateCurrent(true); #region Removed //Saves the frames that will be deleted (using the given list of positions). foreach (var position in removeList) { var frame = frames[position]; var savedFrame = Path.Combine(currentFolder, Path.GetFileName(frame.Path)); //Copy to a folder. File.Copy(frame.Path, savedFrame); savedFrames.Add(new FrameInfo(savedFrame, frame.Delay, frame.CursorX, frame.CursorY, frame.WasClicked, frame.KeyList, frame.Index)); } #endregion #region Altered //Saves the frames that will be altered, without copying the images (using the given list of positions). foreach (var position in alterList) { var frame = frames[position]; savedFrames.Add(new FrameInfo(frame.Path, frame.Delay, frame.CursorX, frame.CursorY, frame.WasClicked, frame.KeyList, frame.Index)); } #endregion UndoStack.Push(new StateChange { Cause = action, Frames = savedFrames, CurrentFolder = currentFolder, //Ignore this property when frame is set as "Altered". Indexes = removeList, Indexes2 = alterList, }); ClearRedo(); TrimUndo(); }
public void SetShapeGeometry(int shapeIndex, int geometryId) { var shape = (Shape)GetCharacterByIndex(shapeIndex); var current = shape.Geometry; var edit = new EditAction(() => shape.Modify((uint)geometryId), () => shape.Modify(current), "Set Shape Geometry"); edit.OnEdit += InvalidateCache; Manager.Edit(edit); }
private void SetEditAction(EditAction action) { editAction = action; lineStartPoint = null; linkObject = null; selection.Clear(); ActionMovePointsBtn.Checked = action == EditAction.ActionMovePoints; ActionAddPointsBtn.Checked = action == EditAction.ActionAddPoints; ActionAddLinesBtn.Checked = action == EditAction.ActionAddLines; }
static EditAction[] BuildResult(LinkNode node) { int c = node.Count; var result = new EditAction[c]; while (c > 0) { result[--c] = node.Action; node = node.Previous; } return(result); }
public void CancelExport(int index) { var exports = Manager.AptFile.Movie.Exports; var exportIndex = exports.FindIndex(e => e.Character == index); var export = exports[exportIndex]; var edit = new EditAction(() => exports.RemoveAt(exportIndex), () => exports.Insert(exportIndex, export), "Cancel Export"); edit.OnEdit += InvalidateCache; Manager.Edit(edit); }
/// <summary> /// Save the state of the list of frames. This overload is used by the EditAction.Reorder. /// </summary> /// <param name="action">The action, currently just the Reorder.</param> /// <param name="frames">The old (current) list of frames.</param> public static void SaveState(EditAction action, List <FrameInfo> frames) { //Saves the frames before the reordering. UndoStack.Push(new StateChange { Cause = action, Frames = frames, }); //Clear the Redo stack. ClearRedo(); }
/// <summary> /// Save the state of the list of frames. This overload is used by the EditAction.Add. /// </summary> /// <param name="action">The action, currently just the Add.</param> /// <param name="position">The position where the frames will be inserted.</param> /// <param name="quantity">The quantity of inserted frames.</param> public static void SaveState(EditAction action, int position, int quantity) { //Saves the position where the new frames will be inserted. UndoStack.Push(new StateChange { Cause = action, Indexes = Util.Other.CreateIndexList2(position, quantity) }); //Clear the Redo stack. ClearRedo(); }
public void On_ClearAllToolButton_Click() { wasClearAll = true; wasUndo = false; lastEditAction = EditAction.ClearAll; lastDeletedTiles.Clear(); lastDeletedTiles.AddRange(tilesPlaced);//initialize with values and not with pointer for (int i = 0; i < tilesPlaced.Count; i++) { Destroy(tilesPlaced[i].TileGameObject); } tilesPlaced.Clear(); }
/* * The internal listeners will create an InsertAction when the text * is inserted. Since it's ugly to have the bug insertion appear * to the user as two items in the undo stack, have this item eat * the other one. */ public override bool CanMerge (EditAction action) { InsertAction insert = action as InsertAction; if (insert == null) { return false; } if (String.Compare(Id, insert.Chop.Text) == 0) { return true; } return false; }
private void Edit() { Cursor.Current = Cursors.WaitCursor; try { EditAction action = new EditAction(solutionsTree, solutionsCheckedListBox.SelectedSolutionNode, m_edit, Edit); UndoRedoManager.Instance.SaveAndExecute(action); } finally { Cursor.Current = Cursors.Default; } }
public void AppendFrame() { if (Frames is null) { throw new InvalidOperationException(); } var newFrame = Frame.Create(new List <FrameItem>()); var editAction = new EditAction(() => Frames.Add(newFrame), () => Frames.RemoveAt(Frames.Count - 1), "Add new frame"); _manager !.AptManager !.Edit(editAction); }
public override bool CanMerge (EditAction action) { InsertAction insert = action as InsertAction; if (insert == null) return false; // Don't group text pastes if (is_paste || insert.is_paste) return false; // Must meet each other if (insert.index != index + chop.Length) return false; // Don't group more than one line (inclusive) if (chop.Text [0] == '\n') return false; // Don't group more than one word (exclusive) if (insert.chop.Text [0] == ' ' || insert.chop.Text [0] == '\t') return false; return true; }
public void Clear() { initialMousePos = Geometry.InvalidPoint; action = EditAction.None; pasteCount = 0; shapes.Clear(); connections.Clear(); }
public override void Merge (EditAction action) { SplitterAction splitter = action as SplitterAction; this.splitTags = splitter.SplitTags; this.chop = splitter.Chop; }
private static bool OnTileEdit(TSPlayer ply, int x, int y, EditAction action, EditType editDetail, short editData, byte style) { if (TileEdit == null) return false; var args = new TileEditEventArgs { Player = ply, X = x, Y = y, Action = action, EditData = editData, editDetail = editDetail, Style = style }; TileEdit.Invoke(null, args); return args.Handled; }
public void AddUndoAction (EditAction action) { if (try_merge && undo_stack.Count > 0) { EditAction top = (EditAction) undo_stack.Peek (); if (top.CanMerge (action)) { // Merging object should handle freeing // action's resources if needed. top.Merge (action); return; } } undo_stack.Push (action); // Clear the redo stack ClearActionStack (redo_stack); // Try to merge new incoming actions try_merge = true; // Have undoable actions now if (undo_stack.Count == 1) { if (UndoChanged != null) { UndoChanged (this, new EventArgs ()); } } }
internal XElement FindElementPosition(NamedContentModelEntity namedEntity, XElement parentElement, bool addToExisting, out EditAction editAction) { Debug.Assert(namedEntity != null); editAction = EditAction.None; int newElementPos = namedEntity.ElementPosition; XElement lastElement = GetLastElement(parentElement); if (lastElement != null) { //Optimization to check last first int lastElementPos = GetNamedEntity(lastElement.Name).ElementPosition; if (newElementPos == lastElementPos) { if (addToExisting) { editAction = EditAction.Append; } else { editAction = EditAction.Update; } return lastElement; } if (newElementPos > lastElementPos) { //We need to add the new element at the end editAction = EditAction.Append; return lastElement; } } int instanceElementPos = -1; XElement instanceElem = null; IEnumerator<XElement> enumerator = parentElement.Elements().GetEnumerator(); while(enumerator.MoveNext()) { instanceElem = enumerator.Current; instanceElementPos = GetElementPosition(instanceElem.Name); if (instanceElementPos == newElementPos) { if (!addToExisting) { //Matching element found for update editAction = EditAction.Update; return instanceElem; } } else if (instanceElementPos > newElementPos) { //Found first element greater than new position editAction = EditAction.AddBefore; return instanceElem; } } //Either its the first element being added or Scanned the whole list, end of list reached editAction = EditAction.Append; return instanceElem; }
public bool CanMerge(EditAction action) { return false; }
public void Merge(EditAction action) { throw new Exception ("InsertImageAction cannot be merged"); }
public void Merge (EditAction action) { throw new Exception ("TagRemoveActions cannot be merged"); }
public override void Merge (EditAction action) { EraseAction erase = (EraseAction) action; if (start == erase.start) { end += erase.end - erase.start; chop.End = erase.chop.End; // Delete the marks, leave the text erase.chop.Destroy (); } else { start = erase.start; TextIter chopStart = chop.Start; chop.Buffer.InsertRange (ref chopStart, erase.chop.Start, erase.chop.End); // Delete the marks and text erase.Destroy (); } }
public void Merge (EditAction action) { throw new Exception ("InsertBulletActions cannot be merged"); }
public void Merge (EditAction action) { throw new Exception ("ChangeDepthActions cannot be merged"); }
public EditBuffer() { action = EditAction.None; initialMousePos = Geometry.InvalidPoint; pasteCount = 0; shapes = new ShapeCollection(); connections = new List<ShapeConnection>(); }
internal void ValidateDeletedState(string del, TextSelInfo tsiInitial, EditAction action) { int ichInsertionPointInitial = Math.Min(tsiInitial.IchAnchor, tsiInitial.IchEnd); TextSelInfo tsiAfterEdit = this.CurrentSelectionInfo; Assert.AreEqual(tsiInitial.AnchorLength - del.Length, tsiAfterEdit.AnchorLength); if (action == EditAction.Backspace) { // check our cursor has retreated Assert.AreEqual(ichInsertionPointInitial - del.Length, tsiAfterEdit.IchAnchor); } else if (action == EditAction.Delete) { // check our cursor is in the same location Assert.AreEqual(ichInsertionPointInitial, tsiAfterEdit.IchAnchor, "Expected same cursor position on a delete."); } // now validate against expected annotations. ValidateStTextAnnotations(tsiInitial.HvoAnchor); }
public abstract bool CanMerge (EditAction action);
public abstract void Merge (EditAction action);
public override bool CanMerge (EditAction action) { EraseAction erase = action as EraseAction; if (erase == null) return false; // Don't group separate text cuts if (is_cut || erase.is_cut) return false; // Must meet eachother if (start != (is_forward ? erase.start : erase.end)) return false; // Don't group deletes with backspaces if (is_forward != erase.is_forward) return false; // Group if something other than text was deleted // (e.g. an email image) if (chop.Text.Length == 0 || erase.chop.Text.Length == 0) return true; // Don't group more than one line (inclusive) if (chop.Text[0] == '\n') return false; // Don't group more than one word (exclusive) if (erase.chop.Text[0] == ' ' || erase.chop.Text[0] == '\t') return false; return true; }