Exemplo n.º 1
0
 /// <summary>
 /// Does the document contain the view?
 /// </summary>
 public bool contains(CadKit.Interfaces.IDocumentView view)
 {
     using (this.Lock.read())
     {
         return(_views.Contains(view));
     }
 }
Exemplo n.º 2
0
 /// <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);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Add the view.
 /// </summary>
 void add(CadKit.Interfaces.IDocumentView view)
 {
     if (null != view && false == this.contains(view))
     {
         using (this.Lock.write())
         {
             _views.Add(view);
         }
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Populate the controls from the active view.
 /// </summary>
 private void _populateControls()
 {
     this._clearControls();
     CadKit.Interfaces.IDocumentView    view   = CadKit.Documents.Manager.Instance.ActiveView;
     CadKit.Interfaces.IJitterAntialias jitter = view as CadKit.Interfaces.IJitterAntialias;
     if (null != jitter)
     {
         _renderPassesComboBox.Items.AddRange(new object[] { jitter.AvailableRenderingPasses });
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Called when the active view changes.
 /// </summary>
 protected void _onActiveViewChanged(CadKit.Interfaces.IDocumentView oldView, CadKit.Interfaces.IDocumentView newView)
 {
     try
     {
         this.update();
     }
     catch (System.Exception e)
     {
         System.Console.WriteLine("Error 3503365250: {0}", e.Message);
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Called when the active view changes.
 /// </summary>
 private void _activeViewChanged(CadKit.Interfaces.IDocumentView oldView, CadKit.Interfaces.IDocumentView newView)
 {
     try
     {
         this._populateControls();
         this._setEnable(_snapPictureButton);
     }
     catch (System.Exception e)
     {
         System.Console.WriteLine("Error 9780016380: {0}", e.Message);
     }
 }
Exemplo n.º 7
0
        /// <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)
            {
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Remove the view.
 /// </summary>
 public void remove(CadKit.Interfaces.IDocumentView view)
 {
     while (true == this.contains(view))
     {
         using (this.Lock.write())
         {
             _views.Remove(view);
         }
     }
     if (0 == this.NumViews)
     {
         CadKit.Documents.Manager.Instance.remove(this);
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Bring the view forward.
 /// </summary>
 private void _activateView(CadKit.Interfaces.IDocumentView view)
 {
     System.Windows.Forms.Form form = view as System.Windows.Forms.Form;
     if (null != form)
     {
         if (true == form.InvokeRequired)
         {
             form.BeginInvoke(new VoidReturnZeroArgumentsDelegate(form.Activate));
         }
         else
         {
             form.Activate();
         }
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Called when the active view changes.
 /// </summary>
 private void _onActiveViewChanged(CadKit.Interfaces.IDocumentView oldView, CadKit.Interfaces.IDocumentView newView)
 {
     try
     {
         try
         {
             CadKit.Interfaces.IPropertyGridObject property = newView as CadKit.Interfaces.IPropertyGridObject;
             _grid.SelectedObject = (null == property) ? null : property.PropertyGridObject;
         }
         catch (System.InvalidCastException)
         {
         }
     }
     catch (System.Exception e)
     {
         System.Console.WriteLine("Error 2589487393: {0}", e.Message);
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Set the active document.
        /// </summary>
        private void _setActiveDocument()
        {
            CadKit.Interfaces.IDocumentView activeView = this.ActiveView;
            CadKit.Interfaces.IDocument     oldDoc     = this.ActiveDocument;

            using (this.Lock.write())
            {
                _activeDoc = (null == activeView) ? null : activeView.Document;
            }

            //if (oldDoc != this.ActiveDocument)
            {
                if (null != this.ActiveDocumentChanged)
                {
                    this.ActiveDocumentChanged(oldDoc, this.ActiveDocument);
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Set the active view.
        /// </summary>
        private void _setActiveView(CadKit.Interfaces.IDocumentView value)
        {
            //if (this.ActiveView != value)
            {
                CadKit.Interfaces.IDocumentView oldView = this.ActiveView;

                using (this.Lock.write())
                {
                    _activeView = value;
                }

                this._setActiveDocument();

                if (null != this.ActiveViewChanged)
                {
                    this.ActiveViewChanged(oldView, this.ActiveView);
                }
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// Called when the active view changes.
 /// </summary>
 private void _onActiveViewChanged(CadKit.Interfaces.IDocumentView oldView, CadKit.Interfaces.IDocumentView newView)
 {
     try
     {
         CadKit.Interfaces.IClearColor color = newView as CadKit.Interfaces.IClearColor;
         if (null != color)
         {
             try
             {
                 _editor.Color = (System.Drawing.Color)color.ClearColor;
             }
             catch (System.InvalidCastException)
             {
             }
         }
     }
     catch (System.Exception e)
     {
         System.Console.WriteLine("Error 6361619200: {0}", e.Message);
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// Does the document contain the view?
 /// </summary>
 bool CadKit.Interfaces.IDocument.contains(CadKit.Interfaces.IDocumentView view)
 {
     return(this.contains(view));
 }
Exemplo n.º 15
0
 /// <summary>
 /// Remove the view.
 /// </summary>
 void CadKit.Interfaces.IDocument.remove(CadKit.Interfaces.IDocumentView view)
 {
     this.remove(view);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Add the view.
 /// </summary>
 void CadKit.Interfaces.IDocument.add(CadKit.Interfaces.IDocumentView view)
 {
     this.add(view);
 }