/// <summary> /// Transform the pipelined row /// </summary> /// <param name="observed">observed operation</param> /// <param name="transform">callback method for transforming the row</param> /// <returns>resulting operation</returns> public static TransformOperation Transform(this IObservableOperation observed, Func <Row, Row> transform) { TransformOperation op = new TransformOperation(transform); observed.Subscribe(op); return(op); }
private void handleOperation(TransformOperation op, Transform target) { switch (op) { case TransformOperation.X: moveX(target, 1); break; case TransformOperation.Y: moveY(target, 1); break; case TransformOperation.Z: moveZ(target, 1); break; case TransformOperation.X_Neg: moveX(target, -1); break; case TransformOperation.Y_Neg: moveY(target, -1); break; case TransformOperation.Z_Neg: moveZ(target, -1); break; } }
/// <summary> /// Transform the pipelined row /// </summary> /// <param name="observed">observed operation</param> /// <param name="transform">callback method for transforming the row</param> /// <returns>resulting operation</returns> public static TransformOperation Many(this IObservableOperation observed, Func <Row, IEnumerable <Row> > transform) { var op = new TransformOperation(transform); observed.Subscribe(op); return(op); }
private PropertyPage CreatePropertyPage(PropertyPage page, TransformOperation section) { switch (section) { case TransformOperation.SongCleanup: page.AddCheckBox("Merge identical patterns:", true, MergePatternsTooltip); // 0 page.AddCheckBox("Delete empty patterns:", true, DeleteEmptyPatternsTooltip); // 1 page.AddCheckBox("Adjust maximum note lengths:", true, AdjustMaximumNoteLengthsTooltip); // 2 page.AddCheckBoxList(PlatformUtils.IsMobile ? "Songs to process:" : null, GetSongNames(), null, SongsTooltips); // 3 break; case TransformOperation.ProjectCleanup: page.AddCheckBox("Delete unused instruments:", true, DeleteUnusedInstrumentsTooltip); // 0 page.AddCheckBox("Merge identical instruments:", true, MergeIdenticalInstrumentsTooltip); // 1 page.AddCheckBox("Unassign unused DPCM instrument keys:", true, UnassignUnusedSamplesTooltip); // 2 page.AddCheckBox("Delete unassigned samples:", true, DeleteUnassignedSamplesTooltip); // 3 page.AddCheckBox("Permanently apply all DPCM samples processing:", false, PermanentlyApplyProcessingTooltip); // 4 page.AddCheckBox("Delete unused arpeggios:", true, DeleteUnusedArpeggiosTooltip); // 5 page.PropertyChanged += ProjectCleanup_PropertyChanged; break; } page.Build(); pages[(int)section] = page; return(page); }
private PropertyPage CreatePropertyPage(PropertyPage page, TransformOperation section) { switch (section) { case TransformOperation.SongCleanup: page.AddCheckBox("Merge identical patterns:", true); // 0 page.AddCheckBox("Delete empty patterns:", true); // 1 page.AddCheckBox("Adjust maximum note lengths:", true); // 2 page.AddCheckBoxList(null, GetSongNames(), null); // 3 break; case TransformOperation.ProjectCleanup: page.AddCheckBox("Delete unused instruments:", true); // 0 page.AddCheckBox("Merge identical instruments:", true); // 1 page.AddCheckBox("Unassign unused DPCM instrument keys:", true); // 2 page.AddCheckBox("Delete unassigned samples:", true); // 3 page.AddCheckBox("Permanently apply all DPCM samples processing:", false); // 4 page.AddCheckBox("Delete unused arpeggios:", true); // 5 page.PropertyChanged += ProjectCleanup_PropertyChanged; break; } page.Build(); pages[(int)section] = page; return(page); }
public TransformDialog(string selectedTile, Image selectedTileImage) { InitializeComponent(); this.selectedTile = selectedTile; this.selectedTilePictureBox.Image = selectedTileImage; this.result = new TransformOperation(); this.UpdatePanels(); }
public void ForEachTransform(TransformOperation op) { ForEachIcon((Icon icon, int index) => { op(icon.icon, icon.iconScaleOrig, index); if (icon.slot != null) { op(icon.slot, icon.slotScaleOrig, index); } }); }
public static TransformOperation Diff(TransformOperation from, Transform to) { var operation = new TransformOperation(); operation.position = to.localPosition - from.position; operation.rotation = Quaternion.Inverse(from.rotation) * to.localRotation; operation.scale = Vector3.Scale(to.localScale, new Vector3(1f / from.scale.x, 1f / from.scale.y, 1f / from.scale.z)); return(operation); }
/// <summary> /// Create a new lossless transform instance with the given parameters. /// </summary> /// <param name="x">The left boundary of the cropping region. This must be evenly divisible by the MCU block /// width (see <see cref="TurboJpegUtilities.GetMcuWidth" />).</param> /// <param name="y">The upper boundary of the cropping region. This must be evenly divisible by the MCU block /// height (see <see cref="TurboJpegUtilities.GetMcuHeight" />).</param> /// <param name="width">The width of the cropping region. Setting this to 0 is the equivalent of setting it to /// (width of the source JPEG image - <paramref name="x"/>).</param> /// <param name="height">The height of the cropping region. Setting this to 0 is the equivalent of setting it to /// (height of the source JPEG image - <paramref name="y"/>).</param> /// <param name="operation">The transform operation.</param> /// <param name="options">One or more of the transform options.</param> /// <param name="customFilter">An instance of an object that implements the <see cref="ICustomFilter"/> /// interface, or <c>null</c> if no custom filter is needed.</param> public TurboJpegTransform(int x, int y, int width, int height, TransformOperation operation, TransformOptions options, ICustomFilter customFilter = null) : this(new Rectangle(x, y, width, height), operation, options, customFilter) { Contract.Requires(x >= 0, "x must be non-negative"); Contract.Requires(y >= 0, "y must be non-negative"); Contract.Requires(width >= 0, "width must be non-negative"); Contract.Requires(height >= 0, "height must be non-negative"); Contract.Requires(Enum.IsDefined(typeof(TransformOperation), operation)); Contract.Requires(Enum.IsDefined(typeof(TransformOptions), options)); }
static TransformOperation GetTransformOperation(Transform t) { foreach (TransformOperation to in operations) { if (to.current.Equals(t)) { return(to); } } GameObject obj = new GameObject(); TransformOperation operation = obj.AddComponent <TransformOperation>(); operation.current = t; operations.Add(operation); return(operation); }
public static void Set(IEnumerable <HostsFileEntry> entries, string filepath = null) { filepath = filepath ?? GetHostsPath(); List <Func <IEnumerable <string>, IEnumerable <string> > > transforms = new List <Func <IEnumerable <string>, IEnumerable <string> > >(); foreach (var entry in entries.Reverse()) { string hostName = entry.Hostname; string address = entry.Address; transforms.Add(Core.Remove.GetRemoveTransformForHost(hostName)); transforms.Add(lines => GetSetHostTransform(lines.ToArray(), hostName, address)); } TransformOperation.TransformFile(filepath, transforms.ToArray()); }
/// <summary>Create a new lossless transform instance with the given parameters.</summary> /// <param name="r">A <see cref="Rectangle"/>> instance that specifies the cropping region. See /// <see cref="TurboJpegTransform (int, int, int, int, TransformOperation, TransformOptions, ICustomFilter)"/> /// for more detail.</param> /// <param name="operation">The transform operation.</param> /// <param name="options">One or more of the transform options.</param> /// <param name="customFilter">An instance of an object that implements the <see cref="ICustomFilter"/> /// interface, or <c>null</c> if no custom filter is needed.</param> public TurboJpegTransform(Rectangle r, TransformOperation operation, TransformOptions options, ICustomFilter customFilter = null) { Contract.Requires(r.X >= 0, "Rectangle X must be non-negative"); Contract.Requires(r.Y >= 0, "Rectangle Y must be non-negative"); Contract.Requires(r.Width >= 0, "Rectangle width must be non-negative"); Contract.Requires(r.Height >= 0, "Rectangle height must be non-negative"); Contract.Requires(Enum.IsDefined(typeof(TransformOperation), operation)); Contract.Requires(Enum.IsDefined(typeof(TransformOptions), options)); this.rect = r; this.operation = operation; this.options = options; this.customFilter = customFilter; }
public void preserves_original_encoding(Encoding encoding) { string expectedContents = String.Join("", Enumerable.Range(0, 2048) .Select(i => (char)i) .Where(c => c != '\n' && c != '\r') .Select(c => c.ToString() + "\r\n") .ToArray()); string filename = GetFileWithContents(expectedContents, encoding); TransformOperation.TransformFile(filename, lines => lines); Encoding encodingUsed; string fileContents = ReadFileContents(filename, out encodingUsed); Assert.That(encodingUsed, Is.EqualTo(encoding)); Assert.That(fileContents, Is.EqualTo(expectedContents)); }
private PropertyPage CreatePropertyPage(PropertyPage page, TransformOperation section) { switch (section) { case TransformOperation.Cleanup: page.AddBoolean("Merge identical patterns:", true); // 0 page.AddBoolean("Delete empty patterns:", true); // 1 page.AddBoolean("Merge identical instruments:", true); // 2 page.AddBoolean("Delete unused instruments:", true); // 3 page.AddBoolean("Delete unused samples:", true); // 4 page.AddStringListMulti(null, GetSongNames(), null); // 5 break; } page.Build(); pages[(int)section] = page; return(page); }
public IGraphNode Transform(TransformOperation operation, object state) { Stack <TransformWalkInfo> frames = new Stack <TransformWalkInfo>(); TransformWalkInfo rootInfo = new TransformWalkInfo { CurrentNode = this, TransformedNode = operation(this, state) }; frames.Push(rootInfo); IGraphNode root = rootInfo.TransformedNode; Dictionary <IGraphNode, IGraphNode> visitedNodes = new Dictionary <IGraphNode, IGraphNode>(); while (frames.Count > 0) { TransformWalkInfo frame = frames.Pop(); if (visitedNodes.ContainsKey(frame.CurrentNode)) { continue; } else { visitedNodes[frame.CurrentNode] = frame.TransformedNode; } for (int i = 0; i < frame.CurrentNode.Children.Count; i++) { IGraphNode current = frame.CurrentNode.Children[i]; IGraphNode transformed = operation(current, state); frame.TransformedNode.Children.Add(transformed); frames.Push(new TransformWalkInfo { CurrentNode = current, TransformedNode = transformed }); } } return(root); }
private void OkButtonClick(object sender, EventArgs e) { switch (this.Operation) { case TransformDialogResult.Fill: { var x = int.Parse(this.fillXTextbox.Text); var y = int.Parse(this.fillYTextbox.Text); var x2 = int.Parse(this.fillX2Textbox.Text); var y2 = int.Parse(this.fillY2Textbox.Text); this.result = new FillOperation(x, y, x2 - x + 1, y2 - y + 1, this.selectedTile); break; } case TransformDialogResult.Clone: { var x = int.Parse(this.cloneXTextbox.Text); var y = int.Parse(this.cloneYTextbox.Text); var x2 = int.Parse(this.cloneX2Textbox.Text); var y2 = int.Parse(this.cloneY2Textbox.Text); var newX = int.Parse(this.cloneNewXTextbox.Text); var newY = int.Parse(this.cloneNewYTextbox.Text); this.result = new CloneOperation(x, y, x2 - x + 1, y2 - y + 1, newX, newY); break; } case TransformDialogResult.MoveItems: { var dx = int.Parse(this.dxTextbox.Text); this.result = new MoveItemsOperation(dx); break; } } this.Close(); }
public void SetOriginalTransform(Transform transform) { originalTransform = new TransformOperation(transform); }
public void MinimapTransformChanged(Transform changed) { minimapChanges = TransformOperation.Diff(originalTransform, changed); }
/// <summary> /// Linear move object from one position to another position /// </summary> /// <param name="trans">target transform in which actual move happens</param> /// <param name="target">target where to move</param> /// <param name="time">time to reach to target</param> public static void DoAnimate(this Transform trans, Transform target, float time) { TransformOperation to = GetTransformOperation(trans); to.StartAnimation(target, time); }
/// <summary> /// Jump from current positon to target position /// </summary> /// <param name="trans">target transform in which actual jump happens</param> /// <param name="target">target where to jump</param> /// <param name="jumpRate">jump rate</param> /// <param name="time">time to reach to target</param> public static void DoJump(this Transform trans, Transform target, float jumpRate, float time) { TransformOperation to = GetTransformOperation(trans); to.StartJump(target, jumpRate, time); }