Example #1
0
        public MTPad(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(float));

            ForeGround        = json.Color;
            BackGround        = json.Background;
            OscObject.Targets = json.Targets;
            Visible           = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Visible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("ForegroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { ForeGround = OscParser.ToColor(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("BackgroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { BackGround = OscParser.ToColor(args); });
            }));

            this.TouchChanged += MTPad_TouchChanged;
        }
Example #2
0
        public TextBox(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(string));

            Text              = json.Content as string;
            FontSize          = json.FontSize;
            OscObject.Targets = json.Targets;
            IsVisible         = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Text", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Text = OscParser.ToString(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("FontSize", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { FontSize = OscParser.ToInt(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { IsVisible = OscParser.ToBool(args); });
            }));

            TextChanged += TextBox_TextChanged;
        }
Example #3
0
        public Label(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(int));

            Text            = (string)json.Content;
            TextColor       = json.Color;
            BackgroundColor = json.Background;
            FontSize        = json.FontSize;

            if (json.Bold)
            {
                if (json.Italic)
                {
                    FontAttributes = Xamarin.Forms.FontAttributes.Bold | Xamarin.Forms.FontAttributes.Italic;
                }
                else
                {
                    FontAttributes = Xamarin.Forms.FontAttributes.Bold;
                }
            }
            else if (json.Italic)
            {
                FontAttributes = Xamarin.Forms.FontAttributes.Italic;
            }
            HorizontalTextAlignment = json.HAlign;
            IsVisible = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Text", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Text = OscParser.ToString(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("FontSize", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { FontSize = OscParser.ToInt(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { IsVisible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("TextColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { TextColor = OscParser.ToColor(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("BackgroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { BackgroundColor = OscParser.ToColor(args); });
            }));
        }
Example #4
0
        public Slider(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(float));

            Minimum           = json.Minimum;
            Maximum           = json.Maximum;
            ForeGround        = json.Color;
            Handle            = json.Handle;
            Background        = json.Background;
            OscObject.Targets = json.Targets;
            Visible           = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Value", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Value = OscParser.ToFloat(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Minimum", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Minimum = OscParser.ToFloat(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Maximum", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Maximum = OscParser.ToFloat(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Visible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("ForegroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { ForeGround = OscParser.ToColor(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("BackgroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Background = OscParser.ToColor(args); });
            }));

            ValueChanged += Slider_ValueChanged;
        }
Example #5
0
        public Knob(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(float));

            Minimum           = json.Minimum;
            Maximum           = json.Maximum;
            Color             = json.Color;
            DisplayName       = json.Content as string;
            ShowValue         = json.ShowValue;
            OscObject.Targets = json.Targets;
            Visible           = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Value", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Value = OscParser.ToFloat(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Minimum", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Minimum = OscParser.ToFloat(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Maximum", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Maximum = OscParser.ToFloat(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("ShowValue", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { ShowValue = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Visible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Color", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Color = OscParser.ToColor(args); });
            }));

            this.ValueChanged += Knob_ValueChanged;
        }
Example #6
0
        public Button(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(bool));

            Text              = json.Content as string;
            ForeGround        = json.Color;
            BackGround        = json.Background;
            TextScale         = json.TextScale;
            OscObject.Targets = json.Targets;
            IsToggle          = json.IsToggle;
            Visible           = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Text", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Text = OscParser.ToString(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("TextScale", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { TextScale = (yGui.Scale)OscParser.ToInt(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Visible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("ForegroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { TextColor = OscParser.ToColor(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("BackgroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { BackgroundColor = OscParser.ToColor(args); });
            }));

            Pressed += Button_Pressed;
        }
Example #7
0
        public XYPad(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(Point));

            ForeGround        = json.Color;
            Border            = json.Color;
            Centered          = json.Centered;
            ShowValue         = json.ShowValue;
            OscObject.Targets = json.Targets;
            Visible           = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Coordinate", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Value = OscParser.ToPoint(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Centered", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Centered = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Visible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("ForegroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { ForeGround = OscParser.ToColor(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("BorderColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Border = OscParser.ToColor(args); });
            }));

            ValueChanged += XYPad_ValueChanged;
        }
Example #8
0
        public Led(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(int));

            Color   = json.Color;
            Scale   = json.Scale;
            Visible = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Blink", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
                {
                    int time = 100;
                    if (args.Length > 0)
                    {
                        if (args[0] is int)
                        {
                            time = (int)args[0];
                        }
                        else if (args[0] is float)
                        {
                            time = (int)args[0];
                        }
                    }
                    Blink(time);
                });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Visible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Color", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Color = OscParser.ToColor(args); });
            }));
        }
        void MakeRandomStrings()
        {
            for (int i = 0; i < m_Addresses.Length; i++)
            {
                k_Builder.Clear();
                var prefix = Random.Range(0f, 1f) > 0.75f ? "/layer/" : "/composition/";

                k_Builder.Append(prefix);
                for (int j = 0; j < m_RandomCharCount; j++)
                {
                    char randChar;
                    do
                    {
                        randChar = (char)Random.Range(32, 255);
                    } while (!OscParser.CharacterIsValidInAddress(randChar));
                    k_Builder.Append((byte)randChar);
                }

                k_Builder.Append((byte)' ');
                m_Addresses[i] = k_Builder.ToString();
            }

            for (int i = 0; i < m_StringElements.Length; i++)
            {
                k_Builder.Clear();
                for (int j = 0; j < m_RandomCharCount; j++)
                {
                    char randChar;
                    do
                    {
                        randChar = (char)Random.Range(32, 255);
                    } while (!OscParser.CharacterIsValidInAddress(randChar));
                    k_Builder.Append((byte)randChar);
                }

                k_Builder.Append((byte)' ');
                m_StringElements[i] = k_Builder.ToString();
            }
        }
Example #10
0
 public void BeforeAll()
 {
     m_BufferHandle = GCHandle.Alloc(m_Buffer, GCHandleType.Pinned);
     m_Parser       = new OscParser(m_Buffer);
 }