Exemplo n.º 1
0
 public DetailedItemPage(DetailedItem item)
 {
     itemx = item;
     InitializeComponent();
     refreshItem();
     initItem();
 }
        public void Creator(DetailedItem item, object obj)
        {
            if (item == null || obj == null) return;
            item.panel.DoubleClick += (s, e) =>
            {
                item.panel.SendMessage(Message.Click, new MouseEventArgs());
            };
            item.panel.Click += (s, e) =>
            {
                CheckBox cb = (CheckBox)item.itemControls["checkbox"];
                cb.Checked = !cb.Checked;
            };
            CheckBox checkbox = new CheckBox(manager);
            checkbox.Init();
            checkbox.Parent = item.panel;
            checkbox.Left = 6;
            checkbox.Top = 3;
            checkbox.Checked = false;
            checkbox.Text = "";
            checkbox.Name = "checkbox";
            item.AddControl(checkbox);

            mtypes types = Utils.GetCompTypes((Type)item.obj);
            if (types == mtypes.none) return;
            bool AO = (types & mtypes.affectother) == mtypes.affectother;
            bool AS = (types & mtypes.affectself) == mtypes.affectself;
            bool D = ((types & mtypes.draw) == mtypes.draw) || (types & mtypes.minordraw) == mtypes.minordraw;
            bool Q = (types & mtypes.tracer) == mtypes.tracer;
            bool TREE = (Type)item.obj == typeof(Tree);
            //int weight = 0;
            //if (AO) weight += 10;
            //if (AS) weight += 1;
            //if (D) weight += 1;
            //if (Q) weight += 3;
            //if (TREE) weight = 50;
            int leftcounter = 135;
            //NewLabel(weight.ToString(), hc, item, "label1");
            //leftcounter += 100;
            if (AO) NewLabel(UserInterface.Checkmark, leftcounter, item, "label2"); else NewLabel(UserInterface.Cross, leftcounter, item, "label2");
            leftcounter += 20;
            if (AS) NewLabel(UserInterface.Checkmark, leftcounter, item, "label3"); else NewLabel(UserInterface.Cross, leftcounter, item, "label3");
            leftcounter += 20;
            if (D)  NewLabel(UserInterface.Checkmark, leftcounter, item, "label4"); else NewLabel(UserInterface.Cross, leftcounter, item, "label4");

            Info info = Utils.GetInfoType((Type)item.obj);
            if (info == null) Console.WriteLine("Info was null on component type " + item.obj);
            else
            {
                string summary = info.summary.wordWrap(32);
                item.panel.MouseOver += (s, e) =>
                {
                    lblCompName.Text = item.obj.ToString().LastWord('.');
                    lblDescription.Text = summary;
                };
            }
        }
Exemplo n.º 3
0
        public DetailedItem GetDetailedItem(int id)
        {
            DetailedItem result    = null;
            string       itemsJson = JsonBody($"http://localhost:8000/item?id={id.ToString()}");
            //json parse
            var options = new JsonDocumentOptions
            {
                AllowTrailingCommas = true
            };

            if (itemsJson != null)
            {
                using (JsonDocument document = JsonDocument.Parse(itemsJson, options))
                {
                    JsonElement element = document.RootElement;


                    int    id2      = element.GetProperty("id").GetInt32();
                    string name     = element.GetProperty("name").GetString();
                    int    price    = element.GetProperty("current_price").GetInt32();
                    int    priceBuy = -1;
                    if (element.GetProperty("quick_buy").GetBoolean())
                    {
                        priceBuy = element.GetProperty("buy_price").GetInt32();
                    }
                    int  minBid   = element.GetProperty("min_bid").GetInt32();
                    bool quickBuy = element.GetProperty("quick_buy").GetBoolean();
                    bool New      = element.GetProperty("new").GetBoolean();

                    string category    = element.GetProperty("category").GetString();
                    string image       = element.GetProperty("image").GetString();
                    string description = element.GetProperty("description").GetString();
                    string end_date    = element.GetProperty("end_date").GetString();
                    string seller      = element.GetProperty("seller").GetString();

                    string sold_to = element.GetProperty("sold_to").GetString();


                    result = (new DetailedItem(id2, name, price, priceBuy, category, image, description, end_date, seller, minBid, quickBuy, New, sold_to));
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        public int AddNewItem(ItemDtoModel item, ItemDetailDtoModel itemDetail)
        {
            using (EF_Models.ESDatabaseContext context = new EF_Models.ESDatabaseContext())
            {
                UnitOfWork uow = new UnitOfWork(context);
                if (item == null || itemDetail == null)
                {
                    throw new ArgumentNullException();
                }
                Item         efItem         = _mapper.Map <Item>(item);
                DetailedItem efDetailedItem = _mapper.Map <DetailedItem>(itemDetail);
                uow.Items.AddNewItem(efItem);
                efItem.DetailedItem.Add(efDetailedItem);
                uow.Commit();

                int itemID = efItem.Id;
                return(itemID);
            }
        }
        private void ItemCreatorDelegate(DetailedItem item, object obj)
        {
            if (item.obj is InspectorInfo)
            {
                InspectorInfo ii = (InspectorInfo)item.obj;
                if (!(ii.obj is Node)) return;
                Node n = (Node)ii.obj;
                item.label.Text = n.name;
                Button btnEdit = new Button(manager);
                btnEdit.Init();
                btnEdit.Parent = item.panel;
                btnEdit.Width = 30;
                btnEdit.Left = item.panel.Width - btnEdit.Width - 10;
                btnEdit.Top = 2;
                btnEdit.Height = item.buttonHeight;

                btnEdit.Text = "Edit";
                btnEdit.ToolTip.Text = "Edit";
                btnEdit.Name = "Player Edit";
                btnEdit.TextColor = UserInterface.TomShanePuke;

                EventHandler editplayer = (s, e) =>
                {
                    item.isSelected = true;
                    //editGroupWindow = new EditGroupWindow(sidebar);
                    //editGroupWindow.componentView.SwitchGroup(g);
                    editGroupWindow = new EditNodeWindow(sidebar, "Player", n.name, ViewType.Node);
                    //editGroupWindow.componentView.SwitchGroup(g);
                    editGroupWindow.componentView.SwitchNode(n, false);
                };

                btnEdit.Click += editplayer;
                item.panel.DoubleClick += editplayer;

                Button btnEnabled = new Button(manager);
                btnEnabled.Init();
                btnEnabled.Parent = item.panel;
                btnEnabled.Width = 30;
                btnEnabled.Left = btnEdit.Left - btnEnabled.Width - 5;
                btnEnabled.Top = 2;
                btnEnabled.Height = item.buttonHeight;
                //btnEnabled.Draw += btnEnabled_Draw;

                //btnEnabled.Text = "On";
                SetButtonBool(btnEnabled, n.active);
                btnEnabled.ToolTip.Text = "Player Enabled";
                btnEnabled.TextColor = UserInterface.TomShanePuke;
                btnEnabled.Click += (s, e) =>
                {
                    n.active = GetButtonBool(btnEnabled);
                    SetButtonBool(btnEnabled, n.active);
                };
            }
        }
        public void InitNode(Node node)
        {
            int heightcounter = 0;
            List<Type> compTypes = new List<Type>();
            foreach (Type ctype in Component.compTypes)
            {
                Info info = Utils.GetInfoType(ctype);
                if (info == null || (int)sidebar.userLevel < (int)info.userLevel) continue;
                if (node.HasComp(ctype)) continue;
                if ((Utils.GetCompTypes(ctype) & mtypes.exclusiveLinker) == mtypes.exclusiveLinker) continue;
                compTypes.Add(ctype);
            }

            compTypes.Sort((t1, t2) => t1.Name.CompareTo(t2.Name));

            foreach(Type ctype in compTypes)
            {
                DetailedItem ditem = new DetailedItem(manager, this, ctype, backPanel, heightcounter, 0);
                SetupScroll(ditem);
                ditem.label.Text = ditem.label.Text;
                ditem.label.Left += 30;
                CreateItem(ditem);
                heightcounter += ditem.panel.Height;
            }
            backPanel.Refresh();
        }
 public void NewLabel(string s, int left, DetailedItem item, string name)
 {
     Label label = new Label(manager);
     label.Init();
     label.Parent = item.panel;
     label.Top = 1;
     label.Left = left;
     label.TextColor = Color.Black;
     label.Width = 30;
     label.Text = s;
     label.Name = name;
     if (s.Equals(UserInterface.Checkmark)) label.TextColor = UserInterface.TomShanePuke;
     else if (s.Equals(UserInterface.Cross)) label.TextColor = Color.Red;
     item.AddControl(label);
 }
 public void CreateNewItem(Group g)
 {
     int top = 0;
     if (viewItems.Count > 0)
     {
         top = (viewItems[0].itemHeight - 4) * viewItems.Count;
     }
     DetailedItem detailedItem = new DetailedItem(manager, this, g, backPanel, top, LeftPadding);
     base.CreateItem(detailedItem);
 }
Exemplo n.º 9
0
        public void refreshItem()
        {
            int Id = itemx.Id;

            itemx = helper.GetDetailedItem(Id);
        }
 public void CreateNewItem(InspectorInfo item)
 {
     int top = 0;
     if (viewItems.Count > 0)
     {
         top = (viewItems[0].itemHeight - 4) * viewItems.Count;
     }
     DetailedItem detailedItem = new DetailedItem(manager, this, item, backPanel, top, LeftPadding);
     if (item.ToolTip.Length > 0) detailedItem.panel.ToolTip.Text = item.ToolTip;
     viewItems.Add(detailedItem);
     SetupScroll(detailedItem);
 }
 private SharedKnowledgeSingleton()
 {
     _selectedItem = new DetailedItem();
 }
 public void OnEvent(Control control, DetailedItem item, EventArgs e)
 {
     if (item == null || control == null || item.obj == null) return;
     if (!(item.obj is InspectorInfo)) return;
     InspectorInfo ins = (InspectorInfo)item.obj;
     if (e is KeyEventArgs && control.GetType() == typeof(TextBox))
     {
         KeyEventArgs ke = (KeyEventArgs)e;
         if (ke.Key != Microsoft.Xna.Framework.Input.Keys.Enter) return;
         TextBox textbox = (TextBox)control;
         object san = ins.TrySanitize(textbox.Text);
         if (san != null)
         {
             ins.SetValue(san);
             //Console.WriteLine(ins.parentItem.obj.GetType() + " >> " + ins + " >> " + san.GetType() + " >> " + san);
             if (GroupSync)
             {
                 ins.ApplyToAllNodes(activeGroup);
             }
         }
         marginalize(textbox);
     }
     else if (control is ComboBox)
     {
         ins.SetValue(control.Text);
         if (GroupSync)
         {
             ins.ApplyToAllNodes(activeGroup);
         }
     }
     else if (control is Button)
     {
         if (control.Name.Equals("bool_button_enabled"))
         {
             ins.SetValue(GetButtonBool((Button)control));
             if (GroupSync)
             {
                 ins.ApplyToAllNodes(activeGroup);
             }
         }
         else if (control.Name.Equals("toggle_button_enabled"))
         {
             ins.SetValue(GetButtonBool((Button)control));
             if (GroupSync)
             {
                 ins.ApplyToAllNodes(activeGroup);
             }
         }
         else if (control.Name.Equals("component_button_enabled"))
         {
             Component component = (Component)ins.obj;
             component.active = GetButtonBool((Button)control);
             if (this is ComponentView)
             {
                 ComponentView cv = (ComponentView)this;
                 if (cv.lblCurrentComp.Text.Equals(component.GetType().ToString().LastWord('.')))
                     cv.lblCurrentComp.TextColor = control.TextColor;
             }
             //ins.SetValue(checkbox.Checked);
             if (GroupSync)
             {
                 foreach (Node n in activeGroup.fullSet)
                 {
                     if (n.HasComp(component.GetType()))
                         n.comps[component.GetType()].active = component.active;
                 }
             }
         }
         else if (control.Name.Equals("component_button_remove"))
         {
             if (ins.obj is Component)
             {
                 Component component = (Component)ins.obj;
                 if (this is ComponentView && (this as ComponentView).viewType == ViewType.Link)
                 {
                     ComponentView cv = (ComponentView)this;
                     cv.rootLink.components.Remove(component.GetType());
                 }
                 else
                 {
                     component.parent.RemoveComponent(component.GetType());
                     if (GroupSync)
                     {
                         foreach (Node n in activeGroup.fullSet)
                         {
                             n.RemoveComponent(component.GetType());
                         }
                     }
                 }
             }
             if (this is ComponentView) (this as ComponentView).RefreshComponents();
         }
         else if (control.Name.Equals("method_button_invoke"))
         {
             if (ins.methodInfo != null)
             {
                 ins.methodInfo.Invoke(ins.parentobj, null);
                 if (GroupSync)
                 {
                     ins.ApplyToAllNodes(activeGroup);
                 }
             }
         }
     }
 }
        private void ItemCreatorDelegate(DetailedItem item, object obj)
        {
            //editGroupWindow = new EditNodeWindow(sidebar, "All Players", room.groups.playerGroup.Name);
            //editGroupWindow.componentView.SwitchGroup(room.groups.playerGroup);
            //editGroupWindow.componentView.SwitchNode(n, false);
            if (obj == null) return;
            if (obj is InspectorInfo)
            {
                InspectorInfo inspectorItem = (InspectorInfo)obj;

                if (inspectorItem.methodInfo != null)
                {
                    Button btnInvoke = new Button(manager);
                    btnInvoke.Init();
                    btnInvoke.Parent = item.panel;
                    btnInvoke.TextColor = Color.Blue;
                    btnInvoke.Width = 50;
                    btnInvoke.Left = item.panel.Width - btnInvoke.Width - btnInvoke.Width - 5;
                    btnInvoke.Height = item.buttonHeight;
                    btnInvoke.ToolTip.Text = "Invoke Method";
                    btnInvoke.Name = "method_button_invoke";
                    btnInvoke.Text = "Do";
                    item.AddControl(btnInvoke);
                }

                if (inspectorItem.obj == null) return;
                object o = inspectorItem.obj;
                bool isToggle = Utils.isToggle(o);

                if (o != null)
                {
                    if (o is Node)
                    {
                        //item.label.Text = "Root";
                        Node n = (Node)o;
                        Button btnEdit = new Button(manager);
                        btnEdit.Init();
                        btnEdit.Parent = item.panel;
                        btnEdit.Width = 30;
                        btnEdit.Left = item.panel.Width - btnEdit.Width - 10;
                        btnEdit.Top = 2;
                        btnEdit.Height = item.buttonHeight;

                        EventHandler editnode = (s, e) =>
                        {
                            //item.isSelected = true;
                            EditNodeWindow editNodeWindow = new EditNodeWindow(sidebar, inspectorItem.Name(), n.name, ViewType.Node);
                            editNodeWindow.componentView.SwitchNode(n, false);
                        };

                        btnEdit.Text = "Edit";
                        btnEdit.ToolTip.Text = "Edit";
                        btnEdit.TextColor = UserInterface.TomShanePuke;

                        btnEdit.Click += editnode;
                    }
                    else if (o is Link)
                    {
                        Link link = (Link)o;
                        Button btnEdit = new Button(manager);
                        btnEdit.Init();
                        btnEdit.Parent = item.panel;
                        btnEdit.Width = 30;
                        btnEdit.Left = item.panel.Width - btnEdit.Width - 10;
                        btnEdit.Top = 2;
                        btnEdit.Height = item.buttonHeight;
                        EventHandler editlink = (s, e) =>
                        {
                            EditLinkWindow editLinkWindow = new EditLinkWindow(sidebar, link, inspectorItem.Name());
                        };
                        btnEdit.Text = "Edit";
                        btnEdit.ToolTip.Text = "Edit";
                        btnEdit.TextColor = UserInterface.TomShanePuke;

                        btnEdit.Click += editlink;
                    }
                    else if (o is Body || o is Component)
                    {
                        item.label.Text = o.GetType().ToString().LastWord('.');
                    }
                    if (o is Component)
                    {
                        Component comp = (Component)o;

                        Button btnEnabled = new Button(manager);
                        btnEnabled.Init();
                        btnEnabled.Parent = item.panel;
                        btnEnabled.TextColor = Color.Red;
                        btnEnabled.Width = 25;
                        btnEnabled.Left = item.panel.Width - btnEnabled.Width - 20;
                        btnEnabled.Top = 3;
                        btnEnabled.Height = item.buttonHeight;
                        btnEnabled.ToolTip.Text = "Toggle Active";
                        btnEnabled.Name = "component_button_enabled";
                        SetButtonBool(btnEnabled, comp.active);
                        item.AddControl(btnEnabled);

                        //check for essential
                        if (!comp.isEssential())
                        {
                            Button btnRemove = new Button(manager);
                            btnRemove.Init();
                            btnRemove.Parent = item.panel;
                            btnRemove.TextColor = Color.Red;
                            btnRemove.Left = btnEnabled.Left - 20;
                            btnRemove.Top = 3;
                            btnRemove.Height = item.buttonHeight;
                            btnRemove.Width = item.buttonWidth;
                            btnRemove.Text = "-";
                            btnRemove.ToolTip.Text = "Remove";
                            btnRemove.Name = "component_button_remove";
                            item.AddControl(btnRemove);
                        }
                    }
                    else if (o is int || o is Single || o is byte || isToggle)
                    {
                        int w = 60;
                        TextBox textbox = new TextBox(manager);
                        textbox.ClientMargins = new Margins();
                        textbox.Init();
                        textbox.Parent = item.panel;
                        textbox.TextColor = UserInterface.TomShanePuke;
                        textbox.Left = backPanel.Width - w - 26;
                        textbox.Width = w;
                        textbox.Height = textbox.Height - 4;

                        textbox.Name = "number_textbox";
                        if (isToggle)
                        {
                            textbox.Name = "toggle_textbox";

                            Button btnEnabled = new Button(manager);
                            btnEnabled.Init();
                            btnEnabled.Parent = item.panel;
                            btnEnabled.TextColor = Color.Red;
                            btnEnabled.Width = 25;
                            btnEnabled.Left = textbox.Left - btnEnabled.Width;
                            //btnEnabled.Top = 3;
                            btnEnabled.Height = item.buttonHeight;
                            btnEnabled.ToolTip.Text = "Toggle Active";
                            btnEnabled.Name = "toggle_button_enabled";
                            SetButtonBool(btnEnabled, (o as dynamic).enabled);
                            item.AddControl(btnEnabled);

                            //item.AddControl(checkbox);

                            //textbox.Text = (o as dynamic).valueString(); // too slow.
                            textbox.Text = "...";
                        }
                        else textbox.Text = o.ToString();
                        textbox.ClientArea.Top += 2;
                        textbox.ClientArea.Left += 4;
                        textbox.FocusLost += delegate
                        {
                            textbox.SendMessage(Message.KeyUp, new KeyEventArgs(Microsoft.Xna.Framework.Input.Keys.Enter));
                        };
                        textbox.ClientArea.Move += delegate
                        {
                            marginalize(textbox);
                        };
                        item.AddControl(textbox);
                        Type primitiveType = !isToggle ? o.GetType() : ((dynamic)o).value.GetType();

                        Button up = new Button(manager);
                        up.SetSize(textbox.ClientArea.Height, textbox.ClientArea.Height / 2);
                        up.Anchor = Anchors.Right;
                        up.Init();
                        up.Left = textbox.ClientArea.Width - up.Width;
                        sidebar.ui.SetScrollableControl(up, List_ChangeScrollPosition);

                        up.ToolTip.Text = "Increment : RightClick = byOne, MiddleClick = byTen, RightClick = Double";
                        up.MouseDown += (s, e) =>
                        {
                            switch (e.Button)
                            {
                                case MouseButton.Left:
                                    textbox.Text = textbox.Text.increment(primitiveType, NumBoxMode.byOne);
                                    break;
                                case MouseButton.Right:
                                    textbox.Text = textbox.Text.increment(primitiveType, NumBoxMode.quadratic);
                                    break;
                                case MouseButton.Middle:
                                    textbox.Text = textbox.Text.increment(primitiveType, NumBoxMode.byTen);
                                    break;
                            }
                            textbox.SendMessage(Message.KeyUp, new KeyEventArgs(Microsoft.Xna.Framework.Input.Keys.Enter));
                            marginalize(textbox);
                        };
                        textbox.Add(up);

                        Button down = new Button(manager);
                        down.SetSize(textbox.ClientArea.Height, textbox.ClientArea.Height / 2);
                        down.Anchor = Anchors.Right;
                        down.Top = up.Height;
                        down.Init();
                        down.ToolTip.Text = "Decrement : RightClick = byOne, MiddleClick = byTen, RightClick = half";
                        down.MouseDown += (s, e) =>
                        {
                            switch (e.Button)
                            {
                                case MouseButton.Left:
                                    textbox.Text = textbox.Text.decrement(primitiveType, NumBoxMode.byOne);
                                    break;
                                case MouseButton.Right:
                                    textbox.Text = textbox.Text.decrement(primitiveType, NumBoxMode.quadratic);
                                    break;
                                case MouseButton.Middle:
                                    textbox.Text = textbox.Text.decrement(primitiveType, NumBoxMode.byTen);
                                    break;
                            }
                            textbox.SendMessage(Message.KeyUp, new KeyEventArgs(Microsoft.Xna.Framework.Input.Keys.Enter));
                            marginalize(textbox);
                        };
                        down.Left = textbox.ClientArea.Width - down.Width;
                        sidebar.ui.SetScrollableControl(down, List_ChangeScrollPosition);
                        textbox.Add(down);

                        //todo: make tiny + and - buttons
                    }
                    else if (o is string)
                    {
                        int w = 60;
                        TextBox textbox = new TextBox(manager);
                        textbox.ClientMargins = new Margins();
                        textbox.Init();
                        textbox.Parent = item.panel;
                        textbox.TextColor = UserInterface.TomShanePuke;
                        textbox.Left = backPanel.Width - w - 26;
                        textbox.Width = w;
                        textbox.Height = textbox.Height - 4;
                        textbox.Text = o.ToString();
                        textbox.Name = "string_textbox";
                        item.AddControl(textbox);

                        textbox.ClientArea.Top += 2;
                        textbox.ClientArea.Left += 2;
                        textbox.KeyPress += delegate
                        {
                            if (!textbox.Text.Equals(""))
                            {
                                textbox.ClientArea.Top += 2;
                                textbox.ClientArea.Left += 2;
                            }
                        };

                    }
                    else if (o is bool)
                    {
                        Button btnEnabled = new Button(manager);
                        btnEnabled.Init();
                        btnEnabled.Parent = item.panel;
                        btnEnabled.TextColor = Color.Red;
                        btnEnabled.Width = 25;
                        btnEnabled.Left = item.panel.Width - btnEnabled.Width - 20;
                        //btnEnabled.Top = 3;
                        btnEnabled.Height = item.buttonHeight;
                        btnEnabled.ToolTip.Text = "Toggle Enabled";
                        btnEnabled.Name = "bool_button_enabled";
                        SetButtonBool(btnEnabled, (bool)o);
                        item.AddControl(btnEnabled);
                    }
                    else if (o.GetType().IsEnum)
                    {
                        int w = 95;
                        ComboBox combobox = new ComboBox(manager);
                        combobox.ClientMargins = new Margins();
                        combobox.Init();
                        combobox.TextColor = UserInterface.TomShanePuke;
                        combobox.Parent = item.panel;
                        combobox.Left = backPanel.Width - w - 26;
                        combobox.Height = combobox.Height - 4;
                        combobox.Width = w;
                        combobox.MaxItems = 15;
                        int i = 0;
                        foreach(string s in Enum.GetNames(o.GetType()))
                        {
                            combobox.Items.Add(s);
                            if (s.Equals(o.ToString())) combobox.ItemIndex = i;
                            i++;
                        }
                        combobox.Name = "enum_combobox";
                        item.AddControl(combobox);

                        combobox.ClientArea.Top += 2;
                        combobox.ClientArea.Left += 2;
                        combobox.ItemIndexChanged += delegate
                        {
                            if (!combobox.Text.Equals(""))
                            {
                                combobox.ClientArea.Top += 2;
                                combobox.ClientArea.Left += 2;
                            }
                        };
                    }

                }
            }
        }
Exemplo n.º 14
0
 public override void SelectItem(DetailedItem item)
 {
     InspectorInfo ii;
     if (item.obj is InspectorInfo && (ii = (InspectorInfo)item.obj).obj is Node)
     {
         Node n = (Node)ii.obj;
         InspectorInfo metaitem = new InspectorInfo(null, n.meta, sidebar);
         insView.SetRootInspectorItem(metaitem);
         base.SelectItem(item);
     }
 }
Exemplo n.º 15
0
        private void ItemCreatorDelegate(DetailedItem item, object obj)
        {
            if (item.obj is Group)
            {
                Group g = (Group)item.obj;
                item.label.Text = g.Name;
                Button btnEdit = new Button(manager);
                btnEdit.Init();
                btnEdit.Parent = item.panel;
                btnEdit.Width = 30;
                btnEdit.Left = item.panel.Width - btnEdit.Width - 10;
                btnEdit.Top = 2;
                btnEdit.Height = item.buttonHeight;

                EventHandler editgroup = (s, e) =>
                {
                    item.isSelected = true;
                    if (parentGroup == room.groups.items)
                    {
                        editGroupWindow = new EditNodeWindow(sidebar, "Item Group", g.Name, ViewType.Group);
                    }
                    else
                    {
                        editGroupWindow = new EditNodeWindow(sidebar, g);
                    }
                    editGroupWindow.componentView.SwitchGroup(g);

                };

                btnEdit.Text = "Edit";
                btnEdit.ToolTip.Text = "Edit";
                btnEdit.TextColor = UserInterface.TomShanePuke;

                btnEdit.Click += editgroup;

                item.panel.DoubleClick += editgroup;

                Button btnEnabled = new Button(manager);
                btnEnabled.Init();
                btnEnabled.Parent = item.panel;
                btnEnabled.Width = 30;
                btnEnabled.Left = btnEdit.Left - btnEnabled.Width - 5;
                btnEnabled.Top = 2;
                btnEnabled.Height = item.buttonHeight;
                //btnEnabled.Draw += btnEnabled_Draw;

                //btnEnabled.Text = "On";
                SetButtonBool(btnEnabled, !g.Disabled);
                btnEnabled.ToolTip.Text = "Group Enabled";
                btnEnabled.TextColor = UserInterface.TomShanePuke;
                btnEnabled.Click += (s, e) =>
                {
                    g.Disabled = !GetButtonBool(btnEnabled);
                    SetButtonBool(btnEnabled, !g.Disabled);
                };

                if (!showRemoveButton) return;

                Button btnRemove = new Button(manager);
                btnRemove.Init();
                btnRemove.Parent = item.panel;
                btnRemove.Width = item.buttonWidth;
                btnRemove.Top = 2;
                btnRemove.Left = btnEnabled.Left - btnRemove.Width - 5;
                btnRemove.Height = item.buttonHeight;

                btnRemove.TextColor = Color.Red;
                btnRemove.Text = "-";
                btnRemove.ToolTip.Text = "Remove";
                btnRemove.Click += (s, e) =>
                {
                    g.EmptyGroup();
                    g.DeleteGroup();
                    UpdateGroups();
                };
            }
        }
Exemplo n.º 16
0
        public void InitializePlayers()
        {
            ClearView();

            int heightCount = 0;
            if (viewItems != null)
            {
                foreach (DetailedItem item in viewItems)
                {
                    backPanel.Remove(item.panel);
                }
            }

            viewItems = new List<DetailedItem>();
            int itemCount = playerGroup.entities.Count;
            int width = backPanel.Width - 4; //#magic number
            if (itemCount >= 10)
                width -= 18;
            foreach (Node p in playerGroup.entities)
            {
                InspectorInfo cItem = new InspectorInfo(null, p, sidebar);
                DetailedItem di = new DetailedItem(manager, this, cItem, backPanel, heightCount, LeftPadding);
                CreateItem(di);
                di.label.Text = p.name;
                heightCount += (viewItems[0].itemHeight - 2);
            }
            //heightCount += compItems[0].label.Height;
            //compItems.Add(new ComponentItem(manager, this, null, compsBackPanel, heightCount, LeftPadding));
            ScrollPosition = 0;
            backPanel.ScrollTo(backPanel.ScrollBarValue.Horizontal, 0);
            SetVisible(true);
            backPanel.Refresh();
        }
        public void SwitchNode(Node node, bool group)
        {
            ClearView();
            if (node == null) return;

            this.rootNode = node;
            if (!group)
            {
                GroupSync = false;
                insView.GroupSync = false;
                this.activeGroup = null;
            }
            //int selected = sidebar.tbcMain.SelectedIndex;
            //if (selected != 3) sidebar.tbcMain.SelectedIndex = 3;
            int heightCount = 0;
            int itemCount = node.comps.Count + 2;
            InspectorInfo rootItem = new InspectorInfo(null, node, sidebar);
            int height = 0;
            if (sidebar.userLevel == UserLevel.Debug)
            {
                CreateItem(new DetailedItem(manager, this, rootItem, backPanel, heightCount, LeftPadding));
                heightCount += viewItems[0].itemHeight - 2;
            }
            InspectorInfo bodyItem = new InspectorInfo(null, rootItem, node.body, node.GetType().GetProperty("body"));
            CreateItem(new DetailedItem(manager, this, bodyItem, backPanel, heightCount, LeftPadding));
            Info inf = Utils.GetInfoClass(node.body);
            if (inf != null) viewItems[0].toolTip = inf.summary;

            height = (viewItems[0].itemHeight - 2);

            InspectorInfo dictItem = new InspectorInfo(null, rootItem, node.comps, node.GetType().GetProperty("comps"));
            foreach (Type c in node.comps.Keys)
            {
                string tooltip = "";
                Info info = Utils.GetInfoClass(node.comps[c]);
                if (info != null)
                {
                    if ((int)info.userLevel > (int)sidebar.userLevel) continue;
                    tooltip = info.summary;
                }
                heightCount += height;
                InspectorInfo cItem = new InspectorInfo(null, dictItem, node.comps[c], c);
                DetailedItem di = new DetailedItem(manager, this, cItem, backPanel, heightCount, LeftPadding);
                di.toolTip = tooltip;
                CreateItem(di);
            }
            ScrollPosition = 0;
            backPanel.ScrollTo(backPanel.ScrollBarValue.Horizontal, 0);
            SetVisible(false);
            backPanel.Refresh();
            //if (selected != 3) sidebar.tbcMain.SelectedIndex = selected;
        }
 public void SwitchLink(Link link)
 {
     ClearView();
     if (link == null) return;
     this.rootLink = link;
     this.GroupSync = false;
     insView.GroupSync = false;
     this.activeGroup = null;
     int heightCount = 0, height = 0;
     int itemCount = link.components.Count;
     InspectorInfo rootItem = new InspectorInfo(null, link, sidebar);
     CreateItem(new DetailedItem(manager, this, rootItem, backPanel, heightCount, LeftPadding));
     height = viewItems[0].itemHeight - 2;
     heightCount += height;
     InspectorInfo formationItem = new InspectorInfo(null, rootItem, link.formation, link.GetType().GetProperty("formation"));
     CreateItem(new DetailedItem(manager, this, formationItem, backPanel, heightCount, LeftPadding));
     InspectorInfo dictItem = new InspectorInfo(null, rootItem, link.components, link.GetType().GetProperty("components"));
     foreach (Type t in link.components.Keys)
     {
         string tooltip = "";
         Info info = Utils.GetInfoClass(link.components[t]);
         if (info != null)
         {
             if ((int)info.userLevel > (int)sidebar.userLevel) continue;
             tooltip = info.summary;
         }
         heightCount += height;
         InspectorInfo cItem = new InspectorInfo(null, dictItem, link.components[t], t);
         DetailedItem di = new DetailedItem(manager, this, cItem, backPanel, heightCount, LeftPadding);
         di.toolTip = tooltip;
         CreateItem(di);
     }
     ScrollPosition = 0;
     backPanel.ScrollTo(backPanel.ScrollBarValue.Horizontal, 0);
     SetVisible(false);
     backPanel.Refresh();
 }
        public override void SelectItem(DetailedItem item)
        {
            base.SelectItem(item);
            if (item.obj == null) return;

            SetComponent(item.obj);
            lblCurrentComp.Text = item.label.Text;
            bottomArea.Refresh();
            if (item.obj is InspectorInfo)
            {
                InspectorInfo i = (InspectorInfo)item.obj;
                if (i.obj is Component)
                {
                    lblCurrentComp.TextColor = item.itemControls["component_button_enabled"].TextColor;
                }
                if (i.obj is Body)
                {
                    lblCurrentComp.TextColor = UserInterface.TomShanePuke;
                }
            }
        }
 public void OnEvent2(Control control, DetailedItem item, EventArgs e)
 {
     if (control == null || item == null) return;
     if (!(item.obj is InspectorInfo)) return;
     if (control.Text.Equals("component_button_remove"))
     {
         RefreshComponents();
     }
 }