コード例 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="colorName"></param>
 /// <param name="colorCode"></param>
 /// <param name="significantFigure"></param>
 /// <param name="multiplier"></param>
 /// <param name="tolerancePercent"></param>
 public ResistorColor(RingColor colorName, string colorCode, UInt16?significantFigure, Int16?multiplier, Single?tolerancePercent)
 {
     ColorName         = colorName;
     ColorCode         = colorCode;
     SignificantFigure = significantFigure;
     Multiplier        = multiplier;
     TolerancePercent  = tolerancePercent;
 }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: Grog84/TowerOfHanoi
        public void Pin(PinDataHandler pinData, Transform ringTransform)
        {
            RingDataHandler ringData  = ringTransform.GetComponent <RingDataHandler>();
            RingColor       ringColor = dh.GetRingColor(ringData);

            int pinOccupation = dh.GetPinOccupationValue(pinData);

            if (pinOccupation > (int)ringColor)     // ring in a wrong spot
            {
                dh.SetWrongOccupation(pinData, ringData, gameStatus);
            }
            else
            {
                if (gameStatus.GetIntValue("targetPinID") == pinData.GetID() && pinData.GetTopStackValue() == (int)RingColor.GREEN && pinData.GetStackLength() == 4)
                {
                    dh.SetVictory(pinData, ringData, gameStatus);
                }
                else
                {
                    dh.SetRightOccupation(pinData, ringData, gameStatus);
                }
            }
        }
コード例 #3
0
ファイル: DonutChart.cs プロジェクト: ntfnd404/SVGChart
        public override void UpdateSvg(XmlDocument document, IEnumerable items)
        {
            try
            {
                var elements = (IEnumerable <Tuple <int, string> >)items;

                var offset         = 25;
                var previousOffset = -1;
                var previousSpace  = -1;

                var root = document.DocumentElement.GetElementsByTagName("g").Cast <XmlElement>().LastOrDefault();

                var donutNode = root.GetElementsByTagName("circle").Cast <XmlElement>()
                                .FirstOrDefault(x => x.HasAttribute("class") && x.Attributes["class"].Value == "donut-hole");

                var donutAttr = donutNode.Attributes;
                donutAttr["fill"].Value = FillColor.ToHex();

                var ringNode = root.GetElementsByTagName("circle").Cast <XmlElement>()
                               .FirstOrDefault(x => x.HasAttribute("class") && x.Attributes["class"].Value == "donut-ring");

                var ringAttr = ringNode.Attributes;
                ringAttr["stroke-width"].Value = StrokeWidth.ToString();
                ringAttr["stroke"].Value       = RingColor.ToHex();

                var segmentNodeToCopy = root.GetElementsByTagName("circle").Cast <XmlElement>()
                                        .FirstOrDefault(x => x.HasAttribute("class") && x.Attributes["class"].Value == "donut-segment");


                var centerTextNode = root.GetElementsByTagName("text").Cast <XmlElement>()
                                     .FirstOrDefault(x => x.HasAttribute("class") && x.Attributes["class"].Value == "center-text");

                centerTextNode.InnerText = CharTitle;

                var textAttr = centerTextNode.Attributes;
                textAttr["fill"].Value = TitleColor.ToHex();

                foreach (var el in elements)
                {
                    if (el.Item1 < 0)
                    {
                        continue;
                    }

                    var newnode = segmentNodeToCopy.CloneNode(true);
                    var attr    = newnode.Attributes;
                    attr["stroke-width"].Value = StrokeWidth.ToString();
                    attr["stroke"].Value       = el.Item2;

                    var spaceDash = 100 - el.Item1;
                    attr["stroke-dasharray"].Value = $"{ el.Item1 }, { spaceDash }";

                    var newOffset = (previousOffset < 0) ? offset : (previousOffset + previousSpace);
                    if (newOffset > 100)
                    {
                        newOffset -= 100;
                    }

                    attr["stroke-dashoffset"].Value = newOffset.ToString();
                    root.InsertAfter(newnode, root.LastChild);

                    previousOffset = newOffset;
                    previousSpace  = spaceDash;
                }

                root.RemoveChild(segmentNodeToCopy);
            }
            catch (InvalidCastException ex) {
                throw new ItemsSourceException("ItemsSource for Donut chart must to be a collection of values and colors IEnumerable<Tuple<int,string>>", ex);
            }
        }
コード例 #4
0
 public void RemoveFromCollisionList(RingColor color)
 {
     data.collidingWith.Remove(color);
 }
コード例 #5
0
        // Collision List

        public void AddToCollisionList(RingColor color)
        {
            data.collidingWith.Add(color);
        }
コード例 #6
0
        // Ring Color

        public void SetDataValue(RingColor val)
        {
            data.color = val;
        }