private void StartOrShowPanel()
        {
            if (Bootstrapper != null)
            {
                Bootstrapper.Application.MainWindow.Show();
                return;
            }

            Bootstrapper = new Bootstrapper()
            {
                Bindings = new ConnectorBindingsRhino()
            };

            if (Application.Current == null)
            {
                new Application();
            }

            Bootstrapper.Setup(Application.Current);
            Bootstrapper.Start(new string[] { });

            Bootstrapper.Application.MainWindow.Initialized += (o, e) =>
            {
                ((ConnectorBindingsRhino)Bootstrapper.Bindings).GetFileContextAndNotifyUI();
            };

            Bootstrapper.Application.MainWindow.Closing += (object sender, System.ComponentModel.CancelEventArgs e) =>
            {
                Bootstrapper.Application.MainWindow.Hide();
                e.Cancel = true;
            };

            var helper = new System.Windows.Interop.WindowInteropHelper(Bootstrapper.Application.MainWindow);

            helper.Owner = RhinoApp.MainWindowHandle();
        }
Exemplo n.º 2
0
 public static void ShowRhinoWindow()
 {
     ShowWindow(RhinoApp.MainWindowHandle(), 1);
     BringWindowToTop(RhinoApp.MainWindowHandle());
 }
Exemplo n.º 3
0
 protected override void OnMouseDown(MouseCallbackEventArgs e)
 {
     if (e.Button == MouseButtons.Left && _cm != null && (_cm.EnabledGlobal && _cm.InActiveDocument) && GetForegroundWindow() == RhinoApp.MainWindowHandle())
     {
         _cm.MouseLine = e.View.ActiveViewport.ClientToWorld(e.ViewportPoint);
         _cm.ExpireSolution(true);
         e.Cancel = true;
     }
     else
     {
         base.OnMouseDown(e);
     }
 }
Exemplo n.º 4
0
            static void SemiModalFormLoad(object sender, EventArgs e)
            {
                IntPtr hMainWnd = RhinoApp.MainWindowHandle();

                UnsafeNativeMethods.EnableWindow(hMainWnd, true);
            }
Exemplo n.º 5
0
        internal static Result Startup()
        {
            if (core is null)
            {
                // Load RhinoCore
                try
                {
                    core = new RhinoCore
                           (
                        new string[]
                    {
                        "/nosplash",
                        "/notemplate",
                        "/captureprintcalls",
                        "/stopwatch",
                        $"/scheme={SchemeName}",
                        $"/language={Revit.ApplicationUI.ControlledApplication.Language.ToLCID()}"
                    },
                        WindowStyle.Hidden
                           );
                }
                catch
                {
                    Addin.CurrentStatus = Addin.Status.Failed;
                    return(Result.Failed);
                }
                finally
                {
                    StartupLog = RhinoApp.CapturedCommandWindowStrings(true);
                    RhinoApp.CommandWindowCaptureEnabled = false;
                }

                MainWindow = new WindowHandle(RhinoApp.MainWindowHandle());
                External.ActivationGate.AddGateWindow(MainWindow.Handle);

                RhinoApp.MainLoop += MainLoop;

                RhinoDoc.NewDocument += OnNewDocument;
                RhinoDoc.EndOpenDocumentInitialViewUpdate += EndOpenDocumentInitialViewUpdate;

                Command.BeginCommand += BeginCommand;
                Command.EndCommand   += EndCommand;

                // Alternative to /runscript= Rhino command line option
                RunScriptAsync
                (
                    script:   Environment.GetEnvironmentVariable("RhinoInside_RunScript"),
                    activate: Addin.StartupMode == AddinStartupMode.AtStartup
                );

                // Reset document units
                UpdateDocumentUnits(RhinoDoc.ActiveDoc);
                UpdateDocumentUnits(RhinoDoc.ActiveDoc, Revit.ActiveDBDocument);

                Type[] types = default;
                try { types = Assembly.GetCallingAssembly().GetTypes(); }
                catch (ReflectionTypeLoadException ex) { types = ex.Types?.Where(x => x is object).ToArray(); }

                // Look for Guests
                guests = types.
                         Where(x => typeof(IGuest).IsAssignableFrom(x)).
                         Where(x => !x.IsInterface).
                         Select(x => new GuestInfo(x)).
                         ToList();

                CheckInGuests();

                //Enable Revit window back
                WindowHandle.ActiveWindow = Revit.MainWindow;
            }

            return(Result.Succeeded);
        }
Exemplo n.º 6
0
 public static void RhinoSetProgressValue(ulong current, ulong maximum)
 {
     SetProgressValue(RhinoApp.MainWindowHandle(), current, maximum);
 }
Exemplo n.º 7
0
 public static void RhinoSetProgressState(ThumbnailProgressState state)
 {
     SetProgressState(RhinoApp.MainWindowHandle(), state);
 }
Exemplo n.º 8
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var filename = string.Empty;

            if (mode == Rhino.Commands.RunMode.Interactive)
            {
                filename = RhinoGet.GetFileName(GetFileNameMode.OpenRhinoOnly, null, "Open", RhinoApp.MainWindowHandle());
            }
            else
            {
                RhinoGet.GetString("Name of Rhino file to open", false, ref filename);
            }

            filename = filename.Trim();
            if (string.IsNullOrEmpty(filename))
            {
                return(Result.Cancel);
            }

            if (!System.IO.File.Exists(filename))
            {
                RhinoApp.WriteLine("File not found.");
                return(Result.Failure);
            }

            // Make sure to surround filename string with double-quote characters
            // in case the path contains spaces.
            var script = string.Format("_-Open \"{0}\"", filename);

            RhinoApp.RunScript(script, false);

            return(Result.Success);
        }
Exemplo n.º 9
0
        public SampleViewModel(/*IAction addBrepsToDoc*/)
        {
            this.HostApplicationWindowHandle = RhinoApp.MainWindowHandle();

            this.AddBrepCommand = new AddBrepCommand(new AddBrepsToDocument());
        }
Exemplo n.º 10
0
 internal static IntPtr GetEnabledPopup() => GetWindow(RhinoApp.MainWindowHandle(), 6 /*GW_ENABLEDPOPUP*/);
Exemplo n.º 11
0
 internal static bool ShowOwnedPopups(bool fShow) => ShowOwnedPopups(RhinoApp.MainWindowHandle(), fShow);
Exemplo n.º 12
0
 public void OpenRhino()
 {
     ShowWindow(RhinoApp.MainWindowHandle(), 1);
     BringWindowToTop(RhinoApp.MainWindowHandle());
 }
        internal static Result Startup()
        {
            if (core is null)
            {
                // Load RhinoCore
                try
                {
                    core = new RhinoCore
                           (
                        new string[]
                    {
                        "/nosplash",
                        "/notemplate",
                        "/captureprintcalls",
                        "/stopwatch",
                        $"/scheme={SchemeName}",
                        $"/language={Revit.ApplicationUI.ControlledApplication.Language.ToLCID()}"
                    },
                        WindowStyle.Hidden
                           );
                }
                catch
                {
                    Addin.CurrentStatus = Addin.Status.Failed;
                    return(Result.Failed);
                }
                finally
                {
                    StartupLog = RhinoApp.CapturedCommandWindowStrings(true);
                    RhinoApp.CommandWindowCaptureEnabled = false;
                }

                MainWindow = new WindowHandle(RhinoApp.MainWindowHandle());
                External.ActivationGate.AddGateWindow(MainWindow.Handle);

                RhinoApp.MainLoop += MainLoop;

                RhinoDoc.NewDocument += OnNewDocument;
                RhinoDoc.EndOpenDocumentInitialViewUpdate += EndOpenDocumentInitialViewUpdate;

                Command.BeginCommand += BeginCommand;
                Command.EndCommand   += EndCommand;

                // Alternative to /runscript= Rhino command line option
                RunScriptAsync
                (
                    script:   Environment.GetEnvironmentVariable("RhinoInside_RunScript"),
                    activate: Addin.StartupMode == AddinStartupMode.AtStartup
                );

                // Add DefaultRenderAppearancePath to Rhino settings if missing
                {
                    var DefaultRenderAppearancePath = System.IO.Path.Combine
                                                      (
                        Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFilesX86),
                        "Autodesk Shared",
                        "Materials",
                        "Textures"
                                                      );

                    if (!Rhino.ApplicationSettings.FileSettings.GetSearchPaths().Any(x => x.Equals(DefaultRenderAppearancePath, StringComparison.InvariantCultureIgnoreCase)))
                    {
                        Rhino.ApplicationSettings.FileSettings.AddSearchPath(DefaultRenderAppearancePath, -1);
                    }

                    // TODO: Add also AdditionalRenderAppearancePaths content from Revit.ini if missing ??
                }

                // Reset document units
                UpdateDocumentUnits(RhinoDoc.ActiveDoc);
                UpdateDocumentUnits(RhinoDoc.ActiveDoc, Revit.ActiveDBDocument);

                Type[] types = default;
                try { types = Assembly.GetCallingAssembly().GetTypes(); }
                catch (ReflectionTypeLoadException ex) { types = ex.Types?.Where(x => x is object).ToArray(); }

                // Look for Guests
                guests = types.
                         Where(x => typeof(IGuest).IsAssignableFrom(x)).
                         Where(x => !x.IsInterface && !x.IsAbstract && !x.ContainsGenericParameters).
                         Select(x => new GuestInfo(x)).
                         ToList();

                CheckInGuests();
            }

            return(Result.Succeeded);
        }