Esempio n. 1
0
        private static int RhinoOptionsPageRunScriptHook(IntPtr constPagePointer, Guid runtimeId, uint uInt)
        {
            const int default_result = (int)Commands.Result.Failure;

            try
            {
                var page = OptionsDialogPageFromRuntimeId(runtimeId);
                if (page == null)
                {
                    return(default_result);
                }
                if (uInt < 1)
                {
                    uInt = RhinoDoc.ActiveDoc?.RuntimeSerialNumber ?? 0;
                }
                var doc = RhinoDoc.FromRuntimeSerialNumber(uInt);
                if (doc != null)
                {
                    return((int)page.RunScript(doc, Commands.RunMode.Scripted));
                }
            }
            catch (Exception ex)
            {
                Rhino.Runtime.HostUtils.ExceptionReport(ex);
            }
            return(default_result);
        }
 //Floating Document Text Panel Events
 #region document text IPanel events
 public void PanelShown(uint documentSerialNumber, ShowPanelReason reason)
 {
     Document = RhinoDoc.FromRuntimeSerialNumber(documentSerialNumber);
     RhinoDoc.DocumentPropertiesChanged += RhinoDoc_DocumentPropertiesChanged;
     RhinoApp.Idle      += RhinoApp_Idle;
     DocumentPanelActive = true;
     LayoutPanel();
 }
 //Floating Document Text Panel Constructor
 public UserStringsPanelControl(uint documentSerialNumber)
 {
     //Called when creating a panel for the Document Text ("like notes")
     Document            = RhinoDoc.FromRuntimeSerialNumber(documentSerialNumber);
     DocumentPanelActive = true;
     IsDocumentText      = true;
     LayoutPanel();
     LoadDocumentStrings();
 }
        private static void SnapshotRestored(int serial, uint doc_serial)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc doc = RhinoDoc.FromRuntimeSerialNumber(doc_serial);
                client.SnapshotRestored(doc);
            }
        }
        private static void AnimationStart(int serial, uint doc_serial, int iFrames)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc doc = RhinoDoc.FromRuntimeSerialNumber(doc_serial);
                client.AnimationStart(doc, iFrames);
            }
        }
        private static int SaveDocument(int serial, uint doc_serial, IntPtr pArchive)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc            doc     = RhinoDoc.FromRuntimeSerialNumber(doc_serial);
                BinaryArchiveWriter archive = new BinaryArchiveWriter(pArchive);
                bool save_doc = client.SaveDocument(doc, archive);
                return(save_doc ? 1 : 0);
            }
            return(0);
        }
        private static void ExtendBoundingBoxForDocumentAnimation(int serial, uint pDoc_serial, IntPtr pArchive_start, IntPtr pArchive_stop, ref Geometry.BoundingBox bbox)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc            doc           = RhinoDoc.FromRuntimeSerialNumber(pDoc_serial);
                BinaryArchiveReader archive_start = new BinaryArchiveReader(pArchive_start);
                BinaryArchiveReader archive_stop  = new BinaryArchiveReader(pArchive_stop);

                client.ExtendBoundingBoxForDocumentAnimation(doc, archive_start, archive_stop, ref bbox);
            }
        }
        private static void ExtendBoundingBoxForObjectAnimation(int serial, uint pDoc_serial, uint obj_serial, ref Geometry.Transform transform, IntPtr pArchive_start, IntPtr pArchive_stop, ref Geometry.BoundingBox bbox)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc doc = RhinoDoc.FromRuntimeSerialNumber(pDoc_serial);
                Rhino.DocObjects.RhinoObject obj           = new DocObjects.RhinoObject(obj_serial);
                BinaryArchiveReader          archive_start = new BinaryArchiveReader(pArchive_start);
                BinaryArchiveReader          archive_stop  = new BinaryArchiveReader(pArchive_stop);

                client.ExtendBoundingBoxForObjectAnimation(doc, obj, ref transform, archive_start, archive_stop, ref bbox);
            }
        }
        private static int RestoreObject(int serial, uint doc_serial, uint obj_serial, ref Geometry.Transform transform, IntPtr pArchive)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc                     doc     = RhinoDoc.FromRuntimeSerialNumber(doc_serial);
                BinaryArchiveReader          archive = new BinaryArchiveReader(pArchive);
                Rhino.DocObjects.RhinoObject obj     = new DocObjects.RhinoObject(obj_serial);

                bool save_doc = client.RestoreObject(doc, obj, ref transform, archive);
                return(save_doc ? 1 : 0);
            }
            return(0);
        }
        private static int PrepareForDocumentAnimation(int serial, uint pDoc_serial, IntPtr pArchive_start, IntPtr pArchive_stop)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc            doc           = RhinoDoc.FromRuntimeSerialNumber(pDoc_serial);
                BinaryArchiveReader archive_start = new BinaryArchiveReader(pArchive_start);
                BinaryArchiveReader archive_stop  = new BinaryArchiveReader(pArchive_stop);

                bool prep_doc = client.PrepareForDocumentAnimation(doc, archive_start, archive_stop);
                return(prep_doc? 1 : 0);
            }
            return(0);
        }
        private static int AnimateDocument(int serial, uint pDoc_serial, double dPos, IntPtr pArchive_start, IntPtr pArchive_stop)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc            doc           = RhinoDoc.FromRuntimeSerialNumber(pDoc_serial);
                BinaryArchiveReader archive_start = new BinaryArchiveReader(pArchive_start);
                BinaryArchiveReader archive_stop  = new BinaryArchiveReader(pArchive_stop);

                bool animate_doc = client.AnimateDocument(doc, dPos, archive_start, archive_stop);
                return(animate_doc ? 1 : 0);
            }
            return(0);
        }
        private static int PrepareForObjectAnimation(int serial, uint pDoc_serial, uint obj_serial, ref Geometry.Transform transform, IntPtr pArchive_start, IntPtr pArchive_stop)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc doc = RhinoDoc.FromRuntimeSerialNumber(pDoc_serial);
                Rhino.DocObjects.RhinoObject obj           = new DocObjects.RhinoObject(obj_serial);
                BinaryArchiveReader          archive_start = new BinaryArchiveReader(pArchive_start);
                BinaryArchiveReader          archive_stop  = new BinaryArchiveReader(pArchive_stop);

                bool animate_doc = client.PrepareForObjectAnimation(doc, obj, ref transform, archive_start, archive_stop);
                return(animate_doc ? 1 : 0);
            }
            return(0);
        }
        private static int IsCurrentModelStateInAnySnapshot(int serial, uint pDoc_serial, IntPtr pArchive, IntPtr pArchives, IntPtr pTextLog)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc                       doc      = RhinoDoc.FromRuntimeSerialNumber(pDoc_serial);
                BinaryArchiveReader            archive  = new BinaryArchiveReader(pArchive);
                SimpleArrayBinaryArchiveReader archives = new SimpleArrayBinaryArchiveReader(pArchives);

                TextLog log = null;
                if (IntPtr.Zero != pTextLog)
                {
                    new TextLog(pTextLog);
                }

                bool equal_doc = client.IsCurrentModelStateInAnySnapshot(doc, archive, archives, log);
                return(equal_doc ? 1 : 0);
            }
            return(0);
        }
Esempio n. 14
0
        public UserStringManagerPanel(uint documentSerialNumber)
        {
            _document_sn = documentSerialNumber;
            _key_table   = new DocumentUserStringsKeyTable(RhinoDoc.FromRuntimeSerialNumber(documentSerialNumber));

            // set up event handlers
            _key_table.CollectionChanged += OnKeyTableChanged;

            // set up list box
            _lb_keys.DataStore = _key_table;

            // write layout
            var layout = new DynamicLayout();

            layout.Padding = 10;
            layout.Spacing = new Size(5, 5);

            layout.Add(_lb_keys);
            layout.Add(null);

            Content = layout;
        }
Esempio n. 15
0
 public static T [] GetPanels <T> (uint documentRuntimeSerialNumber) where T : class => GetPanels <T> (RhinoDoc.FromRuntimeSerialNumber(documentRuntimeSerialNumber));
Esempio n. 16
0
 public static object[] GetPanels(Guid panelId, uint documentRuntimeSerialNumber) => GetPanels(panelId, RhinoDoc.FromRuntimeSerialNumber(documentRuntimeSerialNumber));