Пример #1
0
        public MainWindow()
        {
            InitializeComponent();
            userActivity.KeyDown += UserActivity_KeyDown;
            userActivity.KeyUp   += UserActivity_KeyUp;

            TextCorrecter.GetSource();
            using (var reader = new XmlTextReader("LML_Data\\Highlight.xshd"))
                CommandBox.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);

            if (Settings.Default.IsFirstLaunch)
            {
                Settings.Default.IsFirstLaunch = false;
                Sourcer.CommandSourceUpdate();
            }

            IntelWords = IntelReader.GetArray("ShortCuts>Inputs").ToList();
            for (int i = 0; i < IntelWords.Count; i++)
            {
                IntelWords[i] = IntelWords[i].Replace("/", "");

                if (Regex.IsMatch(IntelWords[i], "[|]"))
                {
                    var words = IntelWords[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    IntelWords[i] = words[0];

                    for (int j = 1; j < words.Length; j++)
                    {
                        IntelWords.Add(words[j]);
                    }
                }
            }

            Files = FileSearcher.GetFilesFast(@"C:\ProgramData\Microsoft\Windows\Start Menu\Programs", "*.*");

            CommandBox.TextArea.TextEntering += IntellisenseTextEntering;
            CommandBox.TextArea.TextEntered  += IntellisenseTextEntered;
        }
Пример #2
0
        private void CmdWindow_KeyUp(object sender, KeyEventArgs e)
        {
            if (Regex.IsMatch(CommandBox.Text, "^\\s*nn"))
            {
                new UserWindows.Notepad().Show();
                CommandBox.Text = "";
                Hide();
            }

            if (e.Key == Key.Space)
            {
                var corrected = TextCorrecter.CorrectLive(CommandBox.Text);
                if (CommandBox.Text != corrected)
                {
                    CommandBox.Text        = corrected;
                    CommandBox.CaretOffset = CommandBox.Text.Length;
                }

                if (Regex.IsMatch(CommandBox.Text, "^\\s*:.+"))
                {
                    CommandBox.Text = Regex.Replace(CommandBox.Text, "^\\s*:", "");
                }
            }

            if (e.Key == Key.Enter)
            {
                CommandBox.Text        = Regex.Replace(CommandBox.Text, @"
", " ", RegexOptions.Multiline);
                CommandBox.CaretOffset = CommandBox.Text.Length;

                try
                {
                    if (CmdWindow.Height != 300d)
                    {
                        CommandBox.Text = CommandBox.Text.Replace("\n", "");
                        ExecuteCommand();
                    }
                }
                catch
                {
                }
            }

            if (e.Key == Key.Escape)
            {
                if (CommandBox.IsFocused || EnterFirstTime)
                {
                    Hide();
                    CommandBox.Text = "";
                    EnterFirstTime  = false;
                }

                EnterFirstTime = true;
            }
            else
            {
                EnterFirstTime = false;
            }

            bool
                isLifeSearch    = Regex.IsMatch(CommandBox.Text, "(^|^\\s+)-\\s+"),
                isClassicSearch = Regex.IsMatch(CommandBox.Text, "(^|^\\s+)(find|search)\\s+");

            if (isLifeSearch || isClassicSearch)
            {
                if (CmdWindow.Height != 300d)
                {
                    CmdWindow.Height = 300d;
                }
            }
            else if (CmdWindow.Height != 50d)
            {
                CmdWindow.Height = 50d;
            }

            if (isLifeSearch && e.Key != Key.Up && e.Key != Key.Down && e.Key != Key.Apps && e.Key != Key.Escape)
            {
                StardLifeSearch();
            }

            else if (isClassicSearch && (e.Key == Key.Right || e.Key == Key.RightCtrl))
            {
                StartSearch();
            }
        }
Пример #3
0
 public void SetCommand(string command)
 {
     Command = TextCorrecter.CorrectToProgramCommand(command);
     Tokens  = GetTokens(Command);
 }