/// <summary>
        /// Adds an overlay to the specified view.
        /// </summary>
        public TOverlay Add <TOverlay>(SolidEdgeFramework.View view) where TOverlay : ViewOverlay
        {
            TOverlay overlay = Activator.CreateInstance <TOverlay>();

            Add(view, overlay);
            return(overlay);
        }
 /// <summary>
 /// Gets the overlay for the specified view.
 /// </summary>
 public ViewOverlay GetOverlay(SolidEdgeFramework.View view)
 {
     if (view == null)
     {
         throw new ArgumentNullException("view");
     }
     return(_overlays.Where(x => x.View.Equals(view)).FirstOrDefault());
 }
Esempio n. 3
0
        void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    // Unhook all events.
                    UnadviseAllSinks();
                }

                _view       = null;
                _controller = null;
                _disposed   = true;
            }
        }
        /// <summary>
        /// Removes all overlays for the specified view.
        /// </summary>
        public void RemoveAll(SolidEdgeFramework.View view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            //var viewOverlays = _overlays.Where(x => x.IsDisposed == false).Where(x => x.View.Equals(view)).ToArray();
            var overlays = _overlays.Where(x => x.View.Equals(view)).ToArray();

            foreach (var overlay in overlays)
            {
                Remove(overlay);
            }
        }
Esempio n. 5
0
    public static void SaveAsImage(SolidEdgeFramework.Window window)
    {
        string[] extensions = { ".jpg", ".bmp", ".tif" };

        SolidEdgeFramework.View view = null;
        Guid   guid   = Guid.NewGuid();
        string folder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

        if (window == null)
        {
            throw new ArgumentNullException("window");
        }

        // Get a reference to the 3D view.
        view = window.View;

        // Save each extension.
        foreach (string extension in extensions)
        {
            // File saved to desktop.
            string filename = Path.ChangeExtension(guid.ToString(), extension);
            filename = Path.Combine(folder, filename);

            double resolution = 1.0;  // DPI - Larger values have better quality but also lead to larger file.
            int    colorDepth = 24;
            int    width      = window.UsableWidth;
            int    height     = window.UsableHeight;

            // You can specify .bmp (Windows Bitmap), .tif (TIFF), or .jpg (JPEG).
            view.SaveAsImage(
                Filename: filename,
                Width: width,
                Height: height,
                AltViewStyle: null,
                Resolution: resolution,
                ColorDepth: colorDepth,
                ImageQuality: SolidEdgeFramework.SeImageQualityType.seImageQualityHigh,
                Invert: false);

            Console.WriteLine("Saved '{0}'.", filename);
        }
    }
        /// <summary>
        /// Adds an overlay to the specified view.
        /// </summary>
        public void Add(SolidEdgeFramework.View view, ViewOverlay overlay)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }
            if (overlay == null)
            {
                throw new ArgumentNullException("overlay");
            }

            if (HasOverlay(view))
            {
                throw new System.Exception("Specified view already has an overlay.");
            }

            overlay.Controller = this;
            overlay.View       = view;
            _overlays.Add(overlay);
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application = null;
            SolidEdgeFramework.Window      window      = null;

            try
            {
                // Register with OLE to handle concurrency issues on the current thread.
                SolidEdgeCommunity.OleMessageFilter.Register();

                // Connect to Solid Edge.
                application = SolidEdgeCommunity.SolidEdgeUtils.Start();

                // 3D windows are of type SolidEdgeFramework.Window.
                window = application.ActiveWindow as SolidEdgeFramework.Window;

                if (window != null)
                {
                    string[] extensions = { ".jpg", ".bmp", ".tif" };

                    SolidEdgeFramework.View view = null;
                    Guid   guid   = Guid.NewGuid();
                    string folder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

                    if (window == null)
                    {
                        throw new ArgumentNullException("window");
                    }

                    // Get a reference to the 3D view.
                    view = window.View;

                    // Save each extension.
                    foreach (string extension in extensions)
                    {
                        // File saved to desktop.
                        string filename = System.IO.Path.ChangeExtension(guid.ToString(), extension);
                        filename = System.IO.Path.Combine(folder, filename);

                        double resolution = 1.0;  // DPI - Larger values have better quality but also lead to larger file.
                        int    colorDepth = 24;
                        int    width      = window.UsableWidth;
                        int    height     = window.UsableHeight;

                        // You can specify .bmp (Windows Bitmap), .tif (TIFF), or .jpg (JPEG).
                        view.SaveAsImage(
                            Filename: filename,
                            Width: width,
                            Height: height,
                            AltViewStyle: null,
                            Resolution: resolution,
                            ColorDepth: colorDepth,
                            ImageQuality: SolidEdgeFramework.SeImageQualityType.seImageQualityHigh,
                            Invert: false);

                        Console.WriteLine("Saved '{0}'.", filename);
                    }
                }
                else
                {
                    throw new System.Exception("No active 3D window.");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                SolidEdgeCommunity.OleMessageFilter.Unregister();
            }
        }
 /// <summary>
 /// Determines if the specified view has an overlay.
 /// </summary>
 public bool HasOverlay(SolidEdgeFramework.View view)
 {
     return(_overlays.Where(x => x.View.Equals(view)).FirstOrDefault() != null);
 }