Esempio n. 1
0
        public void Control_Test_02_Color()
        {
            this.ConnectClients();
            try
            {
                ManualResetEvent Done  = new ManualResetEvent(false);
                ManualResetEvent Error = new ManualResetEvent(false);

                this.cl = new ColorReference(0, 0, 0);

                this.controlClient.Set(this.client2.FullJID, "Color", new ColorReference(1, 2, 3), (sender, e) =>
                {
                    if (e.Ok)
                    {
                        Done.Set();
                    }
                    else
                    {
                        Error.Set();
                    }

                    return(Task.CompletedTask);
                }, null);

                Assert.AreEqual(0, WaitHandle.WaitAny(new WaitHandle[] { Done, Error }, 10000), "Configuration not performed correctly");
                Assert.AreEqual(1, this.cl.Red);
                Assert.AreEqual(2, this.cl.Green);
                Assert.AreEqual(3, this.cl.Blue);
            }
            finally
            {
                this.DisposeClients();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the string value of the control parameter.
        /// </summary>
        /// <param name="Node">Node reference, if available.</param>
        /// <returns>String representation of the value.</returns>
        public override async Task <string> GetStringValue(IThingReference Node)
        {
            ColorReference Value = await this.Get(Node);

            if (!(Value is null))
            {
                return(Value.ToString());
            }
    private void AdjustColor(ColorReference _color)
    {
        if (panel == null)
        {
            panel = this.GetComponent <Image>();
        }

        panel.color = _color.Value;
    }
Esempio n. 4
0
        /// <summary>
        /// Exports form validation rules for the parameter.
        /// </summary>
        /// <param name="Output">Output</param>
        /// <param name="Node">Node reference, if available.</param>
        public override async Task ExportValidationRules(XmlWriter Output, IThingReference Node)
        {
            ColorReference Value = await this.Get(Node);

            Output.WriteStartElement("xdv", "validate", null);
            Output.WriteAttributeString("xmlns", "xdc", null, "urn:xmpp:xdata:color");

            if (Value is null || !Value.HasAlpha)
            {
                Output.WriteAttributeString("datatype", "xdc:color");
                Output.WriteElementString("xdv", "regex", null, "^[0-9a-fA-F]{6}$");
            }
Esempio n. 5
0
        /// <summary>
        /// Gets the string value of the control parameter.
        /// </summary>
        /// <param name="Node">Node reference, if available.</param>
        /// <returns>String representation of the value.</returns>
        public override string GetStringValue(ThingReference Node)
        {
            ColorReference Value = this.Get(Node);

            if (Value != null)
            {
                return(Value.ToString());
            }
            else
            {
                return(string.Empty);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Sets a control parameter in a remote actuator.
        /// </summary>
        /// <param name="To">Full JID of remote actuator.</param>
        /// <param name="ControlParameterName">Control parameter name.</param>
        /// <param name="Value">Value to set.</param>
        /// <param name="ServiceToken">Service token of original sender, if available.</param>
        /// <param name="DeviceToken">Device token of original sender, if available.</param>
        /// <param name="UserToken">User token of original sender, if available.</param>
        /// <param name="Callback">Method called when set operation completes or fails.</param>
        /// <param name="State">State object to pass on to the callback method.</param>
        /// <param name="Nodes">Node(s) to set the parameter on, if residing behind a concentrator.</param>
        public void Set(string To, string ControlParameterName, ColorReference Value, string ServiceToken, string DeviceToken, string UserToken,
                        SetResultCallback Callback, object State, params ThingReference[] Nodes)
        {
            StringBuilder Xml = this.SetHeader(ServiceToken, DeviceToken, UserToken, Nodes);

            Xml.Append("<cl n='");
            Xml.Append(XML.Encode(ControlParameterName));
            Xml.Append("' v='");
            Xml.Append(Value.ToString());
            Xml.Append("'/></set>");

            this.client.SendIqSet(To, Xml.ToString(), SetResultCallback, new object[] { Callback, State });
        }
Esempio n. 7
0
        /// <summary>
        /// Gets the string value of the control parameter.
        /// </summary>
        /// <param name="Node">Node reference, if available.</param>
        /// <returns>String representation of the value.</returns>
        public override async Task <string> GetStringValue(IThingReference Node)
        {
            ColorReference Value = await this.Get(Node);

            if (Value != null)
            {
                return(Value.ToString());
            }
            else
            {
                return(string.Empty);
            }
        }
 /// <summary>
 /// Sets the value of the control parameter.
 /// </summary>
 /// <param name="Node">Node reference, if available.</param>
 /// <param name="Value">Value to set.</param>
 /// <returns>If the parameter could be set (true), or if the value was invalid (false).</returns>
 public bool Set(IThingReference Node, ColorReference Value)
 {
     try
     {
         this.setHandler(Node, Value);
         return(true);
     }
     catch (Exception ex)
     {
         Log.Critical(ex);
         return(false);
     }
 }
Esempio n. 9
0
 public ColorGroup(IReadOnlyList <ColorReference> colors, int row, int column, int width)
 {
     X           = column;
     Y           = row;
     TopLeft     = colors[(row - 1) * width + (column - 1)];
     TopMid      = colors[(row - 1) * width + column];
     TopRight    = colors[(row - 1) * width + column + 1];
     MidLeft     = colors[row * width + (column - 1)];
     Mid         = colors[row * width + column];
     MidRight    = colors[row * width + column + 1];
     BottomLeft  = colors[(row + 1) * width + (column - 1)];
     BottomMid   = colors[(row + 1) * width + column];
     BottomRight = colors[(row + 1) * width + column + 1];
 }
        public OperationResponse Add(ColorReference entity)
        {
            var result = new OperationResponse();

            try
            {
                var dbLocator = AmbientDbContextLocator.Get <RiverdaleDBContext>();
                dbLocator.Add(entity);
            }
            catch (Exception ex)
            {
                result.AddException($"Error adding Funza Color", ex);
            }

            return(result);
        }
Esempio n. 11
0
        /// <summary>
        /// Exports form validation rules for the parameter.
        /// </summary>
        /// <param name="Output">Output</param>
        /// <param name="Node">Node reference, if available.</param>
        public override void ExportValidationRules(XmlWriter Output, ThingReference Node)
        {
            ColorReference Value = this.Get(Node);

            Output.WriteStartElement("xdv", "validate", null);
            Output.WriteAttributeString("xmlns", "xdc", null, "urn:xmpp:xdata:color");

            if (Value == null || !Value.HasAlpha)
            {
                Output.WriteAttributeString("datatype", "xdc:color");
                Output.WriteElementString("xdv", "regex", null, "^[0-9a-fA-F]{6}$");
            }
            else
            {
                Output.WriteAttributeString("datatype", "xdc:colorAlpha");
                Output.WriteElementString("xdv", "regex", null, "^[0-9a-fA-F]{8}$");
            }

            Output.WriteEndElement();
        }
Esempio n. 12
0
            public ColorReference GetColorReference([NotNull] string ruleId, int colorIndex)
            {
                ColorReference result = null;
                var            source = new Lazier <AspectsPaintableItem>(() => {
                    var sourceFound = GetSource(ruleId) as AspectsPaintableItem;
                    if (sourceFound != null)
                    {
                        sourceFound.ColorChanged += (sender, args) => {
                            if (args.ColorIndex == null || args.ColorIndex == colorIndex)
                            {
                                result?.RaiseUpdated();
                            }
                        };
                    }

                    return(sourceFound);
                });

                result = new ColorReference(() => source.Value?.GetColor(colorIndex)?.ToColor(255));
                return(result);
            }
 public void SetColor(PredefinedColor predefinedColor)
 {
     _spriteRenderer.color = ColorReference.GetColor(predefinedColor);
 }
Esempio n. 14
0
 /// <summary>
 /// Sets a control parameter in a remote actuator.
 /// </summary>
 /// <param name="To">Full JID of remote actuator.</param>
 /// <param name="ControlParameterName">Control parameter name.</param>
 /// <param name="Value">Value to set.</param>
 /// <param name="Callback">Method called when set operation completes or fails.</param>
 /// <param name="State">State object to pass on to the callback method.</param>
 /// <param name="Nodes">Node(s) to set the parameter on, if residing behind a concentrator.</param>
 public void Set(string To, string ControlParameterName, ColorReference Value, SetResultCallback Callback, object State, params ThingReference[] Nodes)
 {
     this.Set(To, ControlParameterName, Value, string.Empty, string.Empty, string.Empty, Callback, State, Nodes);
 }
Esempio n. 15
0
 /// <summary>
 /// Sets a control parameter in a remote actuator.
 /// </summary>
 /// <param name="To">Full JID of remote actuator.</param>
 /// <param name="ControlParameterName">Control parameter name.</param>
 /// <param name="Value">Value to set.</param>
 /// <param name="Nodes">Node(s) to set the parameter on, if residing behind a concentrator.</param>
 public void Set(string To, string ControlParameterName, ColorReference Value, params ThingReference[] Nodes)
 {
     this.Set(To, ControlParameterName, Value, string.Empty, string.Empty, string.Empty, null, null, Nodes);
 }
Esempio n. 16
0
        public override void ConnectClients()
        {
            base.ConnectClients();

            Assert.AreEqual(XmppState.Connected, this.client1.State);
            Assert.AreEqual(XmppState.Connected, this.client2.State);

            this.controlClient = new ControlClient(this.client1);
            this.controlServer = new ControlServer(this.client2,
                                                   new BooleanControlParameter("Bool", "Page1", "Bool:", "Boolean value",
                                                                               (sender) => Task.FromResult <bool?>(this.b),
                                                                               (sender, value) => { this.b = value; return(Task.CompletedTask); }),
                                                   new ColorControlParameter("Color", "Page1", "Color:", "Color value",
                                                                             (sender) => Task.FromResult <ColorReference>(this.cl),
                                                                             (sender, value) => { this.cl = value; return(Task.CompletedTask); }),
                                                   new DateControlParameter("Date", "Page1", "Date:", "Date value", DateTime.MinValue, DateTime.MaxValue,
                                                                            (sender) => Task.FromResult <DateTime?>(this.d),
                                                                            (sender, value) => { this.d = value; return(Task.CompletedTask); }),
                                                   new DateTimeControlParameter("DateTime", "Page1", "DateTime:", "DateTime value", DateTime.MinValue, DateTime.MaxValue,
                                                                                (sender) => Task.FromResult <DateTime?>(this.dt),
                                                                                (sender, value) => { this.dt = value; return(Task.CompletedTask); }),
                                                   new DoubleControlParameter("Double", "Page1", "Double:", "Double value",
                                                                              (sender) => Task.FromResult <double?>(this.db),
                                                                              (sender, value) => { this.db = value; return(Task.CompletedTask); }),
                                                   new DurationControlParameter("Duration", "Page1", "Duration:", "Duration value",
                                                                                (sender) => Task.FromResult <Duration>(this.dr),
                                                                                (sender, value) => { this.dr = value; return(Task.CompletedTask); }),
                                                   new EnumControlParameter("Enum", "Page1", "Enum:", "Enum value", typeof(TypeCode),
                                                                            (sender) => Task.FromResult <Enum>(this.e),
                                                                            (sender, value) => { this.e = (TypeCode)value; return(Task.CompletedTask); }),
                                                   new Int32ControlParameter("Int32", "Page1", "Int32:", "Int32 value",
                                                                             (sender) => Task.FromResult <int?>(this.i),
                                                                             (sender, value) => { this.i = value; return(Task.CompletedTask); }),
                                                   new Int64ControlParameter("Int64", "Page1", "Int64:", "Int64 value",
                                                                             (sender) => Task.FromResult <long?>(this.l),
                                                                             (sender, value) => { this.l = value; return(Task.CompletedTask); }),
                                                   new StringControlParameter("String", "Page1", "String:", "String value",
                                                                              (sender) => Task.FromResult <string>(this.s),
                                                                              (sender, value) => { this.s = value; return(Task.CompletedTask); }),
                                                   new TimeControlParameter("Time", "Page1", "Time:", "Time value",
                                                                            (sender) => Task.FromResult <TimeSpan?>(this.t),
                                                                            (sender, value) => { this.t = value; return(Task.CompletedTask); }));
        }
Esempio n. 17
0
 public void InitializeVisuals(PredefinedColor predefinedColor)
 {
     SetRendererColor(ColorReference.GetColor(predefinedColor));
 }
Esempio n. 18
0
        public override void ConnectClients()
        {
            base.ConnectClients();

            Assert.AreEqual(XmppState.Connected, this.client1.State);
            Assert.AreEqual(XmppState.Connected, this.client2.State);

            this.controlClient = new ControlClient(this.client1);
            this.controlServer = new ControlServer(this.client2,
                                                   new BooleanControlParameter("Bool", "Page1", "Bool:", "Boolean value", (sender) => this.b, (sender, value) => this.b = value),
                                                   new ColorControlParameter("Color", "Page1", "Color:", "Color value", (sender) => this.cl, (sender, value) => this.cl = value),
                                                   new DateControlParameter("Date", "Page1", "Date:", "Date value", DateTime.MinValue, DateTime.MaxValue, (sender) => this.d, (sender, value) => this.d = value),
                                                   new DateTimeControlParameter("DateTime", "Page1", "DateTime:", "DateTime value", DateTime.MinValue, DateTime.MaxValue, (sender) => this.dt, (sender, value) => this.dt = value),
                                                   new DoubleControlParameter("Double", "Page1", "Double:", "Double value", (sender) => this.db, (sender, value) => this.db         = value),
                                                   new DurationControlParameter("Duration", "Page1", "Duration:", "Duration value", (sender) => this.dr, (sender, value) => this.dr = value),
                                                   new EnumControlParameter("Enum", "Page1", "Enum:", "Enum value", typeof(TypeCode), (sender) => this.e, (sender, value) => this.e = (TypeCode)value),
                                                   new Int32ControlParameter("Int32", "Page1", "Int32:", "Int32 value", (sender) => this.i, (sender, value) => this.i     = value),
                                                   new Int64ControlParameter("Int64", "Page1", "Int64:", "Int64 value", (sender) => this.l, (sender, value) => this.l     = value),
                                                   new StringControlParameter("String", "Page1", "String:", "String value", (sender) => this.s, (sender, value) => this.s = value),
                                                   new TimeControlParameter("Time", "Page1", "Time:", "Time value", (sender) => this.t, (sender, value) => this.t         = value));
        }
Esempio n. 19
0
 public void ChangeColorImmediate(PredefinedColor predefinedColor)
 {
     SetRendererColor(ColorReference.GetColor(predefinedColor));
 }
Esempio n. 20
0
 public void ChangeColor(PredefinedColor predefinedColor)
 {
     StartCoroutine(ChangeColorCoroutine(ColorReference.GetColor(predefinedColor)));
 }
Esempio n. 21
0
        // Getting SVG path element string from a traced path
        internal static StringBuilder AppendSegments(StringBuilder stringBuilder, IReadOnlyList <Segment> segments, ColorReference color)
        {
            // Path
            stringBuilder.Append($"<path {color.ToSvgString()}d=\"M {segments.First().Start.X} {segments.First().Start.Y} ");
            //http://stackoverflow.com/a/217814/294804
            segments.Aggregate(stringBuilder, (sb, segment) => sb.Append(segment.ToPathString())).Append("Z\" />");

            // Rendering control points
            return(segments.Where(s => s.Radius > 0).Aggregate(stringBuilder, (sb, segment) => sb.Append(segment.ToControlPointString())));
        }
Esempio n. 22
0
 public ColorSelectionItem(ColorReference colorReference, int index)
 {
     Color = new SolidColorBrush(System.Windows.Media.Color.FromArgb(colorReference.A, colorReference.R, colorReference.G, colorReference.B));
     Index = index;
 }