コード例 #1
0
        public bool Pop(MojiType type)
        {
            var x = tags.LastOrDefault(x => x.Type == type);

            if (x != default)
            {
                return(tags.Remove(x));
            }
            return(false);
        }
コード例 #2
0
ファイル: FormMain.cs プロジェクト: ambiesoft/SendToTools
        private void txtName_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (!tsmiSmartDoubleClickSelection.Checked)
            {
                return;
            }

            _dbTick = Environment.TickCount;

            string selText = txtName.SelectedText;

            if (string.IsNullOrEmpty(selText))
            {
                return;
            }

            char     startC  = selText[0];
            MojiType startMT = GetMojiType(startC);
            //if (selText.Length >= 2)
            //{
            //    char endC = selText[selText.Length - 1];
            //    MojiType endMT = GetMojiType(endC);
            //    if (startMT != endMT)
            //        return;
            //}

            // If selection moji type is different, it's over
            //foreach(char c in selText)
            //{
            //    if (GetMojiType(c) != startMT)
            //        return;
            //}

            // expand tail until mojitype are same
            int newEnd = txtName.SelectionStart + 1;

            for (; newEnd < txtName.TextLength; ++newEnd)
            {
                char c = txtName.Text[newEnd];
                if (GetMojiType(c) != startMT)
                {
                    break;
                }
            }
            int selLen = newEnd - txtName.SelectionStart;// +txtName.SelectionLength - 1;

            // expand front
            int newStart = txtName.SelectionStart;

            for (; newStart >= 0; --newStart)
            {
                char c = txtName.Text[newStart];
                if (GetMojiType(c) != startMT)
                {
                    break;
                }
            }

            selLen += txtName.SelectionStart - newStart - 1;

            txtName.SelectionStart  = newStart + 1;
            txtName.SelectionLength = selLen;
        }