예제 #1
0
        public BladeManager(int maxDepth = 10, bool showDebugButton = false, string cssPath = null, bool cssHotReloading = false)
        {
            Thread.CurrentThread.CurrentCulture       = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentUICulture     = new CultureInfo("en-US");
            CultureInfo.DefaultThreadCurrentCulture   = new CultureInfo("en-US");
            CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");

            AppDomain.CurrentDomain.UnhandledException  += new UnhandledExceptionEventHandler((_, e) => ShowUnhandledException((Exception)e.ExceptionObject));
            LINQPad.Controls.Control.UnhandledException += new ThreadExceptionEventHandler((_, e) => ShowUnhandledException(e.Exception));
            TaskScheduler.UnobservedTaskException       +=
                new EventHandler <UnobservedTaskExceptionEventArgs>((_, e) => ShowUnhandledException(e.Exception));

            _maxDepth           = maxDepth;
            _cssPath            = cssPath;
            _cssHotReloading    = cssHotReloading;
            ShowDebugButton     = showDebugButton;
            _stack              = new Stack <Blade>();
            _panels             = Enumerable.Range(0, _maxDepth).Select((e, i) => new DumpContainer()).ToArray();
            _sideBladeContainer = new DumpContainer();
            _styleManager       = new StyleManager();
            _overlay            = new Overlay();
            _popover            = new Popover();
            _toaster            = new Toaster();
            _progressDisplay    = new ProgressDisplay(_overlay);
            _containers         = _panels.Select(Blade).ToArray();

            Util.KeepRunning();
        }
예제 #2
0
        public CollapsablePanel(string header, object body)
        {
            this.SetClass("collapsable-panel");

            var dcBody = new DumpContainer {
                Content = body
            };
            var divBody = new Div(dcBody);

            divBody.SetClass("collapsable-panel--body");

            var divHeader = new Button(header, btn =>
            {
                if (_isOpen)
                {
                    this.RemoveClass("collapsable-panel-open");
                }
                else
                {
                    this.AddClass("collapsable-panel-open");
                }
                _isOpen = !_isOpen;
            });

            divHeader.SetClass("collapsable-panel--header");

            var divContainer = new Div(divHeader, divBody);

            divContainer.SetClass("collapsable-panel--container");

            this.VisualTree.Add(divContainer);
        }
        private DSSRackController FindValidRack(TechType itemTechType, int amount, out int slot)
        {
            slot = -1;
            QuickLogger.Debug($"In FindValidRack", true);
            //Check the filtered racks first
            foreach (DSSRackController baseUnit in BaseRacks)
            {
                var d = DumpContainer.GetTechTypeCount(itemTechType);
                QuickLogger.Debug(d.ToString(), true);
                if (baseUnit.CanHoldItem(amount, itemTechType, out var slotId, d, true))
                {
                    QuickLogger.Debug($"Item: {itemTechType} is allowed in server rack {baseUnit.GetPrefabIDString()} in slot {slotId} is Filtered: {baseUnit.HasFilters()}", true);
                    slot = slotId;
                    return(baseUnit);
                }
            }

            //Check the filtered racks first then the unfiltered
            foreach (DSSRackController baseUnit in BaseRacks)
            {
                if (baseUnit.CanHoldItem(amount, itemTechType, out var slotId))
                {
                    QuickLogger.Debug($"Item: {itemTechType} is allowed in server rack {baseUnit.GetPrefabIDString()} in slot {slotId} is Filtered: {baseUnit.HasFilters()}", true);
                    slot = slotId;
                    return(baseUnit);
                }
            }

            QuickLogger.Debug($"No qualified server rack is found to hold techtype: {itemTechType}", true);
            return(null);
        }
        public override void Initialize()
        {
            QuickLogger.Debug("Initialize Formatter", true);

            _slotState = Animator.StringToHash("SlotState");

            if (AnimationManager == null)
            {
                AnimationManager = gameObject.AddComponent <AnimationManager>();
            }

            if (ColorManager == null)
            {
                ColorManager = gameObject.AddComponent <ColorManager>();
                ColorManager.Initialize(gameObject, DSSModelPrefab.BodyMaterial);
            }

            if (DisplayManager == null)
            {
                DisplayManager = gameObject.AddComponent <DSSServerFormattingStationDisplay>();
                DisplayManager.Setup(this);
            }

            if (DumpContainer == null)
            {
                DumpContainer = new DumpContainer();
                DumpContainer.Initialize(transform, AuxPatchers.BaseDumpReceptacle(), AuxPatchers.NotAllowed(), AuxPatchers.CannotBeStored(), this, 1, 1);
            }

            IsInitialized = true;
        }
예제 #5
0
 public Popover()
 {
     _dc = new DumpContainer();
     _dc.ContentChanged += _ContentChanged;
     this.SetClass("popover");
     this.VisualTree.Add(_dc);
 }
예제 #6
0
        public override void Initialize()
        {
            if (DumpContainer == null)
            {
                DumpContainer = new DumpContainer();
                DumpContainer.Initialize(transform, "Item Display Receptical", AuxPatchers.NotAllowed(), AuxPatchers.CannotBeStored(), this, 1, 1);
            }

            var icon = GameObjectHelpers.FindGameObject(gameObject, "Icon");

            _icon   = icon?.AddComponent <uGUI_Icon>();
            _button = InterfaceHelpers.CreateButton(icon, "IconClick", InterfaceButtonMode.Background,
                                                    OnButtonClick, Color.white, Color.gray, 5.0f);


            _amount = GameObjectHelpers.FindGameObject(gameObject, "Text")?.GetComponent <Text>();

            var addBTN = GameObjectHelpers.FindGameObject(gameObject, "AddBTN");

            InterfaceHelpers.CreateButton(addBTN, "AddBTN", InterfaceButtonMode.Background,
                                          OnButtonClick, Color.gray, Color.white, 5.0f, AuxPatchers.ColorPage());

            var deleteBTN = GameObjectHelpers.FindGameObject(gameObject, "DeleteBTN");

            InterfaceHelpers.CreateButton(deleteBTN, "DeleteBTN", InterfaceButtonMode.Background,
                                          OnButtonClick, Color.gray, Color.white, 5.0f, AuxPatchers.ColorPage());

            AddToBaseManager();

            InvokeRepeating(nameof(UpdateScreen), 1f, 1f);

            IsInitialized = true;
        }
예제 #7
0
        public static async Task AddPadding(DumpContainer dc, object content)
        {
            DumpContainer Wrap(object c)
            {
                var inner = new DumpContainer
                {
                    Content = c
                };

                if (c is not INoContainerPadding noPadding)
                {
                    dc.Style = "padding:10px;width:100%;box-sizing:border-box;";
                }
                return(inner);
            }

            if (content is Task <object> contentTask)
            {
                content = await Task.Run(async() =>
                {
                    object result = await contentTask;
                    return(Wrap(result));
                });
            }
            else
            {
                content = Wrap(content);
            }

            dc.Content = content;
        }
예제 #8
0
        public object Render(QueryBuilder <T> builder)
        {
            _dc = new DumpContainer {
                Style = "margin-left:1em;margin-top:0.6em;"
            };

            var ruleButton = new IconButton(Icons.Plus, (_) =>
            {
                _rules.Add(builder.Rules[0]());
                Refresh(builder);
            }, tooltip: "Add Rule");

            IconButton groupButton  = null;
            IconButton deleteButton = null;

            ContextMenu contextMenu = null;

            if (_parent != null)
            {
                deleteButton = new IconButton(Icons.Delete, (_) =>
                {
                    _parent._rules.Remove(this);
                    _parent.Refresh(builder);
                });

                groupButton = new IconButton(Icons.FolderOpen, (_) =>
                {
                    _rules.Add(new GroupRule <T>(QueryOperator.And, this));
                    Refresh(builder);
                });
            }
            else
            {
                //contextMenu = new ContextMenu(
                //    new IconButton(Icons.DotsHorizontal),
                //    new ContextMenu.Item("Add Group", (_) => {
                //        _rules.Add(new GroupRule<T>(QueryOperator.And, this));
                //        Refresh(builder);
                //    }, icon: Icons.FolderOpen),
                //    new ContextMenu.Item("Save...", (_) => {
                //        //todo?
                //    }),
                //    new ContextMenu.Item("Load...", (_) => {
                //        //todo?
                //    })
                //);
            }

            Refresh(builder);

            var groupId = Guid.NewGuid().ToString();
            var optAnd  = new RadioButton(groupId, "AND", true, (_) => { _operator = QueryOperator.And; });
            var optOr   = new RadioButton(groupId, "OR", false, (_) => { _operator = QueryOperator.Or; });

            return(Layout.Vertical(
                       Layout.Horizontal(optAnd, optOr, ruleButton, groupButton, deleteButton, contextMenu),
                       _dc
                       ));
        }
예제 #9
0
 Div SideBlade(DumpContainer dc)
 {
     return(new Div(
                new Div(
                    new Div(dc).SetClass("blade-container")
                    ).SetClass("blade")
                ).SetClass("side-blade").SetVisibility(false));
 }
예제 #10
0
 public Blade(BladeManager manager, IBladeRenderer renderer, int index, DumpContainer panel, string title, Div container)
 {
     Manager   = manager;
     Index     = index;
     Renderer  = renderer;
     Panel     = panel;
     Title     = title;
     Container = container;
 }
        public override void Initialize()
        {
            if (NameController == null)
            {
                NameController = new ExStorageDepotNameManager();
                NameController.Initialize(this);
            }

            if (AnimationManager == null)
            {
                AnimationManager = gameObject.AddComponent <ExStorageDepotAnimationManager>();
            }

            if (Storage == null)
            {
                Storage = gameObject.AddComponent <ExStorageDepotStorageManager>();
                Storage.Initialize(this);
            }

            if (DumpContainer == null)
            {
                DumpContainer = gameObject.AddComponent <DumpContainer>();
                DumpContainer.Initialize(transform, ExStorageDepotBuildable.DumpContainerLabel(), ExStorageDepotBuildable.FoodNotAllowed(), ExStorageDepotBuildable.ContainerFullMessage(), Storage);
                DumpContainer.OnDumpContainerClosed += Storage.OnDumpContainerClosed;
            }

            if (Display == null)
            {
                Display = gameObject.AddComponent <ExStorageDepotDisplayManager>();
                Display.Initialize(this);
            }

            var locker = GameObjectHelpers.FindGameObject(gameObject, "Locker", SearchOption.StartsWith);
            var sRoot  = GameObjectHelpers.FindGameObject(gameObject, "StorageRoot");

            if (locker != null)
            {
                Destroy(locker);
            }

            if (sRoot != null)
            {
                Destroy(sRoot);
            }

            if (FCSConnectableDevice == null)
            {
                FCSConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>();
                FCSConnectableDevice.Initialize(this, Storage, new ExStoragePowerManager(), true);
                FCSTechFabricator.FcTechFabricatorService.PublicAPI.RegisterDevice(FCSConnectableDevice, GetPrefabID(), Mod.ExStorageTabID);
            }

            _initialized = true;
        }
예제 #12
0
        Div Blade(DumpContainer dc)
        {
            var innerDiv = new Div(dc);

            innerDiv.HtmlElement.SetAttribute("class", "blade-container");

            var outerDiv = new Div(innerDiv);

            outerDiv.HtmlElement.SetAttribute("class", "blade blade-hidden");

            return(outerDiv);
        }
        public bool IsAllowedToAdd(Pickupable pickupable, bool verbose)
        {
            var successful = false;
            var food       = pickupable.GetComponentInChildren <Eatable>();

            if (food != null)
            {
#if DEBUG
                QuickLogger.Debug($"Food Check {CanBeStored(DumpContainer.GetCount() + 1, pickupable.GetTechType())}", true);
#endif

                if ((!food.decomposes || AllowedFoodItems.Contains(pickupable.GetTechType())) && CanBeStored(DumpContainer.GetCount() + 1, pickupable.GetTechType()))
                {
                    successful = true;
                }
                else
                {
                    foreach (KeyValuePair <string, FCSConnectableDevice> seaBreeze in FCSConnectables)
                    {
                        if (seaBreeze.Value.GetTechType() != Mod.GetSeaBreezeTechType())
                        {
                            continue;
                        }
                        if (!seaBreeze.Value.CanBeStored(1, pickupable.GetTechType()))
                        {
                            continue;
                        }
                        successful = true;
                    }
                }

                if (!successful)
                {
                    QuickLogger.Message(AuxPatchers.NoFoodItems(), true);
                }


                QuickLogger.Debug($"Food Allowed Result: {successful}", true);
                return(successful);
            }
#if DEBUG
            QuickLogger.Debug($"{DumpContainer.GetCount() + 1}", true);
#endif

            if (!CanBeStored(DumpContainer.GetCount() + 1, pickupable.GetTechType()))
            {
                QuickLogger.Message(AuxPatchers.CannotBeStored(), true);
                return(false);
            }

            return(true);
        }
예제 #14
0
 public TimerUtil(long total, int maxMeasurement = 1000, int updateInterval = 25)
 {
     _stopwatch = new Stopwatch();
     if (total <= 0)
     {
         throw new Exception("zero total");
     }
     _total          = total.Dump("Total");
     _maxMeasurement = maxMeasurement;
     _updateInterval = updateInterval;
     _progress       = new Util.ProgressBar().Dump("Work");
     _counterDc      = new DumpContainer().Dump("Count");
     _speed          = new DumpContainer("-- ms/item").Dump("Speed");
     _timeLeft       = new DumpContainer("--").Dump("time left estimate");
     _timeDone       = new DumpContainer("--").Dump("time done estimate");
 }
예제 #15
0
        public Field(string label, Control input, string description = "", Func <Control, object> helper = null, bool required = false)
        {
            this.Style = "width:-webkit-fill-available;";

            if (input is not DateBox && input is not SearchBox && input is not FileBox)
            {
                input.HtmlElement.SetAttribute("required", "required");
            }

            var dcHelper = new DumpContainer();

            Span _description = null;

            if (!string.IsNullOrEmpty(description))
            {
                _description = new Span("");
                _description.HtmlElement.SetAttribute("title", description);
                _description.SetClass("field--header-description");
            }

            Span _label = new Span(label + (required ? "*" : ""));

            _label.SetClass("field--header-label");

            var divHeader = new Div((new Control[] { _label, _description, dcHelper }).Where(e => e != null).ToArray());

            divHeader.SetClass("field--header");

            if (helper != null)
            {
                input.OnUpdate(() =>
                {
                    dcHelper.Content = helper(input);
                });
                dcHelper.Content = helper(input);
            }

            _divError = new Div();
            _divError.SetClass("field--error");

            var divContainer = new Div(input, divHeader, _divError);

            divContainer.AddClass("field");

            this.Content = divContainer;
        }
예제 #16
0
            public InternalButton(Action <Div> onClick, object label, string svgIcon, string tooltip)
            {
                DateTime?lastClick = null;

                Action <Div> _onClick =
                    (div) =>
                {
                    if (lastClick != null && (DateTime.Now - lastClick.Value) < TimeSpan.FromSeconds(1))
                    {
                        lastClick = DateTime.Now;
                        return;
                    }
                    lastClick = DateTime.Now;
                    onClick?.Invoke(div);
                };

                this.SetClass("button");
                this.Click += (_, _) =>
                {
                    _onClick(this);
                };

                if (tooltip != null)
                {
                    this.HtmlElement.SetAttribute("title", tooltip);
                }

                if (!string.IsNullOrEmpty(svgIcon))
                {
                    var divIcon = new Div();
                    divIcon.SetClass("menu-button--icon");
                    divIcon.HtmlElement.InnerHtml = svgIcon;
                    this.VisualTree.Add(divIcon);
                }

                if (label is string stringLabel)
                {
                    this.VisualTree.Add(new Span(stringLabel));
                }
                else
                {
                    var dc = new DumpContainer();
                    dc.Content = label;
                    this.VisualTree.Add(new Div(dc).SetClass("dc"));
                }
            }
예제 #17
0
        public static void MyDump(this object content, string title = null, string style = null, bool toDataGrid = false)
        {
            if (string.IsNullOrEmpty(title))
            {
                title = string.Empty;
            }
            if (string.IsNullOrEmpty(style))
            {
                style = string.Empty;
            }

            var myContainer = new DumpContainer {
                Content = content, Style = style
            };

            myContainer.Dump(title, toDataGrid);
        }
예제 #18
0
        public object Render(T obj, EditorField <T> editorField, Action preview)
        {
            var value = Convert.ToBoolean(editorField.GetValue(obj));

            _checkBox = new CheckBox(editorField.Label, value);

            _checkBox.Click += (sender, args) => preview();

            var _container = new Div(_checkBox);

            _container.SetClass("entity-editor-bool");

            _wrapper = new DumpContainer(_container);

            _checkBox.Enabled = editorField.Enabled;

            return(_wrapper);
        }
예제 #19
0
        private void OnButtonClick(string arg1, object arg2)
        {
            switch (arg1)
            {
            case "AddBTN":
                DumpContainer?.OpenStorage();
                break;

            case "IconClick":
                Manager.RemoveItemFromContainer(_currentTechType);
                break;

            case "DeleteBTN":
                _icon.gameObject.SetActive(false);
                _currentTechType = TechType.None;
                _amount.text     = "";
                break;
            }
        }
예제 #20
0
        public static Func <object, PropertyInfo, Func <object>, Action <object>, object> Slider <T>(
            T min, T max,
            Func <T, object> toInt,
            Func <int, T> fromInt)
        => (o, p, gv, sv) =>
        {
            var v  = gv();
            var vc = new DumpContainer {
                Content = v, Style = "min-width: 30px"
            };
            var s = new RangeControl(
                Convert.ToInt32(toInt(min)),
                Convert.ToInt32(toInt(max)),
                Convert.ToInt32(toInt((T)v)))
            {
                IsMultithreaded = true
            };

            s.ValueInput += delegate
            {
                var val = fromInt(s.Value);
                sv(val);
                vc.Content = val;
            };

            var config = new { Min = min, Max = max };
            var editor = EditableDumpContainer.For(config);
            editor.AddChangeHandler(x => x.Min, (_, m) => s.Min = Convert.ToInt32(toInt(m)));
            editor.AddChangeHandler(x => x.Max, (_, m) => s.Max = Convert.ToInt32(toInt(m)));

            var editorDc = new DumpContainer {
                Content = editor
            };
            var display      = true;
            var toggleEditor = new Hyperlinq(() =>
            {
                display        = !display;
                editorDc.Style = display ? "" : "display:none";
            }, "[*]");
            toggleEditor.Action();

            return(Util.VerticalRun(vc, Util.HorizontalRun(false, s, toggleEditor), editorDc));
        };
예제 #21
0
        public override void Initialize()
        {
            if (PowerManager == null)
            {
                PowerManager = gameObject.AddComponent <AlterraGenPowerManager>();
            }

            if (ColorManager == null)
            {
                ColorManager = gameObject.AddComponent <ColorManager>();
                ColorManager.Initialize(gameObject, AlterraGenBuildable.BodyMaterial);
            }

            if (AnimationManager == null)
            {
                AnimationManager = gameObject.AddComponent <AnimationManager>();
            }

            if (DumpContainer == null)
            {
                DumpContainer = gameObject.AddComponent <DumpContainer>();
                DumpContainer.Initialize(transform, "AlterraGen Receptacle", AlterraGenBuildable.NotAllowedItem(), AlterraGenBuildable.StorageFullMessage(), PowerManager, 3, 3);
            }

            if (_fcsConnectableDevice == null)
            {
                _fcsConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>();
                _fcsConnectableDevice.Initialize(this, PowerManager, PowerManager);
                FCSTechFabricator.FcTechFabricatorService.PublicAPI.RegisterDevice(_fcsConnectableDevice, GetPrefabID(), Mod.ModTabID);
            }


            if (DisplayManager == null)
            {
                DisplayManager = gameObject.AddComponent <AlterraGenDisplayManager>();
                DisplayManager.Setup(this);
            }

            _xBubbles = GameObjectHelpers.FindGameObject(gameObject, "xBubbles");

            IsInitialized = true;
        }
예제 #22
0
        private Control _Format(object content, Func <Control, bool, Control> wrapper, object emptyContent, bool formattingEmpty)
        {
            wrapper ??= ((c, e) => c);

            Control Wrapper(Control inner)
            {
                return(wrapper(inner, formattingEmpty));
            }

            Control EmptyFormatter()
            {
                if (!formattingEmpty)
                {
                    return(_Format(emptyContent, wrapper, null, true));
                }
                return(Wrapper(new EmptySpan(content.ToString())));
            }

            return(content switch
            {
                null or "" => EmptyFormatter(),
                string strContent => Wrapper(new Span(strContent)),
                long and 0 => EmptyFormatter(),
                long longContent => Wrapper(new Span(longContent.ToString(IntegerFormat))),
                int and 0 => EmptyFormatter(),
                int intContent => Wrapper(new Span(intContent.ToString(IntegerFormat))),
                double and 0 => EmptyFormatter(),
                double doubleContent => Wrapper(new Span(doubleContent.ToString(DecimalFormat).TrimEnd(".00"))),
                decimal and 0 => EmptyFormatter(),
                decimal decimalContent => Wrapper(new Span(decimalContent.ToString(DecimalFormat).TrimEnd(".00"))),
                bool boolContent => Wrapper(boolContent ? new Icon(Icons.CheckBold, theme: Theme.Success) : Icon.Empty()),
                DateTime dateContent => Wrapper(new Span(dateContent.ToString(DateFormat))),
                DateTimeOffset dateTimeOffset => Wrapper(new Span(dateTimeOffset.ToString(DateFormat))),
                Guid guid => guid == Guid.Empty ? EmptyFormatter() : Wrapper(new Span(guid.ToString())),
                Control control => Wrapper(control),
                DumpContainer dumpContainer => Wrapper(dumpContainer),
                _ => Wrapper(new DumpContainer()
                {
                    Content = content
                })
            });
예제 #23
0
        public override void Initialize()
        {
            if (PowerManager == null)
            {
                PowerManager = gameObject.AddComponent <AlterraGenPowerManager>();
            }

            if (ColorManager == null)
            {
                ColorManager = gameObject.AddComponent <ColorManager>();
                ColorManager.Initialize(gameObject, AlterraGenBuildable.BodyMaterial);
            }

            if (AnimationManager == null)
            {
                AnimationManager = gameObject.AddComponent <AnimationManager>();
            }

            if (DumpContainer == null)
            {
                DumpContainer = gameObject.AddComponent <DumpContainer>();
                DumpContainer.Initialize(transform, "AlterraGen Receptacle", "", AlterraGenBuildable.NotAllowedItem(), PowerManager);
            }

            if (_fcsConnectableDevice == null)
            {
                _fcsConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>();
                _fcsConnectableDevice.Initialize(this, PowerManager, PowerManager);
            }


            if (DisplayManager == null)
            {
                DisplayManager = gameObject.AddComponent <AlterraGenDisplayManager>();
                DisplayManager.Setup(this);
            }

            _xBubbles = GameObjectHelpers.FindGameObject(gameObject, "xBubbles");

            IsInitialized = true;
        }
        private void Initialize(SubRoot habitat)
        {
            ReadySaveData();
            FCSConnectableAwake_Patcher.AddEventHandlerIfMissing(AlertedNewFCSConnectablePlaced);
            FCSConnectableDestroy_Patcher.AddEventHandlerIfMissing(AlertedFCSConnectableDestroyed);

            GetFCSConnectables();


            if (NameController == null)
            {
                NameController = new NameController();
                NameController.Initialize(AuxPatchers.Submit(), Mod.AntennaFriendlyName);
                NameController.OnLabelChanged += OnLabelChangedMethod;

                if (string.IsNullOrEmpty(_savedData?.InstanceID))
                {
                    NameController.SetCurrentName(GetDefaultName());
                }
                else
                {
                    NameController.SetCurrentName(_savedData?.BaseName);
                }
            }

            if (DumpContainer == null)
            {
                DumpContainer = habitat.gameObject.AddComponent <DumpContainer>();
                DumpContainer.Initialize(habitat.transform, AuxPatchers.BaseDumpReceptacle(), AuxPatchers.NotAllowed(),
                                         AuxPatchers.CannotBeStored(), this);
            }

            if (DockingManager == null)
            {
                DockingManager = habitat.gameObject.AddComponent <DSSVehicleDockingManager>();
                DockingManager.Initialize(habitat, this);
                DockingManager.ToggleIsEnabled(_savedData?.AllowDocking ?? false);
            }

            _hasBreakerTripped = _savedData?.HasBreakerTripped ?? false;
        }
예제 #25
0
        public Card(object content, string title = null, CardStyle style = CardStyle.Info) : base()
        {
            this.SetClass($"card card-{style.ToString().ToLower()}");

            List <Control> controls = new();

            if (!string.IsNullOrEmpty(title))
            {
                var titleDiv = new Div(new Literal(title));
                titleDiv.SetClass("card--title");
                controls.Add(titleDiv);
            }

            var dc = new DumpContainer {
                Content = content
            };

            controls.Add(dc);

            this.VisualTree.Add(new Div(controls));
        }
예제 #26
0
        public HeaderPanel(object header, object body, string width = null)
        {
            this.SetClass("header-panel");

            if (width != null)
            {
                this.Styles["width"] = width;
            }

            var dcHeader = new DumpContainer {
                Content = header
            };
            var divHeader = new Div(dcHeader);

            divHeader.SetClass("header-panel--header");

            var dcBody = new DumpContainer();

            if (body != null)
            {
                if (body is RefreshPanel)
                {
                    dcBody.Content = body;
                }
                else
                {
                    ControlExtensions.AddPadding(dcBody, body).GetAwaiter().GetResult();
                }
            }

            var divBody = new Div(dcBody);

            divBody.SetClass("header-panel--body");

            var divContainer = new Div(divHeader, divBody);

            divContainer.SetClass("header-panel--container");

            this.VisualTree.Add(divContainer);
        }
        public override void Initialize()
        {
            if (NameController == null)
            {
                NameController = new ExStorageDepotNameManager();
                NameController.Initialize(this);
            }

            if (AnimationManager == null)
            {
                AnimationManager = gameObject.AddComponent <ExStorageDepotAnimationManager>();
            }

            if (Storage == null)
            {
                Storage = gameObject.AddComponent <ExStorageDepotStorageManager>();
                Storage.Initialize(this);
            }

            if (DumpContainer == null)
            {
                DumpContainer = gameObject.AddComponent <DumpContainer>();
                DumpContainer.Initialize(transform, ExStorageDepotBuildable.DumpContainerLabel(), ExStorageDepotBuildable.FoodNotAllowed(), ExStorageDepotBuildable.ContainerFullMessage(), Storage);
                DumpContainer.OnDumpContainerClosed += Storage.OnDumpContainerClosed;
            }

            if (Display == null)
            {
                Display = gameObject.AddComponent <ExStorageDepotDisplayManager>();
                Display.Initialize(this);
            }

            if (FCSConnectableDevice == null)
            {
                FCSConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>();
                FCSConnectableDevice.Initialize(this, Storage);
            }

            _initialized = true;
        }
예제 #28
0
        public ProgressDisplay(Overlay overlay)
        {
            _overlay = overlay;

            _divTitle = new Div();
            _divTitle.SetClass("progress--title");

            _divAnimationPart1 = new Div();
            _divAnimationPart1.SetClass("line");

            _divAnimationPart2 = new Div();
            _divAnimationPart2.SetClass("line");

            _divAnimationPart3 = new Div();
            _divAnimationPart3.SetClass("line");

            _divAnimationBg = new Div();
            _divAnimationBg.SetClass("animation-bg");

            _divAnimation = new Div(_divAnimationPart1, _divAnimationPart2, _divAnimationPart3, _divAnimationBg);
            _divAnimation.SetClass("progress--animation");

            _btnAbort = new Button("Abort", OnAbort);
            _btnAbort.Hide();

            _progressBar = new Util.ProgressBar(false);

            _progressContainer = new DumpContainer(_progressBar);
            _progressContainer.Hide();

            _divWrap = new Div(_divTitle, _divAnimation, _progressContainer, _btnAbort);
            _divWrap.SetClass("progress-container");

            _divContainer = new Div(_divWrap);
            _divContainer.SetClass("progress");
            _divContainer.Hide();

            VisualTree.Add(_divContainer);
        }
예제 #29
0
        public MultiSelectBox(Option[] options, int[] selectedIndexes = null, Action <MultiSelectBox> onSelectionChanged = null)
        {
            if (options != null && options.Length != 0)
            {
                Options = options;
            }

            _selectedIndexes = selectedIndexes;

            if (onSelectionChanged != null)
            {
                SelectionChanged += delegate
                {
                    onSelectionChanged(this);
                };
            }

            _checkBoxContainer = new DumpContainer();
            _divContainer      = new Div(_checkBoxContainer).SetClass("multi-select-box");

            VisualTree.Add(_divContainer);
        }
예제 #30
0
        public static object StringWithTextBox(object o, PropertyInfo p, Func <object> gv, Action <object> sv, EditorRule.ParseFunc <string, object, bool> parseFunc,
                                               bool supportNullable = true, bool supportEnumerable = true, bool liveUpdate = true)
        {
            var type         = p.PropertyType;
            var isEnumerable = supportEnumerable && type.GetArrayLikeElementType() != null;

            // handle string which is IEnumerable<char>
            if (type == typeof(string) && type.GetArrayLikeElementType() == typeof(char))
            {
                isEnumerable = false;
            }

            string GetStringRepresentationForValue()
            {
                var v = gv();

                var desc = v == null
                    ? NullString
                    : (isEnumerable ? JsonConvert.SerializeObject(v) : $"{v}");

                // hyperlinq doesn't like empty strings
                if (desc == String.Empty)
                {
                    desc = EmptyString;
                }

                return(desc);
            }

            bool TryGetParsedValue(string str, out object @out)
            {
                var canConvert = parseFunc(str, out var output);

                if (isEnumerable)
                {
                    try
                    {
                        var val = JsonConvert.DeserializeObject(str, type);
                        @out = val;
                        return(true);
                    }
                    catch
                    {
                        @out = null;
                        return(false); // can't deserialise
                    }
                }

                if (canConvert)
                {
                    @out = output;
                    return(true);
                }

                if (supportNullable && (str == String.Empty))
                {
                    @out = null;
                    return(true);
                }

                @out = null;
                return(false); // can't convert
            }

            var updateButton = new Button("update")
            {
                Visible = false
            };

            Action <ITextControl> onText = t =>
            {
                var canParse = TryGetParsedValue(t.Text, out var newValue);

                if (liveUpdate && canParse)
                {
                    sv(newValue);
                }
                else
                {
                    updateButton.Visible = canParse;
                }
            };

            var initialText = GetStringRepresentationForValue() ?? "";
            var s           = !isEnumerable
                    ? (ITextControl) new TextBox(initialText, WidthForTextBox(o, p), onText)
            {
                IsMultithreaded = true
            }
                    : (ITextControl) new TextArea(initialText, 40, onText)
            {
                IsMultithreaded = true
            };

            updateButton.Click += (sender, e) =>
            {
                if (!TryGetParsedValue(s.Text, out var newValue))
                {
                    return;
                }

                sv(newValue);
                updateButton.Visible = false;
            };

            var dc = new DumpContainer
            {
                Style   = "text-align: center; vertical-align: middle;",
                Content = Util.HorizontalRun(true, s, updateButton)
            };

            return(dc);
        }