Beispiel #1
0
        private void DeleteVariableButton_Click(object sender, RoutedEventArgs e)
        {
            Button       button = (Button)sender;
            VariablePair pair   = (VariablePair)button.DataContext;

            this.variablePairs.Remove(pair);
        }
Beispiel #2
0
        private async void VariableNameTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
        {
            HideVariableNameIntellisense();
            if (shouldShowIntellisense)
            {
                TextBox variableNameTextBox = sender as TextBox;
                if (ChannelSession.Services.OvrStreamWebsocket != null && !string.IsNullOrEmpty(variableNameTextBox.Text))
                {
                    var title = (await ChannelSession.Services.OvrStreamWebsocket.GetTitles())
                                .SingleOrDefault(t => t.Name.Equals(this.TitleNameTextBox.Text, StringComparison.InvariantCultureIgnoreCase));

                    if (title != null)
                    {
                        var variables = title.Variables
                                        .OrderBy(v => v.Name)
                                        .Where(v => v.Name.IndexOf(variableNameTextBox.Text, StringComparison.InvariantCultureIgnoreCase) >= 0)
                                        .Take(5)
                                        .ToList();

                        if (variables.Count > 0)
                        {
                            VariableNameIntellisenseListBox.ItemsSource = variables;
                            this.activeVariablePair        = variableNameTextBox.DataContext as VariablePair;
                            this.activeVariableNameTextBox = variableNameTextBox;

                            // Select the first variable
                            VariableNameIntellisenseListBox.SelectedIndex = 0;

                            Rect positionOfCarat = variableNameTextBox.GetRectFromCharacterIndex(variableNameTextBox.CaretIndex, true);
                            if (!positionOfCarat.IsEmpty)
                            {
                                Point topLeftOffset = variableNameTextBox.TransformToAncestor(MainGrid).Transform(new Point(positionOfCarat.Left, positionOfCarat.Top));
                                ShowVariableNameIntellisense(topLeftOffset.X, topLeftOffset.Y);
                            }
                        }
                    }
                }
            }
        }