상속: LayoutFarm.UI.UIBox
        void UpdateSuggestionList()
        {
            //find suggestion words
            listView.ClearItems();
            if (textbox.CurrentTextSpan == null)
            {
                listView.Visible = false;
                return;
            }
            //-------------------------------------------------------------------------
            //In this example  all country name start with Captial letter so ...
            string        currentTextSpanText = textbox.CurrentTextSpan.GetText().ToUpper();
            char          firstChar           = currentTextSpanText[0];
            List <string> keywords;

            if (words.TryGetValue(firstChar, out keywords))
            {
                int j             = keywords.Count;
                int listViewWidth = listView.Width;
                for (int i = 0; i < j; ++i)
                {
                    string choice = keywords[i].ToUpper();
                    if (choice.StartsWith(currentTextSpanText))
                    {
                        CustomWidgets.ListItem item = new CustomWidgets.ListItem(listViewWidth, 17);
                        item.BackColor = Color.LightGray;
                        item.Tag       = item.Text = keywords[i];
                        listView.AddItem(item);
                    }
                }
            }

            //-------------------------------------------------------------------------
        }
예제 #2
0
        void UpdateSuggestionList()
        {
            //find suggestion words
            _currentLocalText = null;
            _listbox.ClearItems();
            if (_textbox.CurrentTextSpan == null)
            {
                _listbox.Visible = false;
                return;
            }
            //-------------------------------------------------------------------------
            //simple parse ...
            //In this example  all country name start with Captial letter so ...
            string currentTextSpanText = _textbox.CurrentTextSpan.GetText().ToUpper();

            //analyze content
            char[] textBuffer = currentTextSpanText.ToCharArray();
            var    results    = new List <LayoutFarm.Composers.TextSplitBounds>();

            results.AddRange(_textbox.TextSplitter.ParseWordContent(textBuffer, 0, textBuffer.Length));
            //get last part of splited text
            int m = results.Count;

            if (m < 1)
            {
                return;
            }
            Composers.TextSplitBounds lastSplitPart = results[m - 1];
            _currentLocalText = GetString(textBuffer, lastSplitPart);
            //char firstChar = currentTextSpanText[0];
            char          firstChar = _currentLocalText[0];
            List <string> keywords;

            if (_words.TryGetValue(firstChar, out keywords))
            {
                int j             = keywords.Count;
                int listViewWidth = _listbox.Width;
                for (int i = 0; i < j; ++i)
                {
                    string choice = keywords[i].ToUpper();
                    if (choice.StartsWith(_currentLocalText))
                    {
                        CustomWidgets.ListItem item = new CustomWidgets.ListItem(listViewWidth, 17);
                        item.BackColor = KnownColors.LightGray;
                        item.Tag       = item.Text = keywords[i];
                        _listbox.AddItem(item);
                    }
                }
            }
            if (_listbox.ItemCount > 0)
            {
                _listbox.Visible = true;
            }
            else
            {
                _listbox.Visible = false;
            }

            //-------------------------------------------------------------------------
        }
 static LayoutFarm.CustomWidgets.ListView CreateSampleListView()
 {
     var listview = new LayoutFarm.CustomWidgets.ListView(300, 400);
     listview.SetLocation(10, 10);
     listview.BackColor = KnownColors.FromKnownColor(KnownColor.LightGray);
     //add 
     for (int i = 0; i < 10; ++i)
     {
         var listItem = new LayoutFarm.CustomWidgets.ListItem(400, 20);
         if ((i % 2) == 0)
         {
             listItem.BackColor = KnownColors.FromKnownColor(KnownColor.OrangeRed);
         }
         else
         {
             listItem.BackColor = KnownColors.FromKnownColor(KnownColor.Orange);
         }
         listview.AddItem(listItem);
     }
     return listview;
 }
        static LayoutFarm.CustomWidgets.ListView CreateSampleListView()
        {
            var listview = new LayoutFarm.CustomWidgets.ListView(300, 400);

            listview.SetLocation(10, 10);
            listview.BackColor = KnownColors.FromKnownColor(KnownColor.LightGray);
            //add
            for (int i = 0; i < 10; ++i)
            {
                var listItem = new LayoutFarm.CustomWidgets.ListItem(400, 20);
                if ((i % 2) == 0)
                {
                    listItem.BackColor = KnownColors.FromKnownColor(KnownColor.OrangeRed);
                }
                else
                {
                    listItem.BackColor = KnownColors.FromKnownColor(KnownColor.Orange);
                }
                listview.AddItem(listItem);
            }
            return(listview);
        }
        void UpdateSuggestionList()
        {
            //find suggestion words
            this.currentLocalText = null;
            listView.ClearItems();
            Text.EditableRun currentSpan = textbox.CurrentTextSpan;
            if (currentSpan == null)
            {
                listView.Visible = false;
                return;
            }
            //-------------------------------------------------------------------------
            //sample parse ...
            //In this example  all country name start with Captial letter so ...

            //try to get underlining text

            //int startAt, len;
            //textbox.FindCurrentUnderlyingWord(out startAt, out len);

            string currentTextSpanText = currentSpan.GetText().ToUpper();

            //analyze content
            char[] textBuffer = currentTextSpanText.ToCharArray();
            _textSplitBoundsList.Clear();
            _textSplitBoundsList.AddRange(textbox.TextSplitter.ParseWordContent(textBuffer, 0, textBuffer.Length));

            //get last part of splited text
            int m = _textSplitBoundsList.Count;

            if (m < 1)
            {
                return;
            }

            int splitBoundIndex = GetProperSplitBoundIndex(_textSplitBoundsList, textbox.CurrentLineCharIndex);

            if (splitBoundIndex < 0)
            {
                return;
            }

            //find current split bounds
            Composers.TextSplitBound selectBounds = _textSplitBoundsList[splitBoundIndex];
            this.currentLocalText = GetString(textBuffer, selectBounds);


            char          firstChar = currentLocalText[0];
            List <string> keywords;

            if (words.TryGetValue(firstChar, out keywords))
            {
                int j             = keywords.Count;
                int listViewWidth = listView.Width;
                for (int i = 0; i < j; ++i)
                {
                    string choice = keywords[i].ToUpper();
                    if (StringStartsWithChars(choice, currentLocalText))
                    {
                        CustomWidgets.ListItem item = new CustomWidgets.ListItem(listViewWidth, 17);
                        item.BackColor = Color.LightGray;
                        item.Tag       = item.Text = keywords[i];
                        listView.AddItem(item);
                    }
                }
            }
            if (listView.ItemCount > 0)
            {
                listView.Visible = true;
                //TODO: implement selectedIndex suggestion hint here ***
                listView.SelectedIndex = 0;
                //move listview under caret position
                var caretPos = textbox.CaretPosition;
                //temp fixed
                //TODO: review here
                listView.SetLocation(textbox.Left + caretPos.X, textbox.Top + caretPos.Y + 20);
                listView.EnsureSelectedItemVisible();
            }
            else
            {
                listView.Visible = false;
            }

            //-------------------------------------------------------------------------
        }
예제 #6
0
        void UpdateSuggestionList()
        {
            //find suggestion words
            _currentLocalText = null;
            _sgBox.ClearItems();
            if (_textbox.CurrentTextSpan == null)
            {
                _sgBox.Hide();
                return;
            }
            //-------------------------------------------------------------------------
            //sample parse ...
            //In this example  all country name start with Captial letter so ...
            string currentTextSpanText = _textbox.CurrentTextSpan.GetText().ToUpper();
            //analyze content
            var textBuffer = currentTextSpanText.ToCharArray();
            var results    = new List <LayoutFarm.Composers.TextSplitBounds>();

            results.AddRange(_textbox.TextSplitter.ParseWordContent(textBuffer, 0, textBuffer.Length));
            //get last part of splited text
            int m = results.Count;

            if (m < 1)
            {
                return;
            }
            Composers.TextSplitBounds lastSplitPart = results[m - 1];
            _currentLocalText = GetString(textBuffer, lastSplitPart);
            //char firstChar = currentTextSpanText[0];
            char firstChar = _currentLocalText[0];

            if (_words.TryGetValue(firstChar, out List <string> keywords))
            {
                int j             = keywords.Count;
                int listViewWidth = _sgBox.Width;
                for (int i = 0; i < j; ++i)
                {
                    string choice = keywords[i].ToUpper();
                    if (StringStartsWithChars(choice, _currentLocalText))
                    {
                        CustomWidgets.ListItem item = new CustomWidgets.ListItem(listViewWidth, 17);
                        item.BackColor = KnownColors.LightGray;
                        item.Tag       = item.Text = keywords[i];
                        _sgBox.AddItem(item);
                    }
                }
            }
            if (_sgBox.ItemCount > 0)
            {
                //TODO: implement selectedIndex suggestion hint here
                _sgBox.SelectedIndex = 0;

                //move listview under caret position
                Point caretPos = _textbox.CaretPosition;
                //temp fixed
                //TODO: review here
                if (!_alreadyHasTextBoxGlobalOffset)
                {
                    _textBoxGlobalOffset           = _textbox.GetGlobalLocation();
                    _alreadyHasTextBoxGlobalOffset = true;
                }

                _sgBox.SetLocation(_textBoxGlobalOffset.X + caretPos.X, caretPos.Y + 70);
                _sgBox.Show();
                _sgBox.EnsureSelectedItemVisible();
            }
            else
            {
                _sgBox.Hide();
            }
        }
 public void AddItem(CustomWidgets.ListItem item)
 {
     this.listView.AddItem(item);
 }
        void UpdateSuggestionList()
        {
            //find suggestion words
            this.currentLocalText = null;
            listView.ClearItems();
            if (textbox.CurrentTextSpan == null)
            {
                listView.Visible = false;
                return;
            }
            //-------------------------------------------------------------------------
            //sample parse ...
            //In this example  all country name start with Captial letter so ...
            string currentTextSpanText = textbox.CurrentTextSpan.Text.ToUpper();

            //analyze content
            var textBuffer = currentTextSpanText.ToCharArray();
            var results    = new List <LayoutFarm.Composers.TextSplitBound>();

            results.AddRange(textbox.TextSplitter.ParseWordContent(textBuffer, 0, textBuffer.Length));
            //get last part of splited text
            int m = results.Count;

            if (m < 1)
            {
                return;
            }
            Composers.TextSplitBound lastSplitPart = results[m - 1];
            this.currentLocalText = GetString(textBuffer, lastSplitPart);

            //char firstChar = currentTextSpanText[0];
            char firstChar = currentLocalText[0];

            List <string> keywords;

            if (words.TryGetValue(firstChar, out keywords))
            {
                int j             = keywords.Count;
                int listViewWidth = listView.Width;
                for (int i = 0; i < j; ++i)
                {
                    string choice = keywords[i].ToUpper();
                    if (choice.StartsWith(currentLocalText))
                    {
                        CustomWidgets.ListItem item = new CustomWidgets.ListItem(listViewWidth, 17);
                        item.BackColor = Color.LightGray;
                        item.Tag       = item.Text = keywords[i];

                        listView.AddItem(item);
                    }
                }
            }
            if (listView.ItemCount > 0)
            {
                listView.Visible = true;
                //TODO: implement selectedIndex suggestion hint here ***
                listView.SelectedIndex = 0;

                //move listview under caret position
                var caretPos = textbox.CaretPosition;
                //temp fixed
                //TODO: review here
                listView.SetLocation(textbox.Left + caretPos.X, textbox.Top + caretPos.Y + 20);
            }
            else
            {
                listView.Visible = false;
            }

            //-------------------------------------------------------------------------
        }
 void UpdateSuggestionList()
 {
     //find suggestion words 
     listView.ClearItems();
     if (textbox.CurrentTextSpan == null)
     {
         listView.Visible = false;
         return;
     }
     //-------------------------------------------------------------------------
     //In this example  all country name start with Captial letter so ...
     string currentTextSpanText = textbox.CurrentTextSpan.Text.ToUpper();
     char firstChar = currentTextSpanText[0];
     List<string> keywords;
     if (words.TryGetValue(firstChar, out keywords))
     {
         int j = keywords.Count;
         int listViewWidth = listView.Width;
         for (int i = 0; i < j; ++i)
         {
             string choice = keywords[i].ToUpper();
             if (choice.StartsWith(currentTextSpanText))
             {
                 CustomWidgets.ListItem item = new CustomWidgets.ListItem(listViewWidth, 17);
                 item.BackColor = Color.LightGray;
                 item.Tag = item.Text = keywords[i];
                 listView.AddItem(item);
             }
         }
     }
     listView.Visible = true;
     //-------------------------------------------------------------------------
 }
        void UpdateSuggestionList()
        {
            //find suggestion words 
            this.currentLocalText = null;
            listView.ClearItems();
            if (textbox.CurrentTextSpan == null)
            {
                listView.Visible = false;
                return;
            }
            //-------------------------------------------------------------------------
            //sample parse ...
            //In this example  all country name start with Captial letter so ...
            string currentTextSpanText = textbox.CurrentTextSpan.Text.ToUpper();
            //analyze content
            var textBuffer = currentTextSpanText.ToCharArray();
            var results = new List<LayoutFarm.Composers.TextSplitBound>();
            results.AddRange(textbox.TextSplitter.ParseWordContent(textBuffer, 0, textBuffer.Length));
            //get last part of splited text
            int m = results.Count;
            if (m < 1)
            {
                return;
            }
            Composers.TextSplitBound lastSplitPart = results[m - 1];
            this.currentLocalText = GetString(textBuffer, lastSplitPart);
            //char firstChar = currentTextSpanText[0];
            char firstChar = currentLocalText[0];
            List<string> keywords;
            if (words.TryGetValue(firstChar, out keywords))
            {
                int j = keywords.Count;
                int listViewWidth = listView.Width;
                for (int i = 0; i < j; ++i)
                {
                    string choice = keywords[i].ToUpper();
                    if (choice.StartsWith(currentLocalText))
                    {
                        CustomWidgets.ListItem item = new CustomWidgets.ListItem(listViewWidth, 17);
                        item.BackColor = Color.LightGray;
                        item.Tag = item.Text = keywords[i];
                        listView.AddItem(item);
                    }
                }
            }
            if (listView.ItemCount > 0)
            {
                listView.Visible = true;
                //TODO: implement selectedIndex suggestion hint here ***
                listView.SelectedIndex = 0;
                //move listview under caret position 
                var caretPos = textbox.CaretPosition;
                //temp fixed
                //TODO: review here
                listView.SetLocation(textbox.Left + caretPos.X, textbox.Top + caretPos.Y + 20);
            }
            else
            {
                listView.Visible = false;
            }

            //-------------------------------------------------------------------------
        }
예제 #11
0
 public void Remove(ListItem item)
 {
     items.Remove(item);
     panel.RemoveChild(item);
 }
예제 #12
0
 //----------------------------------------------------
 public void AddItem(ListItem ui)
 {
     items.Add(ui);
     panel.AddChild(ui);
 }