コード例 #1
0
 /// <summary>
 /// テキスト変更
 /// </summary>
 /// <param name="sender">イベント送信元</param>
 /// <param name="e">イベント内容</param>
 void TextChanged(object sender, EventArgs e)
 {
     if (_control.Focused)
     {
         AddSentence(new TokenName(), ".EmulateChangeText(" + GenerateUtility.AdjustText(_control.Text), new TokenAsync(CommaType.Before), ");");
     }
 }
コード例 #2
0
 /// <summary>
 /// テキスト変化イベント
 /// </summary>
 /// <param name="sender">イベント送信元</param>
 /// <param name="e">イベント内容</param>
 void ComboBoxTextChanged(object sender, EventArgs e)
 {
     if (_control.Focused && _control.DropDownStyle != ComboBoxStyle.DropDownList)
     {
         AddSentence(new TokenName(), ".EmulateChangeText(" + GenerateUtility.AdjustText(_control.Text), new TokenAsync(CommaType.Before), ");");
     }
 }
コード例 #3
0
        /// <summary>
        /// ラベル編集イベント
        /// </summary>
        /// <param name="sender">イベント送信元</param>
        /// <param name="e">イベント内容</param>
        void AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            if (e == null || e.Label == null)
            {
                return;
            }
            string from = GetNodePath(e.Node);

            AddSentence(new TokenName(), from + ".EmulateEditLabel(" + GenerateUtility.AdjustText(e.Label), new TokenAsync(CommaType.Before), ");");
        }
コード例 #4
0
        /// <summary>
        /// セル編集イベント
        /// </summary>
        /// <param name="sender">イベント送信元</param>
        /// <param name="e">イベント内容</param>
        void CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewTextBoxCell textBox = _control[e.ColumnIndex, e.RowIndex] as DataGridViewTextBoxCell;

            if (textBox != null)
            {
                object obj   = _control[e.ColumnIndex, e.RowIndex].Value;
                string value = (obj == null) ? string.Empty : obj.ToString();
                AddSentence(new TokenName(), ".EmulateChangeCellText(" + e.ColumnIndex + ", " + e.RowIndex + ", " +
                            GenerateUtility.AdjustText(value), new TokenAsync(CommaType.Before), ");");
                return;
            }
            DataGridViewComboBoxCell comboBox = _control[e.ColumnIndex, e.RowIndex] as DataGridViewComboBoxCell;

            if (comboBox != null)
            {
                object obj   = _control[e.ColumnIndex, e.RowIndex].Value;
                string value = (obj == null) ? string.Empty : obj.ToString();
                int    index = -1;
                for (int i = 0; i < comboBox.Items.Count; i++)
                {
                    string item = (comboBox.Items[i] == null) ? string.Empty : comboBox.Items[i].ToString();
                    if (item == value)
                    {
                        index = i;
                        break;
                    }
                }
                if (index != -1)
                {
                    AddSentence(new TokenName(), ".EmulateChangeCellComboSelect(" + e.ColumnIndex + ", " + e.RowIndex + ", " + index, new TokenAsync(CommaType.Before), ");");
                }
                return;
            }
            DataGridViewCheckBoxCell checkBox = _control[e.ColumnIndex, e.RowIndex] as DataGridViewCheckBoxCell;

            if (checkBox != null)
            {
                object obj   = _control[e.ColumnIndex, e.RowIndex].Value;
                bool   value = (obj != null && obj is bool) ? (bool)obj : false;
                AddSentence(new TokenName(), ".EmulateCellCheck(" +
                            e.ColumnIndex + ", " + e.RowIndex + ", " + value.ToString(CultureInfo.CurrentCulture).ToLower(CultureInfo.CurrentCulture),
                            new TokenAsync(CommaType.Before), ");");
                return;
            }
        }
        /// <summary>
        /// アイテムまでのパスを取得
        /// </summary>
        /// <param name="fromText">至るまでのテキスト</param>
        /// <returns>パス</returns>
        private static string GetItemPath(string[] fromText)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(".FindItem(");
            bool first = true;

            foreach (string element in fromText)
            {
                if (!first)
                {
                    builder.Append(", ");
                }
                first = false;
                builder.Append(GenerateUtility.AdjustText(element));
            }
            builder.Append(")");
            return(builder.ToString());
        }
 /// <summary>
 /// ラベルが編集された。
 /// </summary>
 /// <param name="sender">イベント送信元。</param>
 /// <param name="e">イベント内容。</param>
 void AfterLabelEdit(object sender, LabelEditEventArgs e)
 {
     AddSentence(new TokenName(),
                 ".GetListViewItem(" + e.Item + ").EmulateEditLabel(" + GenerateUtility.AdjustText(e.Label),
                 new TokenAsync(CommaType.Before), ");");
 }
        /// <summary>
        /// コンボボックスにアタッチ
        /// </summary>
        /// <param name="fromIndex">至るまでのインデックス</param>
        /// <param name="item">アタッチ対象アイテム</param>
        /// <returns>アタッチしたか</returns>
        private bool AttachCombo(int[] fromIndex, ToolStripItem item)
        {
            ToolStripComboBox combo = item as ToolStripComboBox;

            if (combo != null)
            {
                //選択変更
                EventHandler selectedIndexChanged = delegate
                {
                    AddSentence("new FormsToolStripComboBox(", new TokenName(),
                                GetItemPath(fromIndex), ").ComboBox.EmulateChangeSelect(",
                                combo.SelectedIndex.ToString(CultureInfo.CurrentCulture), new TokenAsync(CommaType.Before), ");");
                };
                combo.SelectedIndexChanged += selectedIndexChanged;
                _detachHandler.Add(delegate { combo.SelectedIndexChanged -= selectedIndexChanged; });

                //文字列変更
                EventHandler textChanged = delegate
                {
                    if (combo.SelectedIndex != -1)
                    {
                        if (combo.SelectedItem != null && combo.SelectedItem.ToString() == combo.Text)
                        {
                            return;
                        }
                    }
                    AddSentence("new FormsToolStripComboBox(", new TokenName(),
                                GetItemPath(fromIndex), ").ComboBox.EmulateChangeText(", GenerateUtility.AdjustText(combo.Text), new TokenAsync(CommaType.Before), ");");
                };
                combo.TextChanged += textChanged;
                _detachHandler.Add(delegate { combo.TextChanged -= textChanged; });
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// テキストボックスにアタッチ
        /// </summary>
        /// <param name="fromIndex">至るまでのインデックス</param>
        /// <param name="item">アタッチ対象アイテム</param>
        /// <returns>アタッチしたか</returns>
        private bool AttachTextBox(int[] fromIndex, ToolStripItem item)
        {
            ToolStripTextBox textBox = item as ToolStripTextBox;

            if (textBox != null)
            {
                //文字列変更
                EventHandler textChanged = delegate
                {
                    AddSentence("new FormsToolStripTextBox(", new TokenName(),
                                GetItemPath(fromIndex), ").TextBox.EmulateChangeText(", GenerateUtility.AdjustText(textBox.Text), new TokenAsync(CommaType.Before), ");");
                };
                textBox.TextChanged += textChanged;
                _detachHandler.Add(delegate { textBox.TextChanged -= textChanged; });
                return(true);
            }
            return(false);
        }