Example #1
0
        protected override void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            base.Initalize(data, cache, themePath, themeData);
            this.data = data;

            output = true;

            InputName = themeData["inputName"]?.Value <string>();
            output    = !(themeData["invert"]?.Value <bool>() ?? false);

            // super simplistic parsing for now, only supports single prefix ! and &&
            string Calc = themeData["calc"]?.Value <string>();

            if (!string.IsNullOrWhiteSpace(Calc))
            {
                calcFunc = Calc
                           .Split(new string[] { "&&" }, StringSplitOptions.None)
                           .Select(raw =>
                {
                    string trimed = raw.Trim();
                    bool invert   = trimed.StartsWith("!");
                    trimed        = trimed.TrimStart('!');
                    return(new Tuple <bool, string>(invert, trimed));
                })
                           .ToList();
            }
        }
Example #2
0
        protected override void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            base.Initalize(data, cache, themePath, themeData);
            this.data = data;

            Background = Color.White;
            Foreground = Color.Black;

            AxisName  = themeData["axisName"]?.Value <string>();
            Direction = themeData["direction"]?.Value <string>();

            Min    = themeData["min"]?.Value <int>() ?? 0;
            Max    = themeData["max"]?.Value <int>() ?? 0;
            Width  = themeData["width"]?.Value <float>() ?? 0;
            Height = themeData["height"]?.Value <float>() ?? 0;

            string ForegroundCode = themeData["foreground"]?.Value <string>();
            string BackgroundCode = themeData["background"]?.Value <string>();

            try
            {
                Foreground = Color.FromArgb(int.Parse(ForegroundCode, System.Globalization.NumberStyles.HexNumber));
            }
            catch { }
            try
            {
                Background = Color.FromArgb(int.Parse(BackgroundCode, System.Globalization.NumberStyles.HexNumber));
            }
            catch { }
        }
Example #3
0
        protected override void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            base.Initalize(data, cache, themePath, themeData);
            this.data = data;

            AxisNameX = themeData["axisNameX"]?.Value <string>();
            AxisNameY = themeData["axisNameY"]?.Value <string>();

            ScaleFactorX = themeData["scaleFactorX"]?.Value <float>() ?? 0;
            ScaleFactorY = themeData["scaleFactorY"]?.Value <float>() ?? 0;
        }
Example #4
0
        protected override void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            base.Initalize(data, cache, themePath, themeData);

            Height         = themeData["height"]?.Value <float>() ?? 0;
            Width          = themeData["width"]?.Value <float>() ?? 0;
            DrawFromCenter = themeData["center"]?.Value <bool>() ?? false;

            string imageName = themeData["image"]?.Value <string>();

            if (!string.IsNullOrWhiteSpace(imageName))
            {
                DisplayImage = cache.LoadImage(imageName);
            }
        }
Example #5
0
        private void Initalize(ControllerData data, string themePath, JObject themeData)
        {
            this.data = data;
            cache     = new UI_ImageCache(themePath);
            Items     = new List <UI_Item>();

            Height = themeData["height"]?.Value <int>() ?? 100;
            Width  = themeData["width"]?.Value <int>() ?? 100;

            themeData["children"]?.ToList().ForEach(child =>
            {
                string uiType = child["type"]?.Value <string>() ?? "";

                switch (uiType)
                {
                case "":
                    Items.Add(new UI_Item(data, cache, themePath, (JObject)child));
                    break;

                case "image":
                    Items.Add(new UI_GraphicalItem(data, cache, themePath, (JObject)child));
                    break;

                case "showhide":
                    Items.Add(new UL_ShowHide(data, cache, themePath, (JObject)child));
                    break;

                case "slider":
                    Items.Add(new UL_Slider(data, cache, themePath, (JObject)child));
                    break;

                case "trailpad":
                    Items.Add(new UL_TrailPad(data, cache, themePath, (JObject)child));
                    break;

                case "pbar":
                    Items.Add(new UL_PBar(data, cache, themePath, (JObject)child));
                    break;

                case "basic3d1":
                    Items.Add(new UL_Basic3D1(data, cache, themePath, (JObject)child));
                    break;

                default:
                    throw new Exception("Unknown UI Widget Type");
                }
            });
        }
Example #6
0
        protected virtual void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            this.cache = cache;
            Items      = new List <UI_Item>();

            X   = themeData["x"]?.Value <float>() ?? 0;
            Y   = themeData["y"]?.Value <float>() ?? 0;
            Rot = themeData["rot"]?.Value <float>() ?? 0;

            themeData["children"]?.ToList().ForEach(child =>
            {
                string uiType = child["type"]?.Value <string>() ?? "";

                switch (uiType)
                {
                case "":
                    Items.Add(new UI_Item(data, cache, themePath, (JObject)child));
                    break;

                case "image":
                    Items.Add(new UI_GraphicalItem(data, cache, themePath, (JObject)child));
                    break;

                case "showhide":
                    Items.Add(new UL_ShowHide(data, cache, themePath, (JObject)child));
                    break;

                case "slider":
                    Items.Add(new UL_Slider(data, cache, themePath, (JObject)child));
                    break;

                case "trailpad":
                    Items.Add(new UL_TrailPad(data, cache, themePath, (JObject)child));
                    break;

                case "pbar":
                    Items.Add(new UL_PBar(data, cache, themePath, (JObject)child));
                    break;

                case "basic3d1":
                    Items.Add(new UL_Basic3D1(data, cache, themePath, (JObject)child));
                    break;

                default:
                    throw new Exception("Unknown UI Widget Type");
                }
            });
        }
Example #7
0
        protected override void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            base.Initalize(data, cache, themePath, themeData);
            this.data  = data;
            this.cache = cache;

            DisplayType = themeData["mode"]?.Value <string>();
            string ImageName = themeData["image"]?.Value <string>();

            ShadowLName = themeData["shadowl"]?.Value <string>();
            ShadowRName = themeData["shadowr"]?.Value <string>();
            ShadowUName = themeData["shadowu"]?.Value <string>();
            ShadowDName = themeData["shadowd"]?.Value <string>();

            if (!string.IsNullOrWhiteSpace(ImageName))
            {
                DisplayImage = cache.LoadImage(ImageName);
            }

            if (!string.IsNullOrWhiteSpace(ShadowLName))
            {
                ShadowL = cache.LoadImage(ShadowLName);
            }

            if (!string.IsNullOrWhiteSpace(ShadowRName))
            {
                ShadowR = cache.LoadImage(ShadowRName);
            }

            if (!string.IsNullOrWhiteSpace(ShadowUName))
            {
                ShadowU = cache.LoadImage(ShadowUName);
            }

            if (!string.IsNullOrWhiteSpace(ShadowDName))
            {
                ShadowD = cache.LoadImage(ShadowDName);
            }

            Width  = themeData["width"]?.Value <float>() ?? 0;
            Height = themeData["height"]?.Value <float>() ?? 0;

            TiltTranslateX = themeData["tilttranslatex"]?.Value <float>() ?? 0;
            TiltTranslateY = themeData["tilttranslatey"]?.Value <float>() ?? 0;
        }
Example #8
0
        protected override void Initalize(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
        {
            base.Initalize(data, cache, themePath, themeData);
            this.data = data;

            PadPosHistory = new List <PointF?>();

            InputName = themeData["inputName"]?.Value <string>();
            string imageName   = themeData["image"]?.Value <string>();
            int    TrailLength = themeData["length"]?.Value <int>() ?? 0;

            float Width  = themeData["width"]?.Value <float>() ?? 0;
            float Height = themeData["height"]?.Value <float>() ?? 0;

            if (!string.IsNullOrWhiteSpace(imageName) && TrailLength > 0)
            {
                Image  ImagePadDecayBase = cache.LoadImage(imageName);
                string SizeSuffix        = string.Empty;
                if (Width > 0 && Height > 0)
                {
                    ImagePadDecayBase = new Bitmap(ImagePadDecayBase, (int)Width, (int)Height);
                }
                //int scaledTrailLength = (int)(TrailLength * (MainForm.fpsLimit / 60.0f));
                ImagePadDecay = new Image[TrailLength];
                for (int x = 0; x < ImagePadDecay.Length; x++)
                {
                    float percent = ((x + 1) * 1.0f / ImagePadDecay.Length);

                    ImagePadDecay[x] = cache.GetImage($"{imageName}:{Width}:{Height}:{percent}", () => { return(UI_ImageCache.SetImageOpacity(ImagePadDecayBase, percent * 0.15f)); });
                }
            }
            else
            {
                ImagePadDecay = new Image[0];
            }
        }
Example #9
0
        private void Draw2dAs3d(
            UI_ImageCache cache, Graphics g,
            Image image, string ImageGyroLName, Image ImageGyroL, string ImageGyroRName, Image ImageGyroR, string ImageGyroUName, Image ImageGyroU, string ImageGyroDName, Image ImageGyroD,
            float transformX, float transformY,
            float rotationAngle,
            float TiltFactorX, float TiltFactorY,
            float Width, float Height,
            float TiltTranslateX, float TiltTranslateY)
        {
            // fix flip
            if (TiltFactorX < -1)
            {
                TiltFactorX = 2.0f + TiltFactorX;
            }
            if (TiltFactorX > 1)
            {
                TiltFactorX = 2.0f - TiltFactorX;
            }
            if (TiltFactorY < -1)
            {
                TiltFactorY = 2.0f + TiltFactorY;
            }
            if (TiltFactorY > 1)
            {
                TiltFactorY = 2.0f - TiltFactorY;
            }

            PointF location = new PointF((TiltFactorY * -TiltTranslateX) - (Width / 2), (TiltFactorX * TiltTranslateY) - (Height / 2));

            g.RotateTransform(rotationAngle);
            g.ScaleTransform(transformX, transformY);

            g.DrawImage(image, location.X, location.Y, Width, Height);

            if (Math.Abs(TiltFactorX) > 0)
            {
                if (Math.Sign(TiltFactorX) > 0)
                {
                    float percent = TiltFactorX * 2;// * 0.15f;
                    percent = (float)Math.Round(percent * 25f) / 25f;
                    percent = (float)Math.Min(percent, 1.0f);
                    g.DrawImage(cache.GetImage($"{ImageGyroDName}:{percent}", () => { return(UI_ImageCache.SetImageOpacity(ImageGyroD, percent)); }), location.X, location.Y, Width, Height);
                }
                if (Math.Sign(TiltFactorX) < 0)
                {
                    float percent = -TiltFactorX * 2;// * 0.15f;
                    percent = (float)Math.Round(percent * 25f) / 25f;
                    percent = (float)Math.Min(percent, 1.0f);
                    g.DrawImage(cache.GetImage($"{ImageGyroUName}:{percent}", () => { return(UI_ImageCache.SetImageOpacity(ImageGyroU, percent)); }), location.X, location.Y, Width, Height);
                }
            }

            if (Math.Abs(TiltFactorY) > 0)
            {
                if (Math.Sign(TiltFactorY) > 0)
                {
                    float percent = TiltFactorY * 2;// * 0.15f;
                    percent = (float)Math.Round(percent * 25f) / 25f;
                    percent = (float)Math.Min(percent, 1.0f);
                    g.DrawImage(cache.GetImage($"{ImageGyroLName}:{percent}", () => { return(UI_ImageCache.SetImageOpacity(ImageGyroL, percent)); }), location.X, location.Y, Width, Height);
                }
                if (Math.Sign(TiltFactorY) < 0)
                {
                    float percent = -TiltFactorY * 2;// * 0.15f;
                    percent = (float)Math.Round(percent * 25f) / 25f;
                    percent = (float)Math.Min(percent, 1.0f);
                    g.DrawImage(cache.GetImage($"{ImageGyroRName}:{percent}", () => { return(UI_ImageCache.SetImageOpacity(ImageGyroR, percent)); }), location.X, location.Y, Width, Height);
                }
            }
        }
Example #10
0
 public UL_Basic3D1(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData) : base(data, cache, themePath, themeData)
 {
 }
Example #11
0
 public UI_GraphicalItem(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData) : base(data, cache, themePath, themeData)
 {
 }
Example #12
0
 public UI_Item(ControllerData data, UI_ImageCache cache, string themePath, JObject themeData)
 {
     Initalize(data, cache, themePath, themeData);
 }