Example #1
0
        private void MiniGrid_Drop(object sender, System.Windows.DragEventArgs e)
        {
            //MessageBox.Show("MiniGrid_Drop! TODO: Please do query -- TT!");
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Window_Drop:" + DateTime.Now.ToUniversalTime());
            sb.AppendLine("sender:" + sender.ToString());
            sb.AppendLine("e.Data.GetType:" + e.Data.GetType());
            sb.AppendLine("e.Data.Formats:" + string.Join("; ", e.Data.GetFormats(true)));
            sb.AppendLine("e.Source.GetType:" + e.Source.GetType());
            sb.AppendLine("e.Source.ToString:" + e.Source.ToString());
            sb.AppendLine("e.OriginalSource.GetType:" + e.OriginalSource.GetType());
            sb.AppendLine("e.OriginalSource.ToString:" + e.OriginalSource.ToString());
            sb.AppendLine("-- convert e.Data : --");
            _mainWindow.ResultTextBox.Text = sb.ToString();
            sb = new StringBuilder();

            Externel.DragArgDispatcher dispatcher = new Externel.DragArgDispatcher();
            string         text = string.Empty;
            InputQueryType type = new InputQueryType();
            bool           isOK = dispatcher.TryGetQuery(e, ref text, ref type);

            if (isOK)
            {
                _mainWindow.InputTextBox.Text = text;
                _mainWindow.DoDirectQuery(text, type);
            }

            _mainWindow.ResultTextBox.Text += sb.ToString();
            if (!_mainWindow.IsVisible)
            {
                ShowMainWindow();
            }
        }
Example #2
0
        public void Window_Drop(object sender, System.Windows.DragEventArgs e)
        {
            // TODO: Add event handler implementation here.
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Window_Drop:" + DateTime.Now.ToUniversalTime());
            sb.AppendLine("sender:" + sender.ToString());
            sb.AppendLine("e.Data.GetType:" + e.Data.GetType());
            sb.AppendLine("e.Data.Formats:" + string.Join("; ", e.Data.GetFormats(true)));
            sb.AppendLine("e.Source.GetType:" + e.Source.GetType());
            sb.AppendLine("e.Source.ToString:" + e.Source.ToString());
            sb.AppendLine("e.OriginalSource.GetType:" + e.OriginalSource.GetType());
            sb.AppendLine("e.OriginalSource.ToString:" + e.OriginalSource.ToString());
            sb.AppendLine("-- convert e.Data : --");
            ResultTextBox.Text = sb.ToString();
            sb = new StringBuilder();

            Externel.DragArgDispatcher dispatcher = new Externel.DragArgDispatcher();
            string         text = string.Empty;
            InputQueryType type = new InputQueryType();
            bool           isOK = dispatcher.TryGetQuery(e, ref text, ref type);

            if (isOK)
            {
                InputTextBox.Text = text;
                DoDirectQuery(text, type);
            }

            EnableKeyBoardInput();
            ResultTextBox.Text += sb.ToString();
        }
Example #3
0
 internal void DoDirectQuery(string text, InputQueryType queryType)
 {
     lock (_lastInputTimeLock)
     {
         _lastInputTime = DateTime.Now;
     }
     _DoQuery(text, queryType);
 }
Example #4
0
        private void DoDelayedQuery(string text, InputQueryType queryType, int milliSecondsTimedOut)
        {
            DateTime curInputTime = DateTime.Now;

            lock (_lastInputTimeLock)
            {
                if (_lastInputTime < curInputTime)
                {
                    _lastInputTime = curInputTime;
                }
            }
            Thread.Sleep(milliSecondsTimedOut);
            if (_lastInputTime == curInputTime)
            {
                if (text == _lastQueryText)
                {
                    return;
                }
                _DoQuery(text, queryType);
            }
        }
Example #5
0
        private void _DoQuery(string text, InputQueryType queryType)
        {
            if (text == string.Empty)
            {
                return;
            }
            switch (queryType)
            {
            case InputQueryType.Text:
            case InputQueryType.FileName:
            {
                InputQuery query = new InputQuery(text);
                query.QueryType = InputQueryType.Text;

                _lastQueryText = text;
                AddQueryHistory(text);

                this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new Action(
                                           delegate()
                    {
                        _pipeline.OnInputTextReady(query);
                    })
                                       );

                break;
            }

            case InputQueryType.FtpUri:
            case InputQueryType.HttpUri:
            {
                Shell shell = new Shell();
                shell.DoOpenWebBrowser(text);
                break;
            }

            default:
                break;
            }
        }
        private void _DoQuery(string text, InputQueryType queryType)
        {
            if (text == string.Empty)
            {
                return;
            }
            switch (queryType)
            {
                case InputQueryType.Text:
                case InputQueryType.FileName:
                    {
                        InputQuery query = new InputQuery(text);
                        query.QueryType = InputQueryType.Text;

                        _lastQueryText = text;
                        AddQueryHistory(text);

                        this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new Action(
                            delegate()
                            {
                                _pipeline.OnInputTextReady(query);
                            })
                        );

                        break;
                    }
                case InputQueryType.FtpUri:
                case InputQueryType.HttpUri:
                    {
                        Shell shell = new Shell();
                        shell.DoOpenWebBrowser(text);
                        break;
                    }
                default:
                    break;
            }
        }
 private void DoDelayedQuery(string text, InputQueryType queryType, int milliSecondsTimedOut)
 {
     DateTime curInputTime = DateTime.Now;
     lock (_lastInputTimeLock)
     {
         if (_lastInputTime < curInputTime)
         {
             _lastInputTime = curInputTime;
         }
     }
     Thread.Sleep(milliSecondsTimedOut);
     if (_lastInputTime == curInputTime)
     {
         if (text == _lastQueryText)
         {
             return;
         }
         _DoQuery(text, queryType);
     }
 }
 internal void DoDirectQuery(string text, InputQueryType queryType)
 {
     lock (_lastInputTimeLock)
     {
         _lastInputTime = DateTime.Now;
     }
     _DoQuery(text, queryType);
 }
        public void Window_Drop(object sender, System.Windows.DragEventArgs e)
        {
            // TODO: Add event handler implementation here.
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("Window_Drop:" + DateTime.Now.ToUniversalTime());
            sb.AppendLine("sender:" + sender.ToString());
            sb.AppendLine("e.Data.GetType:" + e.Data.GetType());
            sb.AppendLine("e.Data.Formats:" + string.Join("; ",e.Data.GetFormats(true)));
            sb.AppendLine("e.Source.GetType:" + e.Source.GetType());
            sb.AppendLine("e.Source.ToString:" + e.Source.ToString());
            sb.AppendLine("e.OriginalSource.GetType:" + e.OriginalSource.GetType());
            sb.AppendLine("e.OriginalSource.ToString:" + e.OriginalSource.ToString());
            sb.AppendLine("-- convert e.Data : --");
            ResultTextBox.Text = sb.ToString();
            sb = new StringBuilder();

            Externel.DragArgDispatcher dispatcher = new Externel.DragArgDispatcher();
            string text = string.Empty;
            InputQueryType type = new InputQueryType();
            bool isOK = dispatcher.TryGetQuery(e, ref text, ref type);
            if (isOK)
            {
                InputTextBox.Text = text;
                DoDirectQuery(text, type);
            }

            EnableKeyBoardInput();
            ResultTextBox.Text += sb.ToString();
        }
Example #10
0
 /// <summary>
 /// 输入查询的构造函数
 /// </summary>
 /// <param name="text">查询文本</param>
 /// <param name="type">查询类型</param>
 public InputQuery(String text, InputQueryType type)
 {
     Text      = text;
     QueryType = type;
 }
Example #11
0
        private void MiniGrid_Drop(object sender, System.Windows.DragEventArgs e)
        {
            //MessageBox.Show("MiniGrid_Drop! TODO: Please do query -- TT!");
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("Window_Drop:" + DateTime.Now.ToUniversalTime());
            sb.AppendLine("sender:" + sender.ToString());
            sb.AppendLine("e.Data.GetType:" + e.Data.GetType());
            sb.AppendLine("e.Data.Formats:" + string.Join("; ", e.Data.GetFormats(true)));
            sb.AppendLine("e.Source.GetType:" + e.Source.GetType());
            sb.AppendLine("e.Source.ToString:" + e.Source.ToString());
            sb.AppendLine("e.OriginalSource.GetType:" + e.OriginalSource.GetType());
            sb.AppendLine("e.OriginalSource.ToString:" + e.OriginalSource.ToString());
            sb.AppendLine("-- convert e.Data : --");
            _mainWindow.ResultTextBox.Text = sb.ToString();
            sb = new StringBuilder();

            Externel.DragArgDispatcher dispatcher = new Externel.DragArgDispatcher();
            string text = string.Empty;
            InputQueryType type = new InputQueryType();
            bool isOK = dispatcher.TryGetQuery(e, ref text, ref type);
            if (isOK)
            {
                _mainWindow.InputTextBox.Text = text;
                _mainWindow.DoDirectQuery(text, type);
            }

            _mainWindow.ResultTextBox.Text += sb.ToString();
            if (!_mainWindow.IsVisible)
            {
                ShowMainWindow();
            }
        }
Example #12
0
        public bool TryGetQuery(System.Windows.DragEventArgs e, ref string query, ref InputQueryType type)
        {
            StringBuilder sb = new StringBuilder();

            query = "";
            type  = InputQueryType.Unknown;
            if (e.Data.GetDataPresent("Text", true))
            {
                sb.AppendLine("Text:" + e.Data.GetData("Text", true));
                query = e.Data.GetData("Text", true).ToString();
                type  = InputQueryType.Text;
                return(true);
            }
            if (e.Data.GetDataPresent("text/html", true))
            {
                sb.AppendLine("text/html:" + e.Data.GetData("text/html", true));
            }
            if (e.Data.GetDataPresent("text/x-moz-url", true))
            {
                sb.AppendLine("text/x-moz-url:" + e.Data.GetData("text/x-moz-url", true));
            }
            if (e.Data.GetDataPresent("text/html", true))
            {
                sb.AppendLine("text/html:" + e.Data.GetData("text/html", true));
            }
            if (e.Data.GetDataPresent("HTML Format", true))
            {
                sb.AppendLine("HTML Format:" + e.Data.GetData("HTML Format", true));
            }
            if (e.Data.GetDataPresent("UniformText", true))
            {
                sb.AppendLine("UniformText:" + e.Data.GetData("UniformText", true));
            }
            if (e.Data.GetDataPresent("FileName", true))
            {
                sb.AppendLine("FileName:" + e.Data.GetData("FileName", true));
            }
            if (e.Data.GetDataPresent("FileNameW", true))
            {
                sb.AppendLine("FileNameW:" + e.Data.GetData("FileNameW", true));
            }
            if (e.Data.GetDataPresent("FileName", true))
            {
                sb.AppendLine("FileName:" + string.Join("; ", (String[])e.Data.GetData("FileName", true)));
            }
            if (e.Data.GetDataPresent("FileNameW", true))
            {
                sb.AppendLine("FileNameW:" + string.Join("; ", (String[])e.Data.GetData("FileNameW", true)));
                object   data = e.Data.GetData("FileNameW", true);
                String[] strs = data as String[];
                if (strs != null && strs.Length > 0)
                {
                    string filepath = strs[strs.Length - 1];
                    try
                    {
                        filepath = System.IO.Path.GetFileName(filepath);
                    }
                    catch (System.Exception exception) {
                        App.Logger.Warn("Cannot handle: " + filepath);
                        App.Logger.Warn(exception.Message);
                        App.Logger.Warn(exception.StackTrace);
                    }
                    query = filepath;
                    type  = InputQueryType.FileName;
                    return(true);
                }
            }
            if (e.Data.GetDataPresent("UniformResourceLocator", true))
            {
                sb.AppendLine("UniformResourceLocator:" + e.Data.GetData("UniformResourceLocator", true));
            }
            if (e.Data.GetDataPresent("UniformResourceLocatorW", true))
            {
                sb.AppendLine("UniformResourceLocatorW:" + e.Data.GetData("UniformResourceLocatorW", true));
                query = e.Data.GetData("UniformResourceLocatorW", true).ToString();
                type  = InputQueryType.HttpUri;
                return(true);
            }
            return(false);
        }
 public bool TryGetQuery(System.Windows.DragEventArgs e, ref string query, ref InputQueryType type)
 {
     StringBuilder sb = new StringBuilder();
     query = "";
     type = InputQueryType.Unknown;
     if (e.Data.GetDataPresent("Text", true))
     {
         sb.AppendLine("Text:" + e.Data.GetData("Text", true));
         query = e.Data.GetData("Text", true).ToString();
         type = InputQueryType.Text;
         return true;
     }
     if (e.Data.GetDataPresent("text/html", true))
     {
         sb.AppendLine("text/html:" + e.Data.GetData("text/html", true));
     }
     if (e.Data.GetDataPresent("text/x-moz-url", true))
     {
         sb.AppendLine("text/x-moz-url:" + e.Data.GetData("text/x-moz-url", true));
     }
     if (e.Data.GetDataPresent("text/html", true))
     {
         sb.AppendLine("text/html:" + e.Data.GetData("text/html", true));
     }
     if (e.Data.GetDataPresent("HTML Format", true))
     {
         sb.AppendLine("HTML Format:" + e.Data.GetData("HTML Format", true));
     }
     if (e.Data.GetDataPresent("UniformText", true))
     {
         sb.AppendLine("UniformText:" + e.Data.GetData("UniformText", true));
     }
     if (e.Data.GetDataPresent("FileName", true))
     {
         sb.AppendLine("FileName:" + e.Data.GetData("FileName", true));
     }
     if (e.Data.GetDataPresent("FileNameW", true))
     {
         sb.AppendLine("FileNameW:" + e.Data.GetData("FileNameW", true));
     }
     if (e.Data.GetDataPresent("FileName", true))
     {
         sb.AppendLine("FileName:" + string.Join("; ", (String[])e.Data.GetData("FileName", true)));
     }
     if (e.Data.GetDataPresent("FileNameW", true))
     {
         sb.AppendLine("FileNameW:" + string.Join("; ", (String[])e.Data.GetData("FileNameW", true)));
         object data = e.Data.GetData("FileNameW", true);
         String[] strs = data as String[];
         if (strs != null && strs.Length > 0)
         {
             string filepath = strs[strs.Length - 1];
             try
             {
                 filepath = System.IO.Path.GetFileName(filepath);
             }
             catch (System.Exception exception) {
                 App.Logger.Warn("Cannot handle: " + filepath);
                 App.Logger.Warn(exception.Message);
                 App.Logger.Warn(exception.StackTrace);
             }
             query = filepath;
             type = InputQueryType.FileName;
             return true;
         }
     }
     if (e.Data.GetDataPresent("UniformResourceLocator", true))
     {
         sb.AppendLine("UniformResourceLocator:" + e.Data.GetData("UniformResourceLocator", true));
     }
     if (e.Data.GetDataPresent("UniformResourceLocatorW", true))
     {
         sb.AppendLine("UniformResourceLocatorW:" + e.Data.GetData("UniformResourceLocatorW", true));
         query = e.Data.GetData("UniformResourceLocatorW", true).ToString();
         type = InputQueryType.HttpUri;
         return true;
     }
     return false;
 }
Example #14
0
 /// <summary>
 /// 输入查询的构造函数
 /// </summary>
 /// <param name="text">查询文本</param>
 /// <param name="type">查询类型</param>
 public InputQuery(String text, InputQueryType type)
 {
     Text = text;
     QueryType = type;
 }