Skip to content

Commit

Permalink
Add More Server
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1372 committed Mar 20, 2020
1 parent 4bbc7ea commit 93dffd3
Show file tree
Hide file tree
Showing 9 changed files with 257 additions and 30 deletions.
2 changes: 2 additions & 0 deletions UrlShortener/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using HandyControl.Data;
using Prism.Ioc;
using Prism.Regions;
using System;
using System.Windows;
using UrlShortener.Views;
Expand Down Expand Up @@ -42,6 +43,7 @@ public override void Initialize()
{
UpdateSkin(GlobalData.Config.Skin);
}
Container.Resolve<IRegionManager>().RequestNavigate("ContentRegion", "MainShortener");
}
}
}
2 changes: 1 addition & 1 deletion UrlShortener/Data/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ internal class AppConfig
{
public static readonly string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}AppConfig.json";


public bool IsShowNotifyIcon { get; set; } = false;
public bool IsFirstRun { get; set; } = true;
public int SelectedIndex { get; set; } = 0;

public SkinType Skin { get; set; } = SkinType.Default;
}
Expand Down
14 changes: 14 additions & 0 deletions UrlShortener/Data/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Newtonsoft.Json;
using System.Net.Http;
using System.Text;

namespace UrlShortener.Data
{
public static class Extensions
{
public static StringContent AsJson(this object o)
{
return new StringContent(JsonConvert.SerializeObject(o), Encoding.UTF8, "application/json");
}
}
}
8 changes: 8 additions & 0 deletions UrlShortener/Model/ComboModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace UrlShortener.Model
{
public class ComboModel
{
public string Name { get; set; }
public bool IsCustomTextAvailable { get; set; }
}
}
8 changes: 8 additions & 0 deletions UrlShortener/Model/ShorterListModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace UrlShortener.Model
{
public class ShorterListModel
{
public string Link { get; set; }
public string ShortLink { get; set; }
}
}
9 changes: 3 additions & 6 deletions UrlShortener/UrlShortener.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<Version>1.0.0.0</Version>
<Configurations>Debug;Release</Configurations>
<Copyright>Copyright © Mahdi 2018-2020</Copyright>
<FileVersion>4.0.0.0</FileVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<FileVersion>4.1.0.0</FileVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<LangVersion>latest</LangVersion>
<ApplicationIcon>Resources\Img\icon.ico</ApplicationIcon>
<Authors>Coded by Mahdi Hosseini</Authors>
Expand All @@ -26,7 +26,7 @@
<None Remove="Resources\Img\cloud.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="HandyControls" Version="2.4.9" />
<PackageReference Include="HandyControls" Version="2.4.9.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Prism.DryIoc" Version="7.2.0.1422" />
</ItemGroup>
Expand All @@ -42,7 +42,4 @@
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<Folder Include="Model\" />
</ItemGroup>
</Project>
21 changes: 20 additions & 1 deletion UrlShortener/ViewModels/LeftMainContentViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System.Linq;
using System.Windows.Controls;
using UrlShortener.Views;

namespace UrlShortener.ViewModels
{
Expand All @@ -23,7 +25,24 @@ public LeftMainContentViewModel(IRegionManager regionManager)

private void UrlShortener()
{
_regionManager.RequestNavigate("ContentRegion", "MainShortener");
object activeView = _regionManager.Regions["ContentRegion"].ActiveViews.FirstOrDefault();
if (activeView != null)
{
bool IsViewMainShortener = activeView.GetType() == typeof(MainShortener);

if (IsViewMainShortener)
{
_regionManager.Regions["ContentRegion"].RemoveAll();
}
else
{
_regionManager.RequestNavigate("ContentRegion", "MainShortener");
}
}
else
{
_regionManager.RequestNavigate("ContentRegion", "MainShortener");
}
}

private void Switch(SelectionChangedEventArgs e)
Expand Down
Loading

0 comments on commit 93dffd3

Please sign in to comment.