예제 #1
0
파일: Dialog.cs 프로젝트: djlw78/FlaxAPI
        private void OnClosing(ClosingReason reason, ref bool cancel)
        {
            // Check if can close window
            if (CanCloseWindow(reason))
            {
                if (reason == ClosingReason.User)
                {
                    _result = DialogResult.Cancel;
                }

                // Clean up
                _window = null;

                // Check if any thead is blocked during ShowDialog, then wait for it
                bool wait = true;
                while (wait)
                {
                    wait = Interlocked.Read(ref _isWaitingForDialog) > 0;
                    Thread.Sleep(1);
                }

                // Close window
                return;
            }

            // Supress closing
            cancel = true;
        }
예제 #2
0
파일: Dialog.cs 프로젝트: djlw78/FlaxAPI
 /// <summary>
 /// Closes this dialog.
 /// </summary>
 public void Close()
 {
     if (_window != null)
     {
         var win = _window;
         _window = null;
         win.Close();
     }
 }
예제 #3
0
파일: Dialog.cs 프로젝트: djlw78/FlaxAPI
        /// <summary>
        /// Shows the dialog and waits for the result.
        /// </summary>
        /// <param name="parentWindow">The parent window.</param>
        /// <returns>The dialog result.</returns>
        public DialogResult ShowDialog(FlaxEngine.Window parentWindow)
        {
            // Show window
            Show(parentWindow);

            // Set wait flag
            Interlocked.Increment(ref _isWaitingForDialog);

            // Wait for the closing
            do
            {
                Thread.Sleep(1);
            } while (_window);

            // Clear wait flag
            Interlocked.Decrement(ref _isWaitingForDialog);

            return(_result);
        }
예제 #4
0
파일: Dialog.cs 프로젝트: djlw78/FlaxAPI
        /// <summary>
        /// Shows the dialog.
        /// </summary>
        /// <param name="parentWindow">The parent window.</param>
        public void Show(FlaxEngine.Window parentWindow)
        {
            // Setup initial window settings
            CreateWindowSettings settings = CreateWindowSettings.Default;

            settings.Title          = _title;
            settings.Size           = Size;
            settings.AllowMaximize  = false;
            settings.AllowMinimize  = false;
            settings.HasSizingFrame = false;
            settings.StartPosition  = WindowStartPosition.CenterParent;
            settings.Parent         = parentWindow;
            SetupWindowSettings(ref settings);

            // Create window
            _window = FlaxEngine.Window.Create(settings);
            var windowGUI = _window.GUI;

            // Attach events
            _window.OnClosing += OnClosing;
            _window.OnClosed  += OnClosed;

            // Link to the window
            Parent = windowGUI;

            // Show
            _window.Show();
            _window.Focus();
            _window.FlashWindow();

            // Perform layout
            windowGUI.UnlockChildrenRecursive();
            windowGUI.PerformLayout();

            OnShow();
        }
예제 #5
0
파일: Dialog.cs 프로젝트: djlw78/FlaxAPI
 private void OnClosed()
 {
     _window = null;
 }