Skip to content
This repository was archived by the owner on Jun 29, 2023. It is now read-only.

Commit a0d0e85

Browse files
Merge pull request #5 from InvisibleManVPN/invisibleman
Invisible Man VPN version 1.5
2 parents 1ffaa3f + dc3cfe4 commit a0d0e85

6 files changed

Lines changed: 134 additions & 7 deletions

File tree

Invisible Man/Invisible Man.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
<ManifestKeyFile>Invisible Man_TemporaryKey.pfx</ManifestKeyFile>
6363
</PropertyGroup>
6464
<PropertyGroup>
65-
<GenerateManifests>false</GenerateManifests>
65+
<GenerateManifests>true</GenerateManifests>
6666
</PropertyGroup>
6767
<PropertyGroup>
68-
<SignManifests>false</SignManifests>
68+
<SignManifests>true</SignManifests>
6969
</PropertyGroup>
7070
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
7171
<DebugSymbols>true</DebugSymbols>
@@ -115,6 +115,7 @@
115115
</PropertyGroup>
116116
<PropertyGroup />
117117
<PropertyGroup />
118+
<PropertyGroup />
118119
<PropertyGroup>
119120
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
120121
</PropertyGroup>

Invisible Man/InvisibleManCore.cs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public ServerInformation(string serverName, string countryImage, string serverAd
3333
class InvisibleManCore
3434
{
3535
// Initialize
36-
public static int bundleIdentifier = 2;
36+
public static int bundleIdentifier = 3;
3737
public static int index = 0;
3838
public static bool isSelectServer = false;
3939

@@ -286,5 +286,37 @@ public async Task<string> CheckForUpdatesVPN()
286286
return "FailedToConnect";
287287
}
288288
}
289+
290+
/// <summary>
291+
/// Check the server to message
292+
/// </summary>
293+
public async Task<string> CheckForMessage()
294+
{
295+
try
296+
{
297+
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
298+
var url = "https://invisiblemanvpn.github.io/index.html";
299+
HttpClient httpClient = new HttpClient();
300+
string html = await httpClient.GetStringAsync(url);
301+
302+
HtmlDocument htmlDocument = new HtmlDocument();
303+
htmlDocument.LoadHtml(html);
304+
List<HtmlNode> htmlNodeList = htmlDocument.DocumentNode.SelectNodes("//meta")
305+
.Where(node => node.GetAttributeValue("name", "")
306+
.Equals("Message")).ToList();
307+
HtmlAttribute contentHtmlAttribute = htmlNodeList[0].Attributes["content"];
308+
309+
string[] message = contentHtmlAttribute.Value.Split('|');
310+
int messageTime = Convert.ToInt32(message[0]);
311+
string messageContent = message[1];
312+
313+
await Task.Delay(messageTime * 1000);
314+
return messageContent;
315+
}
316+
catch(Exception)
317+
{
318+
return "FailedToConnect";
319+
}
320+
}
289321
}
290322
}

Invisible Man/MainWindow.xaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,42 @@
222222
<EasingDoubleKeyFrame KeyTime="0:0:1.4" Value="360"/>
223223
</DoubleAnimationUsingKeyFrames>
224224
</Storyboard>
225+
<Storyboard x:Key="AnimMessage">
226+
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="GridMessage">
227+
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
228+
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1">
229+
<EasingDoubleKeyFrame.EasingFunction>
230+
<PowerEase EasingMode="EaseOut"/>
231+
</EasingDoubleKeyFrame.EasingFunction>
232+
</EasingDoubleKeyFrame>
233+
</DoubleAnimationUsingKeyFrames>
234+
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="GridMessage">
235+
<EasingDoubleKeyFrame KeyTime="0" Value="-50"/>
236+
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0">
237+
<EasingDoubleKeyFrame.EasingFunction>
238+
<PowerEase EasingMode="EaseOut"/>
239+
</EasingDoubleKeyFrame.EasingFunction>
240+
</EasingDoubleKeyFrame>
241+
</DoubleAnimationUsingKeyFrames>
242+
</Storyboard>
243+
<Storyboard x:Key="AnimMessageClose">
244+
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="GridMessage">
245+
<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
246+
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0">
247+
<EasingDoubleKeyFrame.EasingFunction>
248+
<PowerEase EasingMode="EaseOut"/>
249+
</EasingDoubleKeyFrame.EasingFunction>
250+
</EasingDoubleKeyFrame>
251+
</DoubleAnimationUsingKeyFrames>
252+
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="GridMessage">
253+
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
254+
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-50">
255+
<EasingDoubleKeyFrame.EasingFunction>
256+
<PowerEase EasingMode="EaseOut"/>
257+
</EasingDoubleKeyFrame.EasingFunction>
258+
</EasingDoubleKeyFrame>
259+
</DoubleAnimationUsingKeyFrames>
260+
</Storyboard>
225261
</Window.Resources>
226262
<Window.Background>
227263
<StaticResource ResourceKey="BackgroundGrayVeryLight"/>
@@ -230,6 +266,8 @@
230266
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
231267
<BeginStoryboard Storyboard="{StaticResource AnimStartup}"/>
232268
<BeginStoryboard Storyboard="{StaticResource AnimConnecting}"/>
269+
<BeginStoryboard Storyboard="{StaticResource AnimMessage}"/>
270+
<BeginStoryboard Storyboard="{StaticResource AnimMessageClose}"/>
233271
</EventTrigger>
234272
</Window.Triggers>
235273
<Grid>
@@ -247,6 +285,28 @@
247285
<RowDefinition Height="25"/>
248286
<RowDefinition Height="100"/>
249287
</Grid.RowDefinitions>
288+
<Grid x:Name="GridMessage" Grid.Row="0" VerticalAlignment="Top" Height="40" Background="{StaticResource BackgroundGrayLight}" Visibility="Hidden" RenderTransformOrigin="0.5,0.5">
289+
<Grid.RenderTransform>
290+
<TransformGroup>
291+
<ScaleTransform/>
292+
<SkewTransform/>
293+
<RotateTransform/>
294+
<TranslateTransform/>
295+
</TransformGroup>
296+
</Grid.RenderTransform>
297+
298+
<Grid.ColumnDefinitions>
299+
<ColumnDefinition Width="*"></ColumnDefinition>
300+
<ColumnDefinition Width="35"></ColumnDefinition>
301+
</Grid.ColumnDefinitions>
302+
303+
<Label x:Name="LabelMessage" Grid.Column="0" Padding="0" HorizontalAlignment="Center" VerticalAlignment="Center" Content="Message content" FontFamily="{StaticResource SegoeUI}" FontWeight="Normal" FontSize="13" Foreground="Black"></Label>
304+
<Viewbox x:Name="ButtonCloseMessage" Width="25" Height="25" HorizontalAlignment="Left" Grid.Column="1" Cursor="Hand" PreviewMouseDown="ButtonCloseMessage_PreviewMouseDown" >
305+
<Canvas Width="24" Height="24" Background="{StaticResource BackgroundGrayLight}">
306+
<Path Data="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" Fill="{StaticResource BackgroundRedDark}" />
307+
</Canvas>
308+
</Viewbox>
309+
</Grid>
250310
<Grid x:Name="GridStateLogoDisconnected" Grid.Row="0" VerticalAlignment="Bottom" RenderTransformOrigin="0.5,0.5" Visibility="Visible">
251311
<Grid.RenderTransform>
252312
<TransformGroup>

Invisible Man/MainWindow.xaml.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using System.ComponentModel;
1717
using System.Windows.Threading;
1818
using System.Diagnostics;
19+
using System.Windows.Media.Animation;
1920

2021
namespace Invisible_Man
2122
{
@@ -27,6 +28,7 @@ public partial class MainWindow : Window
2728
// BackgroundWorkers and Dispatchers to check connecting states
2829
private BackgroundWorker connectBackgroundWorker = new BackgroundWorker();
2930
private BackgroundWorker updateBackgroundWorker = new BackgroundWorker();
31+
private BackgroundWorker messageBackgroundWorker = new BackgroundWorker();
3032
private DispatcherTimer connectDispatcherTimer = new DispatcherTimer();
3133
private DispatcherTimer disconnectDispatcherTimer = new DispatcherTimer();
3234
private DispatcherTimer cancelDispatcherTimer = new DispatcherTimer();
@@ -48,6 +50,7 @@ public MainWindow()
4850
// Set BackgroundWorkers and Dispatchers
4951
connectBackgroundWorker.DoWork += connectBackgroundWorker_DoWork;
5052
updateBackgroundWorker.DoWork += updateBackgroundWorker_DoWork;
53+
messageBackgroundWorker.DoWork += messageBackgroundWorker_DoWork;
5154
connectDispatcherTimer.Tick += connectDispatcherTimer_Tick;
5255
connectDispatcherTimer.Interval = TimeSpan.FromSeconds(1);
5356
disconnectDispatcherTimer.Tick += disconnectDispatcherTimer_Tick;
@@ -80,6 +83,9 @@ public MainWindow()
8083

8184
// Check for new version of Invisible Man
8285
updateBackgroundWorker.RunWorkerAsync();
86+
87+
// Check for message of Invisible Man
88+
messageBackgroundWorker.RunWorkerAsync();
8389
}
8490

8591
/// <summary>
@@ -216,6 +222,28 @@ await Dispatcher.BeginInvoke(new Action(delegate
216222
}));
217223
}
218224

225+
/// <summary>
226+
/// Check for message in messageBackgroundWorker
227+
/// </summary>
228+
private async void messageBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
229+
{
230+
InvisibleManCore invisibleManCore = new InvisibleManCore();
231+
string message = await invisibleManCore.CheckForMessage();
232+
233+
await Dispatcher.BeginInvoke(new Action(delegate
234+
{
235+
if (message != "FailedToConnect")
236+
{
237+
LabelMessage.Content = message;
238+
GridMessage.Visibility = System.Windows.Visibility.Visible;
239+
240+
// Run the animation
241+
Storyboard messageStoryboard = this.TryFindResource("AnimMessage") as Storyboard;
242+
messageStoryboard.Begin();
243+
}
244+
}));
245+
}
246+
219247
/// <summary>
220248
/// Check the connection is connect or not each 1 seconds when you connect to VPN
221249
/// </summary>
@@ -374,6 +402,12 @@ private void TextBlockLocation_PreviewMouseDown(object sender, MouseButtonEventA
374402
}
375403
}
376404

405+
private void ButtonCloseMessage_PreviewMouseDown(object sender, MouseButtonEventArgs e)
406+
{
407+
Storyboard messageCloseStoryboard = this.TryFindResource("AnimMessageClose") as Storyboard;
408+
messageCloseStoryboard.Begin();
409+
}
410+
377411
private void Application_Closed(object sender, EventArgs e)
378412
{
379413
notifyIcon.Visible = false;

Invisible Man/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.1.0.0")]
55-
[assembly: AssemblyFileVersion("1.1.0.0")]
54+
[assembly: AssemblyVersion("1.5.0.0")]
55+
[assembly: AssemblyFileVersion("1.5.0.0")]

Invisible Man/Properties/app.manifest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
55
<security>
66
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7-
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
7+
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
88
</requestedPrivileges>
99
<applicationRequestMinimum>
1010
<defaultAssemblyRequest permissionSetReference="Custom" />
11-
<PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" />
11+
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
1212
</applicationRequestMinimum>
1313
</security>
1414
</trustInfo>

0 commit comments

Comments
 (0)