예제 #1
0
        public string GetFromRight()
        {
            string strLeft  = "";
            string strRight = "";

            AmazonQueryControl.ParseLeftRight(this.comboBox_from.Text,
                                              out strLeft,
                                              out strRight);
            if (string.IsNullOrEmpty(strRight) == false)
            {
                return(strRight);
            }

            // 从 Items 中寻找
            string strText = GetLineText(this.comboBox_from, strLeft);

            if (strText == null)
            {
                return(null);
            }

            AmazonQueryControl.ParseLeftRight(strText,
                                              out strLeft,
                                              out strRight);
            return(strRight);
        }
예제 #2
0
        public static string GetLeft(string s)
        {
            string strLeft  = "";
            string strRight = "";

            AmazonQueryControl.ParseLeftRight(s,
                                              out strLeft,
                                              out strRight);

            return(strLeft);
        }
        // 构造参数表
        public void BuildParameterTable(ref IDictionary <string, string> table)
        {
            if (table == null)
            {
                table = new ParameterTable();
            }

            foreach (Item item in this.Items)
            {
                string strName  = item.Name;
                string strValue = item.Value;
                if (string.IsNullOrEmpty(strValue) == false)
                {
                    if (item.ItemType == ItemType.ComboBox)
                    {
                        string strLeft  = "";
                        string strRight = "";
                        AmazonQueryControl.ParseLeftRight(strValue,
                                                          out strLeft,
                                                          out strRight);
                        if (string.IsNullOrEmpty(strRight) == false)
                        {
                            table[strName] = strRight;
                        }
                        else
                        {
                            // TODO: 警告?
                        }
                    }
                    else if (item.ItemType == ItemType.TextBox)
                    {
                        table[strName] = strValue;
                    }
                    else
                    {
                        table[strName] = strValue;
                    }
                }
            }
        }
예제 #4
0
        void FillMatchStyles()
        {
            string[] matchs = null;

            // 保存已有的 Text 值
            string strOldText = this.tabComboBox_match.Text;

            this.tabComboBox_match.Items.Clear();

            string strFrom = this.GetFromRight();

            if (strFrom == "title")
            {
                matchs = new string[] {
                    "默认\t[default]",
                    "前方一致\t-begins",
                    "单词前方一致\t-words-begin"
                };
            }
            else if (strFrom == "author")
            {
                matchs = new string[] {
                    "默认\t[default]",
                    "前方一致\t-begins",
                    "精确一致\t-exact"
                };
            }
            else if (strFrom == "keywords")
            {
                matchs = new string[] {
                    "默认\t[default]",
                    "前方一致\t-begin"
                };
            }
            else if (strFrom == "subject")
            {
                matchs = new string[] {
                    "默认\t[default]",
                    "前方一致\t-begins",
                    "单词前方一致\t-words-begin"
                };
            }
            else if (strFrom == "pubdate")
            {
                matchs = new string[] {
                    "默认\t[default]",
                    "以后\t:after",
                    "正当\t:during"
                };
            }

            if (matchs == null)
            {
                matchs = new string[] {
                    "默认\t[default]"
                };
            }

            foreach (string s in matchs)
            {
                this.tabComboBox_match.Items.Add(s);
            }

            if (string.IsNullOrEmpty(strOldText) == false)
            {
                string strLeft = AmazonQueryControl.GetLeft(strOldText);
                // 重新设置 Text 值
                string strFound = GetLineText(this.tabComboBox_match,
                                              strLeft);
                if (string.IsNullOrEmpty(strFound) == false)
                {
                    if (strOldText == strFound)
                    {
                        // 不用修改
                    }
                    else
                    {
                        this.tabComboBox_match.Text = strLeft;  // 只要左边部分
                    }
                }
                else
                {
                    this.tabComboBox_match.Text = "";   // Text 发现不在列表中,清空以避免问题
                }
            }

            if (string.IsNullOrEmpty(this.tabComboBox_match.Text) == true &&
                matchs != null && matchs.Length > 0)
            {
                this.tabComboBox_match.Text = matchs[0];
            }
        }