Exemplo n.º 1
0
        public MediumLevelRecordEditor(SubRecord sr, SubrecordStructure ss, dFormIDLookupS formIDLookup,
                                       dFormIDScan formIDScan, dLStringLookup strIDLookup)
        {
            InitializeComponent();
            Icon = Resources.tesv_ico;
            SuspendLayout();
            this.sr           = sr;
            this.ss           = ss;
            this.formIDLookup = formIDLookup;
            this.formIDScan   = formIDScan;
            this.strIDLookup  = strIDLookup;

            int offset = 0;

            byte[] data = sr.GetReadonlyData();
            boxes      = new List <TextBox>(ss.elements.Length);
            valueTypes = new List <ElementValueType>(ss.elements.Length);
            elements   = new List <Panel>();
            int groupOffset  = 0;
            int CurrentGroup = 0;

            try
            {
                for (int i = 0; i < ss.elements.Length; i++)
                {
                    if (ss.elements[i].optional && offset == data.Length)
                    {
                        AddElement(ss.elements[i]);
                    }
                    else
                    {
                        AddElement(ss.elements[i], ref offset, data, ref groupOffset, ref CurrentGroup);
                        if (ss.elements[i].repeat > 0)
                        {
                            repeatcount++;
                            if (offset < data.Length)
                            {
                                i--;
                            }
                        }
                    }
                }
                if (ss.elements[ss.elements.Length - 1].repeat > 0 && repeatcount > 0)
                {
                    AddElement(ss.elements[ss.elements.Length - 1]);
                }
            }
            catch
            {
                MessageBox.Show("The subrecord doesn't appear to conform to the expected structure.\n" +
                                "Saving is disabled, and the formatted information may be incorrect", "Warning");
                bSave.Enabled = false;
            }
            ResumeLayout();
        }
Exemplo n.º 2
0
 public HexDataEdit(string RecName, byte[] data, dFormIDLookupS formIDLookup)
 {
   InitializeComponent();
   Icon = Resources.fomm02;
   this.formIDLookup = formIDLookup;
   tbName.Text = RecName;
   var dbytes = new DynamicByteProvider(data);
   bytes = dbytes.Bytes;
   hexBox1.ByteProvider = dbytes;
   Canceled = true;
 }
Exemplo n.º 3
0
        public HexDataEdit(string RecName, byte[] data, dFormIDLookupS formIDLookup)
        {
            InitializeComponent();
            Icon = Resources.fomm02;
            this.formIDLookup = formIDLookup;
            tbName.Text       = RecName;
            var dbytes = new DynamicByteProvider(data);

            bytes = dbytes.Bytes;
            hexBox1.ByteProvider = dbytes;
            Canceled             = true;
        }
Exemplo n.º 4
0
        public MediumLevelRecordEditor(SubRecord sr, SubrecordStructure ss, dFormIDLookupS formIDLookup, dFormIDScan formIDScan, dLStringLookup strIDLookup)
        {
            this.InitializeComponent();
            Icon = Resources.tesv_ico;
            SuspendLayout();
            this.sr = sr;
            this.ss = ss;
            this.formIDLookup = formIDLookup;
            this.formIDScan = formIDScan;
            this.strIDLookup = strIDLookup;

            int offset = 0;
            byte[] data = sr.GetReadonlyData();
            this.boxes = new List<TextBox>(ss.elements.Length);
            this.valueTypes = new List<ElementValueType>(ss.elements.Length);
            this.elements = new List<Panel>();
            int groupOffset = 0;
            int CurrentGroup = 0;
            try
            {
                for (int i = 0; i < ss.elements.Length; i++)
                {
                    if (ss.elements[i].optional > 0 && offset == data.Length)
                    {
                        this.AddElement(ss.elements[i]);
                    }
                    else
                    {
                        this.AddElement(ss.elements[i], ref offset, data, ref groupOffset, ref CurrentGroup);
                        if (ss.elements[i].repeat > 0)
                        {
                            this.repeatcount++;
                            if (offset < data.Length)
                            {
                                i--;
                            }
                        }
                    }
                }

                if (ss.elements[ss.elements.Length - 1].repeat > 0 && this.repeatcount > 0)
                {
                    this.AddElement(ss.elements[ss.elements.Length - 1]);
                }
            }
            catch
            {
                MessageBox.Show("The subrecord doesn't appear to conform to the expected structure.\n" + "Saving is disabled, and the formatted information may be incorrect", "Warning");
                this.bSave.Enabled = false;
            }

            ResumeLayout();
        }
Exemplo n.º 5
0
 public HexDataEdit(string RecName, byte[] data, dFormIDLookupS formIDLookup)
 {
     InitializeComponent();
     this.Icon         = Properties.Resources.tesv_ico;
     this.formIDLookup = formIDLookup;
     Text                += RecName;
     tbName.Text          = RecName;
     Text                += " (hex mode)";
     dbytes               = new Be.Windows.Forms.DynamicByteProvider(data);
     bytes                = dbytes.Bytes;
     hexBox1.ByteProvider = dbytes;
     Canceled             = true;
 }
Exemplo n.º 6
0
 public HexDataEdit(string RecName, byte[] data, dFormIDLookupS formIDLookup)
 {
     this.InitializeComponent();
     Icon = Resources.tesv_ico;
     this.formIDLookup = formIDLookup;
     Text += RecName;
     this.tbName.Text = RecName;
     Text += " (hex mode)";
     this.dbytes = new DynamicByteProvider(data);
     this.bytes = this.dbytes.Bytes;
     this.hexBox1.ByteProvider = this.dbytes;
     Canceled = true;
 }
Exemplo n.º 7
0
 public HexDataEdit(string RecName, byte[] data, dFormIDLookupS formIDLookup)
 {
     InitializeComponent();
     this.Icon=Fomm.Properties.Resources.fomm02;
     this.formIDLookup=formIDLookup;
     Text+=RecName;
     tbName.Text=RecName;
     Text+=" (hex mode)";
     dbytes=new Be.Windows.Forms.DynamicByteProvider(data);
     bytes=dbytes.Bytes;
     hexBox1.ByteProvider=dbytes;
     Canceled=true;
 }
Exemplo n.º 8
0
 public HexDataEdit(string RecName, byte[] data, dFormIDLookupS formIDLookup)
 {
     this.InitializeComponent();
     Icon = Resources.tesv_ico;
     this.formIDLookup = formIDLookup;
     Text                     += RecName;
     this.tbName.Text          = RecName;
     Text                     += " (hex mode)";
     this.dbytes               = new DynamicByteProvider(data);
     this.bytes                = this.dbytes.Bytes;
     this.hexBox1.ByteProvider = this.dbytes;
     Canceled                  = true;
 }
Exemplo n.º 9
0
        public void EditSelectedSubrecord()
        {
            var context = Selection;
            var rec     = Selection.Record as Record;

            if (rec == null)
            {
                return;
            }
            var p = GetPluginFromNode(rec);

            if (p == null)
            {
                return;
            }
            var sr = GetSelectedSubrecord();

            if (sr == null)
            {
                return;
            }

            if (OnEditSubrecord != null)
            {
                OnEditSubrecord(sr, false);
                return;
            }

            if (Properties.Settings.Default.UseOldSubRecordEditor)
            {
                new DataEdit(sr.Name, sr.GetData()).ShowDialog();
                if (!DataEdit.Canceled)
                {
                    sr.SetData(DataEdit.result);
                    sr.Name = DataEdit.resultName;
                }
            }
            else if (!Properties.Settings.Default.UseHexSubRecordEditor &&
                     sr.Structure != null &&
                     sr.Structure.elements != null &&
                     sr.Structure.elements.Length > 0 &&
                     sr.Structure.elements[0].type != ElementValueType.Blob && !sr.Structure.UseHexEditor)
            {
                Form re;
                try
                {
                    if (Properties.Settings.Default.UseOldSubRecordEditor)
                    {
                        var r            = context.Record;
                        var formIDLookup = new dFormIDLookupS(p.LookupFormIDS);
                        var formIDScan   = new dFormIDScan(FormIDScan);
                        var strIDLookup  = new dLStringLookup(p.LookupFormStrings);
                        re = new MediumLevelRecordEditor(sr, sr.Structure, formIDLookup, formIDScan, strIDLookup);
                    }
                    else
                    {
                        re = new NewMediumLevelRecordEditor(p, rec, sr, sr.Structure);
                    }
                }
                catch
                {
                    MessageBox.Show("Subrecord doesn't seem to conform to the expected structure.", Resources.ErrorText);
                    re = null;
                }
                if (re != null)
                {
                    if (DialogResult.OK == re.ShowDialog(this))
                    {
                        if (sr.Parent is Record)
                        {
                            sr.Parent.UpdateShortDescription();
                        }
                        listSubrecord.Refresh();
                        FireSubrecordChanged(sr);
                        FireDataChanged();
                    }
                    return;
                }
            }
            else
            {
                EditSelectedSubrecordHex();
            }
        }