Example #1
0
        private void _chipDialog_RefreshTriggerd(object sender, EventArgs e)
        {
            ChipDialog dialog = (ChipDialog)sender;

            Reload(dialog, true);

#if NO
            LogicChipItem chip      = dialog.LogicChipItem;
            ItemInfo      item_info = FindItemInfo(chip, out ListViewItem item);
            if (item_info == null)
            {
                this.ShowMessage("cant find item_info", "red", true);
                _chipDialog.ShowMessage("cant find item_info", "red", true);
                return;
            }

            string uid = Element.GetHexString(item_info.OldInfo.uid);
            if (LoadChipData(uid, item) == true)
            {
                this.ShowMessage("重新装载成功", "green", true);
                _chipDialog.ShowMessage("重新装载成功", "green", true);
            }
            else
            {
                this.ShowMessage("重新装载失败", "red", true);
                _chipDialog.ShowMessage("重新装载失败", "red", true);
            }
#endif
        }
Example #2
0
        private void listView_chips_DoubleClick(object sender, EventArgs e)
        {
            ListViewItem item = this.listView_chips.FocusedItem;

            if (item == null && this.listView_chips.SelectedItems.Count > 0)
            {
                item = this.listView_chips.SelectedItems[0];
            }

            {
                if (_chipDialog == null)
                {
                    _chipDialog                  = new ChipDialog();
                    _chipDialog.FormClosed      += _chipDialog_FormClosed;
                    _chipDialog.SaveTriggerd    += _chipDialog_SaveTriggerd;
                    _chipDialog.RefreshTriggerd += _chipDialog_RefreshTriggerd;
                }

                if (_chipDialog.Visible == false)
                {
                    _chipDialog.Show(this);
                }
            }

            SetChipDialogContent(item, null);
        }
Example #3
0
        void Reload(ChipDialog dialog, bool show_message)
        {
            string strError = "";

            string reader_name = GetCurrentReaderName();

            if (string.IsNullOrEmpty(reader_name))
            {
                strError = "尚未选定当前读卡器";
                goto ERROR1;
            }

            LogicChipItem chip      = dialog.LogicChipItem;
            ItemInfo      item_info = FindItemInfo(chip, out ListViewItem item);

            if (item_info == null)
            {
                if (show_message)
                {
                    strError = "cant find item_info";
                    goto ERROR1;
                }
                return;
            }

            string uid = item_info.OldInfo.UID;

            if (LoadChipData(uid, item) == true)
            {
                if (show_message)
                {
                    this.ShowMessage("重新装载成功", "green", true);
                    _chipDialog.ShowMessage("重新装载成功", "green", true);
                }
            }
            else
            {
                if (show_message)
                {
                    strError = "重新装载失败";
                    goto ERROR1;
                }
            }
            return;

ERROR1:
            this.ShowMessage(strError, "red", true);
            _chipDialog.ShowMessage(strError, "red", true);
        }
Example #4
0
        // TODO: 如何显示保存成功?注意 ChipDialog 可能会遮挡后面显示的文字
        private void _chipDialog_SaveTriggerd(object sender, EventArgs e)
        {
            string strError = "";

            string reader_name = GetCurrentReaderName();

            if (string.IsNullOrEmpty(reader_name))
            {
                strError = "尚未选定当前读卡器";
                goto ERROR1;
            }

            ChipDialog    dialog    = (ChipDialog)sender;
            LogicChipItem chip      = dialog.LogicChipItem;
            ItemInfo      item_info = FindItemInfo(chip, out ListViewItem item);

            if (item_info == null)
            {
                strError = "cant find item_info";
                goto ERROR1;
            }
            TagInfo new_tag_info = BuildNewTagInfo(
                item_info.OldInfo,
                chip);

            NormalResult result = _driver.WriteTagInfo(GetCurrentReaderName(), item_info.OldInfo, new_tag_info);

            if (result.Value == 0)
            {
                this.ShowMessage("保存成功", "green", true);
                _chipDialog.ShowMessage("保存成功", "green", true);

                Reload(dialog, false);
            }
            else
            {
                strError = $"保存失败:{result.ErrorInfo}";
                goto ERROR1;
            }

            return;

ERROR1:
            this.ShowMessage(strError, "red", true);
            _chipDialog.ShowMessage(strError, "red", true);
        }
Example #5
0
 private void _chipDialog_FormClosed(object sender, FormClosedEventArgs e)
 {
     _chipDialog = null;
 }