diff --git a/Whackerlink CPS/Codeplug.cs b/Whackerlink CPS/Codeplug.cs index 9eb85c7..627ccb1 100644 --- a/Whackerlink CPS/Codeplug.cs +++ b/Whackerlink CPS/Codeplug.cs @@ -79,8 +79,11 @@ public class Channel public string Name { get; set; } public string System { get; set; } public string Tgid { get; set; } + public string EncryptionMode { get; set; } + public string EncryptionType { get; set; } + public string EncryptionKey { get; set; } public Channel() { } } } -} \ No newline at end of file +} diff --git a/Whackerlink CPS/DataForm.Designer.cs b/Whackerlink CPS/DataForm.Designer.cs index ca83e3e..67f2082 100644 --- a/Whackerlink CPS/DataForm.Designer.cs +++ b/Whackerlink CPS/DataForm.Designer.cs @@ -1,153 +1,277 @@ -namespace Whackerlink_CPS -{ - partial class DataForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.txtName = new Krypton.Toolkit.KryptonTextBox(); - this.kryptonLabel1 = new Krypton.Toolkit.KryptonLabel(); - this.kryptonLabel2 = new Krypton.Toolkit.KryptonLabel(); - this.txtTgid = new Krypton.Toolkit.KryptonTextBox(); - this.kryptonLabel3 = new Krypton.Toolkit.KryptonLabel(); - this.btnUpdate = new Krypton.Toolkit.KryptonButton(); - this.kryptonLabel4 = new Krypton.Toolkit.KryptonLabel(); - this.txtZoneName = new Krypton.Toolkit.KryptonTextBox(); - this.cmbSystems = new Krypton.Toolkit.KryptonComboBox(); - ((System.ComponentModel.ISupportInitialize)(this.cmbSystems)).BeginInit(); - this.SuspendLayout(); - // - // txtName - // - this.txtName.Location = new System.Drawing.Point(386, 102); - this.txtName.Name = "txtName"; - this.txtName.Size = new System.Drawing.Size(216, 39); - this.txtName.TabIndex = 2; - this.txtName.Text = "kryptonTextBox1"; - // - // kryptonLabel1 - // - this.kryptonLabel1.Location = new System.Drawing.Point(197, 104); - this.kryptonLabel1.Name = "kryptonLabel1"; - this.kryptonLabel1.Size = new System.Drawing.Size(170, 37); - this.kryptonLabel1.TabIndex = 1; - this.kryptonLabel1.Values.Text = "System Name:"; - // - // kryptonLabel2 - // - this.kryptonLabel2.Location = new System.Drawing.Point(197, 170); - this.kryptonLabel2.Name = "kryptonLabel2"; - this.kryptonLabel2.Size = new System.Drawing.Size(164, 37); - this.kryptonLabel2.TabIndex = 2; - this.kryptonLabel2.Values.Text = "System Select"; - // - // txtTgid - // - this.txtTgid.Location = new System.Drawing.Point(386, 236); - this.txtTgid.Name = "txtTgid"; - this.txtTgid.Size = new System.Drawing.Size(216, 39); - this.txtTgid.TabIndex = 4; - this.txtTgid.Text = "kryptonTextBox1"; - // - // kryptonLabel3 - // - this.kryptonLabel3.Location = new System.Drawing.Point(197, 238); - this.kryptonLabel3.Name = "kryptonLabel3"; - this.kryptonLabel3.Size = new System.Drawing.Size(124, 37); - this.kryptonLabel3.TabIndex = 4; - this.kryptonLabel3.Values.Text = "Talkgroup"; - // - // btnUpdate - // - this.btnUpdate.Location = new System.Drawing.Point(269, 300); - this.btnUpdate.Name = "btnUpdate"; - this.btnUpdate.Size = new System.Drawing.Size(232, 53); - this.btnUpdate.TabIndex = 5; - this.btnUpdate.Values.Text = "Update"; - this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click); - // - // kryptonLabel4 - // - this.kryptonLabel4.Location = new System.Drawing.Point(220, 44); - this.kryptonLabel4.Name = "kryptonLabel4"; - this.kryptonLabel4.Size = new System.Drawing.Size(147, 37); - this.kryptonLabel4.TabIndex = 8; - this.kryptonLabel4.Values.Text = "Zone Name:"; - // - // txtZoneName - // - this.txtZoneName.Location = new System.Drawing.Point(386, 42); - this.txtZoneName.Name = "txtZoneName"; - this.txtZoneName.Size = new System.Drawing.Size(216, 39); - this.txtZoneName.TabIndex = 1; - this.txtZoneName.Text = "kryptonTextBox1"; - // - // cmbSystems - // - this.cmbSystems.DropDownWidth = 216; - this.cmbSystems.IntegralHeight = false; - this.cmbSystems.Location = new System.Drawing.Point(386, 169); - this.cmbSystems.Name = "cmbSystems"; - this.cmbSystems.Size = new System.Drawing.Size(216, 38); - this.cmbSystems.StateCommon.ComboBox.Content.TextH = Krypton.Toolkit.PaletteRelativeAlign.Near; - this.cmbSystems.TabIndex = 3; - this.cmbSystems.Text = "kryptonComboBox1"; - // - // DataForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.cmbSystems); - this.Controls.Add(this.kryptonLabel4); - this.Controls.Add(this.txtZoneName); - this.Controls.Add(this.btnUpdate); - this.Controls.Add(this.txtTgid); - this.Controls.Add(this.kryptonLabel3); - this.Controls.Add(this.kryptonLabel2); - this.Controls.Add(this.kryptonLabel1); - this.Controls.Add(this.txtName); - this.Name = "DataForm"; - this.Text = "DataForm"; - ((System.ComponentModel.ISupportInitialize)(this.cmbSystems)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private Krypton.Toolkit.KryptonTextBox txtName; - private Krypton.Toolkit.KryptonLabel kryptonLabel1; - private Krypton.Toolkit.KryptonLabel kryptonLabel2; - private Krypton.Toolkit.KryptonTextBox txtTgid; - private Krypton.Toolkit.KryptonLabel kryptonLabel3; - private Krypton.Toolkit.KryptonButton btnUpdate; - private Krypton.Toolkit.KryptonLabel kryptonLabel4; - private Krypton.Toolkit.KryptonTextBox txtZoneName; - private Krypton.Toolkit.KryptonComboBox cmbSystems; - } +namespace Whackerlink_CPS +{ + partial class DataForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.txtName = new Krypton.Toolkit.KryptonTextBox(); + this.kryptonLabel1 = new Krypton.Toolkit.KryptonLabel(); + this.kryptonLabel2 = new Krypton.Toolkit.KryptonLabel(); + this.txtTgid = new Krypton.Toolkit.KryptonTextBox(); + this.kryptonLabel3 = new Krypton.Toolkit.KryptonLabel(); + this.btnUpdate = new Krypton.Toolkit.KryptonButton(); + this.kryptonLabel4 = new Krypton.Toolkit.KryptonLabel(); + this.txtZoneName = new Krypton.Toolkit.KryptonTextBox(); + this.cmbSystems = new Krypton.Toolkit.KryptonComboBox(); + this.kryptonLabel6 = new Krypton.Toolkit.KryptonLabel(); + this.EncryptionKey = new Krypton.Toolkit.KryptonTextBox(); + this.kryptonCheckBox1 = new Krypton.Toolkit.KryptonCheckBox(); + this.btnGen = new Krypton.Toolkit.KryptonButton(); + this.kryptonLabel5 = new Krypton.Toolkit.KryptonLabel(); + this.kryptonLabel7 = new Krypton.Toolkit.KryptonLabel(); + this.EncryptionMode = new Krypton.Toolkit.KryptonComboBox(); + this.EncryptionType = new Krypton.Toolkit.KryptonComboBox(); + ((System.ComponentModel.ISupportInitialize)(this.cmbSystems)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.EncryptionMode)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.EncryptionType)).BeginInit(); + this.SuspendLayout(); + // + // txtName + // + this.txtName.Location = new System.Drawing.Point(193, 53); + this.txtName.Margin = new System.Windows.Forms.Padding(2); + this.txtName.Name = "txtName"; + this.txtName.Size = new System.Drawing.Size(108, 23); + this.txtName.TabIndex = 2; + this.txtName.Text = "kryptonTextBox1"; + this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged); + // + // kryptonLabel1 + // + this.kryptonLabel1.Location = new System.Drawing.Point(98, 54); + this.kryptonLabel1.Margin = new System.Windows.Forms.Padding(2); + this.kryptonLabel1.Name = "kryptonLabel1"; + this.kryptonLabel1.Size = new System.Drawing.Size(88, 20); + this.kryptonLabel1.TabIndex = 1; + this.kryptonLabel1.Values.Text = "System Name:"; + this.kryptonLabel1.Click += new System.EventHandler(this.kryptonLabel1_Click); + // + // kryptonLabel2 + // + this.kryptonLabel2.Location = new System.Drawing.Point(98, 88); + this.kryptonLabel2.Margin = new System.Windows.Forms.Padding(2); + this.kryptonLabel2.Name = "kryptonLabel2"; + this.kryptonLabel2.Size = new System.Drawing.Size(85, 20); + this.kryptonLabel2.TabIndex = 2; + this.kryptonLabel2.Values.Text = "System Select"; + // + // txtTgid + // + this.txtTgid.Location = new System.Drawing.Point(193, 123); + this.txtTgid.Margin = new System.Windows.Forms.Padding(2); + this.txtTgid.Name = "txtTgid"; + this.txtTgid.Size = new System.Drawing.Size(108, 23); + this.txtTgid.TabIndex = 4; + this.txtTgid.Text = "kryptonTextBox1"; + this.txtTgid.TextChanged += new System.EventHandler(this.txtTgid_TextChanged); + // + // kryptonLabel3 + // + this.kryptonLabel3.Location = new System.Drawing.Point(108, 123); + this.kryptonLabel3.Margin = new System.Windows.Forms.Padding(2); + this.kryptonLabel3.Name = "kryptonLabel3"; + this.kryptonLabel3.Size = new System.Drawing.Size(65, 20); + this.kryptonLabel3.TabIndex = 4; + this.kryptonLabel3.Values.Text = "Talkgroup"; + this.kryptonLabel3.Click += new System.EventHandler(this.kryptonLabel3_Click); + // + // btnUpdate + // + this.btnUpdate.Location = new System.Drawing.Point(165, 306); + this.btnUpdate.Margin = new System.Windows.Forms.Padding(2); + this.btnUpdate.Name = "btnUpdate"; + this.btnUpdate.Size = new System.Drawing.Size(116, 28); + this.btnUpdate.TabIndex = 5; + this.btnUpdate.Values.Text = "Update"; + this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click); + // + // kryptonLabel4 + // + this.kryptonLabel4.Location = new System.Drawing.Point(110, 23); + this.kryptonLabel4.Margin = new System.Windows.Forms.Padding(2); + this.kryptonLabel4.Name = "kryptonLabel4"; + this.kryptonLabel4.Size = new System.Drawing.Size(77, 20); + this.kryptonLabel4.TabIndex = 8; + this.kryptonLabel4.Values.Text = "Zone Name:"; + // + // txtZoneName + // + this.txtZoneName.Location = new System.Drawing.Point(193, 22); + this.txtZoneName.Margin = new System.Windows.Forms.Padding(2); + this.txtZoneName.Name = "txtZoneName"; + this.txtZoneName.Size = new System.Drawing.Size(108, 23); + this.txtZoneName.TabIndex = 1; + this.txtZoneName.Text = "kryptonTextBox1"; + // + // cmbSystems + // + this.cmbSystems.DropDownWidth = 216; + this.cmbSystems.IntegralHeight = false; + this.cmbSystems.Location = new System.Drawing.Point(193, 88); + this.cmbSystems.Margin = new System.Windows.Forms.Padding(2); + this.cmbSystems.Name = "cmbSystems"; + this.cmbSystems.Size = new System.Drawing.Size(108, 22); + this.cmbSystems.StateCommon.ComboBox.Content.TextH = Krypton.Toolkit.PaletteRelativeAlign.Near; + this.cmbSystems.TabIndex = 3; + this.cmbSystems.Text = "kryptonComboBox1"; + this.cmbSystems.SelectedIndexChanged += new System.EventHandler(this.cmbSystems_SelectedIndexChanged); + // + // kryptonLabel6 + // + this.kryptonLabel6.Location = new System.Drawing.Point(82, 240); + this.kryptonLabel6.Margin = new System.Windows.Forms.Padding(2); + this.kryptonLabel6.Name = "kryptonLabel6"; + this.kryptonLabel6.Size = new System.Drawing.Size(91, 20); + this.kryptonLabel6.TabIndex = 10; + this.kryptonLabel6.Values.Text = "Encryption Key"; + // + // EncryptionKey + // + this.EncryptionKey.Location = new System.Drawing.Point(187, 240); + this.EncryptionKey.Margin = new System.Windows.Forms.Padding(2); + this.EncryptionKey.Name = "EncryptionKey"; + this.EncryptionKey.PaletteMode = Krypton.Toolkit.PaletteMode.ProfessionalSystem; + this.EncryptionKey.Size = new System.Drawing.Size(465, 23); + this.EncryptionKey.TabIndex = 17; + this.EncryptionKey.Text = " EncryptionKey"; + this.EncryptionKey.TextChanged += new System.EventHandler(this.EncryptionKey_TextChanged); + // + // kryptonCheckBox1 + // + this.kryptonCheckBox1.Location = new System.Drawing.Point(193, 268); + this.kryptonCheckBox1.Name = "kryptonCheckBox1"; + this.kryptonCheckBox1.Size = new System.Drawing.Size(53, 20); + this.kryptonCheckBox1.TabIndex = 13; + this.kryptonCheckBox1.Values.Text = "Show"; + this.kryptonCheckBox1.CheckedChanged += new System.EventHandler(this.kryptonCheckBox1_CheckedChanged); + // + // btnGen + // + this.btnGen.Location = new System.Drawing.Point(657, 240); + this.btnGen.Name = "btnGen"; + this.btnGen.Size = new System.Drawing.Size(90, 25); + this.btnGen.TabIndex = 14; + this.btnGen.Values.Text = "Generate Key"; + this.btnGen.Click += new System.EventHandler(this.btnGen_Click); + // + // kryptonLabel5 + // + this.kryptonLabel5.Location = new System.Drawing.Point(79, 161); + this.kryptonLabel5.Margin = new System.Windows.Forms.Padding(2); + this.kryptonLabel5.Name = "kryptonLabel5"; + this.kryptonLabel5.Size = new System.Drawing.Size(104, 20); + this.kryptonLabel5.TabIndex = 18; + this.kryptonLabel5.Values.Text = "Encryption Mode"; + // + // kryptonLabel7 + // + this.kryptonLabel7.Location = new System.Drawing.Point(85, 200); + this.kryptonLabel7.Margin = new System.Windows.Forms.Padding(2); + this.kryptonLabel7.Name = "kryptonLabel7"; + this.kryptonLabel7.Size = new System.Drawing.Size(98, 20); + this.kryptonLabel7.TabIndex = 19; + this.kryptonLabel7.Values.Text = "Encryption Type"; + // + // EncryptionMode + // + this.EncryptionMode.DropDownWidth = 216; + this.EncryptionMode.IntegralHeight = false; + this.EncryptionMode.Location = new System.Drawing.Point(187, 161); + this.EncryptionMode.Margin = new System.Windows.Forms.Padding(2); + this.EncryptionMode.Name = "EncryptionMode"; + this.EncryptionMode.Size = new System.Drawing.Size(108, 22); + this.EncryptionMode.StateCommon.ComboBox.Content.TextH = Krypton.Toolkit.PaletteRelativeAlign.Near; + this.EncryptionMode.TabIndex = 20; + this.EncryptionMode.Text = "EncryptionMode"; + // + // EncryptionType + // + this.EncryptionType.DropDownWidth = 216; + this.EncryptionType.IntegralHeight = false; + this.EncryptionType.Location = new System.Drawing.Point(187, 200); + this.EncryptionType.Margin = new System.Windows.Forms.Padding(2); + this.EncryptionType.Name = "EncryptionType"; + this.EncryptionType.Size = new System.Drawing.Size(108, 22); + this.EncryptionType.StateCommon.ComboBox.Content.TextH = Krypton.Toolkit.PaletteRelativeAlign.Near; + this.EncryptionType.TabIndex = 21; + this.EncryptionType.Text = "EncryptionType"; + this.EncryptionType.SelectedIndexChanged += new System.EventHandler(this.EncryptionType_SelectedIndexChanged); + // + // DataForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1007, 409); + this.Controls.Add(this.EncryptionType); + this.Controls.Add(this.EncryptionMode); + this.Controls.Add(this.kryptonLabel7); + this.Controls.Add(this.kryptonLabel5); + this.Controls.Add(this.btnGen); + this.Controls.Add(this.kryptonCheckBox1); + this.Controls.Add(this.EncryptionKey); + this.Controls.Add(this.kryptonLabel6); + this.Controls.Add(this.cmbSystems); + this.Controls.Add(this.kryptonLabel4); + this.Controls.Add(this.txtZoneName); + this.Controls.Add(this.btnUpdate); + this.Controls.Add(this.txtTgid); + this.Controls.Add(this.kryptonLabel3); + this.Controls.Add(this.kryptonLabel2); + this.Controls.Add(this.kryptonLabel1); + this.Controls.Add(this.txtName); + this.Margin = new System.Windows.Forms.Padding(2); + this.Name = "DataForm"; + this.Text = "DataForm"; + ((System.ComponentModel.ISupportInitialize)(this.cmbSystems)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.EncryptionMode)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.EncryptionType)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Krypton.Toolkit.KryptonTextBox txtName; + private Krypton.Toolkit.KryptonLabel kryptonLabel1; + private Krypton.Toolkit.KryptonLabel kryptonLabel2; + private Krypton.Toolkit.KryptonTextBox txtTgid; + private Krypton.Toolkit.KryptonLabel kryptonLabel3; + private Krypton.Toolkit.KryptonButton btnUpdate; + private Krypton.Toolkit.KryptonLabel kryptonLabel4; + private Krypton.Toolkit.KryptonTextBox txtZoneName; + private Krypton.Toolkit.KryptonComboBox cmbSystems; + private Krypton.Toolkit.KryptonLabel kryptonLabel6; + private Krypton.Toolkit.KryptonTextBox EncryptionKey; + private Krypton.Toolkit.KryptonCheckBox kryptonCheckBox1; + private Krypton.Toolkit.KryptonButton btnGen; + private Krypton.Toolkit.KryptonLabel kryptonLabel5; + private Krypton.Toolkit.KryptonLabel kryptonLabel7; + private Krypton.Toolkit.KryptonComboBox EncryptionMode; + private Krypton.Toolkit.KryptonComboBox EncryptionType; + } } \ No newline at end of file diff --git a/Whackerlink CPS/DataForm.cs b/Whackerlink CPS/DataForm.cs index df32ea7..c06c1ab 100644 --- a/Whackerlink CPS/DataForm.cs +++ b/Whackerlink CPS/DataForm.cs @@ -1,115 +1,259 @@ -/* -* WhackerLink - WhackerLink-CPS -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* Copyright (C) 2024 Hanna Johnson (Elleran) -* -*/ - -using System; -using System.Collections.Generic; -using System.Windows.Forms; - -namespace Whackerlink_CPS -{ - - - public partial class DataForm : Form - { - public event EventHandler ChannelUpdated; - private TreeNode _selectedNode; - private List _systems; - private List _systemIds; - - public DataForm(TreeNode selectedNode, List systems, List systemIds) - { - InitializeComponent(); - _selectedNode = selectedNode; - _systems = systems; - _systemIds = systemIds; - LoadSystems(); - LoadNodeData(); - } - - private void LoadSystems() - { - cmbSystems.DataSource = _systems; - // You might want to use _systemIds for another control or logic - } - public void SetTgid(string tgid) - { - txtTgid.Text = tgid; - } - private void btnUpdate_Click(object sender, EventArgs e) - { - if (_selectedNode != null) - { - string originalChannelName = _selectedNode.Text; - - _selectedNode.Text = txtName.Text; - var channelData = _selectedNode.Tag as Codeplug.Channel ?? new Codeplug.Channel(); - channelData.System = cmbSystems.SelectedItem.ToString(); - channelData.Tgid = txtTgid.Text; - - _selectedNode.Tag = channelData; - _selectedNode.Parent.Text = txtZoneName.Text; - - ChannelUpdated?.Invoke(this, new ChannelUpdatedEventArgs - { - OriginalChannelName = originalChannelName, - ChannelName = txtName.Text, - SystemName = channelData.System, - Tgid = channelData.Tgid, - ZoneName = txtZoneName.Text - }); - - this.DialogResult = DialogResult.OK; - } - } - private void LoadNodeData() - { - if (_selectedNode != null) - { - txtName.Text = _selectedNode.Text; - if (_selectedNode.Tag is Codeplug.Channel channelData) - { - cmbSystems.SelectedItem = channelData.System; - } - txtTgid.Text = Properties.Settings.Default.Tgid; - if (_selectedNode.Parent != null) - { - txtZoneName.Text = _selectedNode.Parent.Text; - } - } - } - public void InvokeUpdateButton() - { - btnUpdate.PerformClick(); - } - public class ChannelUpdatedEventArgs : EventArgs - { - public string OriginalChannelName { get; set; } - public string ChannelName { get; set; } - public string SystemName { get; set; } - public string Tgid { get; set; } - public string ZoneName { get; set; } - } - - private void DataForm_Load(object sender, EventArgs e) - { - - } - } -} \ No newline at end of file +/* +* WhackerLink - WhackerLink-CPS +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* Copyright (C) 2024 Hanna Johnson (Elleran) +* +*/ + +using System; +using System.Collections.Generic; +using System.Security.Cryptography; +using System.Windows.Forms; +using Krypton.Toolkit; + +namespace Whackerlink_CPS +{ + public partial class DataForm : Form + { + public event EventHandler ChannelUpdated; + private TreeNode _selectedNode; + private List _systems; + private List _systemIds; + + public DataForm(TreeNode selectedNode, List systems, List systemIds) + { + InitializeComponent(); + _selectedNode = selectedNode; + _systems = systems; + _systemIds = systemIds; + LoadSystems(); + LoadNodeData(); + EncryptionType.Items.Add("None"); + EncryptionType.Items.Add("AES-256"); + EncryptionType.SelectedIndex = 0; + EncryptionType.SelectedIndexChanged += EncryptionType_SelectedIndexChanged; + EncryptionMode.Items.Add("Strapped"); + EncryptionMode.Items.Add("Selectable"); + EncryptionMode.SelectedIndex = 0; + EncryptionMode.SelectedIndexChanged += EncryptionType_SelectedIndexChanged; + + + + EncryptionKey.Enabled = false; + btnGen.Enabled = false; + kryptonCheckBox1.Enabled = false; + + + + EncryptionKey.UseSystemPasswordChar = true; + } + + private void LoadSystems() + { + cmbSystems.DataSource = _systems; + } + + public void SetTgid(string tgid) + { + txtTgid.Text = tgid; + } + + + + private void btnUpdate_Click(object sender, EventArgs e) + { + if (_selectedNode != null) + { + string originalChannelName = _selectedNode.Text; + + + _selectedNode.Text = txtName.Text; + + + var channelData = _selectedNode.Tag as Codeplug.Channel ?? new Codeplug.Channel(); + + + channelData.Name = txtName.Text; + channelData.System = cmbSystems.SelectedItem?.ToString() ?? string.Empty; + channelData.Tgid = txtTgid.Text; + channelData.EncryptionKey = EncryptionKey.Text; + channelData.EncryptionMode = EncryptionMode.SelectedItem?.ToString() ?? string.Empty; + channelData.EncryptionType = EncryptionType.SelectedItem?.ToString() ?? string.Empty; + + + _selectedNode.Tag = channelData; + + + if (_selectedNode.Parent != null) + { + txtZoneName.Text = _selectedNode.Parent.Text; + } + + + ChannelUpdated?.Invoke(this, new ChannelUpdatedEventArgs + { + OriginalChannelName = originalChannelName, + ChannelName = channelData.Name, + SystemName = channelData.System, + Tgid = channelData.Tgid, + ZoneName = txtZoneName.Text, + EncryptionMode = channelData.EncryptionMode, + EncryptionType = channelData.EncryptionType, + EncryptionKey = channelData.EncryptionKey, + }); + + + this.DialogResult = DialogResult.OK; + } + } + + + private void LoadNodeData() + { + if (_selectedNode != null) + { + txtName.Text = _selectedNode.Text; + if (_selectedNode.Tag is Codeplug.Channel channelData) + { + cmbSystems.SelectedItem = channelData.System; + + } + txtTgid.Text = Properties.Settings.Default.Tgid; + if (_selectedNode.Parent != null) + { + txtZoneName.Text = _selectedNode.Parent.Text; + } + } + } + + public void InvokeUpdateButton() + { + btnUpdate.PerformClick(); + + } + + public class ChannelUpdatedEventArgs : EventArgs + { + public string OriginalChannelName { get; set; } + public string ChannelName { get; set; } + public string SystemName { get; set; } + public string Tgid { get; set; } + public string ZoneName { get; set; } + public string EncryptionMode { get; set; } + public string EncryptionType { get; set; } + public string EncryptionKey { get; set; } + } + + private void DataForm_Load(object sender, EventArgs e) + { + } + + private void btnGen_Click(object sender, EventArgs e) + { + + using (var rng = new RNGCryptoServiceProvider()) + { + byte[] key = new byte[32]; + rng.GetBytes(key); + + + EncryptionKey.Text = BitConverter.ToString(key).Replace("-", ""); + } + } + + private void EncryptionKey_TextChanged(object sender, EventArgs e) + { + Console.WriteLine("AES-256 Key Updated: " + EncryptionKey.Text); + } + + private void kryptonCheckBox1_CheckedChanged(object sender, EventArgs e) + { + EncryptionKey.UseSystemPasswordChar = !kryptonCheckBox1.Checked; + } + + + + + private void cmbSystems_SelectedIndexChanged(object sender, EventArgs e) + { + if (cmbSystems.SelectedItem != null) + { + string selectedSystem = cmbSystems.SelectedItem.ToString(); + Console.WriteLine("Selected System: " + selectedSystem); + } + } + + private void kryptonLabel1_Click(object sender, EventArgs e) + { + + } + + private void txtName_TextChanged(object sender, EventArgs e) + { + + } + + private void kryptonLabel3_Click(object sender, EventArgs e) + { + + } + + private void txtTgid_TextChanged(object sender, EventArgs e) + { + + } + + private void EncryptionType_SelectedIndexChanged(object sender, EventArgs e) + { + if (EncryptionType.SelectedItem != null) + { + string selectedOption = EncryptionType.SelectedItem.ToString(); + + if (selectedOption == "None") + { + EncryptionKey.Text = string.Empty; + EncryptionKey.Enabled = false; + btnGen.Enabled = false; + kryptonCheckBox1.Enabled = false; + EncryptionMode.Enabled = false; + EncryptionMode.Items.Add("Clear"); + EncryptionMode.SelectedItem = "Clear"; + + } + else if (selectedOption == "AES-256") + { + EncryptionKey.Enabled = true; + btnGen.Enabled = true; + kryptonCheckBox1.Enabled = true; + EncryptionMode.Enabled = true; + EncryptionMode.Items.Remove("Clear"); + EncryptionMode.SelectedItem = "Strapped"; + + + + + + } + } + } + + + private void kryptonRichTextBox1_TextChanged(object sender, EventArgs e) + { + + } + } +} diff --git a/Whackerlink CPS/DataForm.resx b/Whackerlink CPS/DataForm.resx index 1af7de1..29dcb1b 100644 --- a/Whackerlink CPS/DataForm.resx +++ b/Whackerlink CPS/DataForm.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/Whackerlink CPS/Resources/BackgroundImage.jpg b/Whackerlink CPS/Resources/BackgroundImage.jpg index 948f87a..aa2bc12 100644 Binary files a/Whackerlink CPS/Resources/BackgroundImage.jpg and b/Whackerlink CPS/Resources/BackgroundImage.jpg differ