Skip to content

Commit

Permalink
Merge pull request #19 from skadefro/master
Browse files Browse the repository at this point in the history
Implement simple intellisense
  • Loading branch information
skadefro authored May 21, 2019
2 parents bae8b62 + 5033377 commit 82c43e6
Show file tree
Hide file tree
Showing 24 changed files with 1,507 additions and 4 deletions.
27 changes: 27 additions & 0 deletions OpenRPA.ExpressionEditor/AutoCompletionPopup.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<ToolTip x:Class="OpenRPA.ExpressionEditor.AutoCompletionPopup"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OpenRPA.ExpressionEditor"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid Name="MainGrid" Width="300" Height="200" >
<ListBox Name="AutoCompletionListBox" IsTextSearchEnabled="True"
ItemsSource="{Binding Path=.}" VirtualizingStackPanel.IsVirtualizing="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<EventSetter Event="MouseDoubleClick" Handler="OnListBoxItemDoubleClick" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Width="Auto" Text="{Binding Path=Name}"
ToolTip="{Binding Path=Description}" Margin="2" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</ToolTip>
65 changes: 65 additions & 0 deletions OpenRPA.ExpressionEditor/AutoCompletionPopup.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace OpenRPA.ExpressionEditor
{
/// <summary>
/// Interaction logic for AutoCompletionPopup.xaml
/// </summary>
public partial class AutoCompletionPopup : ToolTip
{
public AutoCompletionPopup()
{
InitializeComponent();
}

/// <summary>Occurs when an item in the auto-completion list is double clicked.</summary>
public event MouseButtonEventHandler ListBoxItemDoubleClick;

/// <summary>Gets or sets the selected item in the auto-completion list</summary>
public ExpressionNode SelectedItem
{
get { return (ExpressionNode)this.AutoCompletionListBox.SelectedItem; }
set { this.AutoCompletionListBox.SelectedItem = value; }
}

/// <summary>Gets or sets the index of the selected item in the auto-completion list.</summary>
public int SelectedIndex
{
get { return this.AutoCompletionListBox.SelectedIndex; }
set
{
// Protect against the index under- or over-ranging.
if (value < -1 || value > this.AutoCompletionListBox.Items.Count - 1) return;

this.AutoCompletionListBox.SelectedIndex = value;
this.AutoCompletionListBox.ScrollIntoView(this.AutoCompletionListBox.SelectedItem);
}
}

/// <summary>Gets the number of items in the auto-completion list.</summary>
public int Count
{
get { return this.AutoCompletionListBox.Items.Count; }
}
/// <summary>Occurs when an item in the auto-completion list is double-clicked.</summary>
/// <param name="sender">The object from which the event initiated.</param>
/// <param name="e">The object that contains the event data.</param>
protected void OnListBoxItemDoubleClick(object sender, MouseButtonEventArgs e)
{
if (this.ListBoxItemDoubleClick != null) this.ListBoxItemDoubleClick.Invoke(sender, e);
}
}
}
Loading

0 comments on commit 82c43e6

Please sign in to comment.