Esempio n. 1
0
File: UI.cs Progetto: flyingpie/AVA
        public override void Load()
        {
            _uic.HideFromTaskbar(true);

            _uic.Opacity = .9f;

            Maximize();

            // Toggle on Alt-Space
            HotKeyManager.RegisterHotKey(Settings.ToggleUIKey, Settings.ToggleUIKeyModifiers);
            HotKeyManager.HotKeyPressed += (s, a) => Toggle();

            // Minimize on focus lost
            _uic.FocusGained += (s, a) => _log.Info("Gained focus");
            _uic.FocusLost   += (s, a) => { _log.Info("Lost focus"); Minimize(); };

            // Background image
            if (!string.IsNullOrWhiteSpace(Settings.BackgroundImage))
            {
                string bgImage = null;

                try
                {
                    bgImage = Environment.ExpandEnvironmentVariables(Settings.BackgroundImage);
                    _bg     = Texture2D.FromStream(_uic.GraphicsDevice, File.OpenRead(bgImage));
                }
                catch (Exception ex)
                {
                    _log.Error($"Could not load background image at '{bgImage}': {ex.Message}.", ex);
                }
            }

            // TODO: Make configurable
            var style = ImGui.GetStyle();

            style.Colors[(int)ImGuiCol.FrameBg]  = new Vector4(.2f, .2f, .2f, .5f);
            style.Colors[(int)ImGuiCol.WindowBg] = new Vector4(0f, 0f, 0f, .8f);
        }