private void ExecuteDropMove(object parameter) { var sourceFileSystem = new WindowsFileSystem(droppedFiles.First().FullName); var operation = new MoveOperation(droppedFiles, ActiveView.FullPath, sourceFileSystem, ActiveView.FileSystem); OperationsManager.ExecuteOperation(operation); }
private void MoveNode( Node nodeToMove, Node targetNode, MoveOperation operation ) { var siblings = (NodeCollection)targetNode.Parent.Children; var dropPos = siblings.IndexOf( targetNode ); if ( operation == MoveOperation.MoveAfter ) { dropPos++; } if ( siblings.Contains( nodeToMove ) ) { var oldPos = siblings.IndexOf( nodeToMove ); if ( oldPos < dropPos ) { // ObservableCollection first removes the item and then reinserts which invalidates the index dropPos--; } siblings.Move( oldPos, dropPos ); } else { if ( dropPos < siblings.Count ) { siblings.Insert( dropPos, nodeToMove ); } else { siblings.Add( nodeToMove ); } } IsDirty = true; }
private void DropMove(object sender, RoutedEventArgs e) { MenuItem item = (MenuItem)sender; IDirectoryViewItem[] files = (IDirectoryViewItem[])item.Tag; MoveOperation move = new MoveOperation(files, DisplayPath, new WindowsFileSystem(), FileSystem); //Main.SupportOperation(move); }
public override object ReadJson( JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JArray ja = JArray.Load(reader); var result = new List <IRollbackableOperation>(); foreach (var jsonObject in ja) { var unit = default(IRollbackableOperation); switch (jsonObject["Type"].Value <string>()) { case "AppendAllText": unit = new AppendAllTextOperation( jsonObject["path"].Value <string>(), jsonObject["contents"].Value <string>()); break; case "Copy": unit = new CopyOperation( jsonObject["sourceFileName"].Value <string>(), jsonObject["path"].Value <string>(), jsonObject["overwrite"].Value <bool>()); break; case "CreateFile": unit = new CreateFileOperation( jsonObject["path"].Value <string>()); break; case "Delete": unit = new DeleteFileOperation( jsonObject["path"].Value <string>()); break; case "Move": unit = new MoveOperation( jsonObject["sourceFileName"].Value <string>(), jsonObject["destFileName"].Value <string>()); break; case "WriteAllText": unit = new WriteAllTextOperation( jsonObject["path"].Value <string>(), jsonObject["contents"].Value <string>()); break; } serializer.Populate(jsonObject.CreateReader(), unit); result.Add(unit); } return(result); }
private void MoveFront(MoveOperation move, GameSettingsDto gameSettings) { PositionDto position = GetNewFrontPosition(gameSettings.Turtle); bool isValidMove = position.X >= 0 && position.X <= gameSettings.GameBoard.Width && position.Y >= 0 && position.Y <= gameSettings.GameBoard.Height; if (isValidMove) { gameSettings.Turtle.Position = position; } }
public void MoveTo(string destDir, MoveOperation operation) { if (!isDir) { WindowsFileSystemApi.MoveFile((FileInfo)adapted, new FileInfo(Path.Combine(destDir, Name)), MoveFileOptions.CopyAllowed | MoveFileOptions.ReplaceExisting, operation.MovedPieceOfFile); } else { MoveDirectory((DirectoryInfo)adapted, destDir, operation); } }
public void Receive(MoveOperation moveOperation) { PerformMoveOperationEventArgs performMoveOperationEventArgs = new PerformMoveOperationEventArgs(this, moveOperation); OnPerformMoveOperation?.Invoke(this, performMoveOperationEventArgs); moveOperation.PerformOperation(this); MoveOperationPerformedEventArgs moveOperationPerformedEventArgs = new MoveOperationPerformedEventArgs(this, moveOperation); OnMoveOperationPerformed?.Invoke(this, moveOperationPerformedEventArgs); }
/// <summary> /// Method is moving item from one to another folder. /// </summary> /// <param name="item">Item to move.</param> /// <param name="destinationFolder">Destination folder.</param> /// <param name="moveOperation">Move operation (Copy or Move).</param> internal void MoveItem(Item item, Folder destinationFolder, MoveOperation moveOperation) { //Item itemToMove = Item.Bind(ewsSession, item.Id); switch (moveOperation) { case MoveOperation.Copy: item.Copy(destinationFolder.Id); break; case MoveOperation.Move: item.Move(destinationFolder.Id); break; } }
public override void Execute(object parameter) { var source = MainViewModel.ActiveDirectoryContainer.ActiveView; var dest = MainViewModel.InActiveDirectoryContainer.ActiveView; var items = MainViewModel.GetSelectedItems(); if (items.Length == 0) { MessageBox.Show("Zaznacz obiekty do przeniesienia"); return; } var operation = new MoveOperation(items, dest.FullPath, source.FileSystem, dest.FileSystem); OperationManager.ExecuteOperation(operation); }
private void MoveMethodWindowButton_Click(object sender, RoutedEventArgs e) { var screen = new MoveMethodWindow(); if (screen.ShowDialog() == true) { var action = new MoveOperation() { Args = new MoveArgs() { From = MoveMethodWindow.moveNChars, To = MoveMethodWindow.fromto } }; actions.Add(action.Clone()); } }
private void Move(MoveOperation move, GameSettingsDto gameSettings) { switch (move) { case MoveOperation.M: MoveFront(move, gameSettings); break; case MoveOperation.R: MoveRight(gameSettings); break; case MoveOperation.L: MoveLeft(gameSettings); break; } }
/// <summary> /// Moved directory with content to another place /// </summary> /// <param name="dir">Directory to move</param> /// <param name="destination">Destination path</param> /// <param name="operation">MoveOperation to report progress</param> private void MoveDirectory(DirectoryInfo dir, string destination, MoveOperation operation) { //TODO: Check if is WinAPI function for moving directories string moveDir = Path.Combine(destination, dir.Name); Directory.CreateDirectory(moveDir); foreach (FileInfo file in dir.GetFiles()) { WindowsFileSystemApi.MoveFile(file, new FileInfo(Path.Combine(moveDir, file.Name)), MoveFileOptions.CopyAllowed, operation.MovedPieceOfFile); } foreach (DirectoryInfo di in dir.GetDirectories()) { MoveDirectory(di, moveDir, operation); } dir.Delete(true); }
//悔棋设置 public void SetBack(Button button) { button.Click += (object sender, EventArgs e) => { timer.Enabled = false; if (currentPlayer != Player.None && currentChess != ChessType.None) { model[currentPlayer, currentChess].Live = true; currentPlayer = Player.None; currentChess = ChessType.None; } while (list.Count > 0) { MoveOperation op = list[list.Count - 1]; list.RemoveAt(list.Count - 1); ChessType typeS = op.typeS, typeE = op.typeE; Player playerE = whichPlayer, playerS = (Player)((int)whichPlayer ^ 1); CType tmp = ai.DelPiece(op.end.Y * 9 + op.end.X); model[playerS, typeS].Location = op.start; model[playerS, typeS].Live = true; ai.AddPiece(op.start.Y * 9 + op.start.X, tmp); if (typeE != ChessType.None) { model[playerE, typeE].Location = op.end; model[playerE, typeE].Live = true; int ThisOrThat = tmp >= CType.ThatRook ? 0 : 7; ai.AddPiece(op.end.Y * 9 + op.end.X, ThisOrThat + ChessType2CType(typeE)); } playPos[op.start.X, op.start.Y] = playerS; typePos[op.start.X, op.start.Y] = typeS; playPos[op.end.X, op.end.Y] = typeE == ChessType.None ? Player.None : playerE; typePos[op.end.X, op.end.Y] = typeE; whichPlayer = playerS; ChessEnableSet(whichPlayer); if (whichPlayer != computer) { break; } } list.Clear(); }; }
public override void Execute(object parameter) { var active = MainViewModel.ActiveDirectoryContainer.ActiveView; //get data from clipboard var data = Clipboard.GetDataObject(); //files var paths = (string[])data.GetData(DataFormats.FileDrop, true); if (paths == null) { MessageBox.Show("Schowek jest pusty"); return; } //get flag indicating whether it is copy or cut var stream = (MemoryStream)data.GetData("Preferred DropEffect", true); bool copyFlag = stream.ReadByte() == 5 ? true : false; //change paths into IDirectoryViewItems var items = new IDirectoryViewItem[paths.Length]; for (int i = 0; i < paths.Length; i++) { items[i] = WindowsFile.CreateFromPath(paths[i]); } MultiFileOperation operation; if (copyFlag) { operation = new CopyOperation(items, active.FullPath, new WindowsFileSystem(), active.FileSystem); } else { operation = new MoveOperation(items, active.FullPath, new WindowsFileSystem(), active.FileSystem); } OperationManager.ExecuteOperation(operation); }
private void LoadListMethods_Click(object sender, RoutedEventArgs e) { string text = ""; OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == true) { text = System.IO.File.ReadAllText(openFileDialog.FileName); string[] textpart = text.Split('\n'); int numberofMethods = int.Parse(textpart[0]); for (int i = 1; i <= numberofMethods; i++) { string[] textpartoftextpart = textpart[i].Split(' '); if (textpartoftextpart[0] == "Replace") { var action = new ReplaceOperation() { Args = new ReplaceArgs() { From = textpartoftextpart[1], To = textpartoftextpart[2] } }; actions.Add(action.Clone()); } if (textpartoftextpart[0] == "NewCase") { var action = new NewCaseOperation() { Args = new NewCaseArgs() { From = textpartoftextpart[1], To = textpartoftextpart[2] } }; actions.Add(action.Clone()); } if (textpartoftextpart[0] == "FullNameNormalize") { var action = new FullNameOperation() { Args = new FullNameArgs() { From = textpartoftextpart[1], To = textpartoftextpart[2] } }; actions.Add(action.Clone()); } if (textpartoftextpart[0] == "Move") { var action = new MoveOperation() { Args = new MoveArgs() { From = textpartoftextpart[1], To = textpartoftextpart[2] } }; actions.Add(action.Clone()); } if (textpartoftextpart[0] == "UniqueName") { var action = new UniqueNameOperation() { Args = new UniqueNameArgs() { From = textpartoftextpart[1], To = textpartoftextpart[2] } }; actions.Add(action.Clone()); } } } }
protected abstract void Move(MoveOperation operation, TDoc target);
public void MoveNode( INode nodeToMove, INode targetNode, MoveOperation operation ) { MoveNode( (Node)nodeToMove, (Node)targetNode, operation ); IsDirty = true; }
private void ApplyPatch(int patchIndex, AssetLocation patchSourcefile, JsonPatch jsonPatch, ref int applied, ref int notFound, ref int errorCount) { if (jsonPatch.SideType != EnumAppSide.Universal && jsonPatch.SideType != api.Side) { return; } var path = jsonPatch.File.Path; if (!path.EndsWith(".json")) { path += ".json"; } var asset = api.Assets.TryGet(path); if (asset == null) { api.World.Logger.VerboseDebug("Patch {0} in {1}: File {2} not found", patchIndex, patchSourcefile, path); notFound++; return; } Operation op = null; switch (jsonPatch.Op) { case EnumJsonPatchOp.Add: if (jsonPatch.Value == null) { api.World.Logger.Error("Patch {0} in {1} failed probably because it is an add operation and the value property is not set or misspelled", patchIndex, patchSourcefile); errorCount++; return; } op = new AddOperation() { Path = new Tavis.JsonPointer(jsonPatch.Path), Value = jsonPatch.Value.Token }; break; case EnumJsonPatchOp.Remove: op = new RemoveOperation() { Path = new Tavis.JsonPointer(jsonPatch.Path) }; break; case EnumJsonPatchOp.Replace: if (jsonPatch.Value == null) { api.World.Logger.Error("Patch {0} in {1} failed probably because it is a replace operation and the value property is not set or misspelled", patchIndex, patchSourcefile); errorCount++; return; } op = new ReplaceOperation() { Path = new Tavis.JsonPointer(jsonPatch.Path), Value = jsonPatch.Value.Token }; break; case EnumJsonPatchOp.Copy: op = new CopyOperation() { Path = new Tavis.JsonPointer(jsonPatch.Path), FromPath = new JsonPointer(jsonPatch.FromPath) }; break; case EnumJsonPatchOp.Move: op = new MoveOperation() { Path = new Tavis.JsonPointer(jsonPatch.Path), FromPath = new JsonPointer(jsonPatch.FromPath) }; break; } PatchDocument patchdoc = new PatchDocument(op); JToken token = null; try { token = JToken.Parse(asset.ToText()); } catch (Exception e) { api.World.Logger.Error("Patch {0} in {1} failed probably because the syntax of the value is broken: {2}", patchIndex, patchSourcefile, e); errorCount++; return; } try { patchdoc.ApplyTo(token); } catch (Tavis.PathNotFoundException p) { api.World.Logger.Error("Patch {0} in {1} failed because supplied path {2} is invalid: {3}", patchIndex, patchSourcefile, jsonPatch.Path, p.Message); errorCount++; return; } catch (Exception e) { api.World.Logger.Error("Patch {0} in {1} failed, following Exception was thrown: {2}", patchIndex, patchSourcefile, e.Message); errorCount++; return; } string text = token.ToString(); asset.Data = System.Text.Encoding.UTF8.GetBytes(text); applied++; }
public void MoveTo(string path, MoveOperation operation) { throw new NotImplementedException(); }
private void ApplyPatch(int patchIndex, AssetLocation patchSourcefile, JsonPatch jsonPatch, ref int applied, ref int notFound, ref int errorCount) { EnumAppSide targetSide = jsonPatch.Side == null ? jsonPatch.File.Category.SideType : (EnumAppSide)jsonPatch.Side; if (targetSide != EnumAppSide.Universal && jsonPatch.Side != api.Side) { return; } var loc = jsonPatch.File.Clone(); if (jsonPatch.File.Path.EndsWith("*")) { List <IAsset> assets = api.Assets.GetMany(jsonPatch.File.Path.TrimEnd('*'), jsonPatch.File.Domain, false); foreach (var val in assets) { jsonPatch.File = val.Location; ApplyPatch(patchIndex, patchSourcefile, jsonPatch, ref applied, ref notFound, ref errorCount); } jsonPatch.File = loc; return; } if (!loc.Path.EndsWith(".json")) { loc.Path += ".json"; } var asset = api.Assets.TryGet(loc); if (asset == null) { if (jsonPatch.File.Category == null) { api.World.Logger.VerboseDebug("Patch {0} in {1}: File {2} not found. Wrong asset category", patchIndex, patchSourcefile, loc); } else { EnumAppSide catSide = jsonPatch.File.Category.SideType; if (catSide != EnumAppSide.Universal && api.Side != catSide) { api.World.Logger.VerboseDebug("Patch {0} in {1}: File {2} not found. Hint: This asset is usually only loaded {3} side", patchIndex, patchSourcefile, loc, catSide); } else { api.World.Logger.VerboseDebug("Patch {0} in {1}: File {2} not found", patchIndex, patchSourcefile, loc); } } notFound++; return; } Operation op = null; switch (jsonPatch.Op) { case EnumJsonPatchOp.Add: if (jsonPatch.Value == null) { api.World.Logger.Error("Patch {0} in {1} failed probably because it is an add operation and the value property is not set or misspelled", patchIndex, patchSourcefile); errorCount++; return; } op = new AddOperation() { Path = new Tavis.JsonPointer(jsonPatch.Path), Value = jsonPatch.Value.Token }; break; case EnumJsonPatchOp.Remove: op = new RemoveOperation() { Path = new Tavis.JsonPointer(jsonPatch.Path) }; break; case EnumJsonPatchOp.Replace: if (jsonPatch.Value == null) { api.World.Logger.Error("Patch {0} in {1} failed probably because it is a replace operation and the value property is not set or misspelled", patchIndex, patchSourcefile); errorCount++; return; } op = new ReplaceOperation() { Path = new Tavis.JsonPointer(jsonPatch.Path), Value = jsonPatch.Value.Token }; break; case EnumJsonPatchOp.Copy: op = new CopyOperation() { Path = new Tavis.JsonPointer(jsonPatch.Path), FromPath = new JsonPointer(jsonPatch.FromPath) }; break; case EnumJsonPatchOp.Move: op = new MoveOperation() { Path = new Tavis.JsonPointer(jsonPatch.Path), FromPath = new JsonPointer(jsonPatch.FromPath) }; break; } PatchDocument patchdoc = new PatchDocument(op); JToken token = null; try { token = JToken.Parse(asset.ToText()); } catch (Exception e) { api.World.Logger.Error("Patch {0} (target: {3}) in {1} failed probably because the syntax of the value is broken: {2}", patchIndex, patchSourcefile, e, loc); errorCount++; return; } try { patchdoc.ApplyTo(token); } catch (Tavis.PathNotFoundException p) { api.World.Logger.Error("Patch {0} (target: {4}) in {1} failed because supplied path {2} is invalid: {3}", patchIndex, patchSourcefile, jsonPatch.Path, p.Message, loc); errorCount++; return; } catch (Exception e) { api.World.Logger.Error("Patch {0} (target: {3}) in {1} failed, following Exception was thrown: {2}", patchIndex, patchSourcefile, e.Message, loc); errorCount++; return; } string text = token.ToString(); asset.Data = System.Text.Encoding.UTF8.GetBytes(text); applied++; }
protected abstract void Move(MoveOperation operation);
public MoveOperationPerformedEventArgs(IBattle battle, MoveOperation operation) : base(battle) { Operation = operation; }
public void SetInsertPosByMove(MoveOperation op) { switch (op) { case MoveOperation.Left: this.insertPos = PreviousChar(this.insertPos); // 前一个字符是行末,并且不是段末,再往前找一格 if (!this.insertPos.IsPrintableChar() && this.insertPos != this.insertPos.Line.Section.End) { this.insertPos = PreviousChar(this.insertPos); } break; case MoveOperation.Right: // 字符是行末,并且不是段末,多往后找一格 if (!this.insertPos.IsPrintableChar() && this.insertPos != this.insertPos.Line.Section.End) { this.insertPos = NextChar(this.insertPos); } this.insertPos = NextChar(this.insertPos); break; case MoveOperation.Up: PointF pUp = new PointF(this.insertPos.X, this.insertPos.Y - this.font.Height - ROW_SPACING); SetInsertPosByLocation(pUp); break; case MoveOperation.Down: PointF pDown = new PointF(this.insertPos.X, this.insertPos.Y + this.font.Height + ROW_SPACING); SetInsertPosByLocation(pDown); break; case MoveOperation.Home: this.insertPos = HomeChar(this.insertPos); break; case MoveOperation.End: this.insertPos = EndChar(this.insertPos); break; default: break; } }
private void Update() { if (upButton.IsPressed) { cursor.IncreaseSize(); } if (downButton.IsPressed) { cursor.DecreaseSize(); } cursor.UpdateActiveChunks(); if (isWorking) { if (trigger.Value <= 0.2) { isWorking = false; Dictionary <Chunk, float[]> afterEdit = new Dictionary <Chunk, float[]>(); Dictionary <Chunk, float[]> afterColor = new Dictionary <Chunk, float[]>(); foreach (Chunk chunk in beforeEdit.Keys) { float[] voxels = new float[chunk.voxels.Volume]; float[] colors = new float[chunk.voxels.Volume * 3]; chunk.voxels.VoxelBuffer.GetData(voxels); chunk.voxels.ColorBuffer.GetData(colors); afterEdit.Add(chunk, voxels); afterColor.Add(chunk, colors); } MoveOperation op = new MoveOperation(beforeEdit, beforeColor, afterEdit, afterColor); OperationManager.Instance.PushOperation(op); } foreach (Chunk chunk in LayerManager.Instance.activeChunks) { if (!beforeEdit.ContainsKey(chunk)) { float[] voxels = new float[chunk.voxels.Volume]; float[] colors = new float[chunk.voxels.Volume * 3]; chunk.voxels.VoxelBuffer.GetData(voxels); chunk.voxels.ColorBuffer.GetData(colors); beforeEdit.Add(chunk, voxels); beforeColor.Add(chunk, colors); } } PerformAction(); } if (trigger.Value > 0.2) { if (!isWorking) { isWorking = true; beforeEdit = new Dictionary <Chunk, float[]>(); beforeColor = new Dictionary <Chunk, float[]>(); } } else { workBufferPopulated = false; } }