public MoveToolContentRenderer(BitmapLayer activeLayer, MoveToolChanges changes, Result <IRenderer <ColorAlpha8> > lazyDeltaSelectionMask, Result <IRenderer <ColorAlpha8> > lazyFinalSelectionMask) : base(activeLayer.Width, activeLayer.Height, false) { Validate.Begin().IsNotNull <BitmapLayer>(activeLayer, "activeLayer").IsNotNull <MoveToolChanges>(changes, "changes").IsNotNull <Result <IRenderer <ColorAlpha8> > >(lazyDeltaSelectionMask, "lazyDeltaSelectionMask").IsNotNull <Result <IRenderer <ColorAlpha8> > >(lazyFinalSelectionMask, "lazyFinalSelectionMask").Check(); this.activeLayer = activeLayer; this.changes = changes; this.lazyDeltaSelectionMask = lazyDeltaSelectionMask; this.lazyFinalSelectionMask = lazyFinalSelectionMask; switch (changes.PixelSource) { case MoveToolPixelSource.ActiveLayer: this.source = activeLayer.Surface; break; case MoveToolPixelSource.Bitmap: this.source = changes.BitmapSource.Object; break; default: throw ExceptionUtil.InvalidEnumArgumentException <MoveToolPixelSource>(changes.PixelSource, "changes.PixelSource"); } Matrix3x2Double matrix = changes.DeltaTransform * changes.EditTransform; if ((changes.MoveToolResamplingAlgorithm == ResamplingAlgorithm.NearestNeighbor) || changes.FinalTransform.IsIntegerTranslation) { this.sourceTx = new TransformedNearestNeighborContentRenderer(activeLayer.Size(), this.source, matrix); } else { RectDouble baseBounds = changes.BaseBounds; RectInt32 srcCoverageBounds = changes.BaseTransform.Transform(baseBounds).Int32Bound; this.sourceTx = new TransformedBilinearContentRenderer(activeLayer.Size(), this.source, srcCoverageBounds, matrix); } }
protected override string OnGetHistoryMementoNameForChanges(MoveToolChanges oldChanges, MoveToolChanges newChanges) { string name = base.Name; string historyMementoName = null; if ((oldChanges != null) && (newChanges != null)) { if (oldChanges.SecondaryColor != newChanges.SecondaryColor) { historyMementoName = TransactedTool <MoveTool, MoveToolChanges> .FoldHistoryMementoName(historyMementoName, name, PdnResources.GetString("TransactedTool.Changed.PrimaryColorOrSecondaryColor.HistoryMementoName")); } if (oldChanges.SelectionRenderingQuality != newChanges.SelectionRenderingQuality) { historyMementoName = TransactedTool <MoveTool, MoveToolChanges> .FoldHistoryMementoName(historyMementoName, name, PdnResources.GetString("TransactedTool.Changed.SelectionRenderingQuality.HistoryMementoName")); } if (oldChanges.MoveToolResamplingAlgorithm != newChanges.MoveToolResamplingAlgorithm) { historyMementoName = TransactedTool <MoveTool, MoveToolChanges> .FoldHistoryMementoName(historyMementoName, name, PdnResources.GetString("TransactedTool.Changed.SampleAllLayers.HistoryMementoName")); } } if (historyMementoName == null) { switch (((newChanges != null) ? newChanges.EditingMode : oldChanges.EditingMode)) { case TransformEditingMode.None: case TransformEditingMode.Custom: historyMementoName = base.Name; goto Label_0111; case TransformEditingMode.Rotate: historyMementoName = PdnResources.GetString("MoveTool.HistoryMemento.Rotate"); goto Label_0111; case TransformEditingMode.Scale: historyMementoName = PdnResources.GetString("MoveTool.HistoryMemento.Scale"); goto Label_0111; case TransformEditingMode.Translate: historyMementoName = PdnResources.GetString("MoveTool.HistoryMemento.Translate"); goto Label_0111; case TransformEditingMode.MoveRotationAnchor: historyMementoName = PdnResources.GetString("MoveSelectionTool.HistoryMemento.MoveRotationAnchor"); goto Label_0111; } throw new InternalErrorException(ExceptionUtil.InvalidEnumArgumentException <TransformEditingMode>(newChanges.EditingMode, "newChanges.EditingMode")); } Label_0111 :; return(historyMementoName ?? name); }
protected override string OnGetHistoryMementoNameForChanges(MoveToolChanges oldChanges, MoveToolChanges newChanges) { switch (((newChanges != null) ? newChanges.EditingMode : oldChanges.EditingMode)) { case TransformEditingMode.None: case TransformEditingMode.Custom: return(base.Name); case TransformEditingMode.Rotate: return(PdnResources.GetString("MoveSelectionTool.HistoryMemento.Rotate")); case TransformEditingMode.Scale: return(PdnResources.GetString("MoveSelectionTool.HistoryMemento.Scale")); case TransformEditingMode.Translate: return(PdnResources.GetString("MoveSelectionTool.HistoryMemento.Translate")); case TransformEditingMode.MoveRotationAnchor: return(PdnResources.GetString("MoveSelectionTool.HistoryMemento.MoveRotationAnchor")); } throw new InternalErrorException(ExceptionUtil.InvalidEnumArgumentException <TransformEditingMode>(newChanges.EditingMode, "newChanges.EditingMode")); }