public async Task <ToolGroup> Create(ToolGroupCreate toolIn)
        {
            var toolGroup = ToolGroup.FromCreate(toolIn);
            await _toolGroups.InsertOneAsync(toolGroup);

            return(toolGroup);
        }
        public async Task <IActionResult> Update([FromHeader] string authToken, string id, ToolGroupUpdate groupIn)
        {
            if (!await _authenticationService.CheckAccess(authToken, "stuToolMgr"))
            {
                return(Unauthorized());
            }

            var toolGroup = await _toolService.Get(id);

            if (toolGroup == null)
            {
                return(NotFound());
            }

            _toolService.Update(toolGroup, groupIn);

            await _logService.Create(new Log(
                                         null,
                                         AuthenticationHelpers.GetUserIdFromToken(authToken),
                                         DateTime.UtcNow,
                                         "Document modified.",
                                         "toolGroups",
                                         id,
                                         JsonSerializer.Serialize(ToolGroup.FromUpdate(toolGroup, groupIn))
                                         ));

            return(Ok());
        }
示例#3
0
        public void AddToolToGroup(int groupId, BaseTool tool, Action toolActivatedCallback)
        {
            List <ToolGroupEntry> tools = null;

            for (int i = 0; i < m_ToolGroups.Count; ++i)
            {
                if (m_ToolGroups[i].groupId == groupId)
                {
                    tools = m_ToolGroups[i].tools;
                }

                var toolIndex = m_ToolGroups[i].tools.FindIndex(x => x.tool == tool);
                if (toolIndex != -1)
                {
                    Debug.LogError(string.Format("{0} already exist in group.", tool.name));
                    return;
                }
            }

            if (tools == null)
            {
                var toolGroup = new ToolGroup()
                {
                    groupId = groupId
                };
                tools = toolGroup.tools;
                m_ToolGroups.Add(toolGroup);
            }

            tools.Add(new ToolGroupEntry()
            {
                tool             = tool,
                activateCallback = toolActivatedCallback
            });
        }
示例#4
0
 private void SetTintColor()
 {
     for (int i = 0; i < buttonGroups.Count; i++)
     {
         ToolGroup toolGroup = toolGroups[i];
         buttonGroups[i].SetTintColor(StyleManager.Themes[toolGroup.Color]);
     }
 }
示例#5
0
        public static bool IsUsingAnyTool(ToolGroup group)
        {
            if (Swapper == null)
            {
                return(false);
            }

            return(Swapper.IsInToolMode(ToolMode.Probe, group) || Swapper.IsInToolMode(ToolMode.Translator, group) || Swapper.IsInToolMode(ToolMode.SignalScope, group));
        }
示例#6
0
        override protected void CreateChildren()
        {
            base.CreateChildren();

            #region Tools

            Button button = new Button
            {
                SkinClass    = typeof(ImageButtonSkin),
                Icon         = global::eDriven.Core.Caching.ImageLoader.Instance.Load("Icons/cancel"),
                FocusEnabled = false,
                Styles       = ButtonStyles
            };
            button.Click += delegate
            {
                DispatchEvent(new CloseEvent(CloseEvent.CLOSE));
            };
            ToolGroup.AddChild(button);

            #endregion

            #region Image

            _image = new Image {
                Id = "image", PercentWidth = 100, PercentHeight = 100, ScaleMode = ImageScaleMode.ScaleToFit
            };
            AddContentChild(_image);

            #endregion

            #region Control bar

            ControlBarGroup.AddChild(new Spacer {
                PercentWidth = 100
            });

            button = new Button
            {
                Text         = "Close preview",
                SkinClass    = typeof(ImageButtonSkin),
                Icon         = global::eDriven.Core.Caching.ImageLoader.Instance.Load("Icons/color_swatch"),
                FocusEnabled = false,
                Styles       = ButtonStyles
            };
            button.Click += delegate
            {
                DispatchEvent(new CloseEvent(CloseEvent.CLOSE));
            };
            ControlBarGroup.AddChild(button);

            #endregion
        }
示例#7
0
        public bool TryGetTool(out Tool tool, out ToolGroup toolGroup)
        {
            var hand = MyAPIGateway.Session.Player.Character.EquippedTool as IMyHandheldGunObject <MyDeviceBase>;

            if (hand == null)
            {
                tool      = null;
                toolGroup = null;
                return(false);
            }
            int discard;

            return(TryGetTool(hand.PhysicalItemDefinition.Id, out tool, out discard, out toolGroup));
        }
示例#8
0
        public void ToolEdited(Tool tool, bool?equip = null)
        {
            bool toolbar;

            if (equip.HasValue)
            {
                toolbar = equip.Value;
            }
            else
            {
                toolbar = ToolSwitcherSession.IsToolbarCharacter() && ModEnabled && loaded;
            }

            for (int i = groups.Count - 1; i >= 0; i--)
            {
                ToolGroup g = groups[i];
                if (g.Remove(tool))
                {
                    if (g.Count == 0)
                    {
                        groups.RemoveAtFast(i);
                    }
                    else if (toolbar)
                    {
                        g.EquipAny();
                    }
                }
            }

            for (int i = 0; i < groups.Count; i++)
            {
                ToolGroup g = groups[i];
                if (g.ShouldContain(tool))
                {
                    g.Add(tool);
                    if (toolbar)
                    {
                        tool.Equip();
                    }
                    return;
                }
            }

            groups.Add(new ToolGroup(tool.Page, tool.Slot, tool));
            if (toolbar)
            {
                tool.Equip();
            }
        }
示例#9
0
            public ToolGroup GetToolGroup(Type flagType)
            {
                foreach (KeyValuePair <string, ToolGroup> groupPair in ToolGroups)
                {
                    if (groupPair.Key == flagType.Name)
                    {
                        return(groupPair.Value);
                    }
                }
                var group = new ToolGroup();

                group.Flags = new FlagGroup(flagType);
                ToolGroups[flagType.Name] = group;
                return(group);
            }
示例#10
0
 public bool TryGetTool(MyDefinitionId id, out Tool tool, out int index, out ToolGroup toolGroup)
 {
     tool      = null;
     toolGroup = null;
     foreach (ToolGroup g in groups)
     {
         Tool t;
         if (g.TryGetTool(id, out t, out index))
         {
             tool      = t;
             toolGroup = g;
             return(true);
         }
     }
     index = -1;
     return(false);
 }
        public async Task <ActionResult <ToolGroup> > Create([FromHeader] string authToken, ToolGroupCreate tool)
        {
            if (!await _authenticationService.CheckAccess(authToken, "stuToolMgr"))
            {
                return(Unauthorized());
            }

            ToolGroup created = await _toolService.Create(tool);

            await _logService.Create(new Log(
                                         null,
                                         AuthenticationHelpers.GetUserIdFromToken(authToken),
                                         DateTime.UtcNow,
                                         "Document created.",
                                         "toolGroups",
                                         created.Id,
                                         JsonSerializer.Serialize(created)
                                         ));

            return(Ok(tool));
        }
示例#12
0
    public void RefreshToolPanel()
    {
        List <ToolGroup> currentToolGroups = new List <ToolGroup>();

        foreach (ToolGroup toolGroup in totalToolGroups)
        {
            if (!isGeometry && toolGroup.Type != ToolGroupType.Geometry)
            {
                continue;
            }

            ToolGroup filterToolGroup = new ToolGroup();
            filterToolGroup.Icon  = toolGroup.Icon;
            filterToolGroup.Name  = toolGroup.Name;
            filterToolGroup.Color = toolGroup.Color;
            filterToolGroup.Type  = toolGroup.Type;
            filterToolGroup.Tools = new List <Tool>();

            foreach (Tool tool in toolGroup.Tools)
            {
                if (tool.Type == toolType || (tool.Type == GeometryType.General && toolType != GeometryType.ResolvedBody) || tool.Type == GeometryType.Common)
                {
                    filterToolGroup.Tools.Add(tool);
                }
            }
            if (filterToolGroup.Tools.Count > 0)
            {
                currentToolGroups.Add(filterToolGroup);
            }

            // Debug.Log(filterToolGroup.Name + " ------------> ");
            // foreach (Tool tool in filterToolGroup.Tools)
            //     Debug.Log(tool.Name);
            // Debug.Log(filterToolGroup.Name + " <------------ ");
        }

        toolPanel.SetToolGroups(currentToolGroups);
        toolPanel.RefreshButtonGroups();
    }
示例#13
0
        override protected void CreateChildren()
        {
            base.CreateChildren();

            Button button;

            for (var i = 0; i < 14; i++)
            {
                button = new Button
                {
                    Text         = "Button " + (i + 1),
                    SkinClass    = typeof(ImageButtonSkin),
                    FocusEnabled = false,
                    Icon         = Resources.Load <Texture>("Icons/shape_square_add"),
                    Width        = (_random.Next(2) == 1) ? 400 : 200,
                    Height       = (_random.Next(2) == 1) ? 200 : 150
                };
                AddContentChild(button);
            }

            button = new Button
            {
                SkinClass    = typeof(ImageButtonSkin),
                Icon         = ImageLoader.Instance.Load("Icons/cancel"),
                FocusEnabled = false,
                Styles       = _buttonStyles
            };
            button.Click += delegate
            {
                DispatchEvent(new CloseEvent(CloseEvent.CLOSE));
            };
            ToolGroup.AddChild(button);

            _btnHoriz = new Button
            {
                Text         = "Horizontal",
                SkinClass    = typeof(ImageButtonSkin),
                Icon         = ImageLoader.Instance.Load("Icons/color_swatch"),
                ToggleMode   = true,
                FocusEnabled = false,
                Styles       = _buttonStyles
            };
            _btnHoriz.Click += delegate
            {
                //AnimateToLayout(_horizontalLayout);
                SetCurrentState("horizontal");
                Defer(HandleButtons, 1);
            };
            ControlBarGroup.AddChild(_btnHoriz);

            _btnVert = new Button
            {
                Text         = "Vertical",
                SkinClass    = typeof(ImageButtonSkin),
                Icon         = ImageLoader.Instance.Load("Icons/color_swatch"),
                ToggleMode   = true,
                FocusEnabled = false,
                Styles       = _buttonStyles
            };
            _btnVert.Click += delegate
            {
                //AnimateToLayout(_verticalLayout);
                SetCurrentState("vertical");
                Defer(HandleButtons, 1);
            };
            ControlBarGroup.AddChild(_btnVert);

            _btnTile = new Button
            {
                Text         = "Tile",
                SkinClass    = typeof(ImageButtonSkin),
                Icon         = ImageLoader.Instance.Load("Icons/color_swatch"),
                ToggleMode   = true,
                FocusEnabled = false,
                Styles       = _buttonStyles,
                Selected     = true
            };
            _btnTile.Click += delegate
            {
                SetCurrentState("tile"); //tile
                Defer(HandleButtons, 1);
            };
            ControlBarGroup.AddChild(_btnTile);

            ControlBarGroup.AddChild(new Spacer {
                PercentWidth = 100
            });

            button = new Button
            {
                Text         = "Close window",
                SkinClass    = typeof(ImageButtonSkin),
                Icon         = ImageLoader.Instance.Load("Icons/color_swatch"),
                FocusEnabled = false,
                Styles       = _buttonStyles
            };
            button.Click += delegate
            {
                DispatchEvent(new CloseEvent(CloseEvent.CLOSE));
            };
            ControlBarGroup.AddChild(button);

            List <string> icons = new List <string> {
                "lock", "star", "accept"
            };

            for (int i = 0; i < 3; i++)
            {
                button = new Button
                {
                    Text         = UppercaseFirst(icons[i]),
                    SkinClass    = typeof(ImageButtonSkin),
                    FocusEnabled = false,
                    Styles       = _buttonStyles,
                    Icon         = ImageLoader.Instance.Load("Icons/" + icons[i])
                };
                ControlBarGroup.AddChild(button);
            }
        }
示例#14
0
 public async void Update(ToolGroup group, ToolGroupUpdate groupIn) =>
 await _toolGroups.ReplaceOneAsync(toolGroup => toolGroup.Id == group.Id, ToolGroup.FromUpdate(group, groupIn));
示例#15
0
        override protected void CreateChildren()
        {
            base.CreateChildren();

            Button button;

            #region View + vertical scrollbar

            _view = new VGroup
            {
                Id = "view",
                ClipAndEnableScrolling = true,
                Left                      = 0, /*Right = 16, */ Top = 0, Bottom = 0,
                PaddingLeft               = 10,
                PaddingRight              = 10,
                PaddingTop                = 10,
                PaddingBottom             = 10,
                Gap                       = 6,
                StopMouseWheelPropagation = true
            };
            AddContentChild(_view);

            _vScrollBar = new VScrollBar
            {
                Left      = null,
                Right     = 0,
                Top       = 0,
                Bottom    = 0,
                Viewport  = _view,
                SkinClass = typeof(VScrollBarSkin3)
            };
            AddContentChild(_vScrollBar);

            //_vScrollBar.ValidateNow();
            //_view.Right = _vScrollBar.MeasuredWidth;

            #endregion

            for (int i = 0; i < 14; i++)
            {
                button = new Button
                {
                    Text         = "Button " + (i + 1),
                    SkinClass    = typeof(ImageButtonSkin),
                    FocusEnabled = false,
                    Icon         = ImageLoader.Instance.Load("Icons/shape_square_add")
                };
                //button.Click += delegate { AddButton(); };
                _view.AddChild(button);
            }

            List <string> icons = new List <string> {
                "maximize", "cancel"
            };
            for (int i = 0; i < icons.Count; i++)
            {
                button = new Button
                {
                    FocusEnabled = false,
                    SkinClass    = typeof(ImageButtonSkin),
                    Icon         = ImageLoader.Instance.Load("Icons/" + icons[i])
                };
                button.Click += delegate(Event e) { Debug.Log("Clicked: " + e.Target); };
                ToolGroup.AddChild(button);
            }

            button = new Button
            {
                Text         = "Clip",
                SkinClass    = typeof(ImageButtonSkin),
                Icon         = ImageLoader.Instance.Load("Icons/color_swatch"),
                ToggleMode   = true,
                FocusEnabled = false,
                Selected     = true
            };
            button.Change += delegate(Event e)
            {
                Button btn = (Button)e.Target;
                //Debug.Log("Selected: " + btn.Selected);
                _view.ClipAndEnableScrolling = btn.Selected;
            };
            ControlBarGroup.AddChild(button);

            icons = new List <string> {
                "lock", "star", "accept"
            };
            for (int i = 0; i < 3; i++)
            {
                button = new Button
                {
                    Text         = UppercaseFirst(icons[i]),
                    SkinClass    = typeof(ImageButtonSkin),
                    FocusEnabled = false,
                    Icon         = ImageLoader.Instance.Load("Icons/" + icons[i])
                };
                //button.Click += delegate { AddButton(); };
                ControlBarGroup.AddChild(button);
            }
        }
示例#16
0
        override protected void CreateChildren()
        {
            base.CreateChildren();

            Form form = new Form {
                PercentWidth = 100, Left = 10, Right = 10, Top = 10, Bottom = 10
            };

            AddContentChild(form);

            #region Text Fields

            _txtFirstName = new TextField {
                PercentWidth = 100                            /*, Optimized = true*/
            };
            _txtFirstName.TextChange += delegate
            {
                // update item
                _item.FirstName = _txtFirstName.Text;
            };
            form.AddField("first_name", "First name:", _txtFirstName);

            _txtLastName = new TextField {
                PercentWidth = 100                           /*, Optimized = true*/
            };
            _txtLastName.TextChange += delegate
            {
                // update item
                _item.LastName = _txtLastName.Text;
            };
            form.AddField("last_name", "Last name:", _txtLastName);

            _nsAge = new NumericStepper {
                Width = 60, FocusEnabled = true, HighlightOnFocus = true
            };
            _nsAge.ValueCommit += delegate
            {
                // update item
                _item.Age = (int)_nsAge.Value;
            };
            form.AddField("age", "Age:", _nsAge);

            _chkDrivingLicense         = new CheckBox();
            _chkDrivingLicense.Change += delegate
            {
                // update item
                _item.DrivingLicense = _chkDrivingLicense.Selected;
            };
            form.AddField("driving_license", "Driving license:", _chkDrivingLicense);

            #endregion

            ControlBarGroup.AddChild(new Spacer {
                PercentWidth = 100
            });

            #region Close button

            var button = new Button
            {
                SkinClass    = typeof(ImageButtonSkin),
                Icon         = ImageLoader.Instance.Load("Icons/cancel"),
                FocusEnabled = false,
                Styles       = _buttonStyles
            };
            button.Click += delegate
            {
                DispatchEvent(new CloseEvent(CloseEvent.CLOSE));
            };
            ToolGroup.AddChild(button);

            #endregion

            #region Control bar buttons

            button = new Button
            {
                Text         = "Close dialog",
                SkinClass    = typeof(ImageButtonSkin),
                Icon         = ImageLoader.Instance.Load("Icons/color_swatch"),
                FocusEnabled = false,
                Styles       = _buttonStyles
            };
            button.Click += delegate
            {
                DispatchEvent(new CloseEvent(CloseEvent.CLOSE));
            };
            ControlBarGroup.AddChild(button);

            #endregion
        }
示例#17
0
 /// <summary>
 /// 查找刀具
 /// </summary>
 /// <param name="toolName"></param>
 /// <returns></returns>
 public NCGroup FindTool(string toolName)
 {
     return(ToolGroup.Find(a => a.Name.Equals(toolName, StringComparison.CurrentCultureIgnoreCase)));
 }