Esempio n. 1
0
        internal SubBone addBone(string pid, string pname, string psort1, string psort2)
        {
            SubBone bone = new SubBone(fish, this)
            {
                id = pid, name = pname, sort1 = psort1, sort2 = psort2
            };

            bones.Add(bone);
            return(bone);
        }
Esempio n. 2
0
        void addleaf(SubBone bone, DataRow dr)
        {
            //select id,sort1,sort2,ord,indexname, definition,IMPORTANT,format,VALUE,UNIT,VALUENOTE,REFER1,REFER2,REFERTYPE,refernote from d_index where SORT0='863' order by sort2ord,IMPORTANT

            SubBone subbone;

            subbone = bone.addBone(dr.Field <string>("id"), dr.Field <string>("indexname"), dr.Field <string>("sort1"), dr.Field <string>("sort2"));

            double.TryParse(dr["value"].ToString(), out subbone.value);
            double.TryParse(dr["refer1"].ToString(), out subbone.ref1);
            double.TryParse(dr["refer2"].ToString(), out subbone.ref2);
            subbone.format     = dr["format"].ToString();
            subbone.unit       = dr["unit"].ToString();
            subbone.reftype    = dr.Field <string>("refertype");
            subbone.definition = dr.Field <string>("definition");
            subbone.refnote    = dr.Field <string>("refernote");
        }
Esempio n. 3
0
        internal override void cal()
        {
            //计算自身骨长度和子骨长度
            len = parent.subMaxLen;

            subMaxLen = parent.len * 0.8 / (parent.bones.Count + 1);
            //计算方向
            RotateTransform r;

            if (isFirstLayer)
            {
                //if (idx % 2 == 1)
                isUp = idx < parent.bones.Count / 2;
                if (isUp)
                {
                    r = new RotateTransform(fish.para.boneAngle);
                }
                else
                {
                    r = new RotateTransform(-fish.para.boneAngle);
                }
            }
            else
            {
                isUp = (parent as SubBone).isUp;
                if (isUp)
                {
                    r = new RotateTransform(-fish.para.boneAngle);
                }
                else
                {
                    r = new RotateTransform(fish.para.boneAngle);
                }
            }

            direct = (Vector)r.Transform((Point)parent.direct);

            //计算位置from
            Vector vec = parent.to - parent.from;

            vec.Normalize();
            if (isFirstLayer)
            {
                double div = parent.len / (parent.bones.Count) * 2;
                if (isUp)
                {
                    from = parent.from + div * idx * vec;
                }
                else
                {
                    from = parent.from + div * (int)(idx - parent.bones.Count / 2) * vec;
                }
                from2 = from + fish.para.FirstLayerBoneThickness * vec;

                froma  = from + 4 * vec;
                froma2 = from2 - 4 * vec;
            }
            else
            {
                double div = parent.len / (parent.bones.Count + 1);
                from = parent.from + div * (idx + 1) * vec;
                //计算在弧形上的起点 (x-a)²+(y-b)²=r²
                SubBone pb = parent as SubBone;
                double  zr = parent.len * 1.5;
                double  zy = from.Y;
                double  zx = Math.Sqrt(zr * zr - (zy - pb.center.Y) * (zy - pb.center.Y)) + pb.center.X;
                from = new Point(zx - 2, zy);
            }
            //计算位置to
            to  = from + len * direct;
            toa = from + 0.8 * len * direct;

            //求弧形圆心, 供子级使用
            double cr = len * 1.5;
            double cx = len / 2;
            double cy = Math.Sqrt(cr * cr - cx * cx);

            if (isUp)
            {
                r = new RotateTransform(-90);
            }
            else
            {
                r = new RotateTransform(90);
            }
            Vector cv1 = to - from;

            cv1.Normalize();
            Vector cv2 = (Vector)r.Transform((Point)cv1);
            Point  cp1 = from + 0.5 * len * direct;

            center = cp1 + cy * cv2;



            //设置填充
            if (isFirstLayer)
            {
                if (isUp)
                {
                    branchBrush = fish.para.UpBranchBrush;
                }
                else
                {
                    branchBrush = fish.para.DownBranchBrush;
                }
            }
            else
            {
                branchBrush = fish.para.noramlBranchBrush;
            }


            //计算业务逻辑
            isWarning = false;
            if (!isFirstLayer)
            {
                switch (reftype)
                {
                case ">":
                    isWarning = value < ref1;
                    break;

                case "<":
                    isWarning = value > ref1;
                    break;

                case "<>":
                    isWarning = value <ref1 || value> ref2;
                    break;

                case "><":
                    isWarning = value > ref1 && value < ref2;
                    break;
                }

                if (isWarning)
                {
                    branchBrush = fish.para.warningBranchBrush;
                    nameBrush   = fish.para.warningNameBrush;
                    valueBrush  = fish.para.warningValueBrush;
                }
            }


            //子级
            int ord = 0;

            foreach (SubBone bon in bones)
            {
                bon.layer     = layer + 1;
                bon.thickness = fish.para.LeafBoneThickness;
                bon.idx       = ord++;
                bon.cal();
            }
        }