Skip to content

Commit

Permalink
プロジェクト追加
Browse files Browse the repository at this point in the history
  • Loading branch information
Mushus committed Jun 3, 2017
1 parent b341c80 commit 97bf226
Show file tree
Hide file tree
Showing 20 changed files with 2,888 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MyGameStatus/obj/Release/*
MyGameStatus/obj/Debug/*
MyGameStatus/bin/Release/*
MyGameStatus/bin/Debug/*
22 changes: 22 additions & 0 deletions MyGameStatus.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyGameStatus", "MyGameStatus\MyGameStatus.csproj", "{9A5AF689-A8BD-4EC4-86F5-D78821203A56}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9A5AF689-A8BD-4EC4-86F5-D78821203A56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A5AF689-A8BD-4EC4-86F5-D78821203A56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A5AF689-A8BD-4EC4-86F5-D78821203A56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A5AF689-A8BD-4EC4-86F5-D78821203A56}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions MyGameStatus/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
109 changes: 109 additions & 0 deletions MyGameStatus/Form1.Designer.cs

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

86 changes: 86 additions & 0 deletions MyGameStatus/Form1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MyGameStatus
{
public partial class Form1 : Form
{
private Process hProcess = null;
private string processName = "";
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
// 自身のプロセスを取得する
hProcess = Process.GetCurrentProcess();
processName = hProcess.ProcessName;
Visible = false;
// プロセス名を設定
statusToolStripMenuItem.Text = processName;

}

private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}

private void contextMenuStrip_Opened(object sender, EventArgs e)
{
// 一覧を作る
string dir = System.Environment.CurrentDirectory;
string[] files = Directory.GetFiles(dir);

ToolStripDropDownMenu statuses = new ToolStripDropDownMenu();

foreach (string file in files)
{
if (Path.GetExtension(file) != ".exe")
{
continue;
}

string name = Path.GetFileNameWithoutExtension(file);
bool isMyProcess = (processName == name);

// items
ToolStripMenuItem item = new ToolStripMenuItem();
item.Text = name;
item.Checked = isMyProcess;
if (!isMyProcess)
{
item.Click += new System.EventHandler(selectStatus);
}

statuses.Items.Add(item);
}

statusToolStripMenuItem.DropDown = statuses;
}

private void selectStatus(object sender, EventArgs e)
{
ToolStripMenuItem item = (ToolStripMenuItem)sender;
string fileName = item.Text;

string dir = System.Environment.CurrentDirectory;
string exePath = dir + @"\" + fileName + ".exe";

Process p = Process.Start(exePath);

this.Close();
}
}
}
Loading

0 comments on commit 97bf226

Please sign in to comment.