void MainControl_InsertToEndExecuted(object sender, EventArgs e)
        {
            var c = sender as InsertText;

            var  macaron = new VisualStudioMacaron(this);
            bool skip    = c.Skip;
            var  text    = c.Text;

            try {
                macaron.ReplaceSelectionParagraphs(null, (a) =>
                {
                    if (skip && a.Text.EndsWith(text))
                    {
                        a.IsCanceled = true;
                    }
                    else
                    {
                        a.Text = a.Text + text;
                    }
                });
            }
            catch (ActiveDocumentIsNullException) {
                macaron.ShowMessageBox(Resources.InsertTextCaption, Resources.MessageActivateTextEditorForInsertText);
            }             // end try
        }
        }     // end constructor

        #endregion

        #region MainControl(TextFormat)イベント処理

        /// <summary>
        /// メインコントロール の TextFormat で、ボタンが押されたときの処理を実行します。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainControl_Executed(object sender, EventArgs e)
        {
            var c       = sender as TextFormat;
            var macaron = new VisualStudioMacaron(this);

            try
            {
                macaron.ReplaceSelectionParagraphs(null, (a) =>
                {
                    // c(ツールウィンドウ)Text をフォーマット、a(エディタ)選択行を値として、フォーマット変換を実行します。
                    a.Text = TextFormatMacro.Format(c.Text, a.Text);
                });
            }
            catch (ActiveDocumentIsNullException)
            {
                macaron.ShowMessageBox(Resources.TextFormatCaption, Resources.MessageActivateTextEditorForFormatText);
            } // end try
        }     // end sub
        void MainControl_Executed(object sender, InsertSerialNumberEventArgs e)
        {
            if (e.InsertPosition == InsertPosition.None)
            {
                return;
            }

            var  macaron = new VisualStudioMacaron(this);
            long number  = 0;

            if (long.TryParse(e.StartNumberText, out number) == false)
            {
                // TODO: ローカライズ
                macaron.ShowMessageBox(Resources.InsertSerialNumberCaption, Resources.MessageInputNumber);

                //this.MainControl.Focus();
                return;
            }

            var  numberLength  = 0;
            long numberCounter = number;

            try
            {
                macaron.ReplaceSelectionParagraphs(
                    (a) =>
                {
                    numberCounter += 1;
                    numberLength   = numberCounter.ToString().Length;
                },
                    (a) =>
                {
                    var text         = number.ToString();
                    var paddingCount = numberLength - text.Length;
                    if (paddingCount > 0)
                    {
                        switch (e.PaddingKind)
                        {
                        case PaddingKind.Zero:
                            text = new string('0', paddingCount) + text;
                            break;

                        case PaddingKind.Space:
                            text = new string(' ', paddingCount) + text;
                            break;

                        case PaddingKind.None:
                        default:
                            break;
                        }
                    }    // end if


                    if (e.Skip &&
                        (e.InsertPosition == InsertPosition.HeadOfLine && a.Text.StartsWith(text) ||
                         e.InsertPosition == InsertPosition.EndOfLine && a.Text.EndsWith(text))
                        )
                    {
                        a.IsCanceled = true;
                    }
                    else
                    {
                        switch (e.InsertPosition)
                        {
                        case InsertPosition.HeadOfLine:
                            a.Text = text + a.Text;
                            break;

                        case InsertPosition.EndOfLine:
                            a.Text = a.Text + text;
                            break;

                        case InsertPosition.None:
                        default:
                            break;
                        }
                    }
                    number += 1;
                });
            }
            catch (ActiveDocumentIsNullException)
            {
                macaron.ShowMessageBox(Resources.InsertSerialNumberCaption, Resources.MessageActivateTextEditorForInsertText);
            } // end try
        }     // end sub