コード例 #1
0
        /// <summary>
        /// Добавить всплывающую подсказку у слова
        /// </summary>
        public static bool InsertWordToolTip(int idContent, string word, int tooltipType, string comment, string url, string groupName, string foreColor)
        {
            if (eDictionary.Contains(idContent, word))
            {
                MessageBox.Show(string.Format("Слово \"{0}\" уже есть в категории \"{1}\"", word, idContent == 0? Constants.PUBLIC_DICTIONARY_CATEGORY : Constants.PRIVATE_DICTIONARY_CATEGORY)
                                , "Дублирование подсказки", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            QuotedStr(ref word);
            QuotedStr(ref comment);
            QuotedStr(ref url);
            QuotedStr(ref groupName);
            QuotedStr(ref foreColor);

            if (G.ExecSQLiteQuery(
                    string.Format("INSERT INTO word_tooltip ({0}, {2}, {4}, {6}, {8}, {10}, {12}) VALUES ({1},'{3}',{5},'{7}','{9}','{11}','{13}')"
                                  , ID_CONTENT, idContent
                                  , WORD, word
                                  , TOOLTIP_TYPE_COLUMN_NAME, tooltipType
                                  , COMMENT_COLUMN_NAME, comment
                                  , URL_ADR_COLUMN_NAME, url
                                  , GROUP_NAME, groupName
                                  , FORE_COLOR, foreColor
                                  )))
            {
                AddItem(idContent, word, comment, url, (TooltipType)tooltipType);
                DictionaryEditor.AddNode(idContent, groupName, word, foreColor, true);
                AddHelpRow(idContent, word, comment, foreColor, url);
                return(true);
            }
            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Изменить всплывающую подсказку у слова
        /// </summary>
        public static bool UpdateWordToolTip(int idContent, string word, int tooltipType, string comment, string url, string groupName, string foreColor, int oldIdContent, string oldWord)
        {
            if ((oldIdContent != idContent || string.Compare(word, oldWord, true) != 0) &&
                eDictionary.Contains(idContent, word))
            {
                MessageBox.Show(string.Format("Слово \"{0}\" уже есть в категории \"{1}\"", word, idContent == 0 ? Constants.PUBLIC_DICTIONARY_CATEGORY : Constants.PRIVATE_DICTIONARY_CATEGORY)
                                , "Дублирование подсказки", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            QuotedStr(ref word);
            QuotedStr(ref comment);
            QuotedStr(ref url);
            QuotedStr(ref groupName);
            QuotedStr(ref foreColor);
            QuotedStr(ref oldWord);

            if (G.ExecSQLiteQuery(
                    string.Format("UPDATE word_tooltip SET id_content={0}, word='{1}', tooltip_type={2}, comment='{3}', url_adr='{4}', group_name='{5}', fore_color='{6}' WHERE id_content='{7}' AND word='{8}'"
                                  , idContent, word, tooltipType, comment, url, groupName, foreColor, oldIdContent, oldWord)))
            {
                DictionaryInfo oldDicInfo        = eDictionary.GetByTitle(oldIdContent, oldWord);
                string         selectQuestionSql = "select question from vopros where id_content={0}";
                if (MainForm.IdContentUrlRegEx_v1.IsMatch(url) &&
                    G.ExecSQLiteQuery(string.Format(selectQuestionSql, url.Substring(7))) &&
                    G.DT.Rows.Count == 1)
                {
                    eDictionary.Edit(oldDicInfo, word, G.DT.Rows[0][0].ToString(), idContent, tooltipType, url);
                }
                else
                if (MainForm.IdContentUrlRegEx_v2.IsMatch(url) &&
                    G.ExecSQLiteQuery(string.Format(selectQuestionSql, url.Substring(2))) &&
                    G.DT.Rows.Count == 1)
                {
                    eDictionary.Edit(oldDicInfo, word, G.DT.Rows[0][0].ToString(), idContent, tooltipType, url);
                }
                else
                {
                    eDictionary.Edit(oldDicInfo, word, comment, idContent, tooltipType, url);
                }

                TreeNode parentNodeLevel1 = TooltipDictionary.TV_Dictionary.SelectedNode.Parent;
                // Редактировать слово в дереве
                if (TooltipDictionary.TV_Dictionary.SelectedNode.Text == word &&
                    (parentNodeLevel1.Text == groupName || parentNodeLevel1.Text == Constants.WithoutGroup) &&
                    TooltipDictionary.TV_Dictionary.SelectedNode.Name == idContent.ToString())
                {
                    TooltipDictionary.TV_Dictionary.SelectedNode.ForeColor = System.Drawing.Color.FromName(foreColor);
                }
                else
                {
                    TooltipDictionary.TV_Dictionary.SelectedNode.Remove();
                    if (parentNodeLevel1.Nodes.Count == 0)
                    {
                        TreeNode parentNodeLevel0 = parentNodeLevel1.Parent;
                        parentNodeLevel1.Remove();
                        if (parentNodeLevel0.Nodes.Count == 0)
                        {
                            parentNodeLevel0.Remove();
                        }
                    }
                    DictionaryEditor.AddNode(idContent, groupName, word, foreColor, true);
                }

                // Пересоздать запись в HelpDGV
                HelpDT.Rows.Remove(GetHelpDtRow(oldIdContent, oldWord));
                AddHelpRow(idContent, word, comment, foreColor, url);
                return(true);
            }
            return(false);
        }