Exemple #1
0
        private bool LoadTemplates(out string message)
        {
            message = string.Empty;
            if (!System.IO.File.Exists(TemplatePath))
            {
                message = "未找到配置文件.";
                return(false);
            }

            System.Xml.XmlDocument xmlConfig = new System.Xml.XmlDocument();
            try
            {
                xmlConfig.Load(TemplatePath);
                XmlNodeList nodeList = xmlConfig["Templates"].SelectNodes("Template");
                foreach (XmlNode node in nodeList)
                {
                    string templateName = node.Attributes["name"].Value;
                    List <clsSTBoardItem> lstBoardItem = new List <clsSTBoardItem>();
                    foreach (XmlNode xn in node.ChildNodes)
                    {
                        if (xn.Name == "BoardItem")
                        {
                            clsSTBoardItem boardItem = new clsSTBoardItem();

                            int sampleNo = 0;
                            try { sampleNo = int.Parse(xn.Attributes["pos"].Value); }
                            catch { sampleNo = -1; }

                            int typeId = 0;
                            try { typeId = int.Parse(xn.Attributes["type"].Value); }
                            catch { typeId = 0; }

                            int sampleStyleNo = 0;
                            try { sampleStyleNo = int.Parse(xn.Attributes["SampleNo"].Value); }
                            catch { sampleStyleNo = 0; }

                            boardItem.Sequence = sampleNo;
                            boardItem.BoardStyle.SampleStyle   = GetSampleType(typeId);
                            boardItem.BoardStyle.SampleStyleNo = sampleStyleNo;
                            if (boardItem.Sequence > 0)
                            {
                                lstBoardItem.Add(boardItem);
                            }
                        }
                    }

                    if (!string.IsNullOrEmpty(templateName) && lstBoardItem.Count > 0)
                    {
                        clsBoardTemplate template = new clsBoardTemplate(templateName, lstBoardItem);
                        m_lstTemplates.Add(template);
                    }
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(false);
            }
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// 模板改变
        /// </summary>
        /// <param name="template"></param>
        public void ChangedTemplate(clsBoardTemplate template)
        {
            foreach (clsSTBoardItem boardItem in m_lstBoardItems)
            {
                bool isChanged = false;
                foreach (clsSTBoardItem tempItem in template.BoardItems)
                {
                    if (boardItem.Sequence == tempItem.Sequence)
                    {
                        boardItem.BoardStyle = tempItem.BoardStyle;
                        isChanged            = true;
                    }
                }

                if (!isChanged)
                {
                    boardItem.BoardStyle.SampleStyle   = enmSTSampleStyle.NONE;
                    boardItem.BoardStyle.SampleStyleNo = 0;
                }
            }

            if (this.DataChanged != null)
            {
                DataChanged(this, new DataChangedEventArgs(enmSTTextBoxShowStatus.BoardStyle));
            }
        }
Exemple #3
0
        private void m_cboTemplate_SelectedIndexChanged(object sender, EventArgs e)
        {
            clsBoardTemplate template = m_cboTemplate.SelectTemplate;

            if (template != null)
            {
                manager.ChangedTemplate(template);
            }
            m_selectTemplate = template;
        }
Exemple #4
0
        private void LoadData()
        {
            clsBoardTemplate template = new clsBoardTemplate("", new List <clsSTBoardItem>());

            this.Items.Add(template);

            List <clsBoardTemplate> lstTemplates = clsST360Config.CurrentConfig.Templates;

            foreach (clsBoardTemplate boardTemplate in lstTemplates)
            {
                this.Items.Add(boardTemplate);
            }
        }
Exemple #5
0
        private void m_cboTemplate_SelectedIndexChanged(object sender, EventArgs e)
        {
            clsBoardTemplate template = m_cboTemplate.SelectTemplate;

            if (template != null)
            {
                foreach (clsSTBoardItem item in m_lstBoard)
                {
                    item.BoardStyle.SampleStyle   = enmSTSampleStyle.NONE;
                    item.BoardStyle.SampleStyleNo = 0;

                    foreach (clsSTBoardItem templateItem in template.BoardItems)
                    {
                        if (item.Sequence == templateItem.Sequence)
                        {
                            clsSTBoardStyle boardStyle = new clsSTBoardStyle();
                            boardStyle.SampleStyle   = templateItem.BoardStyle.SampleStyle;
                            boardStyle.SampleStyleNo = templateItem.BoardStyle.SampleStyleNo;

                            item.BoardStyle = boardStyle;
                        }
                    }
                }

                foreach (ctlSTTextBox boxItem in m_lstSTTextBoxs)
                {
                    foreach (clsSTBoardItem item in m_lstBoard)
                    {
                        if (boxItem.BoardItem.Sequence == item.Sequence)
                        {
                            boxItem.BoardItem.BoardStyle = item.BoardStyle;
                        }
                    }
                }
            }
            m_selectTemplate = template;
        }