示例#1
0
 public Mouse(
     View view,
     Visual uiRendererRoot,
     NoesisConfig config)
 {
     this.view = view;
     this.doubleClickInterval          = TimeSpan.FromSeconds(config.InputMouseDoubleClickIntervalSeconds);
     this.uiRendererRoot               = uiRendererRoot;
     this.checkIfElementIgnoresHitTest = config.CheckIfElementIgnoresHitTest;
 }
示例#2
0
        public Mouse(
            View view,
            Visual rootVisual,
            FrameworkElement controlTreeRoot,
            NoesisConfig config)
        {
            this.view            = view;
            this.rootVisual      = rootVisual;
            this.controlTreeRoot = controlTreeRoot;

            this.checkIfElementIgnoresHitTest = config.CheckIfElementIgnoresHitTest;
            this.doubleClickInterval          = TimeSpan.FromSeconds(config.InputMouseDoubleClickIntervalSeconds);
            this.isProcessMiddleButton        = config.IsProcessMouseMiddleButton;
        }
        /// <param name="gameWindow">The MonoGame GameWindow instance.</param>
        /// <param name="graphics">Graphics device manager of the game instance.</param>
        /// <param name="rootXamlFilePath">Local XAML file path - will be used as the UI root element.</param>
        /// <param name="themeXamlFilePath">(can be null) Local XAML file path - will be used as global ResourceDictionary (UI style).</param>
        /// <param name="checkIfElementIgnoresHitTest">
        /// Callback to invoke when element is tested for hit test (if callback returns true hit is ignored).
        /// </param>
        /// <param name="onErrorMessageReceived">Callback to invoke when error message received from NoesisGUI.</param>
        /// <param name="onExceptionThrown">
        /// Callback to invoke when exception thrown from NoesisGUI context (can be in event
        /// handler, etc).
        /// </param>
        /// <param name="currentTotalGameTime">Current game time (needed to do proper Update() calls).</param>
        public NoesisConfig(
            GameWindow gameWindow,
            GraphicsDeviceManager graphics,
            string rootXamlFilePath,
            string themeXamlFilePath,
            TimeSpan currentTotalGameTime,
            HitTestIgnoreDelegate checkIfElementIgnoresHitTest = null,
            Action <string> onErrorMessageReceived             = null,
            Action <Exception> onExceptionThrown = null)
        {
            if (string.IsNullOrEmpty(rootXamlFilePath))
            {
                throw new ArgumentNullException(
                          nameof(rootXamlFilePath),
                          "File path to the root xaml element cannot be null");
            }

            //if (string.IsNullOrEmpty(themeXamlFilePath))
            //{
            //    throw new ArgumentNullException(
            //        nameof(themeXamlFilePath),
            //        "File path to the theme xaml element cannot be null");
            //}

            if (gameWindow == null)
            {
                throw new ArgumentNullException(nameof(gameWindow));
            }

            if (graphics == null)
            {
                throw new ArgumentNullException(nameof(graphics));
            }

            this.GameWindow                   = gameWindow;
            this.Graphics                     = graphics;
            this.RootXamlFilePath             = rootXamlFilePath.Replace('/', '\\');
            this.ThemeXamlFilePath            = themeXamlFilePath?.Replace('/', '\\');
            this.CheckIfElementIgnoresHitTest = checkIfElementIgnoresHitTest;
            this.OnErrorMessageReceived       = onErrorMessageReceived;
            this.OnExceptionThrown            = onExceptionThrown;
            this.CurrentTotalGameTime         = currentTotalGameTime;
        }
        /// <param name="gameWindow">The MonoGame GameWindow instance.</param>
        /// <param name="graphics">Graphics device manager of the game instance.</param>
        /// <param name="noesisProviderManager">NoesisGUI Provider Manager (create it before calling this method).</param>
        /// <param name="rootXamlFilePath">Local XAML file path - will be used as the UI root element.</param>
        /// <param name="themeXamlFilePath">
        /// (can be null) Local XAML file path - will be used as global ResourceDictionary (UI
        /// style).
        /// </param>
        /// <param name="checkIfElementIgnoresHitTest">
        /// Callback to invoke when element is tested for hit test (if callback returns true hit is ignored).
        /// It has default implementation so you can skip this.
        /// </param>
        /// <param name="onErrorMessageReceived">Callback to invoke when error message received from NoesisGUI.</param>
        /// <param name="onExceptionThrown">
        /// Callback to invoke when exception thrown from NoesisGUI context (can be in event
        /// handler, etc).
        /// </param>
        /// <param name="currentTotalGameTime">Current game time (needed to do proper Update() calls).</param>
        /// <param name="isEnableDirectionalNavigation">
        /// Is directional (arrow) keys navigation should be enabled? If it's disabled (by default)
        /// arrow key presses will be not passed to NoesisGUI unless it's focused on a textbox.
        /// </param>
        /// <param name="isProcessMouseMiddleButton">
        /// Enable processing of the middle (scrollwheel) mouse button (disabled by
        /// default).
        /// </param>
        public NoesisConfig(
            GameWindow gameWindow,
            GraphicsDeviceManager graphics,
            NoesisProviderManager noesisProviderManager,
            string rootXamlFilePath,
            string themeXamlFilePath,
            TimeSpan currentTotalGameTime,
            HitTestIgnoreDelegate checkIfElementIgnoresHitTest = null,
            Action <string> onErrorMessageReceived             = null,
            Action <Exception> onExceptionThrown = null,
            bool isEnableDirectionalNavigation   = false,
            bool isProcessMouseMiddleButton      = false)
        {
            if (string.IsNullOrEmpty(rootXamlFilePath))
            {
                throw new ArgumentNullException(
                          nameof(rootXamlFilePath),
                          "File path to the root xaml element cannot be null");
            }

            this.GameWindow = gameWindow ?? throw new ArgumentNullException(nameof(gameWindow));
            this.Graphics   = graphics ?? throw new ArgumentNullException(nameof(graphics));

            this.RootXamlFilePath  = rootXamlFilePath.Replace('/', '\\');
            this.ThemeXamlFilePath = themeXamlFilePath?.Replace('/', '\\');

            this.CheckIfElementIgnoresHitTest = checkIfElementIgnoresHitTest
                                                ?? this.DefaultCheckIfElementIgnoresHitTest;

            this.OnErrorMessageReceived        = onErrorMessageReceived;
            this.OnExceptionThrown             = onExceptionThrown;
            this.CurrentTotalGameTime          = currentTotalGameTime;
            this.IsProcessMouseMiddleButton    = isProcessMouseMiddleButton;
            this.NoesisProviderManager         = noesisProviderManager;
            this.IsEnableDirectionalNavigation = isEnableDirectionalNavigation;
        }