Ejemplo n.º 1
0
        Stream(ArrayList data, Autodesk.AutoCAD.Windows.Window win)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(Autodesk.AutoCAD.Windows.Window)));

            data.Add(new Snoop.Data.Object("Handle", win.Handle));
#if (AC2012)
#else
            data.Add(new Snoop.Data.Icon("Icon", win.GetIcon()));
            data.Add(new Snoop.Data.Object("Location", win.GetLocation()));
            data.Add(new Snoop.Data.Object("Size", win.GetSize()));
#endif
            data.Add(new Snoop.Data.String("Text", win.Text));
            data.Add(new Snoop.Data.Bool("Visible", win.Visible));
            data.Add(new Snoop.Data.String("Window state", win.WindowState.ToString()));
        }
Ejemplo n.º 2
0
        public static void changeScreenSize()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;

            Autodesk.AutoCAD.Windows.Window docWindow = doc.Window;

            System.Drawing.Size size = docWindow.GetSize();

            Editor ed = doc.Editor;

            ed.WriteMessage("\nDocument Size:\n" + size.ToString() + "\n");

            docWindow.WindowState = Window.State.Normal;

            docWindow.SetSize(new System.Drawing.Size(500, 500));
        }
Ejemplo n.º 3
0
        private static void ScreenShotToFile(Autodesk.AutoCAD.Windows.Window wd, string filename, int top, int bottom, int left, int right)
        {
            //Read the window points

            System.Windows.Point ConvertPT = wd.DeviceIndependentLocation;
            System.Windows.Size  ConvertSZ = wd.DeviceIndependentSize;

            System.Drawing.Point pt = new System.Drawing.Point();
            System.Drawing.Size  sz = new System.Drawing.Size();

            //check to make sure double is small enough for int and then convert
            if ((int)wd.DeviceIndependentLocation.X < 2147483647)
            {
                pt.X = (int)wd.DeviceIndependentLocation.X;
            }
            else
            {
                Application.ShowAlertDialog("\nScreenshot.cs   Line 53  Double too large for Int ");
                Environment.Exit(0);
            }

            if ((int)wd.DeviceIndependentLocation.Y < 2147483647)
            {
                pt.Y = (int)wd.DeviceIndependentLocation.Y;
            }
            else
            {
                Application.ShowAlertDialog("\nScreenshot.cs   Line 64  Double too large for Int ");
                Environment.Exit(0);
            }
            //Size
            if ((int)wd.DeviceIndependentSize.Width < 2147483647)
            {
                sz.Width = (int)wd.DeviceIndependentSize.Width;
            }
            else
            {
                Application.ShowAlertDialog("\nScreenshot.cs   Line 73  Double too large for Int ");
                Environment.Exit(0);
            }

            if ((int)wd.DeviceIndependentSize.Height < 2147483647)
            {
                sz.Height = (int)wd.DeviceIndependentSize.Height;
            }
            else
            {
                Application.ShowAlertDialog("\nScreenshot.cs   Line 82  Double too large for Int ");
                Environment.Exit(0);
            }


            pt.X      += left;
            pt.Y      += top;
            sz.Height -= top + bottom;
            sz.Width  -= left + right;

            // Set the bitmap object to the size of the screen
            Bitmap bmp = new Bitmap(sz.Width, sz.Height, PixelFormat.Format32bppArgb);

            using (bmp)
            {
                // Create a graphics object from the bitmap

                using (Graphics gfx = Graphics.FromImage(bmp))
                {
                    // Take a screenshot of our window

                    gfx.CopyFromScreen(pt.X, pt.Y, 0, 0, sz, CopyPixelOperation.SourceCopy);

                    // Save the screenshot to the specified location

                    bmp.Save(filename);//, ImageFormat.Bmp

                    bmp.Dispose();
                }
            }
        }
Ejemplo n.º 4
0
        CollectEvent(object sender, CollectorEventArgs e)
        {
            // cast the sender object to the SnoopCollector we are expecting
            Collector snoopCollector = sender as Collector;

            if (snoopCollector == null)
            {
                Debug.Assert(false);    // why did someone else send us the message?
                return;
            }

            // branch to all types we are concerned with
            System.Type type = e.ObjToSnoop as System.Type;
            if (type != null)
            {
                Stream(snoopCollector.Data(), type);
                return;
            }

            System.Version ver = e.ObjToSnoop as System.Version;
            if (ver != null)
            {
                Stream(snoopCollector.Data(), ver);
                return;
            }

            System.Collections.Specialized.StringCollection strCol = e.ObjToSnoop as System.Collections.Specialized.StringCollection;
            if (strCol != null)
            {
                Stream(snoopCollector.Data(), strCol);
                return;
            }

            AcAp.Document doc = e.ObjToSnoop as AcAp.Document;
            if (doc != null)
            {
                Stream(snoopCollector.Data(), doc);
                return;
            }

            AcAp.DocumentCollectionEventArgs docCollectEventArgs = e.ObjToSnoop as AcAp.DocumentCollectionEventArgs;
            if (docCollectEventArgs != null)
            {
                Stream(snoopCollector.Data(), docCollectEventArgs);
                return;
            }

            AcAp.DocumentLockModeWillChangeEventArgs docLockModeEventArgs = e.ObjToSnoop as AcAp.DocumentLockModeWillChangeEventArgs;
            if (docLockModeEventArgs != null)
            {
                Stream(snoopCollector.Data(), docLockModeEventArgs);
                return;
            }

            AcAp.DocumentLockModeChangedEventArgs docLockModeChangedEventArgs = e.ObjToSnoop as AcAp.DocumentLockModeChangedEventArgs;
            if (docLockModeChangedEventArgs != null)
            {
                Stream(snoopCollector.Data(), docLockModeChangedEventArgs);
                return;
            }

            AcAp.DocumentLockModeChangeVetoedEventArgs docLockModeVetoedEventArgs = e.ObjToSnoop as AcAp.DocumentLockModeChangeVetoedEventArgs;
            if (docLockModeVetoedEventArgs != null)
            {
                Stream(snoopCollector.Data(), docLockModeVetoedEventArgs);
                return;
            }

            AcAp.DocumentDestroyedEventArgs docDestroyedEventArgs = e.ObjToSnoop as AcAp.DocumentDestroyedEventArgs;
            if (docDestroyedEventArgs != null)
            {
                Stream(snoopCollector.Data(), docDestroyedEventArgs);
                return;
            }

            AcAp.DocumentCollection docCollection = e.ObjToSnoop as AcAp.DocumentCollection;
            if (docCollection != null)
            {
                Stream(snoopCollector.Data(), docCollection);
                return;
            }

            AcAp.XrefFileLock xrefFileLock = e.ObjToSnoop as AcAp.XrefFileLock;
            if (xrefFileLock != null)
            {
                Stream(snoopCollector.Data(), xrefFileLock);
                return;
            }

            Autodesk.AutoCAD.Windows.Window win = e.ObjToSnoop as Autodesk.AutoCAD.Windows.Window;
            if (win != null)
            {
                Stream(snoopCollector.Data(), win);
                return;
            }

            Autodesk.AutoCAD.Windows.StatusBar statusBar = e.ObjToSnoop as Autodesk.AutoCAD.Windows.StatusBar;
            if (statusBar != null)
            {
                Stream(snoopCollector.Data(), statusBar);
                return;
            }

            Autodesk.AutoCAD.Windows.StatusBarItem statusBarItem = e.ObjToSnoop as Autodesk.AutoCAD.Windows.StatusBarItem;
            if (statusBarItem != null)
            {
                Stream(snoopCollector.Data(), statusBarItem);
                return;
            }
        }