Ejemplo n.º 1
0
        void tbc_Enter(object sender, EventArgs e)
        {
            TGIBlockCombo tbc = sender as TGIBlockCombo;

            if (ltbc.Contains(tbc))
            {
                ClearLinkedPartsTLP(true);//before currentEntry changes
                currentPartEntry    = ltbc.IndexOf(tbc);
                btnMoveUp.Enabled   = currentPartEntry > 0;
                btnMoveDown.Enabled = currentPartEntry < ltbc.Count - 1;
                currentVPXYEntry    = int.Parse(((Label)tlpParts.GetControlFromPosition(0, tlpParts.GetCellPosition(ltbc[currentPartEntry]).Row)).Text, System.Globalization.NumberStyles.HexNumber);
                tlpParts.Controls.Add(lbCurrentPart, 1, currentPartEntry + 1);

                if (tbc.Tag != null)
                {
                    btnAddLinked.Enabled = false;
                    FillLinkedPartsTLP(currentVPXYEntry, tbc.Tag as VPXY.Entry00);
                }
                else
                {
                    btnAddLinked.Enabled = true;
                }
            }
            else
            {
                currentLPEntry    = lLPtbc.IndexOf(tbc);
                btnLPUp.Enabled   = currentLPEntry > 0;
                btnLPDown.Enabled = currentLPEntry < lLPtbc.Count - 1;
                tlpLinkedParts.Controls.Add(lbLPCurrent, 1, currentLPEntry + 1);
            }
        }
Ejemplo n.º 2
0
        void saveVPXY()
        {
            rcol.ResourceChanged -= new EventHandler(rcol_ResourceChanged);
            try
            {
                ClearLinkedPartsTLP(true);
                CountedTGIBlockList ltgib = new CountedTGIBlockList(null);
                vpxy.Entries.Clear();
                int  count   = 0;
                byte count00 = 1;
                for (int row = 1; row < tlpParts.RowCount - 1; row++)
                {
                    TGIBlockCombo c = tlpParts.GetControlFromPosition(2, row) as TGIBlockCombo;
                    if (ltbc.IndexOf(c) < 0)
                    {
                        continue;
                    }
                    if (c.SelectedIndex < 0)
                    {
                        continue;
                    }
                    ltgib.Add(vpxy.TGIBlocks[c.SelectedIndex]);
                    vpxy.Entries.Add(new VPXY.Entry01(0, null, 1, count++));
                    if (c.Tag != null)
                    {
                        VPXY.Entry00 e00 = c.Tag as VPXY.Entry00;
                        if (e00.TGIIndexes.Count <= 0)
                        {
                            continue;
                        }
                        e00.EntryID = count00++;
                        e00.TGIIndexes.ForEach(elem =>
                        {
                            ltgib.Add(vpxy.TGIBlocks[elem]);
                            elem = count++;
                        });
                        if (e00.TGIIndexes.Count > 0)
                        {
                            vpxy.Entries.Add(e00);
                        }
                    }
                }
                if (vpxy.Modular)
                {
                    ltgib.Add(vpxy.TGIBlocks[tbcFTPT.SelectedIndex]);
                    vpxy.FTPTIndex = count++;
                }

                vpxy.TGIBlocks.Clear();
                vpxy.TGIBlocks.AddRange(ltgib);

                result = (byte[])rcol.AsBytes.Clone();
            }
            finally { rcol.ResourceChanged -= new EventHandler(rcol_ResourceChanged); }
        }
Ejemplo n.º 3
0
 void ClearLinkedPartsTLP(bool saving)
 {
     if (currentPartEntry != -1)
     {
         VPXY.Entry00 e00 = ltbc[currentPartEntry].Tag as VPXY.Entry00;
         if (e00 != null)
         {
             e00.TGIIndexes.Clear();
             for (int row = 1; row < tlpLinkedParts.RowCount - 1; row++)
             {
                 TGIBlockCombo c = tlpLinkedParts.GetControlFromPosition(2, row) as TGIBlockCombo;
                 if (lLPtbc.IndexOf(c) < 0)
                 {
                     continue;
                 }
                 if (c.SelectedIndex < 0)
                 {
                     continue;
                 }
                 e00.TGIIndexes.Add(c.SelectedIndex);
             }
             if (saving && e00.TGIIndexes.Count == 0)
             {
                 vpxy.Entries.Remove(e00);
                 ltbc[currentPartEntry].Tag = null;
                 RenumberTLP();
             }
         }
     }
     currentLPEntry = -1;
     lLPtbc         = null;
     for (int i = 0; i < tlpLinkedParts.Controls.Count; i++)
     {
         if (!tlpLinkedParts.Controls[i].Equals(lbLPTitle))
         {
             tlpLinkedParts.Controls.Remove(tlpLinkedParts.Controls[i--]);
         }
     }
     while (tlpLinkedParts.RowStyles.Count > 2)
     {
         tlpLinkedParts.RowStyles.RemoveAt(1);
     }
     tlpLinkedParts.RowCount = 2;
     tlpLPControls.Enabled   = tlpLinkedParts.Enabled = false;
 }
Ejemplo n.º 4
0
        Control ResourceKeyEditor(bool enabled, string name, ref int tabIndex, ObjKeyResource.ObjKeyResource.ComponentDataType cdt)
        {
            ObjKeyResource.ObjKeyResource.CDTResourceKey cdtResourceKey = cdt as ObjKeyResource.ObjKeyResource.CDTResourceKey;
            Label lb = new Label();

            lb.AutoSize = true;
            lb.Text     = "(WWWW) 0xDDDDDDDD-0xDDDDDDDD-0xDDDDDDDDDDDDDDDD";

            TGIBlockCombo tbc = new TGIBlockCombo(objk.TGIBlocks, cdtResourceKey == null ? -1 : cdtResourceKey.Data, false);

            tbc.Anchor               = AnchorStyles.Left;
            tbc.Enabled              = enabled;
            tbc.Name                 = "tbc" + name;
            tbc.TabIndex             = tabIndex++;
            tbc.Width                = lb.PreferredWidth;
            tbc.TGIBlockListChanged += new EventHandler(tbc_TGIBlockListChanged);
            return(tbc);
        }
Ejemplo n.º 5
0
        void moveDown(TableLayoutPanel tlp, List <TGIBlockCombo> ltbc, Label lb, TLPRenumber renumber, ref int entry)
        {
            TGIBlockCombo c1 = tlp.GetControlFromPosition(2, entry + 1) as TGIBlockCombo; //this control
            TGIBlockCombo c2 = tlp.GetControlFromPosition(2, entry + 2) as TGIBlockCombo; //the one below to swap with

            tlp.Controls.Remove(c1);                                                      //leaves entry + 1 free
            tlp.Controls.Add(c2, 2, entry + 1);                                           //leaves entry + 2 free
            tlp.Controls.Add(c1, 2, entry + 2);
            c2.TabIndex--;
            c1.TabIndex++;

            int i = ltbc.IndexOf(c1);

            ltbc.RemoveAt(i);
            ltbc.Insert(i + 1, c1);

            entry++;
            tlp.Controls.Add(lb, 1, entry + 1);
            renumber();
            c1.Focus();
        }
Ejemplo n.º 6
0
        void tbc_SelectedIndexChanged(object sender, EventArgs e)
        {
            TGIBlockCombo tbc = sender as TGIBlockCombo;

            if (ltbc.Contains(tbc))
            {
                int          i   = int.Parse(((Label)tlpParts.GetControlFromPosition(0, tlpParts.GetCellPosition(tbc).Row)).Text, System.Globalization.NumberStyles.HexNumber);
                VPXY.Entry01 e01 = vpxy.Entries[i] as VPXY.Entry01;
                e01.TGIIndex = (tbc.SelectedIndex >= 0) ? tbc.SelectedIndex : 0;
            }
            else
            {
                if (currentPartEntry == -1)
                {
                    return;
                }
                VPXY.Entry00 e00 = ltbc[currentPartEntry].Tag as VPXY.Entry00;
                int          i   = lLPtbc.IndexOf(tbc);
                e00.TGIIndexes[i] = (tbc.SelectedIndex >= 0) ? tbc.SelectedIndex : 0;
            }
        }
Ejemplo n.º 7
0
        void AddTableRowTBC(TableLayoutPanel tlp, int entry, int index, ref int tabindex)
        {
            tlp.RowCount++;
            tlp.RowStyles.Insert(tlp.RowCount - 2, new RowStyle(SizeType.AutoSize));

            Label         lb  = new Label();
            TGIBlockCombo tbc = new TGIBlockCombo(vpxy.TGIBlocks, index, false);

            lb.AutoSize    = true;
            lb.BorderStyle = BorderStyle.Fixed3D;
            lb.Dock        = DockStyle.Fill;
            lb.FlatStyle   = FlatStyle.Standard;
            lb.Margin      = new Padding(0);
            lb.Name        = "lbEntry" + tabindex;
            lb.TabIndex++;
            lb.Text      = entry.ToString("X");
            lb.TextAlign = ContentAlignment.MiddleRight;
            lb.Tag       = tbc;
            lb.Click    += new EventHandler(lb_Click);
            tlp.Controls.Add(lb, 0, tlp.RowCount - 2);

            tbc.Anchor                = AnchorStyles.Left | AnchorStyles.Right;
            tbc.Name                  = "tbc" + tabindex;
            tbc.TabIndex              = tabindex++;
            tbc.Enter                += new EventHandler(tbc_Enter);
            tbc.SelectedIndexChanged += new EventHandler(tbc_SelectedIndexChanged);
            tlp.Controls.Add(tbc, 2, tlp.RowCount - 2);

            if (tlp == tlpParts)
            {
                ltbc.Add(tbc);
            }
            else
            {
                lLPtbc.Add(tbc);
            }
            tbc.Focus();

            tbc.TGIBlockListChanged += new EventHandler(tbg_TGIBlockListChanged);
        }
Ejemplo n.º 8
0
        void saveObjKey()
        {
            objk.Components.Clear();
            objk.ComponentData.Clear();
            foreach (string name in ComponentNames)
            {
                if (!hasComponent(name))
                {
                    continue;
                }
                objk.Components.Add(new ObjKeyResource.ObjKeyResource.ComponentElement(0, null, (ObjKeyResource.ObjKeyResource.Component)Enum.Parse(typeof(ObjKeyResource.ObjKeyResource.Component), name)));
                if (ComponentDataTypeMap.ContainsKey(name))
                {
                    int row = ComponentNames.IndexOf(name);
                    row++;
                    if (name.Equals("Sim") && !((CheckBox)tableLayoutPanel1.GetControlFromPosition(1, row)).Checked)
                    {
                        continue;
                    }

                    TypeKey tk   = ComponentDataTypeMap[name];
                    string  type = tk.type.Name.Substring(3);
                    if (type == "String")
                    {
                        TextBox tb    = (TextBox)tableLayoutPanel1.GetControlFromPosition(2, row);
                        string  value = tb.Text;
                        objk.ComponentData.Add(new ObjKeyResource.ObjKeyResource.CDTString(0, null, tk.key, 0x00, value));
                    }
                    else if (type == "ResourceKey")
                    {
                        TGIBlockCombo cb    = (TGIBlockCombo)tableLayoutPanel1.GetControlFromPosition(2, row);
                        Int32         value = cb.SelectedIndex;
                        objk.ComponentData.Add(new ObjKeyResource.ObjKeyResource.CDTResourceKey(0, null, tk.key, 0x01, value));
                    }
                    else if (type == "AssetResourceName")
                    {
                        TGIBlockCombo cb    = (TGIBlockCombo)tableLayoutPanel1.GetControlFromPosition(2, row);
                        Int32         value = cb.SelectedIndex;
                        objk.ComponentData.Add(new ObjKeyResource.ObjKeyResource.CDTAssetResourceName(0, null, tk.key, 0x02, value));
                    }
                    else if (type == "SteeringInstance")
                    {
                        TextBox tb    = (TextBox)tableLayoutPanel1.GetControlFromPosition(2, row);
                        string  value = tb.Text;
                        objk.ComponentData.Add(new ObjKeyResource.ObjKeyResource.CDTSteeringInstance(0, null, tk.key, 0x03, value));
                    }
                    else if (type == "UInt32")
                    {
                        TextBox tb = (TextBox)tableLayoutPanel1.GetControlFromPosition(2, row);
                        string  s  = tb.Text.ToLower().Trim();
                        UInt32  value;
                        if (s.StartsWith("0x"))
                        {
                            value = uint.Parse(s.Substring(2), System.Globalization.NumberStyles.HexNumber);
                        }
                        else
                        {
                            value = uint.Parse(s);
                        }
                        objk.ComponentData.Add(new ObjKeyResource.ObjKeyResource.CDTUInt32(0, null, tk.key, 0x04, value));
                    }
                }
            }
            if (ckbAllowObjectHiding.Checked)
            {
                objk.ComponentData.Add(new ObjKeyResource.ObjKeyResource.CDTUInt32(0, null, "allowObjectHiding", 0x04, 0));
            }

            result = (byte[])objk.AsBytes.Clone();
        }