예제 #1
0
        private void xamDataGrid_RecordUpdated(object sender, Infragistics.Windows.DataPresenter.Events.RecordUpdatedEventArgs e)
        {
            if (e.Record.Tag == null)
            {
                return;
            }

            if (((string)e.Record.Tag).Equals("AddRecord"))  // is this the "AddRecord"?
            {
                if (e.Record.DataItem.GetType() == typeof(MethodItem))
                {
                    DataRecord methodRecord = (DataRecord)e.Record;

                    MethodItem mi = ((MethodItem)(methodRecord.DataItem));

                    MethodContainer newMethod = new MethodContainer();
                    newMethod.Description     = mi.Description;
                    newMethod.OwnerID         = mi.OwnerID;
                    newMethod.BravoMethodFile = mi.BravoMethodFile;
                    newMethod.IsPublic        = mi.IsPublic;

                    bool success = wgDB.InsertMethod(ref newMethod);
                    if (success)
                    {
                        mi.MethodID = newMethod.MethodID;

                        UnMarkAddNewRecord(methodRecord);

                        MethodItem miNew = new MethodItem();
                        miNew.Description     = "";
                        miNew.MethodID        = mi.MethodID;
                        miNew.OwnerID         = mi.OwnerID;
                        miNew.IsPublic        = false;
                        miNew.BravoMethodFile = "";

                        VM.Methods.Insert(0, miNew);

                        // mark the new Method as the AddRecord
                        RecordCollectionBase coll            = e.Record.ParentCollection;
                        DataRecord           newMethodRecord = (DataRecord)coll.ElementAt(0);
                        MarkAddNewRecord(newMethodRecord);

                        // add the AddRecord Indicator for this new method
                        ObservableCollection <FilterContainer>     exFilts = VM.ExcitationFilters;
                        ObservableCollection <FilterContainer>     emFilts = VM.EmissionsFilters;
                        ObservableCollection <SignalTypeContainer> stList  = VM.SignalTypeList;
                        IndicatorItem ii = new IndicatorItem(0, mi.MethodID, "", ref stList, ref exFilts, ref emFilts);


                        mi.Indicators.Add(ii);

                        // mark the new Indicator as the AddRecord
                        ExpandableFieldRecord expRecord       = (ExpandableFieldRecord)methodRecord.ChildRecords[0];
                        DataRecord            indicatorRecord = (DataRecord)expRecord.ChildRecords[0];

                        if (indicatorRecord.DataItem.GetType() == typeof(IndicatorItem))
                        {
                            MarkAddNewRecord(indicatorRecord);
                        }


                        // add the AddRecord CompoundPlate for this new method
                        CompoundPlateItem cpi = new CompoundPlateItem();
                        cpi.CompoundPlateID = 0;
                        cpi.MethodID        = mi.MethodID;
                        cpi.Description     = "";

                        mi.CompoundPlates.Add(cpi);

                        // mark the new CompoundPlate as the AddRecord
                        ExpandableFieldRecord expRecord1          = (ExpandableFieldRecord)methodRecord.ChildRecords[1];
                        DataRecord            compoundPlateRecord = (DataRecord)expRecord1.ChildRecords[0];

                        if (compoundPlateRecord.DataItem.GetType() == typeof(CompoundPlateItem))
                        {
                            MarkAddNewRecord(compoundPlateRecord);
                        }
                    }
                }
                else if (e.Record.DataItem.GetType() == typeof(IndicatorItem))
                {
                    IndicatorItem ii = (IndicatorItem)(e.Record.DataItem);

                    IndicatorContainer ic = new IndicatorContainer();
                    ic.Description = ii.Description;
                    ic.MethodID    = ii.MethodID;
                    ic.IndicatorID = ii.IndicatorID;
                    ic.ExcitationFilterPosition = ii.ExcitationFilterPosition;
                    ic.EmissionsFilterPosition  = ii.EmissionsFilterPosition;
                    ic.SignalType = ii.SignalType;

                    bool success = wgDB.InsertIndicator(ref ic);

                    if (success)
                    {
                        ii.IndicatorID = ic.IndicatorID;

                        UnMarkAddNewRecord(e.Record);

                        ObservableCollection <FilterContainer>     exFilts = VM.ExcitationFilters;
                        ObservableCollection <FilterContainer>     emFilts = VM.EmissionsFilters;
                        ObservableCollection <SignalTypeContainer> stList  = VM.SignalTypeList;
                        IndicatorItem iiNew = new IndicatorItem(0, ic.MethodID, "", ref stList, ref exFilts, ref emFilts);


                        MethodItem mi = (MethodItem)(((DataRecord)e.Record.ParentRecord.ParentRecord).DataItem);

                        mi.Indicators.Insert(0, iiNew);

                        DataRecord newIndicatorRecord = (DataRecord)e.Record.ParentCollection[0];
                        MarkAddNewRecord(newIndicatorRecord);
                    }
                }
                else if (e.Record.DataItem.GetType() == typeof(CompoundPlateItem))
                {
                    CompoundPlateItem cpi = (CompoundPlateItem)(e.Record.DataItem);

                    CompoundPlateContainer cpc = new CompoundPlateContainer();
                    cpc.CompoundPlateID = cpi.CompoundPlateID;
                    cpc.Description     = cpi.Description;
                    cpc.MethodID        = cpi.MethodID;

                    bool success = wgDB.InsertCompoundPlate(ref cpc);

                    if (success)
                    {
                        cpi.CompoundPlateID = cpc.CompoundPlateID;

                        UnMarkAddNewRecord(e.Record);

                        CompoundPlateItem cpiNew = new CompoundPlateItem();
                        cpiNew.Description     = "";
                        cpiNew.CompoundPlateID = 0;
                        cpiNew.MethodID        = cpc.MethodID;

                        MethodItem mi = (MethodItem)(((DataRecord)e.Record.ParentRecord.ParentRecord).DataItem);

                        mi.CompoundPlates.Insert(0, cpiNew);

                        DataRecord newCompoundPlateRecord = (DataRecord)e.Record.ParentCollection[0];
                        MarkAddNewRecord(newCompoundPlateRecord);
                    }
                }
            }
        }
예제 #2
0
        private void xamDataGrid_RecordUpdated(object sender, Infragistics.Windows.DataPresenter.Events.RecordUpdatedEventArgs e)
        {
            if (e.Record.Tag == null)
            {
                return;
            }

            if (((string)e.Record.Tag).Equals("AddRecord"))  // is this the "AddRecord"?
            {
                if (e.Record.DataItem.GetType() == typeof(PlateTypeItem))
                {
                    DataRecord plateTypeRecord = (DataRecord)e.Record;

                    PlateTypeItem pti = ((PlateTypeItem)(plateTypeRecord.DataItem));

                    PlateTypeContainer ptc = pti.PlateType;

                    bool success = wgDB.InsertPlateType(ref ptc);
                    if (success)
                    {
                        UnMarkAddNewRecord(plateTypeRecord);

                        // add new blank plate type
                        PlateTypeItem newPti = new PlateTypeItem();
                        newPti.PlateType.Description = "";
                        newPti.PlateType.Cols        = ptc.Cols;
                        newPti.PlateType.Rows        = ptc.Rows;
                        newPti.PlateType.IsDefault   = false;
                        newPti.PlateType.PlateTypeID = 0;

                        VM.PlateTypeList.Insert(0, newPti);

                        // mark the new PlateType as the AddRecord
                        RecordCollectionBase coll = e.Record.ParentCollection;
                        DataRecord           newPlateTypeRecord = (DataRecord)coll.ElementAt(0);
                        MarkAddNewRecord(newPlateTypeRecord);

                        // add the blank AddRecord Mask for this new platetype
                        MaskContainer newMask = new MaskContainer();
                        newMask.Description      = "";
                        newMask.Angle            = 0.0;
                        newMask.Cols             = ptc.Cols;
                        newMask.IsDefault        = false;
                        newMask.MaskID           = 0;
                        newMask.PlateTypeID      = ptc.PlateTypeID;
                        newMask.ReferenceImageID = 0;
                        newMask.Rows             = ptc.Rows;
                        newMask.Shape            = 0;
                        newMask.XOffset          = 50;
                        newMask.XSize            = 50;
                        newMask.XStep            = 50;
                        newMask.YOffset          = 50;
                        newMask.YSize            = 50;
                        newMask.YStep            = 50;

                        newPti.MaskList.Add(newMask);

                        // mark the new Mask as the AddRecord
                        ExpandableFieldRecord expRecord  = (ExpandableFieldRecord)newPlateTypeRecord.ChildRecords[0];
                        DataRecord            maskRecord = (DataRecord)expRecord.ChildRecords[0];

                        if (maskRecord.DataItem.GetType() == typeof(MaskContainer))
                        {
                            MarkAddNewRecord(maskRecord);
                        }
                    }
                }
                else if (e.Record.DataItem.GetType() == typeof(MaskContainer))
                {
                    MaskContainer mc = (MaskContainer)(e.Record.DataItem);

                    bool success = wgDB.InsertMask(ref mc);

                    if (success)
                    {
                        UnMarkAddNewRecord(e.Record);

                        // add new blank mask for AddRecord
                        MaskContainer newMask = new MaskContainer();
                        newMask.Description      = "";
                        newMask.Angle            = 0.0;
                        newMask.Cols             = mc.Cols;
                        newMask.IsDefault        = false;
                        newMask.MaskID           = 0;
                        newMask.PlateTypeID      = mc.PlateTypeID;
                        newMask.ReferenceImageID = 0;
                        newMask.Rows             = mc.Rows;
                        newMask.Shape            = 0;
                        newMask.XOffset          = 50;
                        newMask.XSize            = 50;
                        newMask.XStep            = 50;
                        newMask.YOffset          = 50;
                        newMask.YSize            = 50;
                        newMask.YStep            = 50;

                        PlateTypeItem pti = (PlateTypeItem)(((DataRecord)e.Record.ParentRecord.ParentRecord).DataItem);

                        pti.MaskList.Insert(0, newMask);

                        DataRecord newMaskRecord = (DataRecord)e.Record.ParentCollection[0];
                        MarkAddNewRecord(newMaskRecord);
                    }
                }
            }
        }