Exemple #1
0
        public void Edit(object mem, IWin32Window f)
        {
            MemStructObject o = (MemStructObject)mem;

            switch (o.Type)
            {
            case MemStructObject.ObjectType.OBJECT:
                ObjectBlock b = (ObjectBlock)o;

                ObjectFormManager om = new ObjectFormManager(sharedManager, b);
                om.Attach(this);

                ObjectForm of = new ObjectForm(sharedManager, om, "PuzzLearn - Edit Object", b);
                of.ShowDialog(f);

                break;

            case MemStructObject.ObjectType.REGION:
                AddressRegion r = (AddressRegion)o;

                RegionFormManager rm = new RegionFormManager(sharedManager, r);
                rm.Attach(this);

                RegionForm rf = new RegionForm(sharedManager, rm, "PuzzLearn - Edit Region", r);
                rf.ShowDialog(f);

                break;
            }
        }
Exemple #2
0
 public void Update(AddressRegion newStruct, AddressRegion oldStruct)
 {
     if (oldStruct == null)
     {
         structures.Add(newStruct);
     }
     else
     {
         oldStruct.CopyValues(newStruct);
     }
 }
        private static AddressRegion ReadAddressRegion(string[] regionLine, StreamReader reader, ref int lineCount)
        {
            if (regionLine.Count() != 6)
            {
                throw new FormatException("Invalid address region line at line " + lineCount);
            }

            AddressRegion region;
            int           structCount;

            try
            {
                string desc = regionLine[1];
                int    sa   = Convert.ToInt32(regionLine[2]);
                int    ea   = Convert.ToInt32(regionLine[3]);
                int    inc  = Convert.ToInt32(regionLine[4]);
                structCount = Convert.ToInt32(regionLine[5]);

                region = new AddressRegion(desc, new List <MemStructObject>(), sa, ea, inc);
            }
            catch
            {
                throw new FormatException("Invalid address region line at line " + lineCount);
            }

            for (int i = 0; i < structCount; ++i)
            {
                string[] nextLine = reader.ReadLine().Split(',');
                ++lineCount;

                int t = 0;
                if (!int.TryParse(nextLine[0], out t))
                {
                    throw new FormatException("First argument must be an int at line " + lineCount);
                }

                switch (t)
                {
                case (int)MemStructObject.ObjectType.OBJECT:
                    region.Structures.Add(ReadObjectBlock(nextLine, reader, ref lineCount));
                    break;

                case (int)MemStructObject.ObjectType.REGION:
                    region.Structures.Add(ReadAddressRegion(nextLine, reader, ref lineCount));
                    break;

                default:
                    throw new FormatException("Invalid type for a region at line " + lineCount);
                }
            }

            return(region);
        }
        public AddressRegion(AddressRegion copy)
            : base(copy)
        {
            startAddress = copy.startAddress;
            endAddress   = copy.endAddress;
            increment    = copy.increment;

            structures = new List <MemStructObject>();

            foreach (MemStructObject o in copy.structures)
            {
                structures.Add((MemStructObject)(o.Clone()));
            }
        }
Exemple #5
0
        public RegionFormManager(ISharedManager sm, AddressRegion or = null)
        {
            sharedManager = sm;
            oldRegion     = or;
            observers     = new List <IStructureObserver <AddressRegion> >();

            structures = new BindingList <MemStructObject>();
            if (or != null)
            {
                foreach (var o in or.Structures)
                {
                    structures.Add((MemStructObject)o.Clone());
                }
            }
        }
Exemple #6
0
        public bool Confirm(string startAdrStr, string endAdrStr, string description, decimal incrementDec)
        {
            if (startAdrStr == "" || endAdrStr == "" || description == "")
            {
                return(false);
            }

            int startAdr  = Convert.ToInt32(startAdrStr, 16);
            int endAdr    = Convert.ToInt32(endAdrStr, 16);
            int increment = Convert.ToInt32(incrementDec);

            newRegion = new AddressRegion(description, structures, startAdr, endAdr, increment);
            Notify();

            return(true);
        }
Exemple #7
0
        public RegionForm(ISharedManager sm, IRegionFormManager rm, string title, AddressRegion r = null)
        {
            sharedManager = sm;
            rManager      = rm;

            InitializeComponent();
            Text = title;
            StructuresGridView.AutoGenerateColumns = false;
            StructuresGridView.DataSource          = rManager.GetDataSource();

            if (r != null)
            {
                DescriptionTextBox.Text      = r.Description;
                StartAddressTextBox.Text     = r.StartAddress.ToString("X");
                EndAddressTextBox.Text       = r.EndAddress.ToString("X");
                AddressIncrementUpDown.Value = r.Increment;
            }
        }
        private static void WriteAddressRegion(AddressRegion ar, StringBuilder builder)
        {
            builder.Append((int)ar.Type + d + ar.Description + d + ar.StartAddress + d
                           + ar.EndAddress + d + ar.Increment + d + ar.Structures.Count + n);

            foreach (var s in ar.Structures)
            {
                switch (s.Type)
                {
                case MemStructObject.ObjectType.OBJECT:
                    WriteObjectBlock((ObjectBlock)s, builder);
                    break;

                case MemStructObject.ObjectType.REGION:
                    WriteAddressRegion((AddressRegion)s, builder);
                    break;
                }
            }
        }