コード例 #1
0
 private void UserControl_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Escape)
     {
         BLLCommon.CloseWaitWindow(false);
     }
 }
コード例 #2
0
 private void splashWindow_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
 {
     if (e.Key == Key.Escape)
     {
         BLLCommon.CloseWaitWindow(false);
     }
 }
コード例 #3
0
        public void FuncAction(object dtObject, byte eventType)
        {
            DataTable dt = dtObject as DataTable;

            //使用ui元素

            if (dt.Rows.Count >= 1)
            {
                BLLCommon.CloseWaitWindow(false);
                GetServerData(dt, eventType);
            }
            else
            {
                BLLCommon.CloseWaitWindow(false);
                DXMessageBox.Show("当前查询模块没有数据,请确保DTU连接正常或者下位机工作正常!", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #4
0
ファイル: ViewModel.cs プロジェクト: wuhudage/BMSCloud_Client
        private void SendControl()
        {
            if (socketClient != null)
            {
                List <byte> sendControl = new List <byte> {
                    0x7E, 0x27, 0x00, 0x46, 0x45, 0x00, 0x04
                };
                sendControl.Add(infoFlag);
                sendControl.Add(0x00);
                sendControl.Add(0x80);
                if (false)
                {
                    //sendControl.Add(0x10);
                }
                else
                {
                    sendControl.Add(0x1f);
                }
                int sumControl = 0;
                for (int i = 1; i < sendControl.Count; i++)
                {
                    sumControl += sendControl[i];
                }
                sendControl.Add(Convert.ToByte(sumControl & 0x00ff));
                sendControl.Add(0x0D);

                BLLCommon.SendToServer(CS_AskReply.ClientControl, Properties.Settings.Default.DTUIndex, 0xff, 0xff, sendControl.ToArray());
            }
            infoFlag++;
            if (infoFlag == 0xA4)
            {
                infoFlag = 0xA1;
                _timer.Dispose();
                System.Windows.Application.Current.Dispatcher.Invoke(new Action(delegate()
                {
                    BLLCommon.CloseWaitWindow(false);
                    DXMessageBox.Show("已下发紧急操作命令!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                }));
            }
        }
コード例 #5
0
ファイル: ViewModel.cs プロジェクト: wuhudage/BMSCloud_Client
        public void SocketEventHandler(object sender, EventArgs e)
        {
            SocketEvent evt = e as SocketEvent;

            if (evt == null)
            {
                return;
            }
            switch (evt.eventType)
            {
            case SocketEventType.StartEvent:

                break;

            case SocketEventType.ConnectEvent:

                break;

            case SocketEventType.ReceEvent:
                byte remark = evt.remark;
                if (remark == CS_AskReply.ClientReplyGroup)
                {
                    if (modelIndex == 2 || modelIndex == 4)
                    {
                        if (FuncDoAction != null)
                        {
                            System.Windows.Application.Current.Dispatcher.Invoke(FuncDoAction, evt.message, remark);
                        }
                    }
                }
                else if (remark == CS_AskReply.ClientReplyPackStatus)
                {
                    if (modelIndex == 2 || modelIndex == 4)
                    {
                        if (FuncDoAction != null)
                        {
                            System.Windows.Application.Current.Dispatcher.Invoke(FuncDoAction, evt.message, remark);
                        }
                    }
                }
                else if (remark == CS_AskReply.ClientReplyGroupStatus)
                {
                    if (modelIndex == 1)
                    {
                        if (FuncDoAction != null)
                        {
                            System.Windows.Application.Current.Dispatcher.Invoke(FuncDoAction, evt.message, remark);
                        }
                    }
                }
                else if (remark == CS_AskReply.ClientReplyPack)
                {
                    if (modelIndex == 3 || modelIndex == 4)
                    {
                        if (FuncDoAction != null)
                        {
                            System.Windows.Application.Current.Dispatcher.Invoke(FuncDoAction, evt.message, remark);
                        }
                    }
                }
                else if (remark == CS_AskReply.ServerAsk)
                {
                    BLLCommon.SendToServer(CS_AskReply.ServerReply, 0xffff, 0xff, 0xff, System.Text.Encoding.ASCII.GetBytes("0n"));
                }
                else if (remark == CS_AskReply.ClientReplyCust)
                {
                    System.Windows.Application.Current.Dispatcher.Invoke(() =>
                    {
                        DataTable dtCust = evt.message as DataTable;
                        foreach (DataRow item in dtCust.Rows)
                        {
                            CustInfoModel CIM = null;
                            for (int i = 0; i < CustListSource.Count; i++)
                            {
                                if (CustListSource[i].CustId == Convert.ToInt32(item["cust_id"]))
                                {
                                    CIM = CustListSource[i];
                                    break;
                                }
                            }

                            if (CIM == null)
                            {
                                CustListSource.Add(new CustInfoModel(
                                                       Convert.ToInt32(item["cust_id"]),
                                                       Convert.ToInt32(item["group_num"]),
                                                       Convert.ToInt32(item["pack_num"]),
                                                       item["cust_name"].ToString(),
                                                       item["cust_status"].ToString(),
                                                       Convert.ToByte(item["cust_fault"])
                                                       ));
                            }
                            else
                            {
                                CIM.CustId     = Convert.ToInt32(item["cust_id"]);
                                CIM.GroupNum   = Convert.ToInt32(item["group_num"]);
                                CIM.PackNum    = Convert.ToInt32(item["pack_num"]);
                                CIM.CustName   = item["cust_name"].ToString();
                                CIM.CustStatus = item["cust_status"].ToString();
                                CIM.CustFault  = Convert.ToByte(item["cust_fault"]);

                                if (CIM.CustId == Properties.Settings.Default.DTUIndex)
                                {
                                    //刷新当前状态栏数据
                                    FuncUpdateStatus(CIM);
                                }
                            }
                        }
                    });
                }
                else
                {
                    System.Windows.Application.Current.Dispatcher.Invoke(() =>
                    {
                        BLLCommon.CloseWaitWindow(true);
                    });
                }

                break;

            case SocketEventType.SendEvent:

                break;

            case SocketEventType.DisconnectEvent:
                if (socketClient != null)
                {
                    socketClient.Stop();
                    if (FuncRefershOffLine != null)
                    {
                        FuncRefershOffLine(true);
                    }
                    socketClient = null;
                    ExcuteTimer.Stop();
                    ExcuteTimerCust.Stop();
                }
                break;

            case SocketEventType.StopEvent:
                break;
            }
        }