Exemplo n.º 1
0
        private void CharacterInfo_Load(object sender, EventArgs e)
        {
            profBox = (prof.Controls[0] as ElementHost).Child as System.Windows.Controls.TextBox;
            personalityTraitsBox = (personalityTraits.Controls[0] as ElementHost).Child as System.Windows.Controls.TextBox;
            idealsBox            = (ideals.Controls[0] as ElementHost).Child as System.Windows.Controls.TextBox;
            bondsBox             = (bonds.Controls[0] as ElementHost).Child as System.Windows.Controls.TextBox;
            flawsBox             = (flaws.Controls[0] as ElementHost).Child as System.Windows.Controls.TextBox;
            backstoryBox         = (backstory.Controls[0] as ElementHost).Child as System.Windows.Controls.TextBox;
            alliesBox            = (allies.Controls[0] as ElementHost).Child as System.Windows.Controls.TextBox;
            notesBox             = (notes.Controls[0] as ElementHost).Child as System.Windows.Controls.TextBox;


            Form1 form1 = this.Owner as Form1;

            if (form1.portrait != null)
            {
                portraitBytes     = ((Form1)this.Owner).portrait;
                portrait.Image    = (Bitmap)((new ImageConverter()).ConvertFrom(portraitBytes));
                portrait.SizeMode = PictureBoxSizeMode.StretchImage;
            }
            profBox.Text = form1.charInfo[0];
            personalityTraitsBox.Text = form1.charInfo[1];
            idealsBox.Text            = form1.charInfo[2];
            bondsBox.Text             = form1.charInfo[3];
            flawsBox.Text             = form1.charInfo[4];
            backstoryBox.Text         = form1.charInfo[5];
            alliesBox.Text            = form1.charInfo[6];
            notesBox.Text             = form1.charInfo[7];
            profBox.Select(prof.Text.Length, 0);
        }
Exemplo n.º 2
0
        //後ろから前に向けての検索
        private void SearchBackward(object o)
        {
            System.Windows.Controls.TextBox textDetail = (System.Windows.Controls.TextBox)o;

            if (string.IsNullOrEmpty(textDetail.Text))
            {
                return;
            }

            //フォーカス設定
            textDetail.Focus();

            //検索開始位置の設定
            int searchStartIndex = (textDetail.SelectionStart + SearchText2.Length - 1) - 1;

            if (searchStartIndex < 0)
            {
                return;                       //先頭の場合は処理を抜けます
            }
            //検索開始位置が末尾以降になる場合は、検索開始位置を末尾にします
            if (searchStartIndex > textDetail.Text.Length)
            {
                searchStartIndex = textDetail.Text.Length;
            }

            //検索
            int index = textDetail.Text.LastIndexOf(SearchText2, searchStartIndex, StringComparison.OrdinalIgnoreCase);

            if (index >= 0)
            {
                //見つかった場合
                textDetail.Select(index, SearchText2.Length);
            }
        }
Exemplo n.º 3
0
 // update value and remove letters
 private void textBox_TextChanged(object sender, EventArgs e)
 {
     if (int.TryParse(box.Text, out int o))
     {
         Value    = o;
         prevText = box.Text;
     }
     else
     {
         if (box.Text == "" || box.Text == "-")
         {
             prevText = box.Text;
         }
         else
         {
             box.Text = prevText;
             box.Select(box.Text.Length, 0);
         }
     }
 }
Exemplo n.º 4
0
        /*
         * 検索設定はここを参照
         * https://9cubed.info/article/nine_cubed_memo/20180524/
         */

        //前から後ろに向けての検索
        private void SearchForward(object o)
        {
            System.Windows.Controls.TextBox textDetail = (System.Windows.Controls.TextBox)o;

            if (string.IsNullOrEmpty(textDetail.Text))
            {
                return;
            }

            //フォーカス設定
            textDetail.Focus();

            //検索する
            //選択文字列が検索文字列と同じ場合は、次の文字列から検索します
            int offset = textDetail.SelectedText.Equals(SearchText2, StringComparison.OrdinalIgnoreCase) ? 1 : 0;
            int index  = textDetail.Text.IndexOf(SearchText2, textDetail.SelectionStart + offset, StringComparison.OrdinalIgnoreCase);

            if (index >= 0)
            {
                //見つかった場合
                textDetail.Select(index, SearchText2.Length);
            }
        }
Exemplo n.º 5
0
 public void Select(int start, int length)
 {
     _te.Select(start, length);
 }
Exemplo n.º 6
0
            /**
             * Constructor
             */
            public EditBox()
            {
                mEditBox = new System.Windows.Controls.TextBox();
                mPasswordBox = new System.Windows.Controls.PasswordBox();
                // by default, the password box is not visible
                mPasswordBox.Visibility = Visibility.Collapsed;

                CreateTheEditBoxGrid();

                View = mEditBoxGrid;

                mIsPasswordMode = false;
                mIsWatermarkMode = false;
                mPlaceholderText = "";

                // by default, the placeholder font color is gray
                mWaterMarkBrush = new SolidColorBrush();
                mWaterMarkBrush.Color = Colors.Gray;

                mForegroundColor = mEditBox.Foreground;

                /**
                 * @brief Sent from the Edit box when it gains focus(the user selects the widget).
                 * The virtual keyboard is shown.
                 *        MAW_EVENT_EDIT_BOX_EDITING_DID_BEGIN
                 */
                mEditBox.GotFocus += new RoutedEventHandler(
                    delegate(object from, RoutedEventArgs args)
                    {
                        /**
                          * simulating the placeholder/watermark
                          */
                        // if watermark present and no user char has been entered
                        if (mIsWatermarkMode && mFirstChar)
                        {
                            // move the cursor to the first position
                            mEditBox.Select(0, 0);
                            SetWatermarkMode(false);
                        }

                        /**
                         * post the event to MoSync runtime
                         */
                        Memory eventData = new Memory(8);
                        const int MAWidgetEventData_eventType = 0;
                        const int MAWidgetEventData_widgetHandle = 4;
                        eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_EDIT_BOX_EDITING_DID_BEGIN);
                        eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle);
                        mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData);
                    }
                ); // end of mEditBox.GotFocus

                /**
                  * @brief Sent from the Edit box when it loses focus.
                  * The virtual keyboard is hidden.
                  *        MAW_EVENT_EDIT_BOX_EDITING_DID_END
                  */
                mEditBox.LostFocus += new RoutedEventHandler(
                    delegate(object from, RoutedEventArgs args)
                    {
                        /**
                         * simulating the placeholder/watermark
                         */
                        // if no text has been entered by the user than leave the watermark text
                        if (mEditBox.Text.Equals(""))
                        {
                            SetWatermarkMode(true);
                        }

                        /**
                         * post the event to MoSync runtime
                         */
                        Memory eventData = new Memory(8);
                        const int MAWidgetEventData_eventType = 0;
                        const int MAWidgetEventData_widgetHandle = 4;
                        eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_EDIT_BOX_EDITING_DID_END);
                        eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle);
                        mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData);
                    }
                ); // end of mEditBox.LostFocus

                /**
                  * @brief Sent from the Edit box when the text was changed.
                  *        MAW_EVENT_EDIT_BOX_TEXT_CHANGED
                  */
                mFirstChar = true;
                mEditBox.TextInputStart += new TextCompositionEventHandler(
                    delegate(object from, TextCompositionEventArgs args)
                    {
                        /**
                          * simulating the placeholder/watermark
                          */
                        if (mFirstChar)
                        {
                            SetWatermarkMode(false);
                        }

                        /**
                         * post the event to MoSync runtime
                         */
                        Memory eventData = new Memory(8);
                        const int MAWidgetEventData_eventType = 0;
                        const int MAWidgetEventData_widgetHandle = 4;
                        eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_EDIT_BOX_TEXT_CHANGED);
                        eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle);
                        mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData);
                    }
                ); // end of TextInputStart

                /**
                 * @brief Sent from the Password box when it gains focus(the user selects the widget).
                 * The virtual keyboard is shown.
                 *        MAW_EVENT_EDIT_BOX_EDITING_DID_BEGIN
                 */
                mPasswordBox.GotFocus += new RoutedEventHandler(
                    delegate(object from, RoutedEventArgs args)
                    {
                        /**
                         * post the event to MoSync runtime
                         */
                        Memory eventData = new Memory(8);
                        const int MAWidgetEventData_eventType = 0;
                        const int MAWidgetEventData_widgetHandle = 4;
                        eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_EDIT_BOX_EDITING_DID_BEGIN);
                        eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle);
                        mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData);
                    }
                ); // end of mPasswordBox.GotFocus

                /**
                  * @brief Sent from the Password box when it loses focus.
                  * The virtual keyboard is hidden.
                  *        MAW_EVENT_EDIT_BOX_EDITING_DID_END
                  */
                mPasswordBox.LostFocus += new RoutedEventHandler(
                    delegate(object from, RoutedEventArgs args)
                    {
                        /**
                         * post the event to MoSync runtime
                         */
                        Memory eventData = new Memory(8);
                        const int MAWidgetEventData_eventType = 0;
                        const int MAWidgetEventData_widgetHandle = 4;
                        eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_EDIT_BOX_EDITING_DID_END);
                        eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle);
                        mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData);
                    }
                ); // end of mPasswordBox.LostFocus

                /**
                  * @brief Sent from the Password box when the text was changed.
                  *        MAW_EVENT_EDIT_BOX_TEXT_CHANGED
                  */
                mPasswordBox.TextInputStart += new TextCompositionEventHandler(
                    delegate(object from, TextCompositionEventArgs args)
                    {
                        /**
                         * post the event to MoSync runtime
                         */
                        Memory eventData = new Memory(8);
                        const int MAWidgetEventData_eventType = 0;
                        const int MAWidgetEventData_widgetHandle = 4;
                        eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_EDIT_BOX_TEXT_CHANGED);
                        eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle);
                        mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData);
                    }
                ); // end of mPasswordBox.TextInputStart

                /**
                 * @brief Sent from the Edit box when the return button was pressed.
                 * On iphone platform the virtual keyboard is not closed after receiving this event.
                 * EDIT_BOX_RETURN
                 */
                // Not available on Windows Phone 7.1
            }
Exemplo n.º 7
0
            /**
             * Constructor
             */
            public SearchBar()
            {
                mSearchBar = new System.Windows.Controls.TextBox();

                mView = mSearchBar;

                mIsWatermarkMode = false;
                mPlaceholderText = "";

                // by default, the placeholder font color is gray
                mWaterMarkBrush = new SolidColorBrush();
                mWaterMarkBrush.Color = Colors.Gray;

                mForegroundColor = mSearchBar.Foreground;

                /**
                 * @brief Sent from the Search bar when it gains focus(the user selects the widget).
                 * The virtual keyboard is shown.
                 */
                mSearchBar.GotFocus += new RoutedEventHandler(
                    delegate(object from, RoutedEventArgs args)
                    {
                        /**
                          * simulating the placeholder/watermark
                          */

                        // if watermark present and no user char has been entered
                        if (mIsWatermarkMode && mFirstChar)
                        {
                            // move the cursor to the first position
                            mSearchBar.Select(0, 0);
                        }
                    }
                ); // end of mEditBox.GotFocus

                /**
                 * @brief Sent from the Search bar when it loses focus.
                 * The virtual keyboard is hidden.
                 */
                mSearchBar.LostFocus += new RoutedEventHandler(
                    delegate(object from, RoutedEventArgs args)
                    {
                        /**
                         * simulating the placeholder/watermark
                         */

                        // if no text has been entered by the user than leave the watermark text
                        if (mSearchBar.Text.Equals(""))
                        {
                            setWatermarkMode(true);
                        }
                    }
                ); // end of mEditBox.LostFocus

                /**
                  * @brief Sent from the Search bar when the text was changed.
                  * As the search bar allows searching while the user types, this is
                  * the place where we send the search event (the MAW_EVENT_CLICKED with
                  * the search button click 0 (0 = OK, 1 = CANCEL).
                  * The cancel search is not handled on the windows phone platform.
                  */
                mFirstChar = true;
                mSearchBar.TextInputStart += new TextCompositionEventHandler(
                    delegate(object from, TextCompositionEventArgs args)
                    {
                        /**
                          * simulating the placeholder/watermark
                          */
                        if (mFirstChar)
                        {
                            setWatermarkMode(false);
                        }

                        /**
                         * post the event to MoSync runtime
                         * MAW_EVENT_CLICKED + search button clicked = 0 (0 = OK, 1 = CANCEL)
                         */
                        Memory eventData = new Memory(12);
                        const int MAWidgetEventData_eventType = 0;
                        const int MAWidgetEventData_widgetHandle = 4;
                        const int MAWidgetEventData_searchButtonClicked = 8;
                        eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_CLICKED);
                        eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle);
                        eventData.WriteInt32(MAWidgetEventData_searchButtonClicked, 0);
                        mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData);
                    }
                ); // end of TextInputStart
            }
Exemplo n.º 8
0
 void SetCursorLast()
 {
     textBox.Select(textBox.Text.Length, 0);
 }