コード例 #1
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            WindowsInteropHelper.DisableControlBox(this);
            InitializePosition();

            SearchBox.QueryTextBox.DataContext     = _viewModel;
            SearchBox.QueryTextBox.PreviewKeyDown += Launcher_KeyDown;
            SearchBox.QueryTextBox.TextChanged    += QueryTextBox_TextChanged;

            // Set initial language flow direction
            SearchBox_UpdateFlowDirection();

            // Register language changed event
            InputLanguageManager.Current.InputLanguageChanged += SearchBox_InputLanguageChanged;

            SearchBox.QueryTextBox.Focus();
            SearchBox.QueryTextBox.ControlledElements.Add(ListBox.SuggestionsList);

            ListBox.DataContext = _viewModel;
            ListBox.SuggestionsList.SelectionChanged         += SuggestionsList_SelectionChanged;
            ListBox.SuggestionsList.PreviewMouseLeftButtonUp += SuggestionsList_PreviewMouseLeftButtonUp;
            _viewModel.PropertyChanged     += ViewModel_PropertyChanged;
            _viewModel.MainWindowVisibility = Visibility.Collapsed;
            _viewModel.LoadedAtLeastOnce    = true;

            BringProcessToForeground();
        }
コード例 #2
0
ファイル: Msg.xaml.cs プロジェクト: NightBladeStudios/Wox
        public Msg()
        {
            InitializeComponent();
            var screen         = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dipWorkingArea = WindowsInteropHelper.TransformPixelsToDIP(this,
                                                                           screen.WorkingArea.Width,
                                                                           screen.WorkingArea.Height);

            Left = dipWorkingArea.X - Width;
            Top  = dipWorkingArea.Y;
            showAnimation.From = dipWorkingArea.Y;
            showAnimation.To   = dipWorkingArea.Y - Height;

            // Create the fade out storyboard
            fadeOutStoryboard.Completed += fadeOutStoryboard_Completed;
            var fadeOutAnimation = new DoubleAnimation(dipWorkingArea.Y - Height, dipWorkingArea.Y, new Duration(TimeSpan.FromSeconds(5)))
            {
                AccelerationRatio = 0.2
            };

            Storyboard.SetTarget(fadeOutAnimation, this);
            Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty));
            fadeOutStoryboard.Children.Add(fadeOutAnimation);

            imgClose.Source   = ImageLoader.Load(Path.Combine(Constant.ProgramDirectory, "Images\\close.png"));
            imgClose.MouseUp += imgClose_MouseUp;
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: tinybolt/Wox
        private void OnLoaded(object sender, RoutedEventArgs _)
        {
            // todo is there a way to set blur only once?
            ThemeManager.Instance.SetBlurForWindow();
            WindowsInteropHelper.DisableControlBox(this);
            InitProgressbarAnimation();

            _viewModel.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
                {
                    if (Visibility == Visibility.Visible)
                    {
                        Activate();
                        QueryTextBox.Focus();
                        SetWindowPosition();
                        _settings.ActivateTimes++;
                        if (!_viewModel.LastQuerySelected)
                        {
                            QueryTextBox.SelectAll();
                            _viewModel.LastQuerySelected = true;
                        }
                    }
                }
            };
            // since the default main window visibility is visible
            // so we need set focus during startup
            QueryTextBox.Focus();
        }
コード例 #4
0
        private void OnLoaded(object sender, RoutedEventArgs _)
        {
            // todo is there a way to set blur only once?
            BlurWindowHelper.SetBlurForWindow();
            WindowsInteropHelper.DisableControlBox(this);
            //InitProgressbarAnimation();
            InitializePosition();
            // since the default main window visibility is visible
            // so we need set focus during startup
            QueryTextBox.Focus();

            MainViewModel.Current.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
                {
                    if (Visibility == Visibility.Visible)
                    {
                        Activate();
                        QueryTextBox.Focus();
                        UpdatePosition();
                        if (MainViewModel.Current.LastQuerySelected)
                        {
                            QueryTextBox.SelectAll();
                            MainViewModel.Current.LastQuerySelected = false;
                        }
                    }
                }
            };
            InitializePosition();
        }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: royvou/PowerToys
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            WindowsInteropHelper.DisableControlBox(this);
            InitializePosition();

            SearchBox.QueryTextBox.DataContext     = _viewModel;
            SearchBox.QueryTextBox.PreviewKeyDown += Launcher_KeyDown;

            Observable.FromEventPattern <TextChangedEventHandler, TextChangedEventArgs>(
                add => SearchBox.QueryTextBox.TextChanged    += add,
                remove => SearchBox.QueryTextBox.TextChanged -= remove)
            .Do(@event => ClearAutoCompleteText((TextBox)@event.Sender))
            .Throttle(TimeSpan.FromMilliseconds(150))
            .Do(@event => Dispatcher.InvokeAsync(() => PerformSearchQuery((TextBox)@event.Sender)))
            .Subscribe();

            // Set initial language flow direction
            SearchBox_UpdateFlowDirection();

            // Register language changed event
            InputLanguageManager.Current.InputLanguageChanged += SearchBox_InputLanguageChanged;

            SearchBox.QueryTextBox.Focus();
            SearchBox.QueryTextBox.ControlledElements.Add(ListBox.SuggestionsList);

            ListBox.DataContext = _viewModel;
            ListBox.SuggestionsList.SelectionChanged         += SuggestionsList_SelectionChanged;
            ListBox.SuggestionsList.PreviewMouseLeftButtonUp += SuggestionsList_PreviewMouseLeftButtonUp;
            _viewModel.PropertyChanged     += ViewModel_PropertyChanged;
            _viewModel.MainWindowVisibility = Visibility.Collapsed;
            _viewModel.LoadedAtLeastOnce    = true;

            BringProcessToForeground();
        }
コード例 #6
0
        private double WindowTop()
        {
            var screen = GetScreen();
            var dip1   = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
            var dip2   = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
            var top    = ((dip2.Y - SearchBox.ActualHeight) / 4) + dip1.Y;

            return(top);
        }
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: tinybolt/Wox
        private double WindowTop()
        {
            var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dip1   = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
            var dip2   = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
            var top    = (dip2.Y - QueryTextBox.ActualHeight) / 4 + dip1.Y;

            return(top);
        }
コード例 #8
0
ファイル: MainWindow.xaml.cs プロジェクト: xuanwa/PowerToys
        /// <summary>
        /// Calculates X co-ordinate of main window top left corner.
        /// </summary>
        /// <returns>X co-ordinate of main window top left corner</returns>
        private double WindowLeft()
        {
            var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dpi1   = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
            var dpi2   = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
            var left   = (dpi2.X - this.Width) / 2 + dpi1.X;

            return(left);
        }
コード例 #9
0
        private double SetWindowTopPosition()
        {
            var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dip1   = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
            var dip2   = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
            var top    = ((dip2.Y - LauncherControl.ActualHeight) / 4) + dip1.Y;

            return(top);
        }
コード例 #10
0
        private double SetWindowLeftPosition()
        {
            var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dip1   = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
            var dip2   = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
            var left   = ((dip2.X - Width) / 2) + dip1.X;

            return(left);
        }
コード例 #11
0
ファイル: MainWindow.xaml.cs プロジェクト: xuanwa/PowerToys
        /// <summary>
        /// Calculates Y co-ordinate of main window top left corner
        /// </summary>
        /// <returns>Y co-ordinate of main window top left corner</returns>
        private double WindowTop()
        {
            var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dpi1   = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
            var dpi2   = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
            var top    = (dpi2.Y - this.SearchBox.Height) / 4 + dpi1.Y;

            return(top);
        }
コード例 #12
0
        /// <summary>
        /// Calculates X co-ordinate of main window top left corner.
        /// </summary>
        /// <returns>X co-ordinate of main window top left corner</returns>
        private double WindowLeft()
        {
            var screen = GetScreen();
            var dip1   = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
            var dip2   = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
            var left   = ((dip2.X - ActualWidth) / 2) + dip1.X;

            return(left);
        }
コード例 #13
0
        /// <summary>
        /// Calculates Y co-ordinate of main window top left corner
        /// </summary>
        /// <returns>Y co-ordinate of main window top left corner</returns>
        private double WindowTop()
        {
            var screen      = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dpi1        = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
            var dpi2        = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
            var totalHeight = this.SearchBoxBorder.Margin.Top + this.SearchBoxBorder.Margin.Bottom + this.SearchBox.Height + this.ListBoxBorder.Margin.Top + this.ListBoxBorder.Margin.Bottom + MAX_LIST_HEIGHT;
            var top         = (dpi2.Y - totalHeight) / 4 + dpi1.Y;

            return(top);
        }
コード例 #14
0
        private double WindowLeft()
        {
            Screen screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);

            System.Windows.Point dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
            System.Windows.Point dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
            double left = (dip2.X - ActualWidth) / 2 + dip1.X;

            return(left);
        }
コード例 #15
0
        private void BringProcessToForeground()
        {
            // Use SendInput hack to allow Activate to work - required to resolve focus issue https://github.com/microsoft/PowerToys/issues/4270
            WindowsInteropHelper.INPUT input = new WindowsInteropHelper.INPUT {
                type = WindowsInteropHelper.INPUTTYPE.INPUT_MOUSE, data = { }
            };
            WindowsInteropHelper.INPUT[] inputs = new WindowsInteropHelper.INPUT[] { input };

            // Send empty mouse event. This makes this thread the last to send input, and hence allows it to pass foreground permission checks
            _ = WindowsInteropHelper.SendInput(1, inputs, WindowsInteropHelper.INPUT.Size);
            Activate();
        }
コード例 #16
0
ファイル: MainWindow.xaml.cs プロジェクト: zmshan2008/Wox
        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();
        }
コード例 #17
0
        /// <summary>
        /// Checks if Wox should ignore any hotkeys
        /// </summary>
        /// <returns></returns>
        private bool ShouldIgnoreHotkeys()
        {
            //double if to omit calling win32 function
            if (_settings.IgnoreHotkeysOnFullscreen)
            {
                if (WindowsInteropHelper.IsWindowFullscreen())
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #18
0
ファイル: MainWindow.xaml.cs プロジェクト: xuanwa/PowerToys
        private void OnLoaded(object sender, System.Windows.RoutedEventArgs _)
        {
            WindowsInteropHelper.DisableControlBox(this);

            InitializePosition();

            SearchBox.QueryTextBox.DataContext     = _viewModel;
            SearchBox.QueryTextBox.PreviewKeyDown += _launcher_KeyDown;
            SearchBox.QueryTextBox.TextChanged    += QueryTextBox_TextChanged;
            SearchBox.QueryTextBox.Focus();

            _viewModel.PropertyChanged += ViewModel_PropertyChanged;
        }
コード例 #19
0
        private void OnLoaded(object sender, RoutedEventArgs _)
        {
            WindowsInteropHelper.DisableControlBox(this);
            InitializePosition();

            SearchBox.QueryTextBox.DataContext     = _viewModel;
            SearchBox.QueryTextBox.PreviewKeyDown += _launcher_KeyDown;
            SearchBox.QueryTextBox.TextChanged    += QueryTextBox_TextChanged;
            SearchBox.QueryTextBox.Focus();

            ListBox.DataContext = _viewModel;
            ListBox.SuggestionsList.SelectionChanged         += SuggestionsList_SelectionChanged;
            ListBox.SuggestionsList.PreviewMouseLeftButtonUp += SuggestionsList_PreviewMouseLeftButtonUp;
            _viewModel.PropertyChanged += ViewModel_PropertyChanged;
        }
コード例 #20
0
        private void OnLoaded(object sender, RoutedEventArgs _)
        {
            // show notify icon when flowlauncher is hidden
            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;
                        }
                    }
                }
            };
            _settings.PropertyChanged += (o, e) =>
            {
                switch (e.PropertyName)
                {
                case nameof(Settings.HideNotifyIcon):
                    _notifyIcon.Visible = !_settings.HideNotifyIcon;
                    break;

                case nameof(Settings.Language):
                    UpdateNotifyIconText();
                    break;
                }
            };

            InitializePosition();
        }
コード例 #21
0
ファイル: MainWindow.xaml.cs プロジェクト: jsoref/PowerToys
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            WindowsInteropHelper.DisableControlBox(this);
            InitializePosition();

            SearchBox.QueryTextBox.DataContext     = _viewModel;
            SearchBox.QueryTextBox.PreviewKeyDown += Launcher_KeyDown;

            SetupSearchTextBoxReactiveness(_viewModel.GetSearchQueryResultsWithDelaySetting(), _viewModel.GetSearchInputDelaySetting());
            _viewModel.RegisterSettingsChangeListener(
                (s, prop_e) =>
            {
                if (prop_e.PropertyName == nameof(PowerToysRunSettings.SearchQueryResultsWithDelay) || prop_e.PropertyName == nameof(PowerToysRunSettings.SearchInputDelay))
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        SetupSearchTextBoxReactiveness(_viewModel.GetSearchQueryResultsWithDelaySetting(), _viewModel.GetSearchInputDelaySetting());
                    });
                }
            });

            // Set initial language flow direction
            SearchBox_UpdateFlowDirection();

            // Register language changed event
            InputLanguageManager.Current.InputLanguageChanged += SearchBox_InputLanguageChanged;

            SearchBox.QueryTextBox.Focus();
            SearchBox.QueryTextBox.ControlledElements.Add(ListBox.SuggestionsList);

            ListBox.DataContext = _viewModel;
            ListBox.SuggestionsList.SelectionChanged         += SuggestionsList_SelectionChanged;
            ListBox.SuggestionsList.PreviewMouseLeftButtonUp += SuggestionsList_PreviewMouseLeftButtonUp;
            _viewModel.PropertyChanged     += ViewModel_PropertyChanged;
            _viewModel.MainWindowVisibility = Visibility.Collapsed;
            _viewModel.LoadedAtLeastOnce    = true;

            BringProcessToForeground();
        }
コード例 #22
0
        private void OnLoaded(object sender, System.Windows.RoutedEventArgs _)
        {
            WindowsInteropHelper.DisableControlBox(this);

            InitializePosition();
        }
コード例 #23
0
 protected override void OnSourceInitialized(EventArgs e)
 {
     base.OnSourceInitialized(e);
     WindowsInteropHelper.SetPopupStyle(this);
 }