Пример #1
0
        private void OnLoaded(object sender, RoutedEventArgs _)
        {
            InitializeNotifyIcon();
            // todo is there a way to set blur only once?
            ThemeManager.Instance.SetBlurForWindow();
            WindowsInteropHelper.DisableControlBox(this);
            InitProgressbarAnimation();
            InitializePosition();
            // since the default main window visibility is visible
            // so we need set focus during startup
            QueryTextBox.Focus();

            _viewModel.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
                {
                    if (Visibility == Visibility.Visible)
                    {
                        Activate();
                        QueryTextBox.Focus();
                        UpdatePosition();
                        _settings.ActivateTimes++;
                        if (!_viewModel.LastQuerySelected)
                        {
                            QueryTextBox.SelectAll();
                            _viewModel.LastQuerySelected = true;
                        }
                    }
                    return;
                }

                if (e.PropertyName == nameof(MainViewModel.ProgressBarVisibility))
                {
                    if (_viewModel.ProgressBarVisibility == Visibility.Visible)
                    {
                        ProgressBar.BeginStoryboard(_progressBarStoryboard);
                    }
                    else
                    {
                        _progressBarStoryboard.Stop(ProgressBar);
                    }
                }
            };
            _settings.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == nameof(Settings.HideNotifyIcon))
                {
                    _notifyIcon.Visible = !_settings.HideNotifyIcon;
                }
            };
            InitializePosition();
        }
Пример #2
0
        private void InitProgressbarAnimation()
        {
            var da  = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
            var da1 = new DoubleAnimation(ProgressBar.X1, ActualWidth, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));

            Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)"));
            Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)"));
            _progressBarStoryboard.Children.Add(da);
            _progressBarStoryboard.Children.Add(da1);
            _progressBarStoryboard.RepeatBehavior = RepeatBehavior.Forever;
            ProgressBar.BeginStoryboard(_progressBarStoryboard);
            _viewModel.ProgressBarVisibility = Visibility.Hidden;
        }