private void SaveSelection()
        {
            string strSelectionData = string.Format("{{ \"selectedIndex\": \"{0}\", \"selectedValue\": \"{1}\", \"selectedText\": \"{2}\", \"selectedValues\": \"{3}\" }}",
                                                    SelectedIndex,
                                                    SelectedValue.Replace("\"", "\\\""),
                                                    SelectedText.Replace("\"", "\\\""),
                                                    ToString(GetSelectedValues(), ":"));

            hidSelectedData.Value = strSelectionData;
        }
Esempio n. 2
0
 void CopyCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     try
     {
         string text = SelectedText.Replace(" ", "");
         Clipboard.SetText(text);
     }
     catch
     {
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Loads top level entry list
        /// </summary>
        /// <history>
        ///     [tamttt] 20/10/2004	Created
        /// </history>
        private void BindListInfo()
        {
            string listName = SelectedText.Substring(SelectedText.IndexOf(":") + 1);
            string parent   = SelectedText.Replace(listName, "").TrimEnd(':');

            this.lblListParent.Text = parent;
            this.lblListName.Text   = listName;

            this.rowListParent.Visible = (selListInfo.Parent.Length > 0); //(parent.Length > 0)
            if (!SystemList)
            {
                this.cmdDeleteList.Visible = true;
                ClientAPI.AddButtonConfirm(cmdDeleteList, Localization.GetString("DeleteItem"));
            }
            else
            {
                this.cmdDeleteList.Visible = false;
            }
        }
Esempio n. 4
0
        //--------------------------------------------------------------------------------------------------

        protected override void OnTextChanged(TextChangedEventArgs e)
        {
            using (DeclareChangeBlock())
            {
                foreach (var c in e.Changes)
                {
                    if (c.AddedLength == 0)
                    {
                        continue;
                    }
                    Select(c.Offset, c.AddedLength);
                    if (SelectedText.Contains(","))
                    {
                        SelectedText = SelectedText.Replace(',', '.');
                    }
                    Select(c.Offset + c.AddedLength, 0);
                }
            }

            var text = Text;

            if (text.Length == 0)
            {
                Text = "0";
            }
            else
            {
                if (text[0] == '.')
                {
                    Text.Insert(0, "0");
                }
            }

            EvaluateExpression();

            base.OnTextChanged(e);
        }
Esempio n. 5
0
        protected override void OnPreviewKeyDown(System.Windows.Input.KeyEventArgs e)
        {
            // hide intellisense list
            //if (e.Key == System.Windows.Input.Key.Escape)
            //{
            //    //HideSuggestionList();
            //    e.Handled = true;
            //}

            //// show intellisense list
            //if (e.Key == Key.Space && e.KeyboardDevice.Modifiers == ModifierKeys.Control)
            //{
            //    ShowSuggestionList();
            //    e.Handled = true;
            //}

            // shift + tab
            if (e.Key == System.Windows.Input.Key.Tab && e.KeyboardDevice.Modifiers == System.Windows.Input.ModifierKeys.Shift)
            {
                // with selected text
                if (this.SelectedText != String.Empty)
                {
                    string[] lines = this.SelectedText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < lines.Length; i++)
                    {
                        if (lines[i].StartsWith(this.Tab))
                        {
                            lines[i] = lines[i].Substring(this.Tab.Length);
                        }
                        else
                        {
                            lines[i] = lines[i].TrimStart(' ');
                        }
                    }
                    this.SelectedText = String.Join(Environment.NewLine, lines);
                }
                else
                {
                    // current line
                    int index     = this.CaretIndex;
                    int last_line = this.Text.LastIndexOf(Environment.NewLine, index);

                    if (last_line == -1)
                    {
                        last_line = this.Text.Length - 1;
                    }

                    int start_line = this.Text.IndexOf(Environment.NewLine, last_line);

                    if (start_line != -1)
                    {
                        start_line += Environment.NewLine.Length;
                    }
                    else
                    {
                        start_line = 0;
                    }

                    // find empty spaces
                    int spaces = 0;
                    for (int i = start_line; i < this.Text.Length - 1; i++)
                    {
                        if (this.Text[i] == ' ')
                        {
                            spaces++;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (spaces > TabSize)
                    {
                        spaces = TabSize;
                    }

                    this.Text = this.Text.Remove(start_line, spaces);

                    // set position of caret
                    if (index >= start_line + spaces)
                    {
                        this.CaretIndex = index - spaces;
                    }
                    else if (index >= start_line && index < start_line + spaces)
                    {
                        this.CaretIndex = start_line;
                    }
                    else
                    {
                        this.CaretIndex = index;
                    }
                }

                e.Handled = true;
            }

            // tab
            if (e.Key == System.Windows.Input.Key.Tab && e.KeyboardDevice.Modifiers == System.Windows.Input.ModifierKeys.None)
            {
                if (this.SelectedText == String.Empty)
                {
                    int caretPosition = base.CaretIndex;
                    base.Text       = base.Text.Insert(caretPosition, this.Tab);
                    base.CaretIndex = caretPosition + TabSize;
                }
                else
                {
                    if (!this.SelectedText.Contains(Environment.NewLine))
                    {
                        this.SelectedText = this.Tab;
                    }
                    else
                    {
                        this.SelectedText = this.Tab + SelectedText.Replace(Environment.NewLine, Environment.NewLine + this.Tab);
                    }
                }
                e.Handled = true;
            }

            // enter respects indenting
            if (e.Key == System.Windows.Input.Key.Return)
            {
                int index     = this.CaretIndex;
                int last_line = this.Text.LastIndexOf(Environment.NewLine, index);
                int spaces    = 0;

                if (last_line != -1)
                {
                    string line = this.Text.Substring(last_line, this.Text.Length - last_line);

                    int start_line = line.IndexOf(Environment.NewLine);

                    if (start_line != -1)
                    {
                        line = line.Substring(start_line).TrimStart('\r', '\n');
                    }

                    foreach (char c in line)
                    {
                        if (c == ' ')
                        {
                            spaces++;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                this.Text       = this.Text.Insert(index, Environment.NewLine + new String(' ', spaces));
                this.CaretIndex = index + Environment.NewLine.Length + spaces;

                e.Handled = true;
            }

            base.OnPreviewKeyDown(e);
        }
Esempio n. 6
0
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            if (_suggestionList.IsVisible && e.Key.In(Key.Tab, Key.Enter, Key.Return))
            {
                var selectedItem = (Suggestion)_suggestionList.SelectedItem;
                if (selectedItem != null)
                {
                    var selectedText = selectedItem.Completion;
                    var index        = CaretIndex;
                    Text       = Text.Insert(CaretIndex, selectedText);
                    CaretIndex = index + selectedText.Length;
                }
                HideSuggestionList();
                e.Handled = true;
                return;
            }

            if (e.Key == Key.Escape)
            {
                HideSuggestionList();
                e.Handled = true;
            }

            if (ShouldShowSuggestionList(e))
            {
                SyntaxParser.FindSuggestions(Text, SelectionStart);
                ShowSuggestionList();
                e.Handled = true;
            }

            if (e.Key == Key.Tab && e.KeyboardDevice.Modifiers == ModifierKeys.Shift)
            {
                // with selected text
                if (SelectedText != string.Empty)
                {
                    string[] lines = SelectedText.SplitLines();
                    for (int ii = 0; ii < lines.Length; ii++)
                    {
                        if (lines[ii].StartsWith(Tab))
                        {
                            lines[ii] = lines[ii].Substring(Tab.Length);
                        }
                        else
                        {
                            lines[ii] = lines[ii].TrimStart(' ');
                        }
                    }
                    SelectedText = String.Join(Environment.NewLine, lines);
                }
                else
                {
                    var index    = CaretIndex;
                    var lastLine = Text.LastIndexOf(Environment.NewLine, index, StringComparison.Ordinal);

                    if (lastLine == -1)
                    {
                        lastLine = Text.Length - 1;
                    }

                    var startLine = Text.IndexOf(Environment.NewLine, lastLine, StringComparison.Ordinal);

                    if (startLine != -1)
                    {
                        startLine += Environment.NewLine.Length;
                    }
                    else
                    {
                        startLine = 0;
                    }

                    // find empty spaces
                    var spaces = 0;
                    for (var i = startLine; i < Text.Length - 1; i++)
                    {
                        if (Text[i] == ' ')
                        {
                            spaces++;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (spaces > TabSize)
                    {
                        spaces = TabSize;
                    }


                    Text = Text.Remove(startLine, spaces);

                    // set position of caret
                    if (index >= startLine + spaces)
                    {
                        CaretIndex = index - spaces;
                    }

                    else if (index >= startLine && index < startLine + spaces)
                    {
                        CaretIndex = startLine;
                    }
                    else
                    {
                        CaretIndex = index;
                    }
                }

                e.Handled = true;
            }

            // tab
            if (e.Key == Key.Tab && e.KeyboardDevice.Modifiers == ModifierKeys.None)
            {
                if (SelectedText == string.Empty)
                {
                    var caretPosition = CaretIndex;
                    Text       = Text.Insert(caretPosition, Tab);
                    CaretIndex = caretPosition + TabSize;
                }
                else
                {
                    if (!SelectedText.Contains(Environment.NewLine))
                    {
                        SelectedText = Tab;
                    }
                    else
                    {
                        SelectedText = Tab + SelectedText.Replace(Environment.NewLine, Environment.NewLine + Tab);
                    }
                }
                e.Handled = true;
            }

            // enter respects indenting
            if (e.Key == Key.Return)
            {
                var index    = CaretIndex;
                var lastLine = Text.LastIndexOf(Environment.NewLine, index, StringComparison.Ordinal);
                var spaces   = 0;

                if (lastLine != -1)
                {
                    var line      = Text.Substring(lastLine, Text.Length - lastLine);
                    var startLine = line.IndexOf(Environment.NewLine, StringComparison.Ordinal);
                    if (startLine != -1)
                    {
                        line = line.Substring(startLine).TrimStart('\r', '\n');
                    }

                    foreach (var c in line)
                    {
                        if (c == ' ')
                        {
                            spaces++;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                Text       = Text.Insert(index, Environment.NewLine + new String(' ', spaces));
                CaretIndex = index + Environment.NewLine.Length + spaces;

                e.Handled = true;
            }

            base.OnPreviewKeyDown(e);
        }