Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
The Agent - frmOption.vb

frmOption.vb

Caricato da: Totem
Scarica il programma completo

  1. Imports TheAgent.frmHelper
  2. Imports Microsoft.Win32
  3. Public Class frmOption
  4.     'Carica le opzioni, genera checkbox e textbox a runtime per ogni frase
  5.     Private Sub frmOption_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.         Dim T As TextBox
  7.         Dim C As CheckBox
  8.         Dim Y As UInt16 = 19
  9.  
  10.         'Aggiunta controlli
  11.         With frmHelper.Options
  12.             For I As Byte = 0 To UBound(.Sentences)
  13.                 T = New TextBox
  14.                 T.Name = "txtSen" & I
  15.                 T.Tag = I
  16.                 T.Text = .Sentences(I).Text
  17.                 T.Size = New Size(210, 20)
  18.                 T.Location = New Point(155, Y)
  19.  
  20.                 C = New CheckBox
  21.                 C.Name = "chbSen" & I
  22.                 C.Tag = I
  23.                 C.Text = .Sentences(I).Tag
  24.                 C.Checked = .Sentences(I).Play
  25.                 C.Location = New Point(16, Y)
  26.                 C.Width = 120
  27.  
  28.                 grpSen.Controls.Add(T)
  29.                 grpSen.Controls.Add(C)
  30.                 Y += 26
  31.             Next
  32.             Y = 19
  33.             For i As Byte = 0 To UBound(.PredSentences)
  34.                 C = New CheckBox
  35.                 C.Name = "chbPSen" & i
  36.                 C.Tag = i
  37.                 C.Text = .PredSentences(i).Tag
  38.                 C.Checked = .PredSentences(i).Play
  39.                 C.Location = New Point(16, Y)
  40.                 C.Width = 370
  41.  
  42.                 grpPredSen.Controls.Add(C)
  43.                 Y += 26
  44.             Next
  45.  
  46.             'Varie
  47.             chbSpeakOnMouse.Checked = .Speak_On_MouseOver
  48.             chbBugTragedy.Checked = .Tragedy_On
  49.  
  50.             'Riempimento della combobox del meteo
  51.             Dim Names() As String = [Enum].GetNames(GetType(clsOptions.MeteoZones))
  52.             Dim Selected As String = [Enum].GetName(GetType(clsOptions.MeteoZones), frmHelper.Options.Meteo)
  53.             Array.Sort(Names)
  54.             For I As Int16 = 0 To UBound(Names)
  55.                 cmbMeteo.Items.Add(Names(I))
  56.             Next
  57.             cmbMeteo.SelectedItem = Selected
  58.             chbMeteo.Checked = .Meteo_On_startup
  59.             chbMeteoDetails.Checked = .Meteo_Detailed
  60.  
  61.             'POP3
  62.             If .POP3_Enabled Then
  63.                 cmdEnabledMail.Text = "Disattiva il controllo della posta"
  64.             End If
  65.  
  66.             'Agente
  67.             cmbAgent.SelectedItem = .Agent
  68.             nudX.Value = .StartPos.X
  69.             nudY.Value = .StartPos.Y
  70.         End With
  71.  
  72.         'Fumetti
  73.         With frmHelper.Agente.Balloon
  74.             lblFont.Text = .FontName + ", " & .FontSize & "pt"
  75.             lblFont.Font = New Font(.FontName, .FontSize)
  76.             chbBalloon.Checked = .Enabled
  77.         End With
  78.     End Sub
  79.  
  80.     'Salva le opzioni sulle frasi
  81.     Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
  82.         Dim T As TextBox
  83.         Dim C As CheckBox
  84.  
  85.         With frmHelper.Options
  86.             'Frasi definite dall'utente
  87.             For I As Byte = 0 To UBound(.Sentences)
  88.                 T = grpSen.Controls.Find("txtSen" & I, False)(0)
  89.                 C = grpSen.Controls.Find("chbSen" & I, False)(0)
  90.                 .Sentences(I).Text = T.Text
  91.                 .Sentences(I).Play = C.Checked
  92.             Next
  93.  
  94.             'Frasi preimpostate
  95.             For I As Byte = 0 To UBound(.PredSentences)
  96.                 C = grpPredSen.Controls.Find("chbPSen" & I, False)(0)
  97.                 .PredSentences(I).Play = C.Checked
  98.             Next
  99.  
  100.             'Varie
  101.             .Speak_On_MouseOver = chbSpeakOnMouse.Checked
  102.             .Tragedy_On = chbBugTragedy.Checked
  103.         End With
  104.         MessageBox.Show("Salvataggio completato!", "Opzioni", MessageBoxButtons.OK, MessageBoxIcon.Information)
  105.     End Sub
  106.  
  107.     'Cambia il font visualizzando la finestra di dialogo
  108.     Private Sub cmdFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFont.Click
  109.         Dim F As New FontDialog
  110.         If F.ShowDialog = Windows.Forms.DialogResult.OK Then
  111.             lblFont.Text = F.Font.Name + ", " & F.Font.Size & "pt"
  112.             lblFont.Font = F.Font
  113.         End If
  114.     End Sub
  115.  
  116.     'Salva le opzioni sull'agente
  117.     Private Sub cmdSaveAg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSaveAg.Click
  118.         'Fumetti e POP3
  119.         With frmHelper.Options
  120.             .Balloon_Enabled = chbBalloon.Checked
  121.             .Balloon_Font_Name = lblFont.Font.Name
  122.             .Balloon_Font_Size = lblFont.Font.Size
  123.             .POP3_Server = txtServer.Text
  124.             .POP3_Port = txtPort.Text
  125.             .POP3_User = txtUser.Text
  126.             .POP3_Password = txtPass.Text
  127.         End With
  128.  
  129.         'Fumetti
  130.         With frmHelper.Agente.Balloon
  131.             .FontName = lblFont.Font.Name
  132.             .FontSize = lblFont.Font.Size
  133.             .Visible = chbBalloon.Checked
  134.         End With
  135.  
  136.         'Agente
  137.         If cmbAgent.SelectedItem <> Nothing Then
  138.             frmHelper.Options.Agent = cmbAgent.SelectedItem
  139.             With frmHelper
  140.                 Try
  141.                     .Agente.Hide()
  142.                     .AxAgent1.Characters.Unload(.Personaggio)
  143.                     .Personaggio = cmbAgent.SelectedItem
  144.                     .AxAgent1.Characters.Load(cmbAgent.SelectedItem, "C:\WINDOWS\msagent\chars\" + cmbAgent.SelectedItem + ".acs")
  145.                 Catch Ex As Exception
  146.  
  147.                 End Try
  148.                 .Agente = .AxAgent1.Characters(cmbAgent.SelectedItem)
  149.                 .Agente.Show()
  150.                 .Agente.MoveTo(.Position.X, .Position.Y)
  151.             End With
  152.         End If
  153.  
  154.         'Meteo
  155.         For Each M As clsOptions.MeteoZones In [Enum].GetValues(GetType(clsOptions.MeteoZones))
  156.             If cmbMeteo.SelectedItem = M.ToString Then
  157.                 frmHelper.Options.Meteo = M
  158.                 Exit For
  159.             End If
  160.         Next
  161.         frmHelper.Options.Meteo_On_startup = chbMeteo.Checked
  162.         frmHelper.Options.Meteo_Detailed = chbMeteoDetails.Checked
  163.  
  164.         MessageBox.Show("Salvataggio completato!", "Opzioni", MessageBoxButtons.OK, MessageBoxIcon.Information)
  165.     End Sub
  166.  
  167.     'Preleva le posizioni attuali del form principale
  168.     Private Sub cmdCurPos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCurPos.Click
  169.         With frmHelper
  170.             nudX.Value = .Position.X
  171.             nudY.Value = .Position.Y
  172.         End With
  173.     End Sub
  174.  
  175.     'Imposta le voci di registro cosė da abilitare o disabilitare l'esecuzione automatica
  176.     'del programma
  177.     Private Sub chbAutoStart_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chbAutoStart.CheckedChanged
  178.         Dim RegKey As RegistryKey
  179.         RegKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
  180.  
  181.         If chbAutoStart.Checked Then
  182.             RegKey.SetValue("The Agent", Application.ExecutablePath)
  183.         Else
  184.             If RegKey.GetValue("The Agent") <> Nothing Then
  185.                 RegKey.DeleteValue("The Agent")
  186.             End If
  187.         End If
  188.     End Sub
  189.  
  190.     'Attiva il controllo della posta
  191.     Private Sub cmdEnabledMail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEnabledMail.Click
  192.         If frmHelper.tmrControlMail.Enabled Then
  193.             cmdEnabledMail.Text = "Attiva il controllo della posta"
  194.             frmHelper.tmrControlMail.Stop()
  195.             frmHelper.Options.POP3_Enabled = False
  196.         Else
  197.             cmdEnabledMail.Text = "Disattiva il controllo della posta"
  198.             frmHelper.tmrControlMail.Start()
  199.             frmHelper.Options.POP3_Enabled = True
  200.         End If
  201.     End Sub
  202. End Class