Esempio n. 1
0
        public double?GetTagValue(string tagName)
        {
            tagvalue = tagName + "1";

            try
            {
                CalTag result = null;
                if (this.MyCalOrg != null)
                {
                    result = MyCalOrg.GetTag(tagName);
                }
                else if (MyModel != null)
                {
                    result = MyModel.GetTag(tagName);
                }
                tagvalue = tagName + "2";

                if (result != null)
                {
                    return(result.TagValue);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(tagvalue + "标签计算数值出错" + ex.ToString());
                return(0);
            }
        }
Esempio n. 2
0
        public CalTag GetTag(string tagName)
        {
            if (string.IsNullOrEmpty(tagName))
            {
                return(null);
            }

            CalTag result = null;

            string[] spilts = tagName.Split('.');

            int splitIdx = tagName.IndexOf('.');

            bool   findTag    = false;
            string subTagName = tagName;

            if (splitIdx == -1) //如果找不到分隔符表明这是一个标签
            {
                foreach (var item in CalTags)
                {
                    if (item.TagName == tagName)
                    {
                        result  = item;
                        findTag = true;
                        break;
                    }
                }
            }
            else if (splitIdx > 0)
            {
                string subOrgName = tagName.Substring(0, splitIdx);
                foreach (var subOrg in ChildCalOrgs)
                {
                    if (subOrg.OrgName == subOrgName)
                    {
                        subTagName = tagName.Substring(splitIdx + 1, tagName.Length - splitIdx - 1);
                        result     = subOrg.GetTag(subTagName);
                        findTag    = true;
                        break;
                    }
                }
            }
            else //第一个字符是 .  或 没有找到下级目录 到上级目录查找
            {
                subTagName = tagName.Substring(1, tagName.Length - 1);
            }
            if (!findTag)
            {
                if (this.ParentCalOrg != null)
                {
                    result = ParentCalOrg.GetTag(subTagName);
                }
                else if (MyModel != null)
                {
                    result = MyModel.GetTag(subTagName);
                }
            }

            return(result);
        }
Esempio n. 3
0
        public List <CalTag> GetChildTags()
        {
            List <CalTag> subTags = new List <CalTag>();

            if (this.MyCalOrg != null)
            {
                foreach (var item in this.MyCalOrg.ChildCalOrgs)
                {
                    CalTag subTag = item.GetTag(this.TagName);
                    if (subTag != null)
                    {
                        subTags.Add(subTag);
                    }
                }
            }
            else if (this.MyModel != null)
            {
                foreach (var item in this.MyModel.RootOrgs)
                {
                    CalTag subTag = item.GetTag(this.TagName);
                    if (subTag != null)
                    {
                        subTags.Add(subTag);
                    }
                }
            }
            return(subTags);
        }
Esempio n. 4
0
        public void DownIdx(CalTag calTag)
        {
            int idx = _calTags.IndexOf(calTag);

            if (idx >= 0 && idx < _calTags.Count - 1)
            {
                _calTags.Remove(calTag);
                _calTags.Insert(idx + 1, calTag);
            }
        }
Esempio n. 5
0
        public void UpIdx(CalTag calTag)
        {
            int idx = _calTags.IndexOf(calTag);

            if (idx > 0)
            {
                _calTags.Remove(calTag);
                _calTags.Insert(idx - 1, calTag);
            }
        }
Esempio n. 6
0
        public double GetTagValue(string tagName)
        {
            CalTag tag = GetTag(tagName);

            if (tag != null)
            {
                return(tag.TagValue);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 7
0
        public CalTag GetBrotherTag(string tagName)
        {
            CalTag brotherTag = null;

            if (this.MyCalOrg != null)
            {
                brotherTag = this.MyCalOrg.GetTag(tagName);
            }

            if (brotherTag == null && this.MyModel != null)
            {
                brotherTag = this.MyModel.GetTag(tagName);
            }
            return(brotherTag);
        }
Esempio n. 8
0
        public CalTag AddTag(string tagName)
        {
            foreach (var item in RootTags)
            {
                if (item.TagName == tagName)
                {
                    System.Windows.Forms.MessageBox.Show("相同目录下已有此标签:" + tagName);
                    break;
                }
            }
            CalTag tag = new CalTag();

            tag.EID     = Guid.NewGuid().ToString();
            tag.TagName = tagName;
            tag.MyModel = this;
            AllCalTags.Add(tag);
            RootTags.Add(tag);
            return(tag);
        }
Esempio n. 9
0
        public double?GetNullTagValue(string tagName)
        {
            CalTag tag = GetTag(tagName);

            if (tag != null)
            {
                double result = tag.TagValue;
                if (result == 0)
                {
                    return(null);
                }
                else
                {
                    return(result);
                }
            }
            else
            {
                return(null);
            }
        }
Esempio n. 10
0
        public void AddTag(string tagName)
        {
            CalTag tag = new CalTag(this, tagName);

            CalTags.Add(tagName, tag);
        }
Esempio n. 11
0
        //public string TagName
        //{
        //    get
        //    {
        //        return component.TagName;
        //    }
        //    set
        //    {
        //        component.TagName = value;
        //    }
        //}

        //public double TagValue
        //{
        //    get
        //    {
        //        return component.TagValue;
        //    }
        //    set
        //    {
        //        component.TagValue = value;
        //    }
        //}

        //public bool CalFinished
        //{
        //    get
        //    {
        //        return component.CalFinished;
        //    }
        //    set
        //    {
        //        component.CalFinished = value;
        //    }
        //}

        public CalTagDecorator(CalTag tag)
        {
            this.component = tag;
        }
Esempio n. 12
0
 public void RemoveTag(CalTag tag)
 {
     this.CalTags.Remove(tag);
     tag.MyModel.AllCalTags.Remove(tag);
 }
Esempio n. 13
0
        public CalTag GetTag(string tagName)
        {
            string shortTagName = tagName;
            CalOrg myOrg        = null;

            if (tagName.Contains("."))
            {
                string[] items = tagName.Split('.');
                for (int i = 0; i < items.Length - 1; i++)
                {
                    if (myOrg == null)
                    {
                        foreach (var org in this.RootOrgs)
                        {
                            if (org.OrgName == items[i])
                            {
                                myOrg = org;
                                break;
                            }
                        }
                    }
                    else
                    {
                        foreach (var org in myOrg.ChildCalOrgs)
                        {
                            if (org.OrgName == items[i])
                            {
                                myOrg = org;
                                break;
                            }
                        }
                    }
                }
                shortTagName = items[items.Length - 1];
            }
            CalTag result = null;

            if (myOrg == null)
            {
                foreach (var item in this.RootTags)
                {
                    if (item.TagName == shortTagName)
                    {
                        result = item;
                        break;
                    }
                }
                //if (result == null)
                //    result = this.AddTag(shortTagName);
            }
            else
            {
                foreach (var item in myOrg.CalTags)
                {
                    if (item.TagName == shortTagName)
                    {
                        result = item;
                        break;
                    }
                }
                //if (result == null)
                //    result = myOrg.AddTag(shortTagName);
            }

            return(result);
        }
Esempio n. 14
0
 public void RemoveTag(CalTag tag)
 {
     RootTags.Remove(tag);
     AllCalTags.Remove(tag);
 }
Esempio n. 15
0
 public FormaCal(CalTag tag)
     : base(tag)
 {
 }
Esempio n. 16
0
 public AggregateCal(CalTag tag)
     : base(tag)
 {
 }