public ObjectFormManager(ISharedManager sm, ObjectBlock o = null)
        {
            observers     = new List <IStructureObserver <ObjectBlock> >();
            oldBlock      = o;
            sharedManager = sm;
            xAddresses    = new BindingList <IntegerAddress>();
            yAddresses    = new BindingList <IntegerAddress>();
            xPending      = false;

            if (o != null)
            {
                if (o.Information == null)
                {
                    info = null;
                }
                else
                {
                    info = (InformationAddress)o.Information.Clone();
                }
                foreach (var x in o.XAddresses)
                {
                    xAddresses.Add((IntegerAddress)x.Clone());
                }
                foreach (var y in o.YAddresses)
                {
                    yAddresses.Add((IntegerAddress)y.Clone());
                }
            }
        }
예제 #2
0
        private static void WriteObjectBlock(ObjectBlock ob, StringBuilder builder)
        {
            int info = 0;

            if (ob.Information != null)
            {
                info = 1;
            }

            builder.Append((int)ob.Type + d + ob.Description + d + ob.FixedValue + d
                           + ob.XAddresses.Count + d + ob.YAddresses.Count + d + info + n);

            foreach (var x in ob.XAddresses)
            {
                WriteIntegerAddress(x, builder);
            }

            foreach (var y in ob.YAddresses)
            {
                WriteIntegerAddress(y, builder);
            }

            if (ob.Information != null)
            {
                WriteInformationAddress(ob.Information, builder);
            }
        }
예제 #3
0
        public void CopyValues(ObjectBlock copy)
        {
            fixedValue = copy.fixedValue;

            if (copy.information == null)
            {
                information = null;
            }
            else
            {
                information = (InformationAddress)copy.information.Clone();
            }

            xAddresses.Clear();
            foreach (IntegerAddress x in copy.xAddresses)
            {
                xAddresses.Add((IntegerAddress)x.Clone());
            }

            yAddresses.Clear();
            foreach (IntegerAddress y in copy.yAddresses)
            {
                yAddresses.Add((IntegerAddress)y.Clone());
            }

            base.CopyValues(copy);
        }
예제 #4
0
        public ObjectBlock(ObjectBlock copy)
            : base(copy)
        {
            fixedValue = copy.fixedValue;

            if (copy.information == null)
            {
                information = null;
            }
            else
            {
                information = (InformationAddress)copy.information.Clone();
            }

            xAddresses = new List <IntegerAddress>();
            foreach (IntegerAddress x in copy.xAddresses)
            {
                xAddresses.Add((IntegerAddress)x.Clone());
            }

            yAddresses = new List <IntegerAddress>();
            foreach (IntegerAddress y in copy.yAddresses)
            {
                yAddresses.Add((IntegerAddress)y.Clone());
            }
        }
예제 #5
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;
            }
        }
예제 #6
0
 public void Update(ObjectBlock newStruct, ObjectBlock oldStruct)
 {
     if (oldStruct == null)
     {
         structures.Add(newStruct);
     }
     else
     {
         oldStruct.CopyValues(newStruct);
     }
 }
        public bool Confirm(decimal fixedValueDec, string description)
        {
            if (description == "")
            {
                return(false);
            }

            int fixedValue = decimal.ToInt32(fixedValueDec);

            newBlock = new ObjectBlock(description, xAddresses, yAddresses, info, fixedValue);
            Notify();

            return(true);
        }
예제 #8
0
        private static ObjectBlock ReadObjectBlock(string[] objectLine, StreamReader reader, ref int lineCount)
        {
            ++lineCount;

            if (objectLine.Count() != 6)
            {
                throw new FormatException("Invalid object block line at line " + lineCount);
            }

            ObjectBlock ob;
            int         xCount;
            int         yCount;
            int         hasInfo;

            try
            {
                string desc       = objectLine[1];
                int    fixedValue = Convert.ToInt32(objectLine[2]);
                xCount  = Convert.ToInt32(objectLine[3]);
                yCount  = Convert.ToInt32(objectLine[4]);
                hasInfo = Convert.ToInt32(objectLine[5]);

                ob = new ObjectBlock(desc, new List <IntegerAddress>(), new List <IntegerAddress>(), null, fixedValue);
            }
            catch
            {
                throw new FormatException("Invalid object block line at line " + lineCount);
            }

            for (int i = 0; i < xCount; ++i)
            {
                ob.XAddresses.Add(ReadIntegerAddress(reader, ref lineCount));
            }

            for (int i = 0; i < yCount; ++i)
            {
                ob.YAddresses.Add(ReadIntegerAddress(reader, ref lineCount));
            }

            if (hasInfo == 1)
            {
                string[] infoLine = reader.ReadLine().Split(',');
                ++lineCount;
                ob.Information = ReadInformationAddress(infoLine, reader, ref lineCount);
            }

            return(ob);
        }
예제 #9
0
        public ObjectForm(ISharedManager sm, IObjectFormManager ofm, string title, ObjectBlock o = null)
        {
            sharedManager = sm;
            objectManager = ofm;

            InitializeComponent();
            Text = title;
            XAddressesGridView.AutoGenerateColumns = false;
            YAddressesGridView.AutoGenerateColumns = false;

            XAddressesGridView.DataSource  = objectManager.GetXAddresses();
            YAddressesGridView.DataSource  = objectManager.GetYAddresses();
            InformationAddressTextBox.Text = objectManager.GetInfoString();

            if (o != null)
            {
                DescriptionTextBox.Text = o.Description;
                FixedValueUpDown.Value  = o.FixedValue;
            }
        }