Exemplo n.º 1
0
        public SugzWindow()
        {
            Loaded       += SugzWindow_Loaded;
            ShowInTaskbar = false;
            WindowInteropHelper windowHandle = new WindowInteropHelper(this);

            windowHandle.Owner = AppSDK.GetMaxHWND();
            AppSDK.ConfigureWindowForMax(this);
            Show();
        }
Exemplo n.º 2
0
        public void Show()
        {
            // Create an interop helper
            System.Windows.Interop.WindowInteropHelper windowHandle =
                new System.Windows.Interop.WindowInteropHelper(_wnd);

            // Assign the 3ds Max HWnd handle to the interop helper
            windowHandle.Owner = AppSDK.GetMaxHWND();

            // Setup 3ds Max to handle the WPF correctly
            AppSDK.ConfigureWindowForMax(_wnd);

            _wnd.Show();
        }
Exemplo n.º 3
0
 private BitmapSource GetMaxIcon()
 {
     // only works in the context of 3ds Max
     try
     {
         var hBitmap = AppSDK.GetMainApplicationIcon().ToBitmap().GetHbitmap();
         return(Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty,
                                                      BitmapSizeOptions.FromEmptyOptions()));
     }
     catch (Exception ex)
     {
         Log.Instance.Error($"{ex.Message}\n{ex}", Strings.SubmitJob_Icon_Error);
         return(null);
     }
 }
Exemplo n.º 4
0
        public static void OpenMainWindow()
        {
            mainWindow = new MainWindow();
            mainWindow.ShowInTaskbar = false;

            // ReSharper disable once ObjectCreationAsStatement
            new WindowInteropHelper(mainWindow)
            {
                Owner = AppSDK.GetMaxHWND()
            };

            AppSDK.ConfigureWindowForMax(mainWindow);

            Interactions.Setup(mainWindow, new MaxProvider());
            mainWindow.Show();
        }
Exemplo n.º 5
0
        /// <summary>
        /// This will be called when the utility plugin is activated
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="iu"></param>
        public override void BeginEditParams(IInterface ip, IIUtil iu)
        {
            //the window will stay open regardless if you close the utility plugin
            //if a running instance of the mianwindow is found it will just do nothing
            //else it will create a window and show it
            if (MainWindow.Instance != null)
            {
                return;
            }

            // attach the window to the window handling of max
            // that way the window itself wont loose its order
            // but now it wont go to system tray if you minimize it
            MainWindow window = new MainWindow();

            AppSDK.ConfigureWindowForMax(window);

            window.Show();
        }
Exemplo n.º 6
0
        private void OpenJobConfigWindow()
        {
            try
            {
                var dialog = new Window
                {
                    Title                 = Strings.SubmitJob_Title,
                    SizeToContent         = SizeToContent.WidthAndHeight,
                    WindowStartupLocation = WindowStartupLocation.CenterOwner,
                    ResizeMode            = ResizeMode.CanResizeWithGrip,
                    ShowInTaskbar         = true
                };

                _maxRequestInterceptor = new MaxRequestInterceptor();
                var jobSubmissionForm = new JobSubmissionForm(LabsRequestHandler, _maxRequestInterceptor, Log.Instance);
                dialog.Content = jobSubmissionForm;

#if !DEBUG
                // only works in the context of 3ds Max
                var maxIcon = GetMaxIcon();
                if (maxIcon != null)
                {
                    dialog.Icon = maxIcon;
                }

                var windowHandle = new WindowInteropHelper(dialog);
                windowHandle.Owner = AppSDK.GetMaxHWND();
                AppSDK.ConfigureWindowForMax(dialog);
#endif
                dialog.Show();
            }
            catch (Exception ex)
            {
                Log.Instance.Error($"{ex.Message}\n{ex}", Strings.SubmitJob_Error, true);
                MessageBox.Show($"{Strings.SubmitJob_Error}.\n{ex.Message}\n{ex}");
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Sets the main form icon based on the application icon.
 ///
 /// </summary>
 private void InitializeMainIcon()
 {
     this.Icon = AppSDK.GetMainApplicationIcon();
 }
Exemplo n.º 8
0
 /// <summary>
 /// Handles the Closed event.
 ///
 /// </summary>
 /// <param name="sender">The object that generated the event this method handles.</param><param name="e">The args for this event. EventArgs.Empty by default.</param>
 private void FormClosedHandler(object sender, FormClosedEventArgs e)
 {
     this.FormClosed -= new FormClosedEventHandler(this.FormClosedHandler);
     Win32API.BringWindowToTop(AppSDK.GetMaxHWND());
 }
Exemplo n.º 9
0
 /// <summary>
 /// Disables application accelerators when the
 ///             form is activated. Note that this is not called when Frame is active.
 ///
 /// </summary>
 /// <param name="sender">The object that generated the event this method handles.</param><param name="e">The args for this event. EventArgs.Empty by default.</param>
 private void HandleActivate(object sender, EventArgs e)
 {
     AppSDK.DisableAccelerators();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Displays this form as a modal dialog and
 ///             sets the main application's window as the parent.
 ///
 /// </summary>
 ///
 /// <returns>
 /// The result of this modal interaction.  The
 ///             return value is the same as Form.ShowDialog(IWin32Window)
 ///
 /// </returns>
 public virtual DialogResult ShowModal()
 {
     return(this.ShowDialog((IWin32Window)NativeWindow.FromHandle(AppSDK.GetMaxHWND())));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Displays this form modelessly sets the main application's window as
 ///             the parent.
 ///
 /// </summary>
 public virtual void ShowModeless()
 {
     this.Show((IWin32Window)NativeWindow.FromHandle(AppSDK.GetMaxHWND()));
 }