internal static GetterDelegate FlagGetterDelegate(ProviderPropertyDefinition propertyDefinition, int mask) { return(delegate(IPropertyBag bag) { int num = (int)bag[propertyDefinition]; return BoxedConstants.GetBool(0 != (mask & num)); }); }
internal static GetterDelegate InvertFlagGetterDelegate(ProviderPropertyDefinition propertyDefinition, int mask) { return(delegate(IPropertyBag bag) { int num = (int)bag[propertyDefinition]; bool value = 0 == (mask & num); return BoxedConstants.GetBool(value); }); }
internal static GetterDelegate LongFlagGetterDelegate(long mask, ProviderPropertyDefinition propertyDefinition) { return(delegate(IPropertyBag bag) { long num = (long)bag[propertyDefinition]; bool value = 0L != (mask & num); return BoxedConstants.GetBool(value); }); }
protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag) { object value = propertyBag.GetValue(this.nativeProperty); PropertyError propertyError = value as PropertyError; if (propertyError != null) { return(propertyError); } return(BoxedConstants.GetBool(((int)value & this.flag) == this.flag)); }
public void DrawArea(RenderArgs ra, Point offset) { if (_surface == null) { return; } if (_renderContext == null || (_renderContext.Windows != null && _renderContext.Windows.Length != Processor.LogicalCpuCount)) { _renderContext = new RenderContext { Owner = this }; _renderContext.WaitCallback = _renderContext.RenderThreadMethod; _renderContext.Windows = new Surface[Processor.LogicalCpuCount]; _renderContext.Offsets = new Point[Processor.LogicalCpuCount]; _renderContext.Rects = new Rectangle[Processor.LogicalCpuCount]; } Utility.SplitRectangle(ra.Bounds, _renderContext.Rects); for (int i = 0; i < _renderContext.Rects.Length; ++i) { var rect = _renderContext.Rects[i]; if (rect.Width > 0 && rect.Height > 0) { _renderContext.Offsets[i] = new Point(rect.X + offset.X, rect.Y + offset.Y); if (_renderContext.Windows != null) { _renderContext.Windows[i] = ra.Surface.CreateWindow(rect); } } else { if (_renderContext.Windows != null) { _renderContext.Windows[i] = null; } } } for (int i = 0; i < _renderContext.Windows.Length; ++i) { if (_renderContext.Windows[i] != null) { this._threadPool.QueueTask(_renderContext.WaitCallback, BoxedConstants.GetInt32(i)); } } this._threadPool.Drain(); }
private static GetterDelegate MservFlagGetterDelegate(byte mask, ProviderPropertyDefinition propertyDefinition) { return(delegate(IPropertyBag propertyBag) { MservRecord mservRecord = (MservRecord)propertyBag[MServRecipientSchema.MservPrimaryRecord]; if (mservRecord == null) { return propertyDefinition.DefaultValue; } bool value = 0 != (mask & mservRecord.Flags); return BoxedConstants.GetBool(value); }); }
internal static GetterDelegate OWAFlagGetterDelegate(int mask, ProviderPropertyDefinition propertyDefinition) { return(delegate(IPropertyBag bag) { uint?num = (uint?)bag[propertyDefinition]; if (num != null) { long num2 = (long)mask; uint?num3 = num; bool value = 0L != ((num3 != null) ? new long?(num2 & (long)((ulong)num3.GetValueOrDefault())) : null); return BoxedConstants.GetBool(value); } return null; }); }
protected override void OnExecute() { WaitCallback wc = new WaitCallback(RenderThreadProc); for (int n = 0; n < Iterations; ++n) { for (int i = 0; i < Rois.Length; ++i) { object iObj = BoxedConstants.GetInt32(i); ThreadPool.QueueUserWorkItem(wc, iObj); } } ThreadPool.Drain(); }
protected override void OnExecute() { System.Threading.WaitCallback renderDelegate = new System.Threading.WaitCallback(Render); for (int i = 0; i < IterationCount; ++i) { for (int j = 0; j < BlitRects.Length; ++j) { object jObj = BoxedConstants.GetInt32(j); ThreadPool.QueueUserWorkItem(renderDelegate, jObj); } ThreadPool.Drain(); } }
private void RenderGradient(Surface surface, PdnRegion clipRegion, CompositingMode compositingMode, PointF startPointF, ColorBgra startColor, PointF endPointF, ColorBgra endColor) { GradientRenderer gr = AppEnvironment.GradientInfo.CreateGradientRenderer(); gr.StartColor = startColor; gr.EndColor = endColor; gr.StartPoint = startPointF; gr.EndPoint = endPointF; gr.AlphaBlending = (compositingMode == CompositingMode.SourceOver); gr.BeforeRender(); Rectangle[] oldRois = clipRegion.GetRegionScansReadOnlyInt(); Rectangle[] newRois; if (oldRois.Length == 1) { newRois = new Rectangle[Processor.LogicalCpuCount]; Utility.SplitRectangle(oldRois[0], newRois); } else { newRois = oldRois; } RenderContext rc = new RenderContext(); rc.surface = surface; rc.rois = newRois; rc.renderer = gr; WaitCallback wc = new WaitCallback(rc.Render); for (int i = 0; i < Processor.LogicalCpuCount; ++i) { if (i == Processor.LogicalCpuCount - 1) { wc(BoxedConstants.GetInt32(i)); } else { PaintDotNet.Threading.ThreadPool.Global.QueueUserWorkItem(wc, BoxedConstants.GetInt32(i)); } } PaintDotNet.Threading.ThreadPool.Global.Drain(); }
protected override void OnExecute() { for (int n = 0; n < this.iterations; ++n) { for (int i = 0; i < this.rois.Length; ++i) { object iObj = BoxedConstants.GetInt32(i); if (n == this.iterations - 1 && i == this.rois.Length - 1) { RenderThreadProc(iObj); } else { this.threadPool.QueueUserWorkItem(new WaitCallback(RenderThreadProc), iObj); } } } this.threadPool.Drain(); }
public ProviderPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, object defaultValue, PropertyDefinitionConstraint[] readConstraints, PropertyDefinitionConstraint[] writeConstraints, ProviderPropertyDefinition[] supportingProperties, CustomFilterBuilderDelegate customFilterBuilderDelegate, GetterDelegate getterDelegate, SetterDelegate setterDelegate) : base(name, type) { if (supportingProperties == null) { throw new ArgumentNullException("supportingProperties"); } if (readConstraints == null) { throw new ArgumentNullException("readConstraints"); } if (writeConstraints == null) { throw new ArgumentNullException("writeConstraints"); } if (name == null) { throw new ArgumentNullException("name"); } if (type == null) { throw new ArgumentNullException("type"); } if (versionAdded == null) { throw new ArgumentNullException("versionAdded"); } if (defaultValue != null && !ReflectionHelper.IsInstanceOfType(defaultValue, type)) { throw new ArgumentException(DataStrings.ExceptionDefaultTypeMismatch.ToString(), "defaultValue (" + name + ")"); } if (type == typeof(bool) && defaultValue != null) { defaultValue = BoxedConstants.GetBool((bool)defaultValue); } this.defaultValue = defaultValue; this.customFilterBuilderDelegate = customFilterBuilderDelegate; this.versionAdded = versionAdded; if (readConstraints.Length < 1) { this.readOnlyReadConstraints = ProviderPropertyDefinition.EmptyConstraint.Collection; } else { this.readOnlyReadConstraints = new ReadOnlyCollection <PropertyDefinitionConstraint>(readConstraints); } if (writeConstraints.Length < 1 && readConstraints.Length < 1) { this.allStaticConstraints = PropertyDefinitionConstraint.None; this.readOnlyAllConstraints = ProviderPropertyDefinition.EmptyConstraint.Collection; } else { this.allStaticConstraints = new PropertyDefinitionConstraint[readConstraints.Length + writeConstraints.Length]; Array.Copy(writeConstraints, this.allStaticConstraints, writeConstraints.Length); Array.Copy(readConstraints, 0, this.allStaticConstraints, writeConstraints.Length, readConstraints.Length); this.readOnlyAllConstraints = new ReadOnlyCollection <PropertyDefinitionConstraint>(this.allStaticConstraints); } this.getterDelegate = getterDelegate; this.setterDelegate = setterDelegate; if (supportingProperties.Length < 1) { this.supportingProperties = ProviderPropertyDefinition.EmptyCollection; } else { this.supportingProperties = new ReadOnlyCollection <ProviderPropertyDefinition>(supportingProperties); } List <CollectionPropertyDefinitionConstraint> list = new List <CollectionPropertyDefinitionConstraint>(); List <CollectionPropertyDefinitionConstraint> list2 = new List <CollectionPropertyDefinitionConstraint>(); for (int i = 0; i < writeConstraints.Length; i++) { CollectionPropertyDefinitionConstraint collectionPropertyDefinitionConstraint = writeConstraints[i] as CollectionPropertyDefinitionConstraint; if (collectionPropertyDefinitionConstraint != null) { list.Add(collectionPropertyDefinitionConstraint); } } for (int j = 0; j < readConstraints.Length; j++) { CollectionPropertyDefinitionConstraint collectionPropertyDefinitionConstraint2 = readConstraints[j] as CollectionPropertyDefinitionConstraint; if (collectionPropertyDefinitionConstraint2 != null) { list.Add(collectionPropertyDefinitionConstraint2); list2.Add(collectionPropertyDefinitionConstraint2); } } if (list.Count < 1) { this.allStaticCollectionConstraints = ProviderPropertyDefinition.EmptyCollectionConstraint.Array; this.readOnlyAllCollectionConstraints = ProviderPropertyDefinition.EmptyCollectionConstraint.Collection; } else { this.allStaticCollectionConstraints = list.ToArray(); this.readOnlyAllCollectionConstraints = new ReadOnlyCollection <CollectionPropertyDefinitionConstraint>(this.allStaticCollectionConstraints); } if (list2.Count < 1) { this.readOnlyReadCollectionConstraints = ProviderPropertyDefinition.EmptyCollectionConstraint.Collection; } else { this.readOnlyReadCollectionConstraints = new ReadOnlyCollection <CollectionPropertyDefinitionConstraint>(list2.ToArray()); } this.readOnlyDependentProperties = ProviderPropertyDefinition.EmptyCollection; if (this.supportingProperties.Count == 0) { this.dependentProperties = new List <ProviderPropertyDefinition>(); } foreach (ProviderPropertyDefinition providerPropertyDefinition in supportingProperties) { if (providerPropertyDefinition.IsCalculated) { throw new ArgumentException(string.Format("The calculated property '{0}' cannot depend on another calculated property '{1}'", base.Name, providerPropertyDefinition.Name), "supportingProperties"); } if (this.VersionAdded.IsOlderThan(providerPropertyDefinition.VersionAdded)) { throw new ArgumentException(string.Format("The calculated property '{0}' cannot depend on the newer property '{1}'", base.Name, providerPropertyDefinition.Name), "supportingProperties"); } providerPropertyDefinition.AddDependency(this); } if (defaultValue != null && defaultValue != string.Empty) { PropertyValidationError propertyValidationError = this.ValidateValue(defaultValue, false); if (propertyValidationError != null) { throw new ArgumentException(propertyValidationError.Description, "defaultValue"); } } }
private static BitmapLayer ResizeLayer(BitmapLayer layer, int width, int height, ResamplingAlgorithm algorithm, int tileCount, Procedure progressCallback, ref bool pleaseStopMonitor) { Surface surface = new Surface(width, height); surface.Clear(ColorBgra.FromBgra(255, 255, 255, 0)); PaintDotNet.Threading.ThreadPool threadPool = new PaintDotNet.Threading.ThreadPool(); int rectCount; if (tileCount == 0) { rectCount = Processor.LogicalCpuCount; } else { rectCount = tileCount; } Rectangle[] rects = new Rectangle[rectCount]; Utility.SplitRectangle(surface.Bounds, rects); FitSurfaceContext fsc = new FitSurfaceContext(surface, layer.Surface, rects, algorithm); if (progressCallback != null) { fsc.RenderedRect += progressCallback; } WaitCallback callback = new WaitCallback(fsc.FitSurface); for (int i = 0; i < rects.Length; ++i) { if (pleaseStopMonitor) { break; } else { threadPool.QueueUserWorkItem(callback, BoxedConstants.GetInt32(i)); } } threadPool.Drain(); threadPool.DrainExceptions(); if (pleaseStopMonitor) { surface.Dispose(); surface = null; } BitmapLayer newLayer; if (surface == null) { newLayer = null; } else { newLayer = new BitmapLayer(surface, true); newLayer.LoadProperties(layer.SaveProperties()); } if (progressCallback != null) { fsc.RenderedRect -= progressCallback; } return(newLayer); }