Skip to content

Commit

Permalink
build window success
Browse files Browse the repository at this point in the history
  • Loading branch information
help-14 committed Jan 9, 2022
1 parent 5e1730a commit cf020b2
Show file tree
Hide file tree
Showing 23 changed files with 267 additions and 58 deletions.
2 changes: 1 addition & 1 deletion Pitago.Linux/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="clr-namespace:AvaloniaEdit.CodeCompletion;assembly=AvaloniaEdit"
x:Class="Pitago.Linux.App">
x:Class="Pitago.App">
<Application.Styles>
<FluentTheme Mode="Dark"/>
<StyleInclude Source="avares://AvaloniaEdit/AvaloniaEdit.xaml" />
Expand Down
2 changes: 1 addition & 1 deletion Pitago.Linux/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;

namespace Pitago.Linux
namespace Pitago
{
public class App : Application
{
Expand Down
15 changes: 15 additions & 0 deletions Pitago.Linux/Pitago.Linux.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-linux</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>Pitago</RootNamespace>
<AssemblyName>Pitago</AssemblyName>
<ApplicationIcon>icon.ico</ApplicationIcon>
<Version>0.1.0</Version>
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
<RunAnalyzers>false</RunAnalyzers>
<Company>Help-14</Company>
<Product>Pitago</Product>
<EnableNETAnalyzers>False</EnableNETAnalyzers>
<AnalysisLevel>none</AnalysisLevel>
</PropertyGroup>
<ItemGroup>
<None Remove=".gitignore" />
<None Remove="icon.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.11" />
Expand Down
2 changes: 1 addition & 1 deletion Pitago.Linux/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Avalonia.Controls.ApplicationLifetimes;
using System;

namespace Pitago.Linux
namespace Pitago
{
internal class Program
{
Expand Down
Binary file added Pitago.Linux/icon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion Pitago.Mac/App.axaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Pitago.Mac.App">
x:Class="Pitago.App">
<Application.Styles>
<FluentTheme Mode="Light"/>
</Application.Styles>
Expand Down
2 changes: 1 addition & 1 deletion Pitago.Mac/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;

namespace Pitago.Mac
namespace Pitago
{
public class App : Application
{
Expand Down
17 changes: 16 additions & 1 deletion Pitago.Mac/Pitago.Mac.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-macos</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>Pitago</RootNamespace>
<AssemblyName>Pitago</AssemblyName>
<ApplicationIcon>icon.ico</ApplicationIcon>
<Version>0.1.0</Version>
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
<RunAnalyzers>false</RunAnalyzers>
<Company>Help-14</Company>
<Product>Pitago</Product>
<EnableNETAnalyzers>False</EnableNETAnalyzers>
<AnalysisLevel>none</AnalysisLevel>
</PropertyGroup>
<ItemGroup>
<None Remove=".gitignore" />
<None Remove="icon.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.11" />
Expand Down
2 changes: 1 addition & 1 deletion Pitago.Mac/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Avalonia;

namespace Pitago.Mac
namespace Pitago
{
class Program
{
Expand Down
Binary file added Pitago.Mac/icon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion Pitago.Win/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:uip="using:FluentAvalonia.UI.Controls.Primitives"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="clr-namespace:AvaloniaEdit.CodeCompletion;assembly=AvaloniaEdit"
x:Class="Pitago.Win.App">
x:Class="Pitago.App">
<Application.Styles>
<FluentTheme Mode="Dark"/>
<StyleInclude Source="avares://AvaloniaEdit/AvaloniaEdit.xaml" />
Expand Down
2 changes: 1 addition & 1 deletion Pitago.Win/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;

namespace Pitago.Win
namespace Pitago
{
public class App : Application
{
Expand Down
14 changes: 11 additions & 3 deletions Pitago.Win/Pitago.Win.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>Pitago.Win</RootNamespace>
<AssemblyName>Pitago.Win</AssemblyName>
<RootNamespace>Pitago</RootNamespace>
<AssemblyName>Pitago</AssemblyName>
<ApplicationIcon>icon.ico</ApplicationIcon>
<Version>0.1.0</Version>
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
<RunAnalyzers>false</RunAnalyzers>
<Company>Help-14</Company>
<Product>Pitago</Product>
<EnableNETAnalyzers>False</EnableNETAnalyzers>
<AnalysisLevel>none</AnalysisLevel>
</PropertyGroup>
<ItemGroup>
<Content Include="icon.ico" />
Expand All @@ -14,7 +22,7 @@
<PackageReference Include="AngouriMath" Version="1.3.0" />
<PackageReference Include="Avalonia" Version="0.10.11" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.11" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.11" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.11" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Pitago\Pitago.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion Pitago.Win/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Avalonia;

namespace Pitago.Win
namespace Pitago
{
class Program
{
Expand Down
21 changes: 21 additions & 0 deletions Pitago/Constants/Info.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace Pitago.Constants
{
public static class Info
{

/// <summary>
/// Link to the newest version txt on Github
/// </summary>
public const string NewestVersionUrl =
#if BETA
"https://raw.githubusercontent.com/help-14/pitago/main/version/beta.txt";
#else
"https://raw.githubusercontent.com/help-14/pitago/main/version/stable.txt";
#endif

/// <summary>
/// Link to download the newest version
/// </summary>
public const string DownloadUrl = "https://github.com/help-14/pitago/releases";
}
}
18 changes: 18 additions & 0 deletions Pitago/Utils/Network.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Net.NetworkInformation;

namespace Pitago.Utils
{
public static class Network
{

/// <summary>
/// Check if the computer is connected to the internet
/// </summary>
/// <returns>bool</returns>
public static bool IsConnected()
{
return NetworkInterface.GetIsNetworkAvailable();
}

}
}
68 changes: 68 additions & 0 deletions Pitago/Utils/Update.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System.Diagnostics;
using System.Reflection;

namespace Pitago.Utils
{
public static class Update
{

/// <summary>
/// Return current version from app assembly
/// </summary>
/// <returns>Version?</returns>
public static Version? CurrentVersion()
{
return Assembly.GetExecutingAssembly().GetName().Version;
}

/// <summary>
/// Return newest version from Github
/// </summary>
/// <returns>Task<Version?></returns>
public static async Task<Version?> NewestVersion()
{
try
{
var http = new HttpClient();
var result = await http.GetStringAsync(Constants.Info.NewestVersionUrl);
if (string.IsNullOrEmpty(result)) return null;
return new Version(result);
} catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
}

/// <summary>
/// Check if newest version is greater than current version
/// </summary>
/// <returns>Task<bool></returns>
public static async Task<bool> CanUpdate()
{
if (!Network.IsConnected()) return false;

var currentVersion = CurrentVersion();
if (currentVersion == null) return true;
var newestVersion = await NewestVersion();
if(newestVersion == null) return false;
return newestVersion.Major > currentVersion.Major ||
(newestVersion.Major == currentVersion.Major && newestVersion.Minor > currentVersion.Minor) ||
(newestVersion.Major == currentVersion.Major && newestVersion.Minor == currentVersion.Minor && newestVersion.Build > currentVersion.Build);
}

/// <summary>
/// Run update task
/// For now, open download link for the newest version
/// </summary>
public static void RunUpdate()
{
Process.Start(new ProcessStartInfo
{
FileName = Constants.Info.DownloadUrl,
UseShellExecute = true
});
}

}
}
5 changes: 5 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dotnet publish .\Pitago.Win\Pitago.Win.csproj -c Release --runtime win-x64 --self-contained true --output .\Pitago.Win\bin\Release\x64

dotnet publish .\Pitago.Win\Pitago.Win.csproj -c Release --runtime win-x86 --self-contained true --output .\Pitago.Win\bin\Release\x86

dotnet publish .\Pitago.Win\Pitago.Win.csproj -c Release --runtime win-arm64 --self-contained true --output .\Pitago.Win\bin\Release\arm64
10 changes: 10 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

dotnet publish .\Pitago.Linux\Pitago.Linux.csproj -c Release --runtime linux-x64 --self-contained true --output .\Pitago.Linux\bin\Release\x64
dotnet publish .\Pitago.Linux\Pitago.Linux.csproj -c Release --runtime linux-x86 --self-contained true --output .\Pitago.Linux\bin\Release\x86
dotnet publish .\Pitago.Linux\Pitago.Linux.csproj -c Release --runtime linux-arm --self-contained true --output .\Pitago.Linux\bin\Release\arm
dotnet publish .\Pitago.Linux\Pitago.Linux.csproj -c Release --runtime linux-arm64 --self-contained true --output .\Pitago.Linux\bin\Release\arm64

#dotnet workload install macos
#dotnet publish .\Pitago.Mac\Pitago.Mac.csproj -c Release --runtime osx-x64 --self-contained true --output .\Pitago.Mac\bin\Release\x64
#dotnet publish .\Pitago.Mac\Pitago.Mac.csproj -c Release --runtime osx.12-arm64 --self-contained true --output .\Pitago.Mac\bin\Release\arm64
8 changes: 7 additions & 1 deletion pitago/Calculation/CalculationProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class CalculationProcessor
private const string ArrowSign = "=>";
private const string EqualSign = "=";
private const char NewLineSign = '\n';
private const char ReturnSign = '\r';

public string Process(string math, bool formatResult = true)
{
Expand All @@ -31,6 +32,7 @@ public string Process(string math, bool formatResult = true)
}
else // Varriable found, validate the varriable and calculate, if calculation failed then try simplify the math
{
//TODO save the varriable
result = math.Simplify().Stringize();
}

Expand All @@ -50,11 +52,15 @@ public string Process(string math, bool formatResult = true)

public string ProcessDocument(string document, bool calculate = true)
{
document = document
.Replace($"{ReturnSign}{NewLineSign}", NewLineSign.ToString())
.Replace(ReturnSign.ToString(), "");

var lines = document.Split(NewLineSign);
for (var i = 0; i < lines.Length; i++)
{
lines[i] = GetOriginalMath(lines[i]);
if (calculate) lines[i] = Process(lines[i]);
if (calculate) lines[i] = String.Concat(lines[i], Process(lines[i]));
}
return string.Join(NewLineSign, lines);
}
Expand Down
Loading

0 comments on commit cf020b2

Please sign in to comment.