Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option for editing configuration.
- Loading branch information
1 parent
48767af
commit 5900461
Showing
10 changed files
with
4,055 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using IWshRuntimeLibrary; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Windows.Forms; | ||
|
||
namespace Midi2Vol | ||
{ | ||
public class App | ||
{ | ||
|
||
public App() { } | ||
public App(String name, String AppRaw, String ProcessName) | ||
{ | ||
this.name = name; | ||
this.AppRaw = AppRaw; | ||
this.ProcessName = ProcessName; | ||
} | ||
public String name { get; set; } | ||
public String AppRaw { get; set; } | ||
public String ProcessName { get; set; } | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
|
||
namespace Midi2Vol | ||
{ | ||
class Config | ||
{ | ||
public String configFile = "config.json"; | ||
public Config() { } | ||
public List<App> SourceConfig() | ||
{ | ||
String jsonString = System.IO.File.ReadAllText(configFile); | ||
List<App> apps = JsonConvert.DeserializeObject<List<App>>(jsonString); | ||
return apps; | ||
} | ||
public void saveConfig(List<App> apps) | ||
{ | ||
String objectJson = JsonConvert.SerializeObject(apps); | ||
System.IO.File.WriteAllText(configFile, objectJson); | ||
|
||
|
||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace Midi2Vol | ||
{ | ||
public partial class Edit : Form | ||
{ | ||
private List<App> apps; | ||
App currentApp; | ||
public Edit(List<App> apps) | ||
{ | ||
this.apps = apps; | ||
InitializeComponent(); | ||
foreach (App app in apps) | ||
{ | ||
listBox1.Items.Add(app.name); | ||
} | ||
} | ||
|
||
private void button1_Click(object sender, EventArgs e) | ||
{ | ||
|
||
if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "") | ||
{ | ||
foreach (App app in apps) | ||
{ | ||
if (app.name == textBox1.Text) | ||
{ | ||
app.name = textBox1.Text; | ||
app.AppRaw = textBox2.Text; | ||
app.ProcessName = textBox3.Text; | ||
return; | ||
|
||
} | ||
|
||
} | ||
} | ||
// app not found save it | ||
|
||
App newApp = new App(textBox1.Text, textBox2.Text, textBox3.Text); | ||
apps.Add(newApp); | ||
listBox1.Items.Add(textBox1.Text); | ||
|
||
} | ||
private void button2_Click(object sender, EventArgs e) | ||
{ | ||
if (listBox1.SelectedIndex != -1) | ||
{ | ||
String name = listBox1.SelectedItem.ToString(); | ||
listBox1.ClearSelected(); | ||
apps.Remove(currentApp); | ||
listBox1.Items.Remove(currentApp.name); | ||
} | ||
} | ||
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) | ||
{ | ||
if (listBox1.SelectedIndex != -1) | ||
{ | ||
foreach (App app in apps) | ||
{ | ||
if (app.name == listBox1.SelectedItem.ToString()) | ||
{ | ||
currentApp = app; | ||
textBox1.Text = app.name; | ||
textBox2.Text = app.AppRaw; | ||
textBox3.Text = app.ProcessName; | ||
} | ||
} | ||
textBox1.Update(); | ||
textBox2.Update(); | ||
textBox3.Update(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.