-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding files for refact extension * testing github workflow * removing default exe to test workflow * uploading artifacts in workflow * readding exe * cleaning up files * C/C++ now works with grey text * fixed minor typo * can now select intellisense options, whitespace causes less problems for grey text completions and the code will only ask for completions when the cursor is at the end of a line * removing binary and updating build scripts * fixing build script typo * fixing minor build naming issue * Updating code to be consistent with new build script * improved the options page * added comments and fixed formatting * updating enter behaviour * fixing minor bugs and functional issues * added code to fix issues around single vs multiline completions issues #9 and #6 * added scroll bars for the options page * adding status bar and killing server process on shutdown * fixing minor bug where grey text was inserted into incorrect places
- Loading branch information
1 parent
a1a5ca2
commit 77c624c
Showing
9 changed files
with
185 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using Microsoft.VisualStudio.Imaging; | ||
using System; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
|
||
namespace RefactAI | ||
{ | ||
internal class StatusBar{ | ||
Panel panel; | ||
StackPanel stack; | ||
Brush whiteBrush; | ||
Brush errorBrush; | ||
Brush transparentBrush; | ||
|
||
public StatusBar(){ | ||
stack = new StackPanel(); | ||
stack.Width = 75.0; | ||
stack.Orientation = Orientation.Horizontal; | ||
panel = VisualTreeUtils.FindChild(Application.Current.MainWindow, childName: "StatusBarPanel") as Panel; | ||
whiteBrush = new SolidColorBrush(Colors.White); | ||
errorBrush = new SolidColorBrush(Colors.Red); | ||
transparentBrush = new SolidColorBrush(Colors.Transparent); | ||
panel.Children.Add(stack); | ||
ShowDefaultStatusBar(); | ||
} | ||
|
||
public void ShowDefaultStatusBar(){ | ||
stack.Children.Clear(); | ||
stack.Background = transparentBrush; | ||
stack.Children.Add(CreateText("|{ Refact")); | ||
} | ||
|
||
public void ShowStatusBarError(string error){ | ||
stack.Children.Clear(); | ||
stack.Background = errorBrush; | ||
stack.Children.Add(CreateImage("debug-disconnect.png")); | ||
stack.Children.Add(CreateText("Refact.ai")); | ||
stack.ToolTip = createToolTip(text: error, stack); | ||
} | ||
|
||
public void ShowLoadingSymbol(){ | ||
stack.Children.Clear(); | ||
stack.Background = transparentBrush; | ||
var img = new CrispImage() { Moniker = KnownMonikers.Sync, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, Width = 16, Height = 16 }; | ||
stack.Children.Add(img); | ||
stack.Children.Add(CreateText("Refact.ai")); | ||
} | ||
|
||
ToolTip createToolTip(String text, UIElement parent){ | ||
ToolTip toolTip = new ToolTip(); | ||
toolTip.Content = text; | ||
toolTip.IsEnabled = true; | ||
toolTip.PlacementTarget = parent; | ||
toolTip.Placement = System.Windows.Controls.Primitives.PlacementMode.Top; | ||
return toolTip; | ||
} | ||
|
||
public TextBlock CreateText(string text){ | ||
TextBlock textBlock = new TextBlock(); | ||
textBlock.Inlines.Add(text); | ||
textBlock.FontSize = 12.0; | ||
textBlock.Foreground = whiteBrush; | ||
textBlock.VerticalAlignment = VerticalAlignment.Center; | ||
return textBlock; | ||
} | ||
|
||
Image CreateImage(string filename){ | ||
Image myImage = new Image(); | ||
myImage.Height = 16; | ||
|
||
BitmapImage myBitmapImage = new BitmapImage(); | ||
|
||
myBitmapImage.BeginInit(); | ||
var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", filename); | ||
|
||
myBitmapImage.UriSource = new Uri(path); | ||
myBitmapImage.DecodePixelWidth = 200; | ||
myBitmapImage.EndInit(); | ||
myImage.Source = myBitmapImage; | ||
return myImage; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//This file is thanks to madskristensen https://github.com/madskristensen/ShowTheShortcut/blob/master/src/StatusbarInjector.cs | ||
|
||
using System.Windows.Media; | ||
using System.Windows; | ||
|
||
namespace RefactAI | ||
{ | ||
internal static class VisualTreeUtils{ | ||
//breadth first search of visual tree for DependencyObject with name childName | ||
public static DependencyObject FindChild(DependencyObject parent, string childName){ | ||
if (parent == null){ | ||
return null; | ||
} | ||
|
||
int childrenCount = VisualTreeHelper.GetChildrenCount(parent); | ||
|
||
for (int i = 0; i < childrenCount; i++){ | ||
DependencyObject child = VisualTreeHelper.GetChild(parent, i); | ||
|
||
if (child is FrameworkElement frameworkElement && frameworkElement.Name == childName) | ||
{ | ||
return frameworkElement; | ||
} | ||
} | ||
|
||
for (int i = 0; i < childrenCount; i++){ | ||
DependencyObject child = VisualTreeHelper.GetChild(parent, i); | ||
|
||
child = FindChild(child, childName); | ||
|
||
if (child != null){ | ||
return child; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |