public KStreamWindowAggregate(WindowOptions <W> windowOptions, string storeName, Initializer <Agg> initializer, Aggregator <K, V, Agg> aggregator)
 {
     WindowOptions    = windowOptions;
     this.storeName   = storeName;
     this.initializer = initializer;
     this.aggregator  = aggregator;
 }
Ejemplo n.º 2
0
 private void btnOptions_Click(object sender, RibbonControlEventArgs e)
 {
     using (var options = new WindowOptions(OutlookHelpers.GetDictionaryStores()))
     {
         options.ShowDialog();
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a new GlfwWindow.
        /// </summary>
        /// <param name="options">The options to use for this window.</param>
        public unsafe GlfwWindow(WindowOptions options, GlfwWindow parent, GlfwMonitor monitor)
        {
            // Title and Size must be set before the window is created.
            _title = options.Title;
            _size  = options.Size;

            _windowBorder = WindowBorder;

            FramesPerSecond  = options.FramesPerSecond;
            UpdatesPerSecond = options.UpdatesPerSecond;

            RunningSlowTolerance    = options.RunningSlowTolerance;
            UseSingleThreadedWindow = options.UseSingleThreadedWindow;
            ShouldSwapAutomatically = options.ShouldSwapAutomatically;

            _initialOptions = options;
            _initialMonitor = monitor;
            Parent          = (IWindowHost)parent ?? _initialMonitor;

            GlfwProvider.GLFW.Value.GetVersion(out var major, out var minor, out _);
            if (new Version(major, minor) < new Version(3, 3))
            {
                throw new NotSupportedException("GLFW 3.3 or later is required for Silk.NET.Windowing.Desktop.");
            }
        }
Ejemplo n.º 4
0
 public GlfwWindow(WindowOptions optionsCache, GlfwWindow?parent, GlfwMonitor?monitor) : base(optionsCache)
 {
     _glfw            = GlfwProvider.GLFW.Value;
     _parent          = parent;
     _initialMonitor  = monitor;
     _localTitleCache = optionsCache.Title;
 }
        public void OnCustomThemeButtonClick(object sender, RoutedEventArgs e)
        {
            string ButtonName = string.Empty;

            try
            {
                ButtonName = ((Button)sender).Name;
                if (ButtonName == "PART_CustomSsvButton")
                {
                    Common.LogDebug(true, $"OnCustomThemeButtonClick()");

                    WindowOptions windowOptions = new WindowOptions
                    {
                        ShowMinimizeButton = false,
                        ShowMaximizeButton = true,
                        ShowCloseButton    = true
                    };

                    var    ViewExtension   = new SsvScreenshotsView(PluginDatabase.GameContext);
                    Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, resources.GetString("LOCSsvTitle"), ViewExtension, windowOptions);
                    windowExtension.ResizeMode = ResizeMode.CanResize;
                    windowExtension.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                Common.LogError(ex, false, true, PluginDatabase.PluginName);
            }
        }
Ejemplo n.º 6
0
        public void Initialize(WindowOptions windowOptions)
        {
            this.Window.Show(windowOptions.InitialSize, windowOptions.Title);
            var rootWidget = (IWidget)this.ServiceProvider.GetRequiredService(windowOptions.RootWidgetType);

            this.Window.InitializeRootWidget(rootWidget);
        }
Ejemplo n.º 7
0
        public Engine Build()
        {
            RegisterLogger();

            _containerBuilder
            .Register(c => new GameWindow(WindowOptions.CreateWindowOptions()))
            .SingleInstance()
            .AsSelf();

            // Input manager
            _containerBuilder.Register(c => new Input())
            .SingleInstance()
            .AsSelf()
            .As <IPostUpdateSystem>();

            // TODO: Remove this?
            _containerBuilder.Register(c => new EntityManager())
            .SingleInstance()
            .AsSelf();

            var engine = new Engine();

            _containerBuilder.RegisterInstance(engine)
            .As <Engine>();
            engine.Container = _containerBuilder.Build();
            engine.Initialize();

            return(engine);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a window and a graphics device with the given options.
 /// </summary>
 /// <param name="windowCI">The window options, used to create the window.</param>
 /// <param name="deviceOptions">The device options, used to create the graphics device.</param>
 /// <param name="window">The new window.</param>
 /// <param name="gd">The new graphics device.</param>
 public static void CreateWindowAndGraphicsDevice
 (
     WindowOptions windowCI,
     GraphicsDeviceOptions deviceOptions,
     out IWindow window,
     out GraphicsDevice gd
 ) => CreateWindowAndGraphicsDevice(windowCI, deviceOptions, GetPlatformDefaultBackend(), out window, out gd);
Ejemplo n.º 9
0
    /// <summary>
    /// Initializes a new instance of <see cref="DefaultConfiguration"/>.
    /// </summary>
    public DefaultConfiguration()
    {
        AppName            = Assembly.GetEntryAssembly()?.GetName().Name ?? "Chromely App";
        Platform           = ChromelyRuntime.Platform;
        AppExeLocation     = AppDomain.CurrentDomain.BaseDirectory;
        StartUrl           = "local://app/index.html";
        DebuggingMode      = true;
        UrlSchemes         = new List <UrlScheme>();
        CefDownloadOptions = new CefDownloadOptions();
        WindowOptions      = new WindowOptions();
        if (string.IsNullOrWhiteSpace(WindowOptions.Title))
        {
            WindowOptions.Title = AppName;
        }

        // These are all default schemes.
        // They can be removed or replaced.
        UrlSchemes.AddRange(new List <UrlScheme>()
        {
            new UrlScheme(DefaultSchemeName.LOCALRESOURCE, "local", string.Empty, string.Empty, UrlSchemeType.LocalResource),
            new UrlScheme(DefaultSchemeName.LOCALREQUEST, "http", "chromely.com", string.Empty, UrlSchemeType.LocalRequest),
            new UrlScheme(DefaultSchemeName.OWIN, "http", "chromely.owin.com", string.Empty, UrlSchemeType.Owin),
            new UrlScheme(DefaultSchemeName.GITHUBSITE, string.Empty, string.Empty, "https://github.com/chromelyapps/Chromely", UrlSchemeType.ExternalBrowser, true)
        });

        CustomSettings = new Dictionary <string, string>()
        {
            ["cefLogFile"]  = "logs\\chromely.cef.log",
            ["logSeverity"] = "info",
            ["locale"]      = "en-US"
        };
    }
Ejemplo n.º 10
0
        private void btn_Options_Click(object sender, RoutedEventArgs e)
        {
            this.Opacity = 0.4;
            this.Effect  = new BlurEffect();

            WindowOptions options = new WindowOptions()
            {
                Owner         = Parent as Window,
                ShowInTaskbar = false
            };

            options.ShowDialog();

            this.Opacity = 1;
            this.Effect  = null;

            if ((bool)Settings.Default["music"] == false)
            {
                player.Stop();
            }
            else
            {
                player.Position = TimeSpan.Zero;
                player.Play();
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates a client window.
        /// </summary>
        public RootWindow(GraphicsDevice graphicsDevice, IWindowManager windowManager, string title, string titleGroup,
                          WindowOptions windowOptions, Vector2i position, Vector2i size, Vector2i?minSize, Vector2i?maxSize,
                          WindowState windowState, IWidget widget, uint multisampleCount, uint multisampleQuality)
        {
            // 1) Copy data.
            this.graphicsDevice = graphicsDevice;

            // 2) We create render target.
            TypelessTexture2D texture = new TypelessTexture2D(graphicsDevice, Usage.Default, TextureUsage.RenderTarget | TextureUsage.Texture,
                                                              CPUAccess.None, PixelFormat.Parse("R.UN8 G.UN8 B.UN8 A.UN8"), (uint)size.X, (uint)size.Y, 1,
                                                              multisampleCount, multisampleQuality, GraphicsLocality.DeviceOrSystemMemory, null);

            texture.DisposeOnViewDispose = true;

            Guid shareGuid = graphicsDevice.RegisterShared(texture, TextureUsage.Texture);

            RenderTargetView renderTarget = texture.CreateRenderTarget(
                PixelFormat.Parse("R.UN8 G.UN8 B.UN8 A.UN8"));

            window = windowManager.CreateWindow(shareGuid, title, titleGroup, this, windowOptions,
                                                position, size, minSize, maxSize, windowState, null, false);

            // 3) We create graphics canvas.
            GraphicsCanvas canvas = new GraphicsCanvas(graphicsDevice, renderTarget, new Vector2f(1, 1));

            // 4) We create GUI manager.
            GuiManager manager = new GuiManager(canvas);

            manager.RootObject    = widget;
            manager.PreRendering += new Action <GuiManager>(PreRenderingInternal);
            manager.Rendered     += new Action <GuiManager>(RenderedInternal);

            this.root = manager;
        }
Ejemplo n.º 12
0
 public DialogWindow(object model, object context, WindowOptions options)
 {
     DataContext = options;
     InitializeComponent();
     Form.Environment.Add(options.EnvironmentFlags);
     Form.Context = context;
     Form.Model   = model;
 }
        public TimeWindowedKStream(WindowOptions <W> windowOptions, GroupedStreamAggregateBuilder <K, V> aggBuilder, string name, ISerDes <K> keySerde, ISerDes <V> valSerde, List <string> sourceNodes, StreamGraphNode streamsGraphNode, InternalStreamBuilder builder)
            : base(name, keySerde, valSerde, sourceNodes, streamsGraphNode, builder)
        {
            CheckIfParamNull(windowOptions, "windowOptions");

            this.windowOptions = windowOptions;
            this.aggBuilder    = aggBuilder;
        }
Ejemplo n.º 14
0
        private static void Main(string[] args)
        {
            WindowOptions options = WindowOptions.Default;

            options.Size  = new Vector2D <int>(800, 600);
            options.Title = "BuildCraft";
            Init(options, OnLoad, OnUpdate, OnRender, OnClose);
            RunWindow();
        }
Ejemplo n.º 15
0
        public void onReady()
        {
            setConnectButtonState("Disconnect", true, true);

            interAppBus_ = controller_.getInterApplicationBus();
            interAppBus_.addSubscribeListener((uuid, topic) => {
                bool exists = false;

                if (!subscriptionMap.TryGetValue(topic, out exists))
                {
                    subscriptionMap.Add(topic, true);
                    if (subscriptionCallback != null)
                    {
                        subscriptionCallback();
                    }
                }
            });
            Console.WriteLine("OnReady.");
            ApplicationOptions mainAppOptions = new ApplicationOptions(htmlDemoUuid_, htmlDemoUuid_, "https://developer.openf.in/htmlinterappcommdemo/1/index.html");

            mainAppOptions.Version = "v1.0.0.0b";
            mainAppOptions.IsAdmin = true;

            WindowOptions mainWindowOptions = mainAppOptions.MainWindowOptions;

            mainWindowOptions.AutoShow        = true;
            mainWindowOptions.DefaultLeft     = 100;
            mainWindowOptions.DefaultTop      = 100;
            mainWindowOptions.DefaultWidth    = 510;
            mainWindowOptions.DefaultHeight   = 350;
            mainWindowOptions.Maximizable     = false;
            mainWindowOptions.ShowTaskbarIcon = true;

            AckCallback afterAppCreation = (ack) =>
            {
                Console.WriteLine("afterAppCreation");
                Console.WriteLine(ack.getJsonObject().ToString());
                AckCallback afterRun = (runAck) =>
                {
                    Console.WriteLine("afterRun");
                    Console.WriteLine(runAck.getJsonObject().ToString());
                };

                Console.WriteLine("app.run()");
                // Using same callback for success and error in case app is already running
                htmlApplication_.run(afterRun, afterRun);
            };


            // Using same callback for success and error in case app already exists
            Console.WriteLine("Creating App");
            htmlApplication_ = new Application(mainAppOptions, controller_, afterAppCreation, afterAppCreation);
            htmlApplication_.addEventListener("closed", (ack) => {
                controller_.disconnect();
                System.Windows.Forms.Application.ExitThread();
            });
        }
Ejemplo n.º 16
0
        public unsafe IWindow CreateWindow(WindowOptions opts)
        {
            if (IsViewOnly)
            {
                throw new PlatformNotSupportedException("Platform is view-only.");
            }

            return(new SdlWindow(opts, null, null));
        }
Ejemplo n.º 17
0
        public NativeWindow(GraphicsMode mode, WindowOptions options)
        {
            if (options.ScreenMode == ScreenMode.Native)
            {
                options.Width = DisplayDevice.Default.Width;
                options.Height = DisplayDevice.Default.Height;
            }

            GameWindowFlags windowFlags = GameWindowFlags.Default;
            if (options.ScreenMode == ScreenMode.FixedWindow)
                windowFlags = GameWindowFlags.FixedWindow;
            else if (options.ScreenMode == ScreenMode.Fullscreen || options.ScreenMode == ScreenMode.Native)
                windowFlags = GameWindowFlags.Fullscreen;

            this.refreshMode = options.RefreshMode;
            this.internalWindow = new InternalWindow(
                this,
                options.Width,
                options.Height,
                mode,
                options.Title,
                windowFlags);
            this.internalWindow.MakeCurrent();
            this.internalWindow.CursorVisible = true;
            if (!options.SystemCursorVisible)
                this.internalWindow.Cursor = MouseCursor.Empty;
            this.internalWindow.VSync = (options.RefreshMode != RefreshMode.VSync) ? VSyncMode.Off : VSyncMode.On;

            Log.Core.Write("Window Specification: {0}Mode: {1}{0}VSync: {2}{0}SwapInterval: {3}{0}",
                Environment.NewLine,
                this.internalWindow.Context.GraphicsMode,
                this.internalWindow.VSync,
                this.internalWindow.Context.SwapInterval);

            // Retrieve icon from executable file and set it as window icon
            Assembly entryAssembly = Assembly.GetEntryAssembly();
            if (entryAssembly != null)
            {
                string executablePath = Path.GetFullPath(entryAssembly.Location);
                if (File.Exists(executablePath))
                {
                    this.internalWindow.Icon = Icon.ExtractAssociatedIcon(executablePath);
                }
            }

            if (options.ScreenMode == ScreenMode.FullWindow)
                this.internalWindow.WindowState = WindowState.Fullscreen;

            DualityApp.TargetResolution = new Vector2(this.internalWindow.ClientSize.Width, this.internalWindow.ClientSize.Height);

            DualityApp.Mouse.Source = new GameWindowMouseInputSource(this.internalWindow);
            DualityApp.Keyboard.Source = new GameWindowKeyboardInputSource(this.internalWindow);
            DualityApp.UserDataChanged += this.OnUserDataChanged;

            // Determine OpenGL capabilities and log them
            GraphicsBackend.LogOpenGLSpecs();
        }
Ejemplo n.º 18
0
        /// <summary>Show an option window for this instance of <see cref="TCfg" /></summary>
        /// <param name="options">Optional window display options</param>
        /// <returns>Dialog result</returns>
        public Task <DialogResult <TCfg> > ShowWindow(WindowOptions options = null)
        {
            options ??= new WindowOptions
            {
                CanResize = true,
            };

            return(Show.Window(this, options).For <TCfg>(_mapper.Map <TCfg>(this)));
        }
Ejemplo n.º 19
0
 private static extern IntPtr SDL_CreateWindow(
     string title,
     int x,
     int y,
     int width,
     int height,
     [MarshalAs(UnmanagedType.U4)]
     WindowOptions options
     );
Ejemplo n.º 20
0
 public DialogWindow(object model, object context, WindowOptions options)
 {
     DataContext = options;
     InitializeComponent();
     Loaded += (sender, e) => MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
     Form.Environment.Add(options.EnvironmentFlags);
     Form.Context = context;
     Form.Model   = model;
 }
Ejemplo n.º 21
0
        public void Should_Determine_Virtual_Screen()
        {
            var options = new WindowOptions {
                FillScreen = ScreenFill.VirtualScreen
            };
            var frame        = options.GetFrame();
            var virtualFrame = SystemInformation.VirtualScreen;

            Assert.AreEqual(virtualFrame, frame);
        }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            var options = new WindowOptions(true, true, new Point(20, 40),
                                            new Size(1024, 768), 60, 60, GraphicsAPI.Default, "ShowCase",
                                            WindowState.Normal, WindowBorder.Fixed, VSyncMode.Off, int.MaxValue,
                                            false, new VideoMode(60));
            var window = Window.Create(options);

            ComponentManager.Run(typeof(MyComponent), window, new Renderer.OpenGL.ControlRendererFactory());
        }
Ejemplo n.º 23
0
        public IWindow CreateWindow(WindowOptions opts)
        {
            if (opts.WindowState == WindowState.Fullscreen)
            {
                return(new GlfwWindow(opts, null, this));
            }

            opts.Position = new Point(opts.Position.X + Bounds.X, opts.Position.Y + Bounds.Y);
            return(new GlfwWindow(opts, null, null));
        }
Ejemplo n.º 24
0
        public MainWindow(IViewModel <MainWindowViewModel> model, WindowOptions windowOptions)
            : base(model)
        {
            _setBlocker = windowOptions.BlockSet();

            _windowOptions = windowOptions;
            InitializeComponent();

            WindowStartupLocation = WindowStartupLocation.Manual;
        }
Ejemplo n.º 25
0
        /// <inheritdoc />
        public IWindow CreateWindow(WindowOptions options)
        {
            if (!IsApplicable)
            {
                ThrowUnsupported();
                return(null !);
            }

            return(_lastCreatedWindow = new GlfwWindow(options, null, null));
        }
Ejemplo n.º 26
0
 private void OnOkExecute()
 {
     if (HasBuilding)
     {
         InsPoint.Building.BuildingType = BuildingType;
         InsPoint.Window = WindowVM.Window;
         defaultWindow   = WindowVM.Window;
     }
     InsPoint.Height = Height;
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Initializes duality but does not yet run it.
        /// </summary>
        /// <param name="launcherArgs"></param>
        public DualityLauncher(LauncherArgs launcherArgs = null)
        {
            if (launcherArgs == null)
            {
                launcherArgs = new LauncherArgs();
            }

            System.Threading.Thread.CurrentThread.CurrentCulture   = System.Globalization.CultureInfo.InvariantCulture;
            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture;

            // Set up console logging
            this.AddGlobalOutput(new ConsoleLogOutput());

            // Set up file logging
            try
            {
                StreamWriter logfileWriter = new StreamWriter("logfile.txt");
                logfileWriter.AutoFlush = true;
                this.disposables.Push(logfileWriter);

                this.AddGlobalOutput(new TextWriterLogOutput(logfileWriter));
            }
            catch (Exception e)
            {
                Logs.Core.WriteWarning("Text Logfile unavailable: {0}", LogFormat.Exception(e));
            }

            // Set up a global exception handler to log errors
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            // Write initial log message before actually booting Duality
            Logs.Core.Write("Running DualityLauncher with flags: {1}{0}",
                            Environment.NewLine,
                            launcherArgs);

            // Initialize the Duality core
            DualityApp.Init(
                DualityApp.ExecutionEnvironment.Launcher,
                DualityApp.ExecutionContext.Game,
                new DefaultAssemblyLoader(),
                launcherArgs);

            // Open up a new window
            WindowOptions options = new WindowOptions
            {
                Size                = DualityApp.UserData.Instance.WindowSize,
                ScreenMode          = launcherArgs.IsDebugging ? ScreenMode.Window : DualityApp.UserData.Instance.WindowMode,
                RefreshMode         = launcherArgs.IsProfiling ? RefreshMode.NoSync : DualityApp.UserData.Instance.WindowRefreshMode,
                Title               = DualityApp.AppData.Instance.AppName,
                SystemCursorVisible = launcherArgs.IsDebugging || DualityApp.UserData.Instance.SystemCursorVisible
            };

            this.window = DualityApp.OpenWindow(options);
        }
Ejemplo n.º 28
0
 public WindowOptionsViewModel(WindowOptions window)
 {
     if (window != null)
     {
         HasWindow           = true;
         Window              = window.Copy();
         WindowConstructions = new ObservableCollection <WindowConstruction>(WindowConstruction.WindowConstructions);
         Quarters            = new ObservableCollection <double>(WindowOptions.Quarters);// { 0.07, 0.13, 0.26 };
     }
     Reset = new RelayCommand(OnResetExecute, CanResetExecute);
 }
Ejemplo n.º 29
0
        public static WindowOptions AddWindow(this IApplicationBuilder applicationBuilder, Size initialSize, string title)
        {
            var windowList = new List <WindowOptions>(applicationBuilder.Options.Windows);
            var newWindow  = new WindowOptions {
                InitialSize = initialSize, Title = title
            };

            windowList.Add(newWindow);
            applicationBuilder.Options.Windows = windowList;
            return(newWindow);
        }
Ejemplo n.º 30
0
        public NativeWindow(WindowOptions options)
        {
            this.ScreenMode = options.ScreenMode;

            window         = (JSObject)Runtime.GetGlobalObject("window");
            updateDelegate = new Action <double>(OnUpdate);

            // ToDo
            //DualityApp.Mouse.Source = new GameWindowMouseInputSource(this.internalWindow);
            DualityApp.Keyboard.Source = new KeyboardInputSource();
        }
Ejemplo n.º 31
0
        private void OpenPageInternal(string id)
        {
            var url    = string.Format("{0}{1}", CPApplication.Current.PortalBaseAddress, "Pages/SendMail.aspx?MessageID={0}&LanguageCode={1}");
            var option = new WindowOptions();

            option.Size = new System.Windows.Size {
                Width = 1024, Height = 768
            };
            option.Resizable = true;
            UtilityHelper.OpenPage(string.Format(url, id, CPApplication.Current.LanguageCode), option);
        }
Ejemplo n.º 32
0
 INativeWindow IGraphicsBackend.CreateWindow(WindowOptions options)
 {
     return new DummyNativeWindow();
 }
Ejemplo n.º 33
0
        public NativeWindow(GraphicsMode mode, WindowOptions options)
        {
            if (options.ScreenMode == ScreenMode.Native)
            {
                options.Width = DisplayDevice.Default.Width;
                options.Height = DisplayDevice.Default.Height;
            }

            GameWindowFlags windowFlags = GameWindowFlags.Default;
            if (options.ScreenMode == ScreenMode.FixedWindow)
                windowFlags = GameWindowFlags.FixedWindow;
            else if (options.ScreenMode == ScreenMode.Fullscreen || options.ScreenMode == ScreenMode.Native)
                windowFlags = GameWindowFlags.Fullscreen;

            this.refreshMode = options.RefreshMode;
            this.internalWindow = new InternalWindow(
                this,
                options.Width,
                options.Height,
                mode,
                options.Title,
                windowFlags);
            this.internalWindow.MakeCurrent();
            this.internalWindow.CursorVisible = true;
            if (!options.SystemCursorVisible)
                this.internalWindow.Cursor = MouseCursor.Empty;
            this.internalWindow.VSync = (options.RefreshMode != RefreshMode.VSync) ? VSyncMode.Off : VSyncMode.On;

            Log.Core.Write(
                "Window Specification: " + Environment.NewLine +
                "Buffers: {0}"           + Environment.NewLine +
                "Samples: {1}"           + Environment.NewLine +
                "ColorFormat: {2}"       + Environment.NewLine +
                "AccumulatorFormat: {3}" + Environment.NewLine +
                "Depth: {4}"             + Environment.NewLine +
                "Stencil: {5}"           + Environment.NewLine +
                "VSync: {6}"             + Environment.NewLine +
                "SwapInterval: {7}",
                this.internalWindow.Context.GraphicsMode.Buffers,
                this.internalWindow.Context.GraphicsMode.Samples,
                this.internalWindow.Context.GraphicsMode.ColorFormat,
                this.internalWindow.Context.GraphicsMode.AccumulatorFormat,
                this.internalWindow.Context.GraphicsMode.Depth,
                this.internalWindow.Context.GraphicsMode.Stencil,
                this.internalWindow.VSync,
                this.internalWindow.Context.SwapInterval);

            // Retrieve icon from executable file and set it as window icon
            Assembly entryAssembly = Assembly.GetEntryAssembly();
            if (entryAssembly != null)
            {
                string executablePath = Path.GetFullPath(entryAssembly.Location);
                if (File.Exists(executablePath))
                {
                    this.internalWindow.Icon = Icon.ExtractAssociatedIcon(executablePath);
                }
            }

            if (options.ScreenMode == ScreenMode.FullWindow)
                this.internalWindow.WindowState = WindowState.Fullscreen;

            DualityApp.TargetResolution = new Vector2(this.internalWindow.ClientSize.Width, this.internalWindow.ClientSize.Height);

            // Register events and input
            this.HookIntoDuality();

            // Determine OpenGL capabilities and log them
            GraphicsBackend.LogOpenGLSpecs();
        }
Ejemplo n.º 34
0
        public NativeWindow(GraphicsMode mode, WindowOptions options)
        {
            if (options.ScreenMode == ScreenMode.Native && DisplayDevice.Default != null)
            {
                options.Width = DisplayDevice.Default.Width;
                options.Height = DisplayDevice.Default.Height;
            }

            GameWindowFlags windowFlags = GameWindowFlags.Default;
            if (options.ScreenMode == ScreenMode.FixedWindow)
                windowFlags = GameWindowFlags.FixedWindow;
            else if (options.ScreenMode == ScreenMode.Fullscreen || options.ScreenMode == ScreenMode.Native)
                windowFlags = GameWindowFlags.Fullscreen;

            this.refreshMode = options.RefreshMode;
            this.internalWindow = new InternalWindow(
                this,
                options.Width,
                options.Height,
                mode,
                options.Title,
                windowFlags);
            this.internalWindow.MakeCurrent();
            this.internalWindow.CursorVisible = true;
            if (!options.SystemCursorVisible)
                this.internalWindow.Cursor = MouseCursor.Empty;
            this.internalWindow.VSync = (options.RefreshMode != RefreshMode.VSync) ? VSyncMode.Off : VSyncMode.On;

            Log.Core.Write(
                "Window Specification: " + Environment.NewLine +
                "  Buffers: {0}"         + Environment.NewLine +
                "  Samples: {1}"         + Environment.NewLine +
                "  ColorFormat: {2}"     + Environment.NewLine +
                "  AccumFormat: {3}"     + Environment.NewLine +
                "  Depth: {4}"           + Environment.NewLine +
                "  Stencil: {5}"         + Environment.NewLine +
                "  VSync: {6}"           + Environment.NewLine +
                "  SwapInterval: {7}",
                this.internalWindow.Context.GraphicsMode.Buffers,
                this.internalWindow.Context.GraphicsMode.Samples,
                this.internalWindow.Context.GraphicsMode.ColorFormat,
                this.internalWindow.Context.GraphicsMode.AccumulatorFormat,
                this.internalWindow.Context.GraphicsMode.Depth,
                this.internalWindow.Context.GraphicsMode.Stencil,
                this.internalWindow.VSync,
                this.internalWindow.Context.SwapInterval);

            // Retrieve icon from executable file and set it as window icon
            string executablePath = null;
            try
            {
                Assembly entryAssembly = Assembly.GetEntryAssembly();
                if (entryAssembly != null)
                {
                    executablePath = Path.GetFullPath(entryAssembly.Location);
                    if (File.Exists(executablePath))
                    {
                        this.internalWindow.Icon = Icon.ExtractAssociatedIcon(executablePath);
                    }
                }
            }
            // As described in issue 301 (https://github.com/AdamsLair/duality/issues/301), the
            // icon extraction can fail with an exception under certain circumstances. Don't fail
            // just because of an icon. Log the error and continue.
            catch (Exception e)
            {
                Log.Core.WriteError(
                    "There was an exception while trying to extract the " +
                    "window icon from the game's main executable '{0}'. This is " +
                    "uncritical, but still an error: {1}",
                    executablePath,
                    Log.Exception(e));
            }

            if (options.ScreenMode == ScreenMode.FullWindow)
                this.internalWindow.WindowState = WindowState.Fullscreen;

            DualityApp.TargetResolution = new Vector2(this.internalWindow.ClientSize.Width, this.internalWindow.ClientSize.Height);

            // Register events and input
            this.HookIntoDuality();

            // Determine OpenGL capabilities and log them
            GraphicsBackend.LogOpenGLSpecs();
        }