コード例 #1
0
ファイル: Main.xaml.cs プロジェクト: shellscape/Lumen
        public Main()
        {
            InitializeComponent();

            this.WindowStartupLocation = WindowStartupLocation.Manual;
            this.Top           = this.Left = 0;
            this.Focusable     = true;
            this.ShowInTaskbar = false;

            var style = (Style)FindResource("CommandInput");
            var block = new RichTextBox()
            {
                Style = style
            };

            this.Loaded += delegate(object sender, RoutedEventArgs e) {
                this.Visibility = Visibility.Hidden;

                _hotkeys = new HotKeyHandeler(this);
                _hotkeys.RegisterHotKey(AccessModifierKeys.Win | AccessModifierKeys.Alt, Key.Space);
                _hotkeys.HotKeyPressed += _hotkeys_HotKeyPressed;
            };

            _initialWidth = block.Width == 0 ? 660 : (int)block.Width;

            style = (Style)FindResource("Result");
            var resultBlock = new TextBlock()
            {
                Style = style
            };

            _resultHeight = (int)resultBlock.Height;

            _TextCommand.TextChanged += _TextCommand_TextChanged;
            _BorderMain.SizeChanged  += _Canvas_SizeChanged;

            ExtensionManager.Current.ForEach((e) => {
                var commands = e.GetCommands();
                commands.ForEach((c) => {
                    _registeredCommands.Add(new LumenCommand()
                    {
                        Command = c, ParameterHint = ""
                    });
                });
            });

            if (Search.WindowsSearchProvider.IsAvailable)
            {
                _windowsSearch.ResultsChanged += WindowsSearch_ResultsChanged;
            }

            Styles.Init(this);
            PrepareCategories();
        }
コード例 #2
0
        // ************************************************************************
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            // Method 1

            //IntPtr mainWindowPtr = new WindowInteropHelper(this).Handle;
            //HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
            //if (mainWindowSrc != null)
            //{
            //	mainWindowSrc.AddHook(WndProc);
            //}

            // Method 2
            HwndSource source = PresentationSource.FromVisual(this) as HwndSource;

            source.AddHook(WndProc);

            _hotKeyHandler = new HotKeyHandeler(this);
            _hotKeyHandler.HotKeyPressed += _hotKeyHandler_HotKeyPressed;
            _hotKeyHandler.RegisterHotKey(0, Key.NumPad0);

            this.Visibility = Visibility.Hidden;
        }