-
Notifications
You must be signed in to change notification settings - Fork 2
/
ChatGPTWindowControl.xaml
140 lines (124 loc) · 8.87 KB
/
ChatGPTWindowControl.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<UserControl x:Class="ChatGPTExtension.GptToolWindowControl"
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:vsshell="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.15.0"
xmlns:controls="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
Background="{DynamicResource {x:Static vsshell:VsBrushes.WindowKey}}"
Foreground="{DynamicResource {x:Static vsshell:VsBrushes.WindowTextKey}}"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
PreviewKeyDown="UserControl_PreviewKeyDown"
Name="ChatGPTWindowControl">
<Grid>
<!-- Define styles for buttons and checkbox -->
<Grid.Resources>
<!-- Style for the buttons -->
<Style TargetType="Button" x:Key="CustomButtonStyle">
<Setter Property="Background" Value="#343541"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Height" Value="30"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#40414F"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- ToggleSwitch Style for CheckBox -->
<Style TargetType="CheckBox" x:Key="CustomCheckBoxStyle">
<Setter Property="Margin" Value="0,2,0,2"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Toggle switch part -->
<Border Grid.Column="0" Background="#343541" BorderBrush="#343541" BorderThickness="1" CornerRadius="8" Height="18" Width="36" VerticalAlignment="Center">
<Grid>
<Rectangle x:Name="BackgroundRect" Fill="#343541" RadiusX="8" RadiusY="8" />
<Ellipse x:Name="SwitchCircle" Fill="White" Width="16" Height="16" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="1"/>
</Grid>
</Border>
<!-- Text part -->
<TextBlock Grid.Column="1" Text="Enable Copy Code" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="White"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="BackgroundRect" Property="Fill" Value="#4CC2FF"/>
<Setter TargetName="SwitchCircle" Property="HorizontalAlignment" Value="Right"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- Context Menu Button -->
<Button Grid.Row="0" Grid.Column="3" Content="▼" Height="30" FontFamily="Segoe UI Emoji" Style="{StaticResource CustomButtonStyle}">
<Button.ContextMenu>
<ContextMenu x:Name="CodeActionsContextMenu" FontSize="15">
</ContextMenu>
</Button.ContextMenu>
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="ContextMenu.IsOpen">
<DiscreteBooleanKeyFrame KeyTime="0:0:0" Value="True"/>
</BooleanAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
<!-- VS.NET to GPT Button -->
<Button Grid.Row="0" Grid.Column="0" Name="btnVSNETToAI" Content="VS.NET to GPT ➡️" Click="OnSendCodeButtonClick" Tag="btnVSNETToAI" Height="30" FontFamily="Segoe UI Emoji" Style="{StaticResource CustomButtonStyle}" ToolTip="Transfer selected code from VS.NET to GPT"/>
<!-- Fix Code in GPT Button -->
<Button Grid.Row="0" Grid.Column="1" Name="btnFixCodeInAI" Content="Fix Code in GPT ➡️" Click="OnSendCodeButtonClick" Tag="Fix {languageCode} code below:" Height="30" FontFamily="Segoe UI Emoji" Style="{StaticResource CustomButtonStyle}" ToolTip="Transfer selected code from GPT to VS.NET"/>
<!-- Improve Code in GPT Button -->
<Button Grid.Row="0" Grid.Column="2" Name="btnImproveCodeInAI" Content="Improve Code in GPT ➡️" Click="OnSendCodeButtonClick" Tag="Improve {languageCode} code below:" Height="30" FontFamily="Segoe UI Emoji" Style="{StaticResource CustomButtonStyle}" ToolTip="Refactor selected code from VS.NET in GPT" />
<!-- GPT to VS.NET Button -->
<Button Grid.Row="1" Grid.Column="0" Name="btnAIToVSNET" Content="⬅️ GPT to VS.NET" Click="OnReceiveCodeButtonClick" Height="30" FontFamily="Segoe UI Emoji" Style="{StaticResource CustomButtonStyle}" ToolTip="Transfer selected code from GPT to VS.NET"/>
<!-- Attach Current File Button -->
<Button Grid.Row="1" Grid.Column="1" Name="btnAttachFile" Content="Attach Current VS File📎" Click="OnAttachFileButtonClick" Height="30" FontFamily="Segoe UI Emoji" Style="{StaticResource CustomButtonStyle}" ToolTip="Attach currently selected file to AI (hit Enter after file is set in dialog)"/>
<!-- Complete Code Button -->
<Button Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" Name="btnCompleteCodeInAI" Content="Complete Code ✅" Click="OnCompleteCodeButtonClick" Height="30" FontFamily="Segoe UI Emoji" Style="{StaticResource CustomButtonStyle}" ToolTip="Ask GPT to provide full complete code"/>
<!-- New File Button -->
<Button Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="1" Name="btnNewFile" Content="📄 New File" Style="{StaticResource CustomButtonStyle}" Click="OnNewFileButtonClick" ToolTip="Create a new file from GPT content" />
<!-- New Continue Code Button -->
<Button Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="1" Name="btnContinueCode" Content="Continue Code ⏩" Click="OnContinueCodeButtonClick" Height="30" FontFamily="Segoe UI Emoji" Style="{StaticResource CustomButtonStyle}" ToolTip="Continue code generation"/>
<!-- Enable Copy Code Checkbox -->
<Border Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Background="#343541" CornerRadius="4">
<CheckBox Style="{StaticResource CustomCheckBoxStyle}" HorizontalAlignment="Right" Name="EnableCopyCodeCheckBox" Click="EnableCopyCodeCheckBox_Click" IsChecked="True" ToolTip="Enable sending code from GPT to VS.NET when Copy code button is clicked in GPT" />
</Border>
<!-- WebView2 Control -->
<controls:WebView2 Grid.Row="4" Grid.ColumnSpan="4" Name="webView" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>
</UserControl>