コード例 #1
0
ファイル: Program.cs プロジェクト: yyscamper/com_owner_spy
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //build "Device Map" from registry
            try
            {
                ComPortControlTable.InitTable();
            }
            catch (Exception err)
            {
                yMessageBox.ShowError(null, err.Message);
                return;
            }

            //load config file
            try
            {
                OwnerTranslate.LoadFromFile();
                AppConfig.LoadGlobalConfig();
                ThemeManager.Init();
            }
            catch //if config file has error, just ignore it, we will use the default setting
            {
            }

            Application.Run(new FormMain());
        }
コード例 #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string domainUser = tboxDomainUser.Text.Trim();

            if (!OwnerEntry.VerifyDomainUser(domainUser))
            {
                yMessageBox.ShowError(this, "Your input Domain\\User is not correct!", "Error Domain\\User");
                return;
            }

            if (OwnerTranslate.Contains(domainUser))
            {
                yMessageBox.ShowError(this, "Your input Domain\\User has existed! Please input different one.");
                return;
            }

            string fullName = tboxOwnerFullName.Text.Trim();

            if (fullName.Length == 0)
            {
                yMessageBox.ShowError(this, "The full name fields should not be empty!");
                return;
            }

            string shortName = tboxOwnerShortName.Text.Trim();

            if (shortName.Length == 0)
            {
                yMessageBox.ShowError(this, "The shot name fields should not be empty!");
                return;
            }

            string phone = tboxOwnerPhone.Text.Trim();

            if (phone.Length == 0)
            {
                yMessageBox.ShowError(this, "The phone fields should not be empty!");
                return;
            }

            OwnerEntry entry = new OwnerEntry(domainUser);

            entry.FullName  = fullName;
            entry.ShortName = shortName;
            entry.Phone     = phone;

            if (_listen != null)
            {
                _listen.OnInputOwnerTranslateCompleted(_mode, entry);
            }

            this.Close();
        }
コード例 #3
0
        private void DeleteOwnerTranslate()
        {
            if (listViewOwnerTranslate.SelectedItems.Count <= 0)
            {
                return;
            }

            if (DialogResult.No == yMessageBox.ShowConfirm(this, "Are your sure want to delete the '" + listViewOwnerTranslate.SelectedItems[0].SubItems[0].Text + "'?", "Delete Owner Translate Confirm", MessageBoxButtons.YesNo))
            {
                return;
            }
            string key = listViewOwnerTranslate.SelectedItems[0].SubItems[0].Text;

            OwnerTranslate.Remove(key);
            OwnerTranslate.SaveToFile();
            RefreshTabOwnerTranslate();
        }
コード例 #4
0
        private void EditOwnerTranslate()
        {
            if (listViewOwnerTranslate.SelectedItems.Count <= 0)
            {
                return;
            }

            string     key = listViewOwnerTranslate.SelectedItems[0].SubItems[0].Text;
            OwnerEntry own = OwnerTranslate.Get(key);

            m_selectedOwner = own;

            FormInputOwnerTranslateItem formInputTranslate =
                new FormInputOwnerTranslateItem(InputOwnerTranslateMode.Edit, this, own);

            formInputTranslate.ShowDialog();
            m_selectedOwner = null;
        }
コード例 #5
0
        public void OnInputOwnerTranslateCompleted(InputOwnerTranslateMode mode, OwnerEntry owner)
        {
            if (mode == InputOwnerTranslateMode.Add)
            {
                OwnerTranslate.Add(owner);
                RefreshTabOwnerTranslate();
                SelectOwnerTranslateVisuable(owner.DomainUser);

                OwnerTranslate.SaveToFile();
            }
            else
            {
                if (m_selectedOwner != null)
                {
                    OwnerTranslate.Remove(m_selectedOwner.DomainUser);
                    OwnerTranslate.Add(owner);
                    RefreshTabOwnerTranslate();
                    SelectOwnerTranslateVisuable(owner.DomainUser);

                    OwnerTranslate.SaveToFile();
                }
            }
        }
コード例 #6
0
        private void RefreshUIData()
        {
            labelSelectPortName.Text = _selPort.PortName;
            labelOwnerName.Text      = OwnerTranslate.GetOwnerShow(OwnerShowFormat.FullName, _selPort.OwnUser)
                                       + " (" + _selPort.OwnUser + ", Phone:"
                                       + OwnerTranslate.GetOwnerShow(OwnerShowFormat.Phone, _selPort.OwnUser)
                                       + ")";

            _allOwnerProcess = new Dictionary <int, List <ComPortItem> >();
            ComPortItem[] allItems = ComPortControlTable.AllItems;
            foreach (ComPortItem item in allItems)
            {
                if (item.OwnProcessId < 0 || item.OwnUser == null || item.OwnUser.Length <= 0)
                {
                    continue;
                }

                if (item.OwnUser == _selPort.OwnUser)
                {
                    if (_allOwnerProcess.ContainsKey(item.OwnProcessId))
                    {
                        List <ComPortItem> lst = _allOwnerProcess[item.OwnProcessId];
                        lst.Add(item);
                    }
                    else
                    {
                        List <ComPortItem> lst = new List <ComPortItem>();
                        lst.Add(item);
                        _allOwnerProcess.Add(item.OwnProcessId, lst);
                    }
                }
            }

            listViewAllOwnProcs.Items.Clear();
            foreach (int key in _allOwnerProcess.Keys)
            {
                List <ComPortItem> lst     = _allOwnerProcess[key];
                StringBuilder      stext   = new StringBuilder();
                string             appName = null;
                bool fst = true;
                foreach (ComPortItem item in lst)
                {
                    if (fst)
                    {
                        appName = item.OwnAppName;
                        fst     = false;
                    }
                    else
                    {
                        stext.Append(", ");
                    }
                    stext.Append(item.PortName);
                }

                AutoSizeLastColumnWidth();

                ListViewItem lvi = new ListViewItem(new string[] { key.ToString(), appName, stext.ToString() });
                lvi.Tag = key;
                listViewAllOwnProcs.Items.Add(lvi);
                if (key == _selPort.OwnProcessId)
                {
                    lvi.Checked   = true;
                    lvi.BackColor = ThemeManager.CurrentTheme.ColorD;
                }
            }
        }