Skip to content

Commit

Permalink
Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Terry authored and Marcus Terry committed Apr 10, 2018
1 parent 424196b commit f665c28
Showing 1 changed file with 38 additions and 35 deletions.
73 changes: 38 additions & 35 deletions ACT_DiscordTriggers/ACT_DiscordTriggers/DiscordPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ private void InitializeComponent() {
//
// logBox
//
this.logBox.BackColor = System.Drawing.SystemColors.Control;
this.logBox.Location = new System.Drawing.Point(251, 41);
this.logBox.BackColor = System.Drawing.SystemColors.Window;
this.logBox.Location = new System.Drawing.Point(21, 262);
this.logBox.Multiline = true;
this.logBox.Name = "logBox";
this.logBox.ReadOnly = true;
this.logBox.Size = new System.Drawing.Size(436, 348);
this.logBox.Size = new System.Drawing.Size(461, 170);
this.logBox.TabIndex = 44;
//
// chkAutoConnect
Expand All @@ -88,7 +88,7 @@ private void InitializeComponent() {
//
// sliderTTSSpeed
//
this.sliderTTSSpeed.Location = new System.Drawing.Point(21, 363);
this.sliderTTSSpeed.Location = new System.Drawing.Point(289, 154);
this.sliderTTSSpeed.Maximum = 20;
this.sliderTTSSpeed.Name = "sliderTTSSpeed";
this.sliderTTSSpeed.Size = new System.Drawing.Size(193, 45);
Expand All @@ -98,15 +98,15 @@ private void InitializeComponent() {
// lblTTSSpeed
//
this.lblTTSSpeed.AutoSize = true;
this.lblTTSSpeed.Location = new System.Drawing.Point(22, 345);
this.lblTTSSpeed.Location = new System.Drawing.Point(290, 136);
this.lblTTSSpeed.Name = "lblTTSSpeed";
this.lblTTSSpeed.Size = new System.Drawing.Size(62, 13);
this.lblTTSSpeed.TabIndex = 56;
this.lblTTSSpeed.Text = "TTS Speed";
//
// sliderTTSVol
//
this.sliderTTSVol.Location = new System.Drawing.Point(21, 296);
this.sliderTTSVol.Location = new System.Drawing.Point(289, 87);
this.sliderTTSVol.Maximum = 20;
this.sliderTTSVol.Name = "sliderTTSVol";
this.sliderTTSVol.Size = new System.Drawing.Size(193, 45);
Expand All @@ -116,7 +116,7 @@ private void InitializeComponent() {
// lblTTSVol
//
this.lblTTSVol.AutoSize = true;
this.lblTTSVol.Location = new System.Drawing.Point(18, 276);
this.lblTTSVol.Location = new System.Drawing.Point(286, 67);
this.lblTTSVol.Name = "lblTTSVol";
this.lblTTSVol.Size = new System.Drawing.Size(66, 13);
this.lblTTSVol.TabIndex = 54;
Expand Down Expand Up @@ -163,15 +163,15 @@ private void InitializeComponent() {
//
this.cmbTTS.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbTTS.FormattingEnabled = true;
this.cmbTTS.Location = new System.Drawing.Point(21, 242);
this.cmbTTS.Location = new System.Drawing.Point(289, 33);
this.cmbTTS.Name = "cmbTTS";
this.cmbTTS.Size = new System.Drawing.Size(193, 21);
this.cmbTTS.TabIndex = 49;
//
// lblTTS
//
this.lblTTS.AutoSize = true;
this.lblTTS.Location = new System.Drawing.Point(18, 227);
this.lblTTS.Location = new System.Drawing.Point(286, 18);
this.lblTTS.Name = "lblTTS";
this.lblTTS.Size = new System.Drawing.Size(58, 13);
this.lblTTS.TabIndex = 48;
Expand Down Expand Up @@ -202,7 +202,7 @@ private void InitializeComponent() {
// lblLog
//
this.lblLog.AutoSize = true;
this.lblLog.Location = new System.Drawing.Point(248, 18);
this.lblLog.Location = new System.Drawing.Point(18, 239);
this.lblLog.Name = "lblLog";
this.lblLog.Size = new System.Drawing.Size(60, 13);
this.lblLog.TabIndex = 45;
Expand Down Expand Up @@ -248,7 +248,7 @@ private void InitializeComponent() {
this.Controls.Add(this.txtToken);
this.Controls.Add(this.lblBotTok);
this.Name = "DiscordPlugin";
this.Size = new System.Drawing.Size(722, 439);
this.Size = new System.Drawing.Size(505, 455);
((System.ComponentModel.ISupportInitialize)(this.sliderTTSSpeed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.sliderTTSVol)).EndInit();
this.ResumeLayout(false);
Expand All @@ -259,15 +259,8 @@ private void InitializeComponent() {
#endregion

#endregion
public DiscordPlugin() {
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
InitializeComponent();
var tts = new SpeechSynthesizer();
foreach (InstalledVoice v in tts.GetInstalledVoices())
cmbTTS.Items.Add(v.VoiceInfo.Name);
cmbTTS.SelectedIndex = 0;
}

#region Init Variables
Label lblStatus;
string settingsFile;
SettingsSerializer xmlSettings;
Expand All @@ -289,7 +282,19 @@ public DiscordPlugin() {
private Label lblLog;
private TextBox txtToken;
private Label lblBotTok;
private Random ran = new Random();
#endregion

public DiscordPlugin() {
//Load UI Components and Assemblies
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
InitializeComponent();

//Add installed voices to dropdown
var tts = new SpeechSynthesizer();
foreach (InstalledVoice v in tts.GetInstalledVoices())
cmbTTS.Items.Add(v.VoiceInfo.Name);
cmbTTS.SelectedIndex = 0;
}

#region IActPluginV1 Members
public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText) {
Expand Down Expand Up @@ -348,8 +353,6 @@ private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs a
}
#endregion

private object speaklock = new object();

#region Discord Methods
private void speak(string text) {
DiscordClient.Speak(text, cmbTTS.SelectedItem.ToString(), sliderTTSVol.Value, sliderTTSSpeed.Value);
Expand Down Expand Up @@ -433,15 +436,25 @@ private void btnLeave_Click(object sender, EventArgs e) {
private void cmbServer_SelectedIndexChanged(object sender, EventArgs e) {
populateChannels(cmbServer.SelectedItem.ToString());
}

private void discordConnectbtn_Click(object sender, EventArgs e) {

if (DiscordClient.IsConnected()) {
Log("Already connected to Discord.");
return;
}
if (DiscordClient.InIt(txtToken.Text))
Log("Connected to Discord.");
else
Log("Error connecting to Discord. Discord may be down or key is incorrect.");
}
#endregion

#region Discord Events
#region Settings
public void Log(string text) {
logBox.AppendText(text + "\n");
}
#endregion

#region Settings
public void LoadSettings() {
xmlSettings.AddControlSetting(txtToken.Name, txtToken);
xmlSettings.AddControlSetting(sliderTTSVol.Name, sliderTTSVol);
Expand Down Expand Up @@ -485,16 +498,6 @@ public bool SaveSettings() {
}
#endregion

private void discordConnectbtn_Click(object sender, EventArgs e) {

if (DiscordClient.IsConnected()) {
Log("Already connected to Discord.");
return;
}
if (DiscordClient.InIt(txtToken.Text))
Log("Connected to Discord.");
else
Log("Error connecting to Discord. Discord may be down or key is incorrect.");
}
}
}

0 comments on commit f665c28

Please sign in to comment.