示例#1
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (e.Key == Key.F && Keyboard.IsKeyDown(Key.LeftCtrl))
            {
                txtFilter.Focus();
                txtFilter.SelectAll();
            }

            if (e.Key == Key.Down && txtFilter.IsFocused)
            {
                lstRepositories.Focus();
            }

            // show/hide the titlebar to move the window for screenshots, for example
            if (e.Key == Key.F11)
            {
                var currentStyle = AcrylicWindow.GetAcrylicWindowStyle(this);
                var newStyle     = currentStyle == AcrylicWindowStyle.None ? AcrylicWindowStyle.Normal : AcrylicWindowStyle.None;
                AcrylicWindow.SetAcrylicWindowStyle(this, newStyle);
            }

            // keep window open on deactivate to make screeshots, for example
            if (e.Key == Key.F12)
            {
                _closeOnDeactivate = !_closeOnDeactivate;
            }
        }
示例#2
0
 public static void SetWindowFluent(this Window window, Settings settings)
 {
     try
     {
         var disc = RuntimeInformation.OSDescription;
         if (!disc.Contains("Windows", StringComparison.OrdinalIgnoreCase))
         {
             return;
         }
         var ver     = disc.Split(' ')[2];
         var version = Version.Parse(ver);
         if (version.Major < 10)
         {
             return;
         }
         AcrylicWindow.SetEnabled(window, true);
         AcrylicWindow.SetAcrylicWindowStyle(window, AcrylicWindowStyle.NoIcon);
         AcrylicWindow.SetAcrylicAccentState(window, settings.IsEnableAcrylicStyle ? AcrylicAccentState.Default : AcrylicAccentState.Disabled);
         settings.PropertyChanged += (_, args) =>
         {
             if (args.PropertyName == nameof(Settings.IsEnableAcrylicStyle))
             {
                 AcrylicWindow.SetAcrylicAccentState(window, settings.IsEnableAcrylicStyle ? AcrylicAccentState.Default : AcrylicAccentState.Disabled);
             }
         };
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
示例#3
0
        public MainWindow()
        {
            AcrylicWindow.SetEnabled(this, true);
            AcrylicWindow.SetTintColor(this, (Color)ColorConverter.ConvertFromString("#FFF7F7F7"));
            AcrylicWindow.SetFallbackColor(this, (Color)ColorConverter.ConvertFromString("#FFF7F7F7"));
            AcrylicWindow.SetTintOpacity(this, 1);
            AcrylicWindow.SetNoiseOpacity(this, 0.001);

            InitializeComponent();
        }
示例#4
0
        public MainWindow(StatusCharacterMap statusCharacterMap,
                          IRepositoryInformationAggregator aggregator,
                          IRepositoryMonitor repositoryMonitor,
                          IRepositoryActionProvider repositoryActionProvider,
                          IRepositoryIgnoreStore repositoryIgnoreStore,
                          IAppSettingsService appSettingsService,
                          ITranslationService translationService)
        {
            _translationService = translationService;

            InitializeComponent();

            AcrylicWindow.SetAcrylicWindowStyle(this, AcrylicWindowStyle.None);

            DataContext = new MainWindowPageModel(appSettingsService);
            SettingsMenu.DataContext = DataContext;             // this is out of the visual tree

            _monitor = repositoryMonitor as DefaultRepositoryMonitor;
            if (_monitor != null)
            {
                _monitor.OnScanStateChanged += OnScanStateChanged;
                ShowScanningState(_monitor.Scanning);
            }

            _repositoryActionProvider   = repositoryActionProvider ?? throw new ArgumentNullException(nameof(repositoryActionProvider));
            _repositoryIgnoreStore      = repositoryIgnoreStore ?? throw new ArgumentNullException(nameof(repositoryIgnoreStore));
            lstRepositories.ItemsSource = aggregator.Repositories;
            var view = CollectionViewSource.GetDefaultView(lstRepositories.ItemsSource);

            view.CollectionChanged += View_CollectionChanged;
            view.Filter             = FilterRepositories;

            lstRepositories.Items.SortDescriptions.Add(
                new SortDescription(nameof(RepositoryView.Name),
                                    ListSortDirection.Ascending));

            var appName = System.Reflection.Assembly.GetEntryAssembly().GetName();

            txtHelpCaption.Text = appName.Name + " " + appName.Version.ToString(2);
            txtHelp.Text        = GetHelp(statusCharacterMap);

            PlaceFormByTaskbarLocation();
        }
示例#5
0
        public void LoadSettings()
        {
            SettingsController.LoadSettings();
            IniData data = SettingsController.GetCurrentSettings();

            if (data["Hotkeys"]["HotkeysEnable"] == "1")
            {
                SetHotkeysByStrings(data["Hotkeys"]["HotkeyUp"], data["Hotkeys"]["HotkeyDown"]);
            }

            if (data["Misc"]["Blur"] == "1" && Environment.OSVersion.Version.Major == 10)
            {
                Background = null;
                AcrylicWindow.SetEnabled(this, true);
            }

            UpdateCheckTimer.Tick += (sender, e) =>
            {
                CheckForUpdates(false);
            };

            if (data["Updates"]["DisableCheckEveryDay"] != "1")
            {
                UpdateCheckTimer.Start();
            }

            if (data["Updates"]["DisableCheckOnStartup"] != "1")
            {
                CheckForUpdates(false);
            }

            //AutoBrightness
            if (data["AutoBrightness"]["Enabled"] == "1")
            {
                CheckForSunriset.Start();
            }

            SetupAutoBrightnessTimer();

            TrayIcon.TrayBalloonTipClicked += (senderB, eB) => new Update().Window_Loaded();
        }
示例#6
0
        internal static void EnableBlur(IntPtr hwnd)
        {
            var accent           = new AccentPolicy();
            var accentStructSize = Marshal.SizeOf(accent);
            // ウィンドウ背景のぼかしを行うのはWindows10の場合のみ
            // OSのバージョンに従い、AccentStateを切り替える
            var currentVersion = SystemInfo.Version.Value;

            if (currentVersion >= VersionInfos.Windows10_1809)
            {
                accent.AccentState = AccentState.ACCENT_ENABLE_ACRYLICBLURBEHIND; //AccentState.ACCENT_ENABLE_ACRYLICBLURBEHIND;
            }
            else if (currentVersion >= VersionInfos.Windows10)
            {
                accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND;
            }
            else
            {
                accent.AccentState = AccentState.ACCENT_ENABLE_TRANSPARENTGRADIENT;
            }

            accent.AccentFlags = 0x20 | 0x40 | 0x80 | 0x100;
            //accent.GradientColor = 0x99FFFFFF;  // 60%の透明度が基本
            accent.GradientColor = 0x00FFFFFF;  // Tint Colorはここでは設定せず、Bindingで外部から変えられるようにXAML側のレイヤーとして定義

            var accentPtr = Marshal.AllocHGlobal(accentStructSize);

            Marshal.StructureToPtr(accent, accentPtr, false);

            var data = new WindowCompositionAttributeData();

            data.Attribute  = WindowCompositionAttribute.WCA_ACCENT_POLICY;
            data.SizeOfData = accentStructSize;
            data.Data       = accentPtr;

            AcrylicWindow.SetWindowCompositionAttribute(hwnd, ref data);

            Marshal.FreeHGlobal(accentPtr);
        }
示例#7
0
 private void StyleCheckBox_Checked(object sender, RoutedEventArgs e)
 {
     AcrylicWindow.SetEnabled(this, false);             // Doesn't work? :(
 }