예제 #1
0
    /// <summary>
    /// 刷新组件列表
    /// </summary>
    private void RefreshCom()
    {
        tag_comPropertys.Clear();
        m_pComProperty.Clear();
        Utils.RemoveChildren(m_objRoot.transform);

        // 加载组件配置
        LoadCompConfig((js) => {
            ReadCompDataForUI(js);
            for (int i = 0; i < m_pComProperty.Count; i++)
            {
                List <ComProperty> pComProperty;
                ComProperty cpp = m_pComProperty[i];
                string strTag   = cpp.m_strTag;
                pComProperty    = tag_comPropertys.ContainsKey(strTag) ? tag_comPropertys[strTag] : new List <ComProperty>();
                pComProperty.Add(cpp);
                tag_comPropertys.AddOrReplace(strTag, pComProperty);
            }
            List <string> pTags = new List <string>(tag_comPropertys.Keys);

            m_strCurTag  = "";
            m_currentCom = null;

            // 通知UI,刷新组件列表
            Message msg = new Message(MsgType.MainView_RefreshTag, this);
            msg["tags"] = pTags;
            msg.Send();
        });
    }
예제 #2
0
        private void OnComCloseSucc()
        {
            ComProperty objComP = this._ComManager.GetComProperty();

            DoNotice((objComP != null) ? string.Format("串口({0})已关闭", objComP.PortName) : string.Format("串口已关闭"));
            DoStopSucc();
        }
예제 #3
0
 private void OnComOpenSucc()
 {
     if (this._ComManager.GetComProperty() != null)
     {
         ComProperty objComProperty = (ComProperty)this._ComManager.GetComProperty().Clone();
     }
     DoStartSucc();
 }
예제 #4
0
 /// <summary>
 /// 开启
 /// </summary>
 /// <param name="objPortProperty">串口配置</param>
 public void Start(ComProperty objPortProperty)
 {
     if (objPortProperty != null)
     {
         objPortProperty.Encoding  = this._CurrentEncoding;
         objPortProperty.DtrEnable = DtrEnable;
         objPortProperty.RtsEnable = RtsEnable;
     }
     this._ComManager.OpenCom(objPortProperty);
 }
예제 #5
0
 /// <summary>
 /// 选择组件
 /// </summary>
 /// <param name="_cpp"></param>
 private void ComItemClick(ComProperty _cpp)
 {
     txt_id.text      = _cpp.m_strCode;
     ipt_comName.text = _cpp.m_strShowName;
     ipt_tag.text     = _cpp.m_strTag;
     txt_imgName.text = _cpp.m_strImg;
     txt_file.text    = _cpp.m_strModelName;
     ResManager.Instance.OnLoadServerTexure(_cpp.m_strImg, _cpp.m_strImgCrc, (_tx) => {
         img_com.sprite = Sprite.Create(_tx, new Rect(0, 0, _tx.width, _tx.height), Vector2.zero);
     });
 }
예제 #6
0
    /// <summary>
    /// 新组件
    /// </summary>
    /// <param name="_msg"></param>
    private void NewComp(Message _msg)
    {
        m_currentCom = null;
        m_rNewImg    = null;
        m_rNewModel  = null;

        ComProperty newCom = new ComProperty();

        m_currentCom = newCom;
        m_pComProperty.Add(newCom);
    }
예제 #7
0
    /// <summary>
    /// 选择组件
    /// </summary>
    /// <param name="_msg"></param>
    private void ComItemClick(Message _msg)
    {
        ComProperty cpp = _msg["com"] as ComProperty;

        m_currentCom = cpp;

        m_rNewImg   = null;
        m_rNewModel = null;

        // 载入组件
        LoadCompModelFromServer(cpp.m_strModelName, cpp.m_strModelCrc);
    }
예제 #8
0
    /// <summary>
    /// 解析组件配置,提取组件属性
    /// </summary>
    /// <param name="_strJson"></param>
    private void ReadCompDataForUI(string _strJson)
    {
        m_pComProperty = new List <ComProperty>();

        JsonData ConfigJD = JsonMapper.ToObject(_strJson);

        // 所有组件分类
        for (int i = 0; i < ConfigJD.Count; ++i)
        {
            JsonData    classJD = ConfigJD[i];
            ComProperty cpp     = new ComProperty(classJD);
            m_pComProperty.Add(cpp);
        }
    }
예제 #9
0
    /// <summary>
    /// 刷新组件
    /// </summary>
    /// <param name="_msg"></param>
    private void RefreshComList(Message _msg)
    {
        CleanUI();

        m_pComProperty = _msg["coms"] as List <ComProperty>;

        int nLength = m_nComp * m_pComProperty.Count;

        Utils.RemoveChildren(comGrid);

        RectTransform rtf = comGrid.GetComponent <RectTransform>();

        rtf.sizeDelta = new Vector2(nLength, rtf.sizeDelta.y);

        for (int i = 0; i < m_pComProperty.Count; i++)
        {
            GameObject  comItem = GameObject.Instantiate(m_objComPrefabs);
            ComProperty cpp     = m_pComProperty[i];
            Button      btn     = comItem.GetComponent <Button>();
            Image       img     = comItem.GetComponent <Image>();
            btn.onClick.AddListener(() => {
                if (m_strCurCom.Equals(cpp.m_strCode))
                {
                    return;
                }
                m_strCurCom = cpp.m_strCode;

                ComItemClick(cpp);

                Message msg = new Message(MsgType.MainView_ComItemClick, this);
                msg["com"]  = cpp;
                msg.Send();
            });
            string strTips = string.Format("Code:{0}", cpp.m_strCode);
            Text   txt     = comItem.GetComponentInChildren <Text>();
            txt.text = strTips;
            ResManager.Instance.OnLoadServerTexure(cpp.m_strImg, cpp.m_strImgCrc, (_tx) => {
                if (img != null)
                {
                    img.sprite = Sprite.Create(_tx, new Rect(0, 0, _tx.width, _tx.height), Vector2.zero);
                }
            });
            comItem.transform.SetParent(comGrid);
        }
    }
예제 #10
0
    /// <summary>
    /// 修改,新增到服务器
    /// </summary>
    /// <param name="_msg"></param>
    private void SaveToServer(Message _msg)
    {
        string strNewTag      = _msg["tag"] as string;
        string strNewShowName = _msg["name"] as string;

        m_currentCom.OnAffirm(m_rNewModel, m_rNewImg, strNewTag, strNewShowName);

        // 遍历所有的需要更新的组件
        m_pMemeryRes.Clear();
        m_qUpdateComp   = new Queue <CompConfigData>();
        code_CompConfig = new Dictionary <string, CompConfigData>();
        m_pUpdateErComp = new List <CompConfigData>();

        for (int i = 0; i < m_pComProperty.Count; i++)
        {
            ComProperty cpp = m_pComProperty[i];
            if (cpp.m_bNeedUpdate)
            {
                CompConfigData ccd = new CompConfigData();
                ccd.m_jsData  = cpp.m_infoJson;
                ccd.m_strCode = cpp.m_strCode;
                m_qUpdateComp.Enqueue(ccd);
                code_CompConfig.AddOrReplace(ccd.m_strCode, ccd);

                if (cpp.m_rNewImg != null)
                {
                    m_pMemeryRes.Add(cpp.m_rNewImg);
                }
                if (cpp.m_rNewModel != null)
                {
                    m_pMemeryRes.Add(cpp.m_rNewModel);
                }
            }
        }

        // 先上传资源,再上传配置
        UpdateRes(() => {
            UpdateCompConfig(() => {
                // 刷新列表
                RefreshCom();
            });
        });
    }
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            //Invoke Com Api method to process outcomes
            ComProperty oCom    = new ComProperty();
            string      comData = string.Format("<objects xmlns='nsAction'><object name='pobuddywager.buddywager'><actions xmlns='nsAction'><sbmovetoticker newsid='{0}'/></actions></object></objects>", nNewsID);
            string      sResult = oCom.InvokeMember(Config.ComApi, Config.ComApiCreateRemind, 0, 0, DateTime.Now, comData, "", "");

            if (sResult == null)
            {
                lblInfo.ForeColor = Color.Red;
                lblInfo.Text      = "Com Error occured.";
                return;
            }

            int nRes     = 0;
            int nEventID = GetParamInt(Config.ParamEventID);

            if (nEventID <= 0)
            {
                nEventID = Utils.GetInt(hdnEventID.Value);
            }

            string strNewsDate = "";

            if (nEventID > 0)
            {
                SqlCommand             oCmd    = DBase.GetCommand(Config.DbSaveEventNewsDetails);
                SqlParameterCollection oParams = oCmd.Parameters;

                oParams.Add("@EventNewsID", nNewsID);
                oParams.Add("@EventID", nEventID);
                oParams.Add("@Subject", txtSubject.Text);
                oParams.Add("@Body", txtBody.Text);
                SqlParameter oParam = new SqlParameter("@NewsDate", System.Data.SqlDbType.DateTime);
                oParam.Direction = ParameterDirection.Output;
                oParams.Add(oParam);

                nRes        = DBase.ExecuteReturnInt(oCmd);
                strNewsDate = oParams["@NewsDate"].Value.ToString();
            }
            else
            {
                nRes = -10;
            }

            if (nRes > 0)
            {
                hdnNewsID.Value = nRes.ToString();
                StoreBackID(nRes);
                lblDate.Text = strNewsDate;

                lblInfo.ForeColor = Color.Green;
                lblInfo.Text      = "News details have been saved";

                Response.Redirect(GetGoBackUrl());
            }
            else
            {
                switch (nRes)
                {
                case -10:
                    lblInfo.Text = "Not specified event! (Parameter error)";
                    break;

                case 0:
                    lblInfo.Text = "Database error occured";
                    break;

                default:
                    lblInfo.Text = "Unknown error occured";
                    break;
                }
            }
        }