public KSKit(KSKit obj) : this() { if (obj != null) { DirectSocket = new KSSocket(obj.DirectSocket); BridgedSocket = new KSSocket(obj.BridgedSocket); SelectedSocket = obj.SelectedSocket; Code = obj.Code; Description = obj.Description; Url = obj.Url; Photo = obj.Photo; } }
public KSSelector() { dataProvider = new KSDataProvider(); workingKit = null; selectedKit = null; selectionChanged = false; configurationChanged = false; InitializeComponent(); Text = Messages.KS_CAPTION_SELECTOR; dcpNoneSocketEditor1.OnParamChanged = (KSNoneSocketEditor.ParamChanged) Delegate.Combine(dcpNoneSocketEditor1.OnParamChanged, new KSNoneSocketEditor.ParamChanged(OnParamChanged)); dcpSerialSocketEditor1.OnParamChanged = (KSSerialSocketEditor.ParamChanged) Delegate.Combine(dcpSerialSocketEditor1.OnParamChanged, new KSSerialSocketEditor.ParamChanged(OnParamChanged)); dcpTcpIpSocketEditor1.OnParamChanged = (KSTcpIpSocketEditor.ParamChanged) Delegate.Combine(dcpTcpIpSocketEditor1.OnParamChanged, new KSTcpIpSocketEditor.ParamChanged(OnParamChanged)); dcpUsbSocketEditor1.OnParamChanged = (KSUsbSocketEditor.ParamChanged) Delegate.Combine(dcpUsbSocketEditor1.OnParamChanged, new KSUsbSocketEditor.ParamChanged(OnParamChanged)); buttonOk.Enabled = false; }
public bool Add(KSKit kit) { bool flag = false; try { if (kit.IsValid() && (Find(kit.Code) == null)) { kits.Add(kit); MoveTo(CursorStep.CursorLast); isModified = true; flag = true; } } catch (Exception) { } return flag; }
public bool Update(KSKit kit) { try { for (int i = 0; i < kits.Count; i++) if (kits[i].Code == kit.Code) { kits[i] = kit; isModified = true; return true; } } catch (Exception) { } return false; }
public KSSelector(string dbkFile, KSKit selKit) : this() { Configure(dbkFile, selKit); }
private void LookUpKit(KSKit kit) { errorProvider1.SetError(linkLabelUrl, ""); linkLabelUrl.Visible = false; pictureBoxKitPhoto.Image = workingKit.Photo; labelKitDescription.Text = workingKit.Description; linkLabelUrl.Visible = workingKit.Url != ""; comboBoxActiveSocket.Items.Clear(); comboBoxActiveSocket.Items.Add(KSSocketAvailable.Direct); if (kit.BridgedSocket.Protocol.Length > 0) { comboBoxActiveSocket.Items.Add(KSSocketAvailable.Bridged); } comboBoxActiveSocket.SelectedItem = workingKit.SelectedSocket; }
private void FillComboKitCode(KSKit selKit) { KSKit item = null; try { comboBoxKitCode.Items.Clear(); for (item = dataProvider.MoveTo(KSDataProvider.CursorStep.CursorFirst); item != null; item = dataProvider.MoveTo(KSDataProvider.CursorStep.CursorNext)) { if ((selKit != null) && (item.Code == selKit.Code)) { item.DirectSocket.Param = selKit.DirectSocket.Param; item.BridgedSocket.Param = selKit.BridgedSocket.Param; item.SelectedSocket = selectedKit.SelectedSocket; } comboBoxKitCode.Items.Add(item); } comboBoxKitCode.Enabled = !dataProvider.IsEmpty; if (comboBoxKitCode.Items.Contains(selKit)) { comboBoxKitCode.SelectedItem = selKit; } else { comboBoxKitCode.SelectedIndex = comboBoxKitCode.Items.Count - 1; } } catch (Exception) { comboBoxKitCode.Enabled = false; } }
private void KSSelector_Load(object sender, EventArgs e) { selectionChanged = false; configurationChanged = false; workingKit = new KSKit(selectedKit); FillComboKitCode(workingKit); }
private void comboBoxKitCode_SelectedIndexChanged(object sender, EventArgs e) { workingKit = (KSKit) comboBoxKitCode.SelectedItem; LookUpKit(workingKit); }
private void buttonOk_Click(object sender, EventArgs e) { try { selectionChanged = true; configurationChanged = true; if (selectedKit != null) { selectionChanged = workingKit.Code != selectedKit.Code; configurationChanged = workingKit.Socket.Param != selectedKit.Socket.Param; } selectedKit = workingKit; } catch (Exception) { selectionChanged = false; configurationChanged = false; } }
public void Configure(string dbkFile, KSKit selKit) { if (dataProvider.Load(dbkFile)) { selectedKit = selKit; } buttonOk.Enabled = !dataProvider.IsEmpty; }
private void toolStripButtonConfirm_Click(object sender, EventArgs e) { KSKit kit = new KSKit { Code = textBoxCode.Text.Trim().ToUpper(), Description = textBoxDescription.Text, Photo = pictureBoxPhoto.Image, Url = textBoxUrl.Text }; kit.DirectSocket.Type = (KSSocketType) comboBoxDirectSocket.SelectedIndex; kit.DirectSocket.Protocol = textBoxDirectProtocol.Text; kit.BridgedSocket.Type = KSSocketType.TcpIp; kit.BridgedSocket.Protocol = textBoxBridgedProtocol.Text; switch (editorState) { case EditorState.Insert: if (!kitDataProvider.Add(kit)) { MessageBox.Show(Messages.KS_ERROR_ADD, Messages.KS_CAPTION_EDITOR, MessageBoxButtons.OK, MessageBoxIcon.Hand); LookUpKit(kitDataProvider.MoveTo(KSDataProvider.CursorStep.CursorFirst)); break; } LookUpKit(kitDataProvider.MoveTo(KSDataProvider.CursorStep.CursorLast)); break; case EditorState.Modify: if (!kitDataProvider.Update(kit)) { MessageBox.Show(Messages.KS_ERROR_MODIFY, Messages.KS_CAPTION_EDITOR, MessageBoxButtons.OK, MessageBoxIcon.Hand); LookUpKit(kitDataProvider.MoveTo(KSDataProvider.CursorStep.CursorFirst)); } break; } editorState = EditorState.Viewer; UpdateControls(); }
private void LookUpKit(KSKit kit) { ClearForm(); if (kit != null) { textBoxCode.Text = kit.Code; textBoxDescription.Text = kit.Description; pictureBoxPhoto.Image = kit.Photo; textBoxUrl.Text = kit.Url; textBoxDirectProtocol.Text = kit.DirectSocket.Protocol; textBoxBridgedProtocol.Text = kit.BridgedSocket.Protocol; comboBoxDirectSocket.SelectedIndex = (int) kit.DirectSocket.Type; } }