Esempio n. 1
0
 bool configFont(string key, string value, Configuration.Options options)
 {
     container_.Font      = value != string.Empty ? value : Default.Font;
     container_.FontSize  = options.asFloat(0, Default.FontSize);
     container_.FontColor = options.asColor(1, Default.FontColor);
     return(true);
 }
Esempio n. 2
0
                bool configAlignment(string key, string value, Configuration.Options options)
                {
                    string data = value.ToLower();

                    switch (data)
                    {
                    case "center":
                    case "c":
                        gfx_.alignment_ = TextAlignment.CENTER;
                        break;

                    case "left":
                    case "l":
                        gfx_.alignment_ = TextAlignment.LEFT;
                        break;

                    case "right":
                    case "r":
                        gfx_.alignment_ = TextAlignment.RIGHT;
                        break;

                    default:
                        return(false);
                    }

                    gfx_.useDefaultAlignment_ = false;
                    return(true);
                }
Esempio n. 3
0
            public Graphic(ContentContainer template, Configuration.Options options)
                : base($"GraphicObject:{GraphicIDCounter++}")
            {
                Options          = options;
                Template         = template;
                DataAccessorName = "";
                RenderData       = createRenderDataObj();

                // defaults
                MaxDCUpdateInterval = Default.DCRefresh;
                Position            = Default.Position;
                PositionType        = Default.PositionType;
                Size              = Default.Size;
                SizeType          = Default.SizeType;
                VisibleThresholdA = -1.0;
                VisibleOperatorA  = greaterequal;
                VisibleThresholdB = -1.0;
                VisibleOperatorB  = val_true;
                VisibleCondition  = cond_and;

                RenderData.BackgroundColor    = new Color(0, 0, 0, 0);
                RenderData.BackgroundIconName = IconNameSquareSimple;
                RenderData.BackgroundRotation = 0f;

                RenderData.BorderColor     = new Color(0, 0, 0, 0);
                RenderData.BorderThickness = 0f;
                RenderData.BorderSpacing   = 0f;
                RenderData.BorderName      = "Simple";
            }
Esempio n. 4
0
            bool configBatteryColors(string key, string value, Configuration.Options options)
            {
                switch (value.ToLower())
                {
                case "onoff":
                    borderColors_[0] = options.asColor(0, Color.Red);
                    break;

                case "load":
                    borderColors_[1] = options.asColor(0, Color.Red);
                    borderColors_[2] = options.asColor(1, Color.Green);
                    break;

                case "mode":
                    borderColors_[3] = options.asColor(0, new Color(254, 69, 7));
                    borderColors_[4] = options.asColor(1, Color.Blue);
                    break;

                case "bar":
                    barColors_[0] = options.asColor(0, Color.Red);
                    barColors_[1] = options.asColor(1, Color.Green);
                    break;

                default:
                    return(false);
                }

                return(true);
            }
Esempio n. 5
0
            bool configSetSlider(string key, string value, Configuration.Options options)
            {
                switch (value.ToLower())
                {
                case "top":
                case "t":
                    sliderOrientation_ = SliderOrientation.Top;
                    break;

                case "left":
                case "l":
                    sliderOrientation_ = SliderOrientation.Left;
                    break;

                case "bottom":
                case "b":
                    sliderOrientation_ = SliderOrientation.Bottom;
                    break;

                case "right":
                case "r":
                    sliderOrientation_ = SliderOrientation.Right;
                    break;

                default:
                    log(Console.LogType.Error, $"Invalid slider orientation '{value}'");
                    return(false);
                }

                sliderWidth_ = options.asFloat(0, 0.03f);
                sliderColor_ = options.asColor(1, Color.WhiteSmoke);
                return(true);
            }
Esempio n. 6
0
                bool configBackground(string key, string value, Configuration.Options options)
                {
                    // background:color:icon:rotation:thickness:type

                    graphic_.RenderData.BackgroundColor = Configuration.asColor(value, Default.GfxBackgroundColor);

                    if (options.Count > 0)
                    {
                        graphic_.RenderData.BackgroundIconName = options[0] == "" ? IconNameSquareSimple : options[0];
                        graphic_.RenderData.BackgroundIcon     = Icon.getIcon(options[0]);
                        if (graphic_.RenderData.BackgroundIcon == null)
                        {
                            graphic_.log(Console.LogType.Error, $"Invalid background icon '{options[0]}'");
                            return(false);
                        }

                        graphic_.BackgroundRotation = (options.asFloat(1, 0f) / 180f) * (float)Math.PI;

                        graphic_.BackgroundThickness = options.asFloat(2, 0f);
                        ValueType vt;
                        if (!toValueType(options[3], out vt, Default.ValueType))
                        {
                            return(false);
                        }

                        graphic_.BackgroundThicknessType = vt;
                    }

                    return(true);
                }
Esempio n. 7
0
                bool configRefresh(string key, string value, Configuration.Options options)
                {
                    float seconds = Configuration.asFloat(value, Default.RefreshInSec);

                    container_.Refresh = TimeSpan.FromSeconds(seconds);
                    return(true);
                }
Esempio n. 8
0
                bool configBorder(string key, string value, Configuration.Options options)
                {
                    // border:style:size:spacing:type:color

                    //string prefix = "VIS_Icon_Border";
                    graphic_.RenderData.BorderIcon = Icon.getIcon($"VIS_Icon_Border{value}");
                    if (graphic_.RenderData.BorderIcon == null)
                    {
                        graphic_.log(Console.LogType.Error, $"Invalid border icon '{value}'");
                        return(false);
                    }
                    graphic_.RenderData.BorderName = value;

                    graphic_.BorderSize    = options.asFloat(0, Default.BorderSize);
                    graphic_.BorderSpacing = options.asFloat(1, Default.BorderSpacing);

                    ValueType vt;

                    if (!toValueType(options[2], out vt, Default.ValueType))
                    {
                        return(false);
                    }
                    graphic_.BorderSizeType = vt;

                    graphic_.RenderData.BorderColor = options.asColor(3, Default.BorderColor);
                    return(true);
                }
Esempio n. 9
0
            public DataCollectorThruster(Configuration.Options options, string connector)
                : base("thruster", "", options, connector)
            {
                AcceptBlock = (block) =>
                {
                    // IMyThrust.GridThrustDirection
                    // X => 1 == Left, -1 Right
                    // Y => 1 == Down, -1 Up
                    // Z => 1 == Forward, -1 == Backwards

                    if (referenceController_ != null)
                    {
                        // direction
                        Matrix thrusterMatrix;
                        block.Orientation.GetMatrix(out thrusterMatrix);
                        var directionVector = Vector3D.Rotate(thrusterMatrix.Forward, referenceControllerMatrix_);
                        var orientation     = Base6Directions.GetDirection(directionVector);

                        if (sameThrusterDirection(orientation) && sameThrusterType(block.DetailedInfo))
                        {
                            Blocks.Add(block);
                        }
                    }
                };
            }
Esempio n. 10
0
            bool configText(string key, string value, Configuration.Options options)
            {
                textShow_ = Configuration.asBoolean(value, true);
                if (textShow_ == true)
                {
                    switch (options[0].ToLower())
                    {
                    case "":
                    case "normal":
                        textStyle_ = TextStyle.Normal;
                        break;

                    case "onlyname":
                        textStyle_ = TextStyle.OnlyName;
                        break;

                    case "minvalue":
                    case "currentvalue":
                        textStyle_ = TextStyle.CurrentValue;
                        break;

                    default:
                        return(false);
                    }
                }

                return(true);
            }
Esempio n. 11
0
        public RedisCacheProvider(IEnvironmentProvider environmentProvider, IEncryptionProvider encryptionProvider, Configuration.Options options)
        {
            _environmentProvider = environmentProvider;
            _encryptionProvider  = encryptionProvider;
            _options             = options;

            InitializeConnection();
        }
Esempio n. 12
0
 bool configFont(string key, string value, Configuration.Options options)
 {
     gfx_.font_           = value != string.Empty ? value : Default.Font;
     gfx_.fontSize_       = options.asFloat(0, 0f);
     gfx_.Color           = options.asColor(1, Default.FontColor);
     gfx_.useDefaultFont_ = false;
     return(true);
 }
Esempio n. 13
0
                bool configGraphic(string key, string value, Configuration.Options options)
                {
                    Graphic graphic = null;

                    switch (value.ToLower())
                    {
                    case "text":
                        graphic = new GraphicText(container_, options);
                        break;

                    case "battery":
                        graphic = new GraphicBattery(container_, options);
                        break;

                    case "list":
                        graphic = new GraphicList(container_, options);
                        break;

                    case "bar":
                        graphic = new GraphicBar(container_, options);
                        break;

                    case "icon":
                        graphic = new GraphicIcon(container_, options);
                        break;

                    case "slider":
                        graphic = new GraphicSlider(container_, options);
                        break;

                    case "test":
                        graphic = new GraphicTest(container_, options);
                        break;

                    case "curvedbar":
                        graphic = new GraphicCurvedBar(container_, options);
                        break;
                    }

                    if (graphic != null)
                    {
                        if (graphic.construct())
                        {
                            setSubHandler(graphic.getConfigHandler());
                            container_.graphics_.Add(graphic);
                            return(true);
                        }
                        else
                        {
                            container_.log(Console.LogType.Error, $"Failed to construct graphic:{value}");
                        }
                    }
                    else
                    {
                        container_.log(Console.LogType.Error, $"Invalid graphic type:{value}");
                    }
                    return(false);
                }
Esempio n. 14
0
 bool configMaxShipSpeed(string key, string value, Configuration.Options options)
 {
     if (key == "maxspeed")
     {
         manager_.log(Console.LogType.Error, "Setting 'maxspeed' is deprecated. Use 'maxshipspeed' instead!");
     }
     Default.MaxShipSpeed = Configuration.asFloat(value, Default.MaxShipSpeed);
     return(true);
 }
Esempio n. 15
0
 //Color backgroundColor_ = Default.BarBackgroundColor;
 bool configBackgroundColor(string key, string value, Configuration.Options options)
 {
     log(Console.LogType.Error, $"Config Graphic:Bar 'bgcolor' is deprecated! Use 'background' instead.");
     //backgroundColor_ = Configuration.asColor(value, Default.BarBackgroundColor);
     RenderData.BackgroundColor    = Configuration.asColor(value, Default.BackgroundColor);
     RenderData.BackgroundIcon     = Icon.getIcon(IconNameSquareSimple);
     RenderData.BackgroundIconName = IconNameSquareSimple;
     return(true);
 }
Esempio n. 16
0
            bool configReplace(string key, string value, Configuration.Options options)
            {
                double val  = Configuration.asFloat(value);
                string text = options[0];

                replace_[val] = text;
                replace_      = replace_.OrderByDescending(x => x.Key).ToDictionary(a => a.Key, b => b.Value);
                return(true);
            }
Esempio n. 17
0
                bool configScreen(string key, string value, Configuration.Options options)
                {
                    // set surface index
                    int      screenId   = Configuration.asInteger(value, Default.DisplayID);
                    string   groupId    = Default.EmptyDisplayGroupID;
                    Vector2I coordinate = Default.DisplayCoordinate;

                    // extract group id
                    if (options.Count == 2)
                    {
                        // extract group id
                        groupId = options[0];

                        // extract coordinates
                        coordinate = options.asVector(1, Default.DisplayCoordinate);
                    }

                    if (screenId < 0 || screenId >= provider_.surfaceProvider_.SurfaceCount)
                    {
                        provider_.log(Console.LogType.Error, $"Invalid display id: {screenId}");
                        return(false);
                    }

                    Display display = Display.createDisplay(groupId, screenId, provider_.customName_);

                    if (display == null)
                    {
                        return(false);
                    }

                    // create render target to display
                    RenderTargetID RTID = RenderTargetID.fromSurfaceProvider(provider_.surfaceProvider_, screenId);

                    if (!display.addRenderTarget(provider_.surfaceProvider_.GetSurface(screenId), RTID, coordinate))
                    {
                        provider_.log(Console.LogType.Error, $"Render target exists: {groupId}:{coordinate}");
                        return(false);
                    }

                    // configure display
                    if (coordinate == new Vector2I(0, 0))
                    {
                        // setup display text
                        IMyTextPanel lcdPanel = provider_.surfaceProvider_ as IMyTextPanel;
                        if (lcdPanel != null)
                        {
                            display.PanelConnector = new Display.PanelConnectorObj(lcdPanel);
                        }

                        // create content container
                        ContentContainer container = new ContentContainer(display.GroupId);
                        setSubHandler(container.getConfigHandler());
                        display.ContentContainer = container;
                    }

                    return(true);
                }
Esempio n. 18
0
 bool configThickness(string key, string value, Configuration.Options options)
 {
     thickness_ = Configuration.asFloat(value, Default.Thickness);
     if (options.Count > 0)
     {
         toValueType(options[0], out thicknessSizeType_, Default.SizeType);
     }
     return(true);
 }
Esempio n. 19
0
                bool configCaptureRaw(string key, string value, Configuration.Options options)
                {
                    if (captureRaw_)
                    {
                        rawConfig_.AppendLine($"{key}:{value}:{options}");
                        return(true);
                    }

                    return(false);
                }
Esempio n. 20
0
                bool configDisplayNameTag(string key, string value, Configuration.Options options)
                {
                    if (value == "")
                    {
                        return(false);
                    }

                    vDisplayNameTag_ = value;
                    return(true);
                }
Esempio n. 21
0
                bool configDCRefresh(string key, string value, Configuration.Options options)
                {
                    float interval = Configuration.asFloat(value, Default.DCRefreshInSec);

                    graphic_.MaxDCUpdateInterval = TimeSpan.FromSeconds(interval);
                    if (graphic_.DataCollector != null)
                    {
                        graphic_.DataCollector.MaxUpdateInterval = graphic_.MaxDCUpdateInterval;
                    }
                    return(true);
                }
Esempio n. 22
0
 protected virtual bool configGradient(string key, string value, Configuration.Options options)
 {
     if (options.Count == 1)
     {
         float threshold = Configuration.asFloat(value, 0f);
         Color color     = options.asColor(0, Default.Color);
         graphic_.addGradientColor(threshold, color);
         return(true);
     }
     return(false);
 }
Esempio n. 23
0
 public DataCollectorInventory(Configuration.Options options, string typeId, string connector)
     : base("inventory", typeId, options, connector)
 {
     AcceptBlock = (block) =>
     {
         if (block.HasInventory)
         {
             constructBlocks_.Add(block);
         }
     };
 }
Esempio n. 24
0
 bool configIcon(string key, string value, Configuration.Options options)
 {
     iconName_ = value;
     icon_     = Icon.getIcon(value);
     if (icon_ == null)
     {
         log(Console.LogType.Error, $"Invalid icon name:{value}");
         return(false);
     }
     return(true);
 }
Esempio n. 25
0
                /*bool configTemplate(string key, string value, Configuration.Options options)
                 * {
                 *  // create new template
                 *  manager_.log(Console.LogType.Error, "The template configuration isnt' fully implemented yet");
                 *  return false;
                 * }*/

                bool configConsole(string key, string value, Configuration.Options options)
                {
                    var block = App.GridTerminalSystem.GetBlockWithName(value);

                    if (block != null)
                    {
                        manager_.log(Console.LogType.Info, $"Console redirected to {block.CustomName}");
                        return(manager_.Console.redirectConsole(block as IMyTextSurfaceProvider, options.asInteger(0, 0)));
                    }

                    return(false);
                }
Esempio n. 26
0
            public IDataCollector getDataCollector(string name, Configuration.Options options, string connector = "")
            {
                Requested++;
                IDataCollector collector = dataCollectors_.Find(x => x.isSameCollector(name, options, connector));

                if (collector != null)
                {
                    return(collector);
                }

                return(createDataCollector(name, options, connector));
            }
Esempio n. 27
0
 public DataCollectorProperty(string collectorTypeName, string typeId, Configuration.Options options, string connector)
     : base(collectorTypeName, typeId, options, connector)
 {
     AcceptBlock = (block) =>
     {
         float min, max;
         if (getMinMax(block, out min, out max))
         {
             valueMin_ += min;
             valueMax_ += max;
             Blocks.Add(block);
         }
     };
 }
Esempio n. 28
0
                protected virtual bool configPosition(string key, string value, Configuration.Options options)
                {
                    graphic_.Position = Configuration.asVector(value, Default.Position);
                    if (options.Count > 0)
                    {
                        ValueType vt;
                        if (!toValueType(options[0], out vt, Default.PositionType))
                        {
                            return(false);
                        }
                        graphic_.PositionType = vt;
                    }

                    return(true);
                }
Esempio n. 29
0
                bool configBlockEnd(string key, string value, Configuration.Options options)
                {
                    if (currentBlock_ != null)
                    {
                        manager_.displayProviders_.Add(new DisplayProvider(
                                                           currentBlock_.CustomName,
                                                           currentBlock_ as IMyTextSurfaceProvider,
                                                           rawConfig_.ToString()));
                    }

                    captureRaw_ = false;
                    rawConfig_.Clear();
                    currentBlock_ = null;
                    return(true);
                }
Esempio n. 30
0
            bool configStyle(string key, string value, Configuration.Options options)
            {
                minDegree_ = Configuration.asFloat(value, minDegree_);
                maxDegree_ = options.asFloat(0, maxDegree_);
                colorLerp_ = options.asBoolean(1, colorLerp_);

                if (minDegree_ > maxDegree_)
                {
                    minDegree_ -= 360f;
                }

                thickness_ = options.asFloat(2, thickness_);

                return(true);
            }