/// <summary> /// Called when the button needs to be painted. /// </summary> private void _setEnable(object sender) { System.Windows.Forms.Control control = sender as System.Windows.Forms.Control; if (null != control) { CadKit.Interfaces.IDocumentView view = CadKit.Documents.Manager.Instance.ActiveView; CadKit.Interfaces.ISnapShot snap = view as CadKit.Interfaces.ISnapShot; control.Enabled = (null != snap); } }
/// <summary> /// Take a picture. /// </summary> private void _snapPicture() { try { CadKit.Interfaces.IDocumentView view = CadKit.Documents.Manager.Instance.ActiveView; CadKit.Interfaces.ISnapShot snap = view as CadKit.Interfaces.ISnapShot; if (null != snap) { // Get properties. float frameScale = this._getFloat(_frameScaleTextBox.Text, _frameScaleTextBox); float scatterScale = this._getFloat(_scatterScaleTextBox.Text, _scatterScaleTextBox); uint renderPasses = this._getUInt32(_renderPassesComboBox.Text, _renderPassesComboBox); // Save in registry. CadKit.Persistence.Registry.Instance.setString(REGISTRY_SECTION, FRAME_SCALE, _frameScaleTextBox.Text); CadKit.Persistence.Registry.Instance.setString(REGISTRY_SECTION, SCATTER_SCALE, _scatterScaleTextBox.Text); CadKit.Persistence.Registry.Instance.setString(REGISTRY_SECTION, RENDER_PASSES, _renderPassesComboBox.Text); // Make file name. string file = this._makeTempImageFile("bmp"); // Feedback. System.Console.WriteLine(System.String.Format("Saving image file: {0}", file)); System.DateTime start = System.DateTime.Now; // Take picture. snap.takePicture(file, renderPasses, frameScale, scatterScale); // Feedback. System.TimeSpan duration = System.DateTime.Now - start; System.Console.WriteLine(System.String.Format("Time to save image file: {0}", duration)); // Save in list. _files.Add(file); // Launch default program for image file. System.Diagnostics.Process.Start(file); } } // Eat these exceptions. catch (System.ArgumentNullException) { } catch (System.OverflowException) { } catch (System.FormatException) { } }