本文整理汇总了C#中System.Windows.Forms.Document.ReplaceMetaDataFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Document.ReplaceMetaDataFrom方法的具体用法?C# Document.ReplaceMetaDataFrom怎么用?C# Document.ReplaceMetaDataFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Document
的用法示例。
在下文中一共展示了Document.ReplaceMetaDataFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResizeDocument
public static Document ResizeDocument(Document document, Size newSize, AnchorEdge edge, ColorBgra background)
{
Document newDoc = new Document(newSize.Width, newSize.Height);
newDoc.ReplaceMetaDataFrom(document);
for (int i = 0; i < document.Layers.Count; ++i)
{
Layer layer = (Layer)document.Layers[i];
if (layer is BitmapLayer)
{
Layer newLayer;
try
{
newLayer = ResizeLayer((BitmapLayer)layer, newSize, edge, background);
}
catch (OutOfMemoryException)
{
newDoc.Dispose();
throw;
}
newDoc.Layers.Add(newLayer);
}
else
{
throw new InvalidOperationException("Canvas Size does not support Layers that are not BitmapLayers");
}
}
return newDoc;
}
示例2: PerformAction
public override HistoryMemento PerformAction(DocumentWorkspace documentWorkspace)
{
int newWidth;
int newHeight;
double newDpu;
MeasurementUnit newDpuUnit;
string resamplingAlgorithm = Settings.CurrentUser.GetString(PdnSettings.LastResamplingMethod,
ResamplingAlgorithm.SuperSampling.ToString());
ResamplingAlgorithm alg;
try
{
alg = (ResamplingAlgorithm)Enum.Parse(typeof(ResamplingAlgorithm), resamplingAlgorithm, true);
}
catch
{
alg = ResamplingAlgorithm.SuperSampling;
}
bool maintainAspect = Settings.CurrentUser.GetBoolean(PdnSettings.LastMaintainAspectRatio, true);
using (ResizeDialog rd = new ResizeDialog())
{
rd.OriginalSize = documentWorkspace.Document.Size;
rd.OriginalDpuUnit = documentWorkspace.Document.DpuUnit;
rd.OriginalDpu = documentWorkspace.Document.DpuX;
rd.ImageHeight = documentWorkspace.Document.Height;
rd.ImageWidth = documentWorkspace.Document.Width;
rd.ResamplingAlgorithm = alg;
rd.LayerCount = documentWorkspace.Document.Layers.Count;
rd.Units = rd.OriginalDpuUnit;
rd.Resolution = documentWorkspace.Document.DpuX;
rd.Units = PdnSettings.GetLastNonPixelUnits();
rd.ConstrainToAspect = maintainAspect;
DialogResult result = rd.ShowDialog(documentWorkspace);
if (result == DialogResult.Cancel)
{
return null;
}
Settings.CurrentUser.SetString(PdnSettings.LastResamplingMethod, rd.ResamplingAlgorithm.ToString());
Settings.CurrentUser.SetBoolean(PdnSettings.LastMaintainAspectRatio, rd.ConstrainToAspect);
newDpuUnit = rd.Units;
newWidth = rd.ImageWidth;
newHeight = rd.ImageHeight;
newDpu = rd.Resolution;
alg = rd.ResamplingAlgorithm;
if (newDpuUnit != MeasurementUnit.Pixel)
{
Settings.CurrentUser.SetString(PdnSettings.LastNonPixelUnits, newDpuUnit.ToString());
if (documentWorkspace.AppWorkspace.Units != MeasurementUnit.Pixel)
{
documentWorkspace.AppWorkspace.Units = newDpuUnit;
}
}
// if the new size equals the old size, there's really no point in doing anything
if (documentWorkspace.Document.Size == new Size(rd.ImageWidth, rd.ImageHeight) &&
documentWorkspace.Document.DpuX == newDpu &&
documentWorkspace.Document.DpuUnit == newDpuUnit)
{
return null;
}
}
HistoryMemento ha;
if (newWidth == documentWorkspace.Document.Width &&
newHeight == documentWorkspace.Document.Height)
{
// Only adjusting Dpu or DpuUnit
ha = new MetaDataHistoryMemento(StaticName, StaticImage, documentWorkspace);
documentWorkspace.Document.DpuUnit = newDpuUnit;
documentWorkspace.Document.DpuX = newDpu;
documentWorkspace.Document.DpuY = newDpu;
}
else
{
try
{
using (new WaitCursorChanger(documentWorkspace))
{
ha = new ReplaceDocumentHistoryMemento(StaticName, StaticImage, documentWorkspace);
}
Document newDocument = new Document(newWidth, newHeight);
newDocument.ReplaceMetaDataFrom(documentWorkspace.Document);
newDocument.DpuUnit = newDpuUnit;
newDocument.DpuX = newDpu;
newDocument.DpuY = newDpu;
ResizeProgressDialog rpd = new ResizeProgressDialog(documentWorkspace, newDocument, documentWorkspace.Document, new Size(newWidth, newHeight), alg);
Utility.GCFullCollect();
bool result = rpd.DoResize();
//.........这里部分代码省略.........