Exemplo n.º 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;
            }
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 3
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();
        }