public void docStateChanged(NSNotification notification) { DocChange change = notification.object_().To<DocChange>(); NSGradient gradient = null; if (!NSObject.IsNullOrNil(change.Document)) { if ((change.Type & ChangeType.Palette) == ChangeType.Palette) { float[] locations = new float[change.Document.Palette.Length]; NSMutableArray colors = NSMutableArray.arrayWithCapacity((uint) change.Document.Palette.Length); for (int i = 0; i < change.Document.Palette.Length; ++i) { locations[i] = change.Document.Palette[i].Location; colors.addObject((NSColor) change.Document.Palette[i].Color); } gradient = NSGradient.Create(colors, locations).Retain(); } } else { gradient = NSGradient.Create(NSColor.blackColor(), NSColor.blackColor()).Retain(); } if (gradient != null) { if (m_gradient != null) m_gradient.release(); m_gradient = gradient; setNeedsDisplay(true); } }
public void docStateChanged(NSNotification notification) { DocChange change = notification.object_().To<DocChange>(); m_document = change.Document; m_exponent.setEnabled(!NSObject.IsNullOrNil(m_document)); if (!NSObject.IsNullOrNil(m_document)) { if ((change.Type & ChangeType.Palette) == ChangeType.Palette) { window().setTitle(NSString.Create(m_document.Palette.Name)); } if ((change.Type & ChangeType.PaletteExponent) == ChangeType.PaletteExponent) { m_exponent.setFloatValue(m_document.PaletteExponent); } } else { m_exponent.setFloatValue(0.0f); window().setTitle(NSString.Create("Palette")); } }
public void docStateChanged(NSNotification notification) { DocChange change = notification.object_().To<DocChange>(); string left = string.Empty; string right = string.Empty; string top = string.Empty; string bottom = string.Empty; string minDwell = string.Empty; string maxDwell = string.Empty; string precision = string.Empty; string title = "Document Info"; if (!NSObject.IsNullOrNil(change.Document)) { FractalSettings settings = change.Document.Settings; left = settings.Extent.Left.ToString().Replace('@', 'E'); right = settings.Extent.Right.ToString().Replace('@', 'E'); top = settings.Extent.Top.ToString().Replace('@', 'E'); bottom = settings.Extent.Bottom.ToString().Replace('@', 'E'); minDwell = change.Document.MinDwell.ToString(); maxDwell = change.Document.MaxDwell.ToString(); #if LIBGMP float p1 = (settings.Extent.Width/settings.Width).Precision; float p2 = (settings.Extent.Height/settings.Height).Precision; uint p = Math.Max((uint) p1, (uint) p2); if (p < Computer.MaxDoubleBits) precision = string.Format("{0} bits (double)", p); else precision = string.Format("{0} bits (bigfloat)", p); #else precision = "52 bits"; #endif NSURL url = change.Document.fileURL(); if (!NSObject.IsNullOrNil(url)) { string path = url.path().description(); title = System.IO.Path.GetFileNameWithoutExtension(path) + " Info"; } } m_left.setStringValue(NSString.Create(left)); m_right.setStringValue(NSString.Create(right)); m_top.setStringValue(NSString.Create(top)); m_bottom.setStringValue(NSString.Create(bottom)); m_minDwell.setStringValue(NSString.Create(minDwell)); m_maxDwell.setStringValue(NSString.Create(maxDwell)); m_precision.setStringValue(NSString.Create(precision)); window().setTitle(NSString.Create(title)); }
public void docStateChanged(NSNotification notification) { DocChange change = notification.object_().To<DocChange>(); if (m_document == change.Document) { if ((change.Type & ChangeType.Settings) == ChangeType.Settings) { m_document = change.Document; FractalSettings settings = m_document.Settings; NSBitmapImageRep rep = NSBitmapImageRep.Alloc().initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel( IntPtr.Zero, // initWithBitmapDataPlanes (null means use meshed) settings.Width, // pixelsWide settings.Height, // pixelsHigh 8, // bitsPerSample 3, // samplesPerPixel false, // hasAlpha false, // isPlanar Externs.NSDeviceRGBColorSpace, // colorSpaceName 0, // bitmapFormat 0, // bytesPerRow (padding may be added) 0).To<NSBitmapImageRep>(); // bitsPerPixel (don't add meaningless bits) rep.autorelease(); // so the rep is released if an exception is thrown NSImage image = NSImage.Create(); image.addRepresentation(rep); DoCleanup(); m_rep = rep.Retain(); m_image = image.Retain(); setFrameSize(new NSSize(settings.Width, settings.Height)); m_selection = NSRect.Empty; } if (!m_refreshing) { m_refreshing = true; NSApplication.sharedApplication().BeginInvoke(this.DoRefresh, TimeSpan.FromMilliseconds(100)); } } }
public void docStateChanged(NSNotification notification) { DocChange change = notification.object_().To<DocChange>(); m_width.setEnabled(!NSObject.IsNullOrNil(change.Document)); m_height.setEnabled(!NSObject.IsNullOrNil(change.Document)); m_maxDwells.setEnabled(!NSObject.IsNullOrNil(change.Document)); if (!NSObject.IsNullOrNil(change.Document)) { if ((change.Type & ChangeType.Settings) == ChangeType.Settings) { m_width.setIntegerValue(change.Document.Settings.Width); m_height.setIntegerValue(change.Document.Settings.Height); m_maxDwells.setIntegerValue((int) change.Document.Settings.MaxDwell); string time = string.Format("Render Time: {0:0.000} mins", change.Document.RenderTime); m_timeLabel.setStringValue(NSString.Create(time)); } } }