Skip to content
This repository has been archived by the owner on Sep 17, 2022. It is now read-only.

Commit

Permalink
Main application core code is complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Serenity committed Aug 15, 2021
1 parent 21b1ef7 commit c493765
Show file tree
Hide file tree
Showing 15 changed files with 8,468 additions and 77 deletions.
13 changes: 13 additions & 0 deletions Classes/csGitHub.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Octo_Streamer.Classes
{
class csGitHub
{
public static string token = "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";
}
}
66 changes: 41 additions & 25 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

92 changes: 75 additions & 17 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;
using Octokit;
using Octo_Streamer.Classes;

namespace Octo_Streamer
{
Expand All @@ -29,6 +31,9 @@ private void Form1_Load(object sender, EventArgs e)
// Check for stream files
checkStreamDirectory();

// Set current version of application in the tool menu
toolCurrentVersionToolStripMenuItem.Text = "Version: " + Program.ApplicationVersion;

// Reset server status label
toolServerStatus.Text = null;

Expand All @@ -51,6 +56,10 @@ private void Form1_Load(object sender, EventArgs e)
// start receive connection timer
tmrUpdateConnectionData.Start();

// check for application updates
tmrCheckForUpdates.Enabled = true;
tmrCheckForUpdates.Start();

if (Properties.Settings.Default.Host == "")
{
// Change state for the connection to the server button event
Expand Down Expand Up @@ -402,24 +411,11 @@ private void remoteServerHandshake(string host, string port, string apiKey)

#endregion

#region DEV
private void btnFlash_Click(object sender, EventArgs e)
{
Properties.Settings.Default.Host = "";
Properties.Settings.Default.Port = "";
Properties.Settings.Default.ApiKey = "";
Properties.Settings.Default.Save();

Application.ExitThread();
}

#endregion

#region Application Exit
private void tsExitApplication_Click(object sender, EventArgs e)
{
// Exit Application
Application.ExitThread();
System.Windows.Forms.Application.Exit();
}
#endregion

Expand All @@ -433,7 +429,6 @@ private void linkDualznzGithub_Click(object sender, EventArgs e)

#region Main API Interaction


private void tmrApi_Tick(object sender, EventArgs e)
{
// Create connection to the api request declaration
Expand Down Expand Up @@ -751,7 +746,7 @@ private void applicationSettingsToolStripMenuItem_Click(object sender, EventArgs
private void checkStreamDirectory()
{
// Define base location of application stream files
string coreLocation = Application.StartupPath;
string coreLocation = System.Windows.Forms.Application.StartupPath;
string streamDirectory = "stream";

// Check to see if stream directory has been created or not
Expand Down Expand Up @@ -947,7 +942,7 @@ private void displayLayerProgressFiles(string coreDirectory, string subDirectory
private void streamToFiles()
{
// Define base location for data fields
string defaultDirectory = Application.StartupPath + "/stream/";
string defaultDirectory = System.Windows.Forms.Application.StartupPath + "/stream/";

// Define sub-directories
string printerDir = "printer/";
Expand Down Expand Up @@ -1124,5 +1119,68 @@ private void streamToFiles()

#endregion

#region Application Update Check

private void tmrCheckForUpdates_Tick(object sender, EventArgs e)
{
// Stop the timer
tmrCheckForUpdates.Stop();
tmrCheckForUpdates.Enabled = false;

// Check for updates
UpdateCheck();
}
private async void UpdateCheck()
{
try
{
var github = new GitHubClient(new ProductHeaderValue("Octo-Streamer"));
var basicAuth = new Credentials(csGitHub.token);
github.Credentials = basicAuth;
var repo = await github.Repository.Release.GetLatest("dualznz", "Octo-Streamer");

// check to see if there is a new version
if (Program.ApplicationVersion != repo.TagName)
{
// New application release is available, enable and show update event
linkGithubReleases.Enabled = true;
linkGithubReleases.Visible = true;

// Navigate to the github releases page
System.Diagnostics.Process.Start("https://github.com/dualznz/Octo-Streamer/releases");
}
else
{
// Application is on the latest version
linkGithubReleases.Enabled = false;
linkGithubReleases.Visible = false;
}

}
catch (Exception)
{
// No tags have been found or error connecting to GitHub
Console.WriteLine("Unable to connect to Octo-Streamer Repo and check for new releases");
}
}
#endregion

#region Github Homepage
private void githubHomepageToolStripMenuItem_Click(object sender, EventArgs e)
{
// Navigate to project homepage
System.Diagnostics.Process.Start("https://github.com/dualznz/Octo-Streamer");
}

#endregion

#region Github Issues
private void githubIssuesRequestsToolStripMenuItem_Click(object sender, EventArgs e)
{
// Navigate to project issue / features page
System.Diagnostics.Process.Start("https://github.com/dualznz/Octo-Streamer/issues");
}
#endregion

}
}
Loading

0 comments on commit c493765

Please sign in to comment.