//统计标签
    protected void StatLabel(ServerConnection conn, ProjectInfo projectInfo, LabelTag tag, ref string strError)
    {
        if (tag.PartInfo.PartID == 0)
        {
            return;
        }

        for (int i = 0; i < tag.Items.Length; i++)
        {
            LabelItem item = tag.Items[i];
            if (item.TagName.Length == 2)
            {
                StatPassrate(conn, projectInfo.ProjectID, tag.PartInfo.PartID, ref item.Value[0], ref item.Value[1], ref strError);
            }
            else
            {
                if (item.TagName[0] == "平均合格率" && item.Value[0] < 0)
                {
                    item.Value[0] = StatPassrate(conn, projectInfo.ProjectID, tag.PartInfo.PartID, ref strError);
                    item.Value[0] = (float)Math.Round(item.Value[0] * 100, 1);
                }

                if (item.TagName[0] == "CII指数" && item.Value[0] < 0)
                {
                    item.Value[0] = StatCII(conn, projectInfo.ProjectID, tag.PartInfo.PartID, ref strError);
                }
            }
        }
    }
        public void AddLabels(Label[] labels)
        {
            foreach (Label l in labels) {
                // Set Tag of the label
                LabelTag tag = new LabelTag();
                tag.Left = l.Left;
                tag.Top = l.Top;
                tag.FontSize = l.Font.SizeInPoints;
                tag.Selected = false; // false: Unselected , true: Selected

                // Set Properties
                l.Tag = tag;
                l.Cursor = Cursors.SizeAll;
                l.Visible = _showLabels;
                l.BackColor = Color.Transparent;

                // Set Event Handlers
                l.MouseDown += new MouseEventHandler(Label_MouseDown);
                l.MouseUp += new MouseEventHandler(Label_MouseUp);
                l.MouseMove += new MouseEventHandler(Label_MouseMove);
                l.DoubleClick += new EventHandler(Label_DoubleClick);
            }

            // Add labels to the container
            this.Container.Controls.AddRange(labels);
        }
Exemple #3
0
    //创建Label标签
    protected LabelTag CreateLabelTag(XmlNode nodeTag)
    {
        string strItems = nodeTag.Attributes["Key"].Value;

        string[] arrItem = strItems.Split('|');

        LabelTag tag = new LabelTag();

        tag.PartInfo.PartName = nodeTag.Attributes["PartName"].Value;
        tag.Items             = new LabelItem[arrItem.Length];
        for (int i = 0; i < arrItem.Length; i++)
        {
            if (arrItem[i] == "合格率最值")
            {
                RangeItem item = new RangeItem();
                item.TagName[0] = "最差合格率";
                item.TagName[1] = "最好合格率";
                tag.Items[i]    = item;
            }
            else
            {
                tag.Items[i]            = new LabelItem();
                tag.Items[i].TagName[0] = arrItem[i];
            }
        }
        return(tag);
    }
    //统计CII
    protected void StatCII(ServerConnection conn, ProjectInfo projectInfo, CIIChartTag tag, ref string strError)
    {
        if (tag.PartInfo.PartID == 0)
        {
            return;
        }

        float        fCII     = 0;
        List <float> arrSigma = new List <float>();

        CmdStat.StatCII(conn, projectInfo.ProjectID, tag.PartInfo.PartID, GlobalSession.Period, ref strError, ref fCII, ref arrSigma);
        fCII = (float)Math.Round(fCII, 3);

        //更新相关标签信息
        for (int nTagIndex = 0; nTagIndex < projectInfo.Tags.Length; nTagIndex++)
        {
            if (projectInfo.Tags[nTagIndex].TagName == "Label")
            {
                LabelTag label = (LabelTag)projectInfo.Tags[nTagIndex];

                if (label.PartInfo.PartID == tag.PartInfo.PartID)
                {
                    for (int j = 0; j < label.Items.Length; j++)
                    {
                        if (label.Items[j].TagName[0] == "CII指数")
                        {
                            label.Items[j].Value[0] = fCII;
                        }
                    }
                }
            }
            if (projectInfo.Tags[nTagIndex].TagName == "CIIChart")
            {
                CIIChartTag ciiTag = (CIIChartTag)projectInfo.Tags[nTagIndex];
                ciiTag.AxisX    = new string[arrSigma.Count];
                ciiTag.Passrate = new float[arrSigma.Count];
                for (int i = 0; i < arrSigma.Count; i++)
                {
                    ciiTag.AxisX[i]    = (i + 1).ToString();
                    ciiTag.Passrate[i] = arrSigma[i];
                }
            }
        }
    }
        public Label AddLabel(int x, int y, string text, Color labelBackgroundColor)
        {
            Label newLabel = new Label();
            LabelTag tag = new LabelTag();

            // Deselect All Labels
            DeselectAllLabels();

            // Add this label to the container
            this.Container.Controls.Add(newLabel);

            // Set Properties
            newLabel.Visible = _showLabels;
            newLabel.Font = this.DefaultLabelFont;
            newLabel.ForeColor = CalculateLabelForeColor(labelBackgroundColor);
            newLabel.AutoSize = true;
            newLabel.Text = text;
            newLabel.Left = x - (newLabel.Width / 2);
            newLabel.Top = y - (newLabel.Height / 2);
            newLabel.Padding = new Padding(0);
            newLabel.Cursor = Cursors.SizeAll;

            // Set Tag of the label
            tag.Left = (int)(newLabel.Left / _zoomScale);
            tag.Top = (int)(newLabel.Top / _zoomScale);
            tag.FontSize = newLabel.Font.SizeInPoints / _zoomScale;
            tag.Selected = false; // false: Unselected , true: Selected

            newLabel.Tag = tag;

            // Set Event Handlers
            newLabel.MouseDown += new MouseEventHandler(Label_MouseDown);
            newLabel.MouseUp += new MouseEventHandler(Label_MouseUp);
            newLabel.MouseMove += new MouseEventHandler(Label_MouseMove);
            newLabel.DoubleClick += new EventHandler(Label_DoubleClick);

            // Select The Label
            SelectLabel(newLabel);

            // Fire event
            LabelPropertiesChanged(null, null);

            return newLabel;
        }
 public BoundConditionalGotoStatement(LabelTag label, BoundExpression condition, bool jumpIf = false)
 {
     Label     = label;
     Condition = condition;
     JumpIf    = jumpIf;
 }
    protected void StatPassrate(ServerConnection conn, ProjectInfo projectInfo, PassrateChartTag tag, ref string strError)
    {
        if (tag.PartInfo.PartID == 0)
        {
            return;
        }

        float fAveragePassRate = 0;

        List <DM_ModelPassRate> arrPassrate = CmdStat.StatPassRate(conn, projectInfo.ProjectID, tag.PartInfo.PartID, GlobalSession.Period, ref strError);

        tag.Passrate = new float[arrPassrate.Count];
        tag.AxisX    = new string[arrPassrate.Count];

        int   i    = 0;
        float fMin = 10;
        float fMax = -1;

        foreach (DM_ModelPassRate passrate in arrPassrate)
        {
            fAveragePassRate += passrate.PassRate;
            tag.Passrate[i]   = passrate.PassRate;
            tag.AxisX[i]      = passrate.MeasureDate.ToString("MM/dd/yyyy");
            fMin              = Math.Min(fMin, tag.Passrate[i]);
            fMax              = Math.Max(fMax, tag.Passrate[i]);
            i++;
        }

        if (fMax < 0)
        {
            fMax = 0;
        }
        if (fMin > 1)
        {
            fMin = 1;
        }

        if (arrPassrate.Count > 0)
        {
            fAveragePassRate /= arrPassrate.Count;
            fAveragePassRate  = (float)Math.Round(fAveragePassRate, 3);
        }

        //更新相关标签信息
        for (int nTagIndex = 0; nTagIndex < projectInfo.Tags.Length; nTagIndex++)
        {
            if (projectInfo.Tags[nTagIndex].TagName == "Label")
            {
                LabelTag label = (LabelTag)projectInfo.Tags[nTagIndex];
                if (label.PartInfo.PartID == tag.PartInfo.PartID)
                {
                    for (int j = 0; j < label.Items.Length; j++)
                    {
                        if (label.Items[j].TagName[0] == "平均合格率")
                        {
                            label.Items[j].Value[0] = (float)Math.Round(fAveragePassRate * 100, 1);
                        }
                        else if (label.Items[j].TagName.Length > 1)
                        {
                            if (label.Items[j].TagName[0] == "最差合格率")
                            {
                                label.Items[j].Value[0] = fMin;
                            }
                            if (label.Items[j].TagName[1] == "最好合格率")
                            {
                                label.Items[j].Value[1] = fMax;
                            }
                        }
                    }
                }
            }
        }
    }
Exemple #8
0
 public BoundGotoStatement(LabelTag label)
 {
     Label = label;
 }
Exemple #9
0
 public void Init()
 {
     _labelTag = new LabelTag(new StringNode("Name:"));
 }
Exemple #10
0
 /// <summary>
 /// 测试标签
 /// </summary>
 /// <param name="text">文本(经过格式化)</param>
 /// <param name="origin">原始文本</param>
 /// <param name="regex">正则表达式</param>
 /// <param name="type">目标标签类型</param>
 private void MatchTag(string text, string origin, Regex regex, TagType type)
 {
     if (this.Config.tagregex.TagPairEndTest.IsMatch(text) || this.Config.tagregex.EmptyTest.IsMatch(text) ||
         this.Config.tagregex.ifTagKeyTest.IsMatch(text))
     {
         return;
     }
     TheMatch = regex.Match(text);
     if (TheMatch.Success)
     {
         this.Html = this.Html.Replace(origin, text);
         if (type == TagType._tag_list)
         {
             text = FindFirstListTagStr(text, this.TagList.Count());
         }
         if (type == TagType._tag_command)
         {
             CMDTag tag = new CMDTag(text, origin, Deep, this.Config, this.TagList.Count);
             GetCMD(tag);
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_list)
         {
             if (this is SubListPage)
             {
                 ListTag tag = new ListTag(text, origin, Deep, (this as SubListPage).PageName, this.Config, this.TagList.Count);
                 this.TagList.Add(tag);
             }
             else
             {
                 ListTag tag = new ListTag(text, origin, Deep, this is ItemPage ? (this as ItemPage).PageName : "", this.Config, this.TagList.Count);
                 this.TagList.Add(tag);
             }
         }
         else if (type == TagType._tag_read)
         {
             ReadTag tag = new ReadTag(text, origin, Deep, this.Config, this.TagList.Count);
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_label)
         {
             LabelTag tag = new LabelTag(text, origin, Deep, this is LabelPage ? (this as LabelPage).PageName : "", this.Config, this.TagList.Count);
             tag.LazyLoad();
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_static)
         {
             StaticTag tag = new StaticTag(text, origin, Deep, this is StaticPage ? (this as StaticPage).PageName : "", this.Config, this.TagList.Count);
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_filed)
         {
             FieldTag tag = new FieldTag(text, origin, Deep, this.Config, this.TagList.Count);
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_method)
         {
             MethodTag tag = new MethodTag(text, origin, Deep, this.Config, this.TagList.Count);
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_pager)
         {
             PagerTag tag = new PagerTag(text, origin, Deep, this.Config, this.TagList.Count);
             this.TagList.Add(tag);
         }
         else if (type == TagType._tag_form)
         {
             FormTag tag = new FormTag(text, origin, Deep, this.Config, this.TagList.Count);
             this.TagList.Add(tag);
             this.TagCallBack = "form";
         }
         else if (type == TagType._tag_json)
         {
             JsonTag tag = new JsonTag(text, origin, Deep, this.Config, this.TagList.Count);
             this.TagList.Add(tag);
             this.TagCallBack = "json";
         }
     }
 }
 public BoundLabelStatement(LabelTag label)
 {
     Label = label;
 }