private void btnOK_Click(object sender, EventArgs e) { try { int num = 0; foreach (TreeNode treeNode in this.tvwPanel.Nodes) { if (treeNode.Nodes != null) { foreach (TreeNode treeNode2 in treeNode.Nodes) { if (treeNode2 != null && treeNode2.Checked && (treeNode2.Tag.GetType() == typeof(LedPanel) || treeNode2.Tag.GetType() == typeof(LedPanelCloud))) { num++; } } } } if (num == 0) { MessageBox.Show(this, formMain.ML.GetStr("formPanelSelectForItem_Message_PleaseSelectPanel")); } else { if (this.mode == ExecuteMode.ShareItem) { this.originalItem.SharedItemOfPanelIDs.Clear(); } foreach (TreeNode treeNode3 in this.tvwPanel.Nodes) { if (treeNode3.Nodes != null) { foreach (TreeNode treeNode4 in treeNode3.Nodes) { if (treeNode4 != null && treeNode4.Checked && (treeNode4.Tag.GetType() == typeof(LedPanel) || treeNode4.Tag.GetType() == typeof(LedPanelCloud))) { LedPanel ledPanel = (LedPanel)treeNode4.Tag; if (this.mode == ExecuteMode.CopyItem) { LedItem ledItem = new LedItem(); if (ledPanel.Items == null) { ledPanel.Items = new List <LedItem>(); } int num2 = ledPanel.Items.Count; if (num2 > 0) { foreach (LedItem current in ledPanel.Items) { if (num2 < current.No) { num2 = current.No; } } } num2++; ledItem.TextName = formMain.ML.GetStr("Display_Item") + num2; ledItem.ValueName = ledItem.TextName; ledItem.No = num2; ledItem.ParentPanel = ledPanel; if (this.originalItem != null) { ledItem.Copy(this.originalItem); } ledPanel.AddItem(ledItem); } else if (this.mode == ExecuteMode.CopyPanelItems) { ledPanel.CopyItems(this.originalPanel, formMain.ML.GetStr("Display_Item")); } else if (this.mode == ExecuteMode.ShareItem) { LedSharedItem ledSharedItem = new LedSharedItem(); if (ledPanel.Items == null) { ledPanel.Items = new List <LedItem>(); } ledSharedItem.Share(this.originalItem); ledSharedItem.TextName = this.itemName; ledPanel.AddSharedItem(ledSharedItem); this.originalItem.SharedItemOfPanelIDs.Add(ledPanel.ID); } } } } } if (this.mode == ExecuteMode.ShareItem) { this.originalItem.TextName = this.itemName; this.originalItem.Shared = true; formMain.ledsys.SharedItemNoCounter = 1; } base.DialogResult = DialogResult.OK; base.Close(); } } catch (Exception ex) { MessageBox.Show(this, formMain.ML.GetStr("formPanelSelectForItem_Message_ExceptionError") + ex.Message); } }