コード例 #1
0
        public void init_config(bool _bDisplayProgressBar = true)
        {
            m_is_init = true;

            TcpIpSetting.m_mode_ipversion = 0;
            TcpIpSetting.m_mode_ipaddress = (byte)EnumIPType.DHCP;
            TcpIpSetting.m_ip0            = 0;
            TcpIpSetting.m_ip1            = 0;
            TcpIpSetting.m_ip2            = 0;
            TcpIpSetting.m_ip3            = 0;
            TcpIpSetting.m_mask0          = 0;
            TcpIpSetting.m_mask1          = 0;
            TcpIpSetting.m_mask2          = 0;
            TcpIpSetting.m_mask3          = 0;
            TcpIpSetting.m_gate0          = 0;
            TcpIpSetting.m_gate1          = 0;
            TcpIpSetting.m_gate2          = 0;
            TcpIpSetting.m_gate3          = 0;

            IpInfoRecord m_rec          = null;
            AsyncWorker  worker         = new AsyncWorker(Application.Current.MainWindow);
            string       strPrinterName = ((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter;

            m_printerName = strPrinterName;

            if (_bDisplayProgressBar)
            {
                worker.InvokeMethod <IpInfoRecord>(strPrinterName, ref m_rec, DllMethodType.GetIpInfo, this);
            }
            else
            {
                m_rec = worker.GetIpInfo(strPrinterName);
            }

            if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK)
            {
                byte[] arr = m_rec.Ip.GetAddressBytes();
                TcpIpSetting.m_ip0 = arr[0];
                TcpIpSetting.m_ip1 = arr[1];
                TcpIpSetting.m_ip2 = arr[2];
                TcpIpSetting.m_ip3 = arr[3];

                arr = m_rec.Mask.GetAddressBytes();
                TcpIpSetting.m_mask0 = arr[0];
                TcpIpSetting.m_mask1 = arr[1];
                TcpIpSetting.m_mask2 = arr[2];
                TcpIpSetting.m_mask3 = arr[3];

                arr = m_rec.Gate.GetAddressBytes();
                TcpIpSetting.m_gate0 = arr[0];
                TcpIpSetting.m_gate1 = arr[1];
                TcpIpSetting.m_gate2 = arr[2];
                TcpIpSetting.m_gate3 = arr[3];

                TcpIpSetting.m_mode_ipversion = m_rec.IpVersion;
                TcpIpSetting.m_mode_ipaddress = (byte)m_rec.IpAddressMode;
            }

            string addr_ip   = "";
            string addr_mask = "";
            string addr_gate = "";

            addr_ip += TcpIpSetting.m_ip0.ToString();
            addr_ip += ".";
            addr_ip += TcpIpSetting.m_ip1.ToString();
            addr_ip += ".";
            addr_ip += TcpIpSetting.m_ip2.ToString();
            addr_ip += ".";
            addr_ip += TcpIpSetting.m_ip3.ToString();

            addr_mask += TcpIpSetting.m_mask0.ToString();
            addr_mask += ".";
            addr_mask += TcpIpSetting.m_mask1.ToString();
            addr_mask += ".";
            addr_mask += TcpIpSetting.m_mask2.ToString();
            addr_mask += ".";
            addr_mask += TcpIpSetting.m_mask3.ToString();

            addr_gate += TcpIpSetting.m_gate0.ToString();
            addr_gate += ".";
            addr_gate += TcpIpSetting.m_gate1.ToString();
            addr_gate += ".";
            addr_gate += TcpIpSetting.m_gate2.ToString();
            addr_gate += ".";
            addr_gate += TcpIpSetting.m_gate3.ToString();

            tb_ip.Text   = addr_ip;
            tb_mask.Text = addr_mask;
            tb_gate.Text = addr_gate;

            rdbtn_dhcp.IsChecked = ((byte)EnumIPType.DHCP == TcpIpSetting.m_mode_ipaddress);
            //Add by KevinYin for BMS Bug 56149 begin
            rdbtn_static.IsChecked = !rdbtn_dhcp.IsChecked;
            //Add by KevinYin for BMS Bug 56149 end

            if (true == rdbtn_dhcp.IsChecked)
            {
                tb_ip.IsEnabled   = false;
                tb_gate.IsEnabled = false;
                tb_mask.IsEnabled = false;
            }
            else
            {
                tb_ip.IsEnabled   = true;
                tb_gate.IsEnabled = true;
                tb_mask.IsEnabled = true;
            }
        }