Ejemplo n.º 1
0
        public void Validator4(object o)
        {
            HoldsOneElement holder = (HoldsOneElement)o;
            ColorElement    color  = (ColorElement)holder.Element;

            Assert.AreEqual("Red", color.ColorName);
        }
        private static IColorReference ReferenceFromConstructor(IObjectCreationExpression constructorExpression)
        {
            var constructedType = constructorExpression.TypeReference?.Resolve().DeclaredElement as ITypeElement;

            if (constructedType == null)
            {
                return(null);
            }

            var unityColorTypes = UnityColorTypes.GetInstance(constructedType.Module);

            if (!unityColorTypes.IsUnityColorType(constructedType))
            {
                return(null);
            }

            var arguments = constructorExpression.Arguments;

            if (arguments.Count < 3 || arguments.Count > 4)
            {
                return(null);
            }

            Color?color = null;

            if (unityColorTypes.UnityColorType != null && unityColorTypes.UnityColorType.Equals(constructedType))
            {
                var baseColor = GetColorFromFloatARGB(arguments);
                if (baseColor == null)
                {
                    return(null);
                }

                color = baseColor.Item1.HasValue
                    ? Color.FromArgb((int)(255.0 * baseColor.Item1.Value), baseColor.Item2)
                    : baseColor.Item2;
            }
            else if (unityColorTypes.UnityColor32Type != null && unityColorTypes.UnityColor32Type.Equals(constructedType))
            {
                var baseColor = GetColorFromIntARGB(arguments);
                if (baseColor == null)
                {
                    return(null);
                }

                color = baseColor.Item1.HasValue
                    ? Color.FromArgb(baseColor.Item1.Value, baseColor.Item2)
                    : baseColor.Item2;
            }

            if (color == null)
            {
                return(null);
            }

            var colorElement = new ColorElement(color.Value);
            var argumentList = constructorExpression.ArgumentList;

            return(new UnityColorReference(colorElement, constructorExpression, argumentList, argumentList.GetDocumentRange()));
        }
Ejemplo n.º 3
0
        // 色を指定して菌トークンを取り出す
        public Bacteria DrawByColor(ColorElement color)
        {
            var ret = _source.Find(b => b.Color == color && b.IsStrong == false);

            _source.Remove(ret);
            return(ret);
        }
Ejemplo n.º 4
0
        public void Test_CrearElemento()
        {
            ColorElement e = new ColorElement(ColorElement.eColor.YELLOW);

            Assert.AreEqual(ColorElement.eColor.YELLOW.ToString(), e.Color.ToString());
            Assert.AreEqual(ColorElement.eColor.YELLOW, e.Color);
        }
Ejemplo n.º 5
0
        //show damage at a point and make it a certain color
        public void ShowDamage(int _damage, Vector2 _pos, ColorElement _color)
        {
            //make new display object
            GameObject _display = (GameObject)GameObject.Instantiate(_emptyNums, _pos, Quaternion.identity);

            //length of the string representation of the value
            int _length = ((int)_damage).ToString().Length;

            //start to the left of the center for odd digit numbers
            float _startX = 0f - _length / 2 * _spacing;

            //if one digit set at origin
            if (_length == 1)
            {
                _startX = 0;
            }
            //if even digit number adjust spacing
            else if ((_length & 1) == 0)
            {
                _startX += _spacing / 2;
            }

            //create number
            for (int i = 0; i < _length; i++)
            {
                //find digit
                GameObject num    = (GameObject)Resources.Load(_numPath + _damage.ToString().Substring(i, 1));
                GameObject newNum = (GameObject)GameObject.Instantiate(num);
                //set within empty num
                newNum.transform.parent = _display.transform;
                //arrange position based on digit
                newNum.transform.localPosition = new Vector2(_startX + i * _spacing, 0);
                newNum.GetComponent <Renderer>().material.color = CustomColor.GetColor(_color);
            }
        }
Ejemplo n.º 6
0
        public object LoadWithProvidedNameScope(string xaml)
        {
            Element elem = new ColorElement {
                ColorName = "Red"
            };

            return(LoadWithInjectedName(xaml, "InjectedName", elem));
        }
Ejemplo n.º 7
0
 void Awake()
 {
     _color = ColorElement.White;
     //init meter color
     _meterColor = new Color(0.5f, 0.5f, 0.5f);
     //find controller
     _controller = this.GetComponent <PlayerController>();
 }
Ejemplo n.º 8
0
 public override string OnColorClose(ColorElement element)
 {
     if (element.HasParent(ElementType.Link))
     {
         return("");
     }
     return("</span>");
 }
Ejemplo n.º 9
0
 public override string OnColorOpen(ColorElement element)
 {
     return(string.Format("<font color={0}#{1:X2}{2:X2}{3:X2}{0}>",
                          this.Quote,
                          element.Color.Red,
                          element.Color.Green,
                          element.Color.Blue));
 }
Ejemplo n.º 10
0
        public void MarkupExtensionEscapes_TreeValidator(object o)
        {
            var root = (ElementResourceHolder)o;
            var dict = (ElementResourceDictionary)root.Resources;
            var list = (ElementChildren)root.Children;

            ColorElement gray = (ColorElement)dict["gray"];

            Assert.IsNotNull(gray, "gray is null");

            ColorElement red = (ColorElement)dict["{red}"];

            Assert.IsNotNull(red, "red is null");

            ColorElement blue = (ColorElement)dict["{blue}{blue}"];

            Assert.IsNotNull(blue, "blue is null");

            ColorElement green = (ColorElement)dict["green"];

            Assert.IsNotNull(green, "green is null");

            if (list.Count != 18)
            {
                Assert.Fail("Element count is not 18");
            }
            ElementWithTitle ewt;
            HoldsOneElement  hoe;

            for (int i = 0; i < 4; i++)
            {
                hoe = (HoldsOneElement)list[i];
                Assert.AreSame(hoe.Element, gray);
            }
            ewt = (ElementWithTitle)list[4];
            Assert.Equals(ewt.Title, "-- space --");

            for (int i = 5; i < 11; i++)
            {
                hoe = (HoldsOneElement)list[i];
                Assert.AreSame(hoe.Element, red);
            }

            ewt = (ElementWithTitle)list[11];
            Assert.Equals(ewt.Title, "{This is a spacer}");

            hoe = (HoldsOneElement)list[12];
            Assert.AreSame(hoe.Element, blue);

            ewt = (ElementWithTitle)list[13];
            Assert.Equals(ewt.Title, "\\{This is a spacer\\}");

            for (int i = 14; i < 18; i++)
            {
                hoe = (HoldsOneElement)list[i];
                Assert.AreSame(hoe.Element, green);
            }
        }
Ejemplo n.º 11
0
        //for determining weights of color
        public static ColorElement Weights(ColorElement _color)
        {
            float _rand = 0;

            switch (_color)
            {
            case ColorElement.Red:
                return(ColorElement.Red);

            case ColorElement.Green:
                return(ColorElement.Green);

            case ColorElement.Blue:
                return(ColorElement.Blue);

            case ColorElement.Yellow:
                _rand = Random.Range(0f, 1f);
                return(_rand >= 0.5f ? ColorElement.Red : ColorElement.Green);

            case ColorElement.Cyan:
                _rand = Random.Range(0f, 1f);
                return(_rand >= 0.5f ? ColorElement.Green : ColorElement.Blue);

            case ColorElement.Magenta:
                _rand = Random.Range(0f, 1f);
                return(_rand >= 0.5f ? ColorElement.Red : ColorElement.Blue);

            case ColorElement.Orange:
                _rand = Random.Range(0f, 1f);
                return(_rand >= 0.25f ? ColorElement.Red : ColorElement.Green);

            case ColorElement.Chartreuse:
                _rand = Random.Range(0f, 1f);
                return(_rand >= 0.75f ? ColorElement.Red : ColorElement.Green);

            case ColorElement.Spring:
                _rand = Random.Range(0f, 1f);
                return(_rand >= 0.25f ? ColorElement.Green : ColorElement.Blue);

            case ColorElement.Azure:
                _rand = Random.Range(0f, 1f);
                return(_rand >= 0.75f ? ColorElement.Green : ColorElement.Blue);

            case ColorElement.Rose:
                _rand = Random.Range(0f, 1f);
                return(_rand >= 0.25f ? ColorElement.Red : ColorElement.Blue);

            case ColorElement.Violet:
                _rand = Random.Range(0f, 1f);
                return(_rand >= 0.75f ? ColorElement.Red : ColorElement.Blue);

            case ColorElement.White:
                return(ColorElement.White);
            }
            return(ColorElement.Black);
        }
Ejemplo n.º 12
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as ProdCharacteristic;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Height != null)
            {
                dest.Height = (Hl7.Fhir.Model.Quantity)Height.DeepCopy();
            }
            if (Width != null)
            {
                dest.Width = (Hl7.Fhir.Model.Quantity)Width.DeepCopy();
            }
            if (Depth != null)
            {
                dest.Depth = (Hl7.Fhir.Model.Quantity)Depth.DeepCopy();
            }
            if (Weight != null)
            {
                dest.Weight = (Hl7.Fhir.Model.Quantity)Weight.DeepCopy();
            }
            if (NominalVolume != null)
            {
                dest.NominalVolume = (Hl7.Fhir.Model.Quantity)NominalVolume.DeepCopy();
            }
            if (ExternalDiameter != null)
            {
                dest.ExternalDiameter = (Hl7.Fhir.Model.Quantity)ExternalDiameter.DeepCopy();
            }
            if (ShapeElement != null)
            {
                dest.ShapeElement = (Hl7.Fhir.Model.FhirString)ShapeElement.DeepCopy();
            }
            if (ColorElement != null)
            {
                dest.ColorElement = new List <Hl7.Fhir.Model.FhirString>(ColorElement.DeepCopy());
            }
            if (ImprintElement != null)
            {
                dest.ImprintElement = new List <Hl7.Fhir.Model.FhirString>(ImprintElement.DeepCopy());
            }
            if (Image != null)
            {
                dest.Image = new List <Hl7.Fhir.Model.Attachment>(Image.DeepCopy());
            }
            if (Scoring != null)
            {
                dest.Scoring = (Hl7.Fhir.Model.CodeableConcept)Scoring.DeepCopy();
            }
            return(dest);
        }
        private static IColorReference ReferenceFromInvocation(IReferenceExpression qualifier,
                                                               IReferenceExpression methodReferenceExpression)
        {
            var invocationExpression = InvocationExpressionNavigator.GetByInvokedExpression(methodReferenceExpression);

            if (invocationExpression == null || invocationExpression.Arguments.IsEmpty)
            {
                return(null);
            }

            var methodReference = methodReferenceExpression.Reference;

            var name = methodReference.GetName();

            if (!string.Equals(name, "HSVToRGB", StringComparison.Ordinal))
            {
                return(null);
            }

            var arguments = invocationExpression.Arguments;

            if (arguments.Count < 3 || arguments.Count > 4)
            {
                return(null);
            }

            var color = GetColorFromHSV(arguments);

            if (color == null)
            {
                return(null);
            }

            var qualifierType = qualifier.Reference.Resolve().DeclaredElement as ITypeElement;

            if (qualifierType == null)
            {
                return(null);
            }

            var unityColorTypes = UnityColorTypes.GetInstance(qualifierType.Module);

            if (!unityColorTypes.IsUnityColorTypeSupportingHSV(qualifierType))
            {
                return(null);
            }

            var colorElement = new ColorElement(color.Value);
            var argumentList = invocationExpression.ArgumentList;

            return(new UnityColorReference(colorElement, invocationExpression,
                                           argumentList, argumentList.GetDocumentRange()));
        }
Ejemplo n.º 14
0
    public CardControl CreateCard(MeatType type, ColorElement color, Guid ID)
    {
        var view = Instantiate(_cardPrefab).GetComponent <CardControl>();

        view.ModelID = ID;
        view.Color   = color;
        view.Type    = type;

        var position = transform.position;

        position.z -= 1f;
        view.transform.position = position;

        return(view);
    }
Ejemplo n.º 15
0
        //get color based on enum element
        public static Color GetColor(ColorElement _color)
        {
            switch (_color)
            {
            case ColorElement.Red:
                return(new Color(1f, 0f, 0f));

            case ColorElement.Green:
                return(new Color(0f, 1f, 0f));

            case ColorElement.Blue:
                return(new Color(0f, 0f, 1f));

            case ColorElement.Yellow:
                return(new Color(1f, 1f, 0f));

            case ColorElement.Cyan:
                return(new Color(0f, 1f, 1f));

            case ColorElement.Magenta:
                return(new Color(1f, 0f, 1f));

            case ColorElement.Orange:
                return(new Color(1f, 0.5f, 0f));

            case ColorElement.Chartreuse:
                return(new Color(0.5f, 1f, 0f));

            case ColorElement.Spring:
                return(new Color(0f, 1f, 0.5f));

            case ColorElement.Azure:
                return(new Color(0f, 0.5f, 1f));

            case ColorElement.Rose:
                return(new Color(1f, 0f, 0.5f));

            case ColorElement.Violet:
                return(new Color(0.5f, 0f, 1f));

            case ColorElement.White:
                return(new Color(1f, 1f, 1f));

            case ColorElement.Black:
                return(new Color(0f, 0f, 0f));
            }
            return(new Color(0f, 0f, 0f));
        }
Ejemplo n.º 16
0
        public void Test_CrearFilaDeElementos()
        {
            ColorElement e1 = new ColorElement(ColorElement.eColor.BLACK);
            ColorElement e2 = new ColorElement(ColorElement.eColor.GREEN);
            ColorElement e3 = new ColorElement(ColorElement.eColor.ORANGE);
            ColorElement e4 = new ColorElement(ColorElement.eColor.YELLOW);

            RowElements row = new RowElements();

            row.AddElement(e1);
            row.AddElement(e2);
            row.AddElement(e3);
            row.AddElement(e4);

            Assert.AreEqual(4, row.GetElements().Count);
        }
Ejemplo n.º 17
0
        public override string OnColorOpen(ColorElement element)
        {
            if (element.HasParent(ElementType.Link))
            {
                return("");
            }
            if (this._style == TextStyle.Strip)
            {
                return("<span>");
            }
            Color color = element.Color;

            if (this._style == TextStyle.Invert)
            {
                color = _invert(color);
            }
            return(string.Format("<span style=\"color: #{0:X2}{1:X2}{2:X2}\">",
                                 color.Red, color.Green, color.Blue));
        }
Ejemplo n.º 18
0
 public IColorReference GetColorReference(ITreeNode element)
 {
     if (element is IColorLiteral colorLiteral)
     {
         var values = colorLiteral.Numbers;
         if (values.Count == 3 || values.Count == 4)
         {
             var r = GetColorValue(values[0]);
             var g = GetColorValue(values[1]);
             var b = GetColorValue(values[2]);
             // Technically, the colour should have 4 values, but show the highlight even if we're unfinished
             var a            = values.Count == 4 ? GetColorValue(values[3]) : 255;
             var colorElement = new ColorElement(Color.FromArgb(a, r, g, b));
             var range        = GetDocumentRange(values[0], values.Last());
             return(new ShaderLabColorReference(colorElement,
                                                ColorPropertyValueNavigator.GetByColor(colorLiteral),
                                                ColorValueNavigator.GetByConstant(colorLiteral), range));
         }
     }
     return(null);
 }
        private static IColorReference ReferenceFromProperty(IReferenceExpression qualifier,
                                                             IReferenceExpression colorQualifiedMemberExpression)
        {
            var name = colorQualifiedMemberExpression.Reference.GetName();

            var color = UnityNamedColors.Get(name);

            if (color == null)
            {
                return(null);
            }

            var qualifierType = qualifier.Reference.Resolve().DeclaredElement as ITypeElement;

            if (qualifierType == null)
            {
                return(null);
            }

            var unityColorTypes = UnityColorTypes.GetInstance(qualifierType.Module);

            if (!unityColorTypes.IsUnityColorTypeSupportingProperties(qualifierType))
            {
                return(null);
            }

            var property = colorQualifiedMemberExpression.Reference.Resolve().DeclaredElement as IProperty;

            if (property == null)
            {
                return(null);
            }

            var colorElement = new ColorElement(color.Value, name);

            return(new UnityColorReference(colorElement, colorQualifiedMemberExpression,
                                           colorQualifiedMemberExpression, colorQualifiedMemberExpression.NameIdentifier.GetDocumentRange()));
        }
        public IColorReference GetColorReference(ITreeNode element)
        {
            if (element is IVectorLiteral vectorLiteral)
            {
                var vectorPropertyValue = VectorPropertyValueNavigator.GetByVector(vectorLiteral);
                if (vectorPropertyValue != null)
                {
                    // Does the vector literal belong to a vector property or a color property?
                    var propertyDeclation = PropertyDeclarationNavigator.GetByPropertValue(vectorPropertyValue);
                    if (propertyDeclation == null)
                    {
                        return(null);
                    }

                    if (!(propertyDeclation.PropertyType is ISimplePropertyType simplePropertyType) ||
                        simplePropertyType.Keyword?.NodeType != ShaderLabTokenType.COLOR_KEYWORD)
                    {
                        return(null);
                    }
                }

                var values = vectorLiteral.Numbers;
                if (values.Count == 3 || values.Count == 4)
                {
                    var r = GetColorValue(values[0]);
                    var g = GetColorValue(values[1]);
                    var b = GetColorValue(values[2]);
                    // Technically, the colour should have 4 values, but show the highlight even if we're unfinished
                    var a            = values.Count == 4 ? GetColorValue(values[3]) : 255;
                    var colorElement = new ColorElement(Color.FromArgb(a, r, g, b));
                    var range        = GetDocumentRange(values[0], values.Last());
                    return(new ShaderLabColorReference(colorElement,
                                                       VectorPropertyValueNavigator.GetByVector(vectorLiteral),
                                                       ColorValueNavigator.GetByConstant(vectorLiteral), range));
                }
            }
            return(null);
        }
Ejemplo n.º 21
0
        //Update UI spheres
        public void UpdateSpheres(ColorElement _color)
        {
            if (CustomColor.GetColor(_color).r > 0)
            {
                _r.UpdateSphereColor(ColorElement.Red);
            }
            else
            {
                _r.UpdateSphereColor(ColorElement.White);
            }

            if (CustomColor.GetColor(_color).g > 0)
            {
                _g.UpdateSphereColor(ColorElement.Green);
            }
            else
            {
                _g.UpdateSphereColor(ColorElement.White);
            }

            if (CustomColor.GetColor(_color).b > 0)
            {
                _b.UpdateSphereColor(ColorElement.Blue);
            }
            else
            {
                _b.UpdateSphereColor(ColorElement.White);
            }

            if (_color.Equals(ColorElement.Black))
            {
                _r.UpdateSphereColor(ColorElement.Black);
                _g.UpdateSphereColor(ColorElement.Black);
                _b.UpdateSphereColor(ColorElement.Black);
            }
        }
            public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as DispenseComponent;

                if (dest != null)
                {
                    base.CopyTo(dest);
                    if (Product != null)
                    {
                        dest.Product = (Hl7.Fhir.Model.Coding)Product.DeepCopy();
                    }
                    if (EyeElement != null)
                    {
                        dest.EyeElement = (Code <Hl7.Fhir.Model.VisionPrescription.VisionEyes>)EyeElement.DeepCopy();
                    }
                    if (SphereElement != null)
                    {
                        dest.SphereElement = (Hl7.Fhir.Model.FhirDecimal)SphereElement.DeepCopy();
                    }
                    if (CylinderElement != null)
                    {
                        dest.CylinderElement = (Hl7.Fhir.Model.FhirDecimal)CylinderElement.DeepCopy();
                    }
                    if (AxisElement != null)
                    {
                        dest.AxisElement = (Hl7.Fhir.Model.Integer)AxisElement.DeepCopy();
                    }
                    if (PrismElement != null)
                    {
                        dest.PrismElement = (Hl7.Fhir.Model.FhirDecimal)PrismElement.DeepCopy();
                    }
                    if (BaseElement != null)
                    {
                        dest.BaseElement = (Code <Hl7.Fhir.Model.VisionPrescription.VisionBase>)BaseElement.DeepCopy();
                    }
                    if (AddElement != null)
                    {
                        dest.AddElement = (Hl7.Fhir.Model.FhirDecimal)AddElement.DeepCopy();
                    }
                    if (PowerElement != null)
                    {
                        dest.PowerElement = (Hl7.Fhir.Model.FhirDecimal)PowerElement.DeepCopy();
                    }
                    if (BackCurveElement != null)
                    {
                        dest.BackCurveElement = (Hl7.Fhir.Model.FhirDecimal)BackCurveElement.DeepCopy();
                    }
                    if (DiameterElement != null)
                    {
                        dest.DiameterElement = (Hl7.Fhir.Model.FhirDecimal)DiameterElement.DeepCopy();
                    }
                    if (Duration != null)
                    {
                        dest.Duration = (Hl7.Fhir.Model.SimpleQuantity)Duration.DeepCopy();
                    }
                    if (ColorElement != null)
                    {
                        dest.ColorElement = (Hl7.Fhir.Model.FhirString)ColorElement.DeepCopy();
                    }
                    if (BrandElement != null)
                    {
                        dest.BrandElement = (Hl7.Fhir.Model.FhirString)BrandElement.DeepCopy();
                    }
                    if (NotesElement != null)
                    {
                        dest.NotesElement = (Hl7.Fhir.Model.FhirString)NotesElement.DeepCopy();
                    }
                    return(dest);
                }
                else
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }
            }
        private static IColorReference ReferenceFromProperty(IReferenceExpression qualifier,
            IReferenceExpression colorQualifiedMemberExpression)
        {
            var name = colorQualifiedMemberExpression.Reference.GetName();

            var color = UnityNamedColors.Get(name);
            if (color == null) return null;

            var qualifierType = qualifier.Reference.Resolve().DeclaredElement as ITypeElement;
            if (qualifierType == null) return null;

            var unityColorTypes = UnityColorTypes.GetInstance(qualifierType.Module);
            if (!unityColorTypes.IsUnityColorTypeSupportingProperties(qualifierType)) return null;

            var property = colorQualifiedMemberExpression.Reference.Resolve().DeclaredElement as IProperty;
            if (property == null) return null;

            var colorElement = new ColorElement(color.Value, name);
            return new UnityColorReference(colorElement, colorQualifiedMemberExpression,
                 colorQualifiedMemberExpression, colorQualifiedMemberExpression.NameIdentifier.GetDocumentRange());
        }
Ejemplo n.º 24
0
 public ColorElementViewModel(string description, ColorElement element)
 {
     this._element      = element;
     this._description  = description;
     this._cPBViewModel = new ColorPickButtonViewModel(element.GetColor());
 }
        private static IColorReference ReferenceFromConstructor(IObjectCreationExpression constructorExpression)
        {
            var constructedType = constructorExpression.TypeReference?.Resolve().DeclaredElement as ITypeElement;
            if (constructedType == null) return null;

            var unityColorTypes = UnityColorTypes.GetInstance(constructedType.Module);
            if (!unityColorTypes.IsUnityColorType(constructedType)) return null;

            var arguments = constructorExpression.Arguments;
            if (arguments.Count < 3 || arguments.Count > 4) return null;

            Color? color = null;
            if (unityColorTypes.UnityColorType != null && unityColorTypes.UnityColorType.Equals(constructedType))
            {
                var baseColor = GetColorFromFloatARGB(arguments);
                if (baseColor == null) return null;

                color = baseColor.Item1.HasValue
                    ? Color.FromArgb((int) (255.0 * baseColor.Item1.Value), baseColor.Item2)
                    : baseColor.Item2;
            }
            else if (unityColorTypes.UnityColor32Type != null && unityColorTypes.UnityColor32Type.Equals(constructedType))
            {
                var baseColor = GetColorFromIntARGB(arguments);
                if (baseColor == null) return null;

                color = baseColor.Item1.HasValue
                    ? Color.FromArgb(baseColor.Item1.Value, baseColor.Item2)
                    : baseColor.Item2;
            }

            if (color == null) return null;

            var colorElement = new ColorElement(color.Value);
            var argumentList = constructorExpression.ArgumentList;
            return new UnityColorReference(colorElement, constructorExpression, argumentList, argumentList.GetDocumentRange());
        }
Ejemplo n.º 26
0
 private IApplyable Wrap(ColorElement elem, string desc)
 {
     return(new ColorElementViewModel(desc, elem));
 }
Ejemplo n.º 27
0
 private ColorTable()
 {
     m_mapElements    = new Dictionary <int, ColorElement>();
     m_emptyItem      = new ColorElement();
     m_vecAllElements = new List <ColorElement>();
 }
        private static IColorReference ReferenceFromInvocation(IReferenceExpression qualifier,
            IReferenceExpression methodReferenceExpression)
        {
            var invocationExpression = InvocationExpressionNavigator.GetByInvokedExpression(methodReferenceExpression);
            if (invocationExpression == null || invocationExpression.Arguments.IsEmpty)
            {
                return null;
            }

            var methodReference = methodReferenceExpression.Reference;

            var name = methodReference.GetName();
            if (!string.Equals(name, "HSVToRGB", StringComparison.Ordinal)) return null;

            var arguments = invocationExpression.Arguments;
            if (arguments.Count < 3 || arguments.Count > 4) return null;

            var color = GetColorFromHSV(arguments);
            if (color == null) return null;

            var qualifierType = qualifier.Reference.Resolve().DeclaredElement as ITypeElement;
            if (qualifierType == null) return null;

            var unityColorTypes = UnityColorTypes.GetInstance(qualifierType.Module);
            if (!unityColorTypes.IsUnityColorTypeSupportingHSV(qualifierType)) return null;

            var colorElement = new ColorElement(color.Value);
            var argumentList = invocationExpression.ArgumentList;
            return new UnityColorReference(colorElement, invocationExpression,
                argumentList, argumentList.GetDocumentRange());
        }
Ejemplo n.º 29
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as DeviceMetric;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (Type != null)
            {
                dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy();
            }
            if (Unit != null)
            {
                dest.Unit = (Hl7.Fhir.Model.CodeableConcept)Unit.DeepCopy();
            }
            if (Source != null)
            {
                dest.Source = (Hl7.Fhir.Model.ResourceReference)Source.DeepCopy();
            }
            if (Parent != null)
            {
                dest.Parent = (Hl7.Fhir.Model.ResourceReference)Parent.DeepCopy();
            }
            if (OperationalStatusElement != null)
            {
                dest.OperationalStatusElement = (Code <Hl7.Fhir.Model.DeviceMetric.DeviceMetricOperationalStatus>)OperationalStatusElement.DeepCopy();
            }
            if (ColorElement != null)
            {
                dest.ColorElement = (Code <Hl7.Fhir.Model.DeviceMetric.DeviceMetricColor>)ColorElement.DeepCopy();
            }
            if (CategoryElement != null)
            {
                dest.CategoryElement = (Code <Hl7.Fhir.Model.DeviceMetric.DeviceMetricCategory>)CategoryElement.DeepCopy();
            }
            if (MeasurementPeriod != null)
            {
                dest.MeasurementPeriod = (Hl7.Fhir.Model.Timing)MeasurementPeriod.DeepCopy();
            }
            if (Calibration != null)
            {
                dest.Calibration = new List <Hl7.Fhir.Model.DeviceMetric.CalibrationComponent>(Calibration.DeepCopy());
            }
            return(dest);
        }
Ejemplo n.º 30
0
    public bool LoadBin(byte[] binContent)
    {
        m_mapElements.Clear();
        m_vecAllElements.Clear();
        int nCol, nRow;
        int readPos = 0;

        readPos += GameAssist.ReadInt32Variant(binContent, readPos, out nCol);
        readPos += GameAssist.ReadInt32Variant(binContent, readPos, out nRow);
        List <string> vecLine     = new List <string>(nCol);
        List <int>    vecHeadType = new List <int>(nCol);
        string        tmpStr;
        int           tmpInt;

        for (int i = 0; i < nCol; i++)
        {
            readPos += GameAssist.ReadString(binContent, readPos, out tmpStr);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out tmpInt);
            vecLine.Add(tmpStr);
            vecHeadType.Add(tmpInt);
        }
        if (vecLine.Count != 5)
        {
            Ex.Logger.Log("Color.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "ID")
        {
            Ex.Logger.Log("Color.csv中字段[ID]位置不对应"); return(false);
        }
        if (vecLine[1] != "Type")
        {
            Ex.Logger.Log("Color.csv中字段[Type]位置不对应"); return(false);
        }
        if (vecLine[2] != "Color")
        {
            Ex.Logger.Log("Color.csv中字段[Color]位置不对应"); return(false);
        }
        if (vecLine[3] != "Res")
        {
            Ex.Logger.Log("Color.csv中字段[Res]位置不对应"); return(false);
        }
        if (vecLine[4] != "Desc")
        {
            Ex.Logger.Log("Color.csv中字段[Desc]位置不对应"); return(false);
        }

        for (int i = 0; i < nRow; i++)
        {
            ColorElement member = new ColorElement();
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.ID);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Type);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Color);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Res);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Desc);

            member.IsValidate = true;
            m_vecAllElements.Add(member);
            m_mapElements[member.ID] = member;
        }
        return(true);
    }
Ejemplo n.º 31
0
 //Update the UI sphere
 public void UpdateSphereColor(ColorElement _color)
 {
     _sphere.color = CustomColor.GetColor(_color);
 }
Ejemplo n.º 32
0
 public override string OnColorOpen(ColorElement element)
 {
     return("");
 }
Ejemplo n.º 33
0
 public override string OnColorClose(ColorElement element)
 {
     return("");
 }