Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="displaySelectMessage"></param>
        private void DeleteSelectedListViewItem(bool displaySelectMessage)
        {
            ListViewItem lvi = GetSelectedListViewItem();

            if (lvi == null)
            {
                if (displaySelectMessage)
                {
                    SelectListViewItemFirst();
                }
                return;
            }

            DialogResult dr = NUnit.UiKit.UserMessage.Ask(Strings.AreYouSureDelete);

            if (dr == DialogResult.Yes)
            {
                int index = lvi.Index;

                SendItem item = lvi.Tag as SendItem;
                listView1.Items.Remove(lvi);
                App.Default.Config.SendCollection.Remove(item);

                if (this.listView1.Items.Count > 0)
                {
                    if (index >= this.listView1.Items.Count)
                    {
                        index = this.listView1.Items.Count - 1;
                    }
                    this.listView1.SelectedIndices.Clear();
                    this.listView1.SelectedIndices.Add(index);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void menuitem_Click(object sender, EventArgs e)
        {
            ToolStripItem item     = sender as ToolStripItem;
            SendItem      senditem = (SendItem)item.Tag;

            SetSendBytes(senditem.Bytes);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        private void AddSendItemToListView(SendItem item)
        {
            ListViewItem lvi = this.listView1.Items.Add(item.Name);
            string       s   = HexStringConverter.Default.ConvertToObject(item.Bytes).ToString();

            lvi.SubItems.Add(s);
            lvi.Tag = item;
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmSendData  f  = new frmSendData();
            DialogResult dr = f.ShowDialog();

            if (dr == DialogResult.OK)
            {
                SendItem item = f.SendItem;
                App.Default.Config.SendCollection.Add(item);
                AddSendItemToListView(item);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        private void AddSendItemToContextMenu(SendItem item, int no)
        {
            string s = string.Format(
                "{0}: {1}",
                GetNoMenuText(no),
                item.Name);


            ToolStripMenuItem menuitem = new ToolStripMenuItem(s);

            menuitem.Tag    = item;
            menuitem.Click += new EventHandler(menuitem_Click);

            this.contextMenuStrip1.Items.Add(menuitem);
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void SendManage_Click(object sender, EventArgs e)
        {
            frmSendDataManager f = new frmSendDataManager();

            if (f.ShowDialog() == DialogResult.OK)
            {
                SendItem selectedItem = f.SelectedSendItem;
                if (selectedItem != null)
                {
                    SetSendBytes(selectedItem.Bytes);
                }
            }

            CreateContextMenu();
        }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        private void SelectSendItem()
        {
            ListViewItem lvi = GetSelectedListViewItem();

            if (lvi != null)
            {
                SendItem item = lvi.Tag as SendItem;
                this._selectedSendItem = item;

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                SelectListViewItemFirst();
                return;
            }
        }
Exemplo n.º 8
0
        void SendAdd_Click(object sender, EventArgs e)
        {
            byte[] bs;
            if (this.GetSendBytes(out bs))
            {
                SendItem item = new SendItem();

                item.Name  = HexStringConverter.Default.ConvertToObject(bs).ToString();
                item.Bytes = bs;

                frmSendData f = new frmSendData(item);
                if (f.ShowDialog() == DialogResult.OK)
                {
                    this.SendCollection.Add(item);
                    CreateContextMenu();
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sendItem"></param>
        public frmSendData(SendItem sendItem)
        {
            if (sendItem == null)
            {
                throw new ArgumentNullException("sendItem");
            }

            InitializeComponent();

            this.SendItem = sendItem;
            this.IsEdit   = true;

            this.txtName.Text  = this.SendItem.Name;
            this.txtDatas.Text = HexStringConverter.Default.ConvertToObject(this.SendItem.Bytes).ToString();

            this.Text = string.Format(
                "{0} - {1}",
                this.Text,
                Strings.Edit);
        }
Exemplo n.º 10
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            ListViewItem lvi = GetSelectedListViewItem();

            if (lvi == null)
            {
                SelectListViewItemFirst();
                return;
            }

            SendItem     item = lvi.Tag as SendItem;
            frmSendData  f    = new frmSendData(item);
            DialogResult dr   = f.ShowDialog();

            if (dr == DialogResult.OK)
            {
                lvi.Text = item.Name;
                string s = HexStringConverter.Default.ConvertToObject(item.Bytes).ToString();
                lvi.SubItems[1].Text = s;
            }
        }
Exemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        private void CreateContextMenu()
        {
            this.contextMenuStrip1.Items.Clear();

            ToolStripItem m = null;

            m        = this.contextMenuStrip1.Items.Add(Strings.SendDataSave);
            m.Click += new EventHandler(SendAdd_Click);

            m        = this.contextMenuStrip1.Items.Add(Strings.SendDataManage);
            m.Click += new EventHandler(SendManage_Click);

            m = new ToolStripSeparator();
            this.contextMenuStrip1.Items.Add(m);

            for (int i = 0; i < this.SendCollection.Count; i++)
            {
                SendItem si = this.SendCollection[i];
                this.AddSendItemToContextMenu(si, i + 1);
            }
        }