Ejemplo n.º 1
0
        void BrowseForBravoMethodFile(MethodItem method)
        {
            // Create OpenFileDialog
            OpenFileDialog dlg = new OpenFileDialog();

            // Set filter for file extension and default file extension
            dlg.DefaultExt       = ".pro";
            dlg.Filter           = "Bravo Protocol Files (*.pro)|*.pro|ANY Files (*.*)|*.*";
            dlg.InitialDirectory = GlobalVars.VWorksProtocolFileDirectory;

            // Display OpenFileDialog by calling ShowDialog method
            Nullable <bool> result = dlg.ShowDialog();

            //
            if (result == true)
            {
                method.BravoMethodFile = dlg.FileName;

                if (wgDB == null)
                {
                    wgDB = new WaveguideDB();
                }

                MethodContainer mc = new MethodContainer();
                mc.Description     = method.Description;
                mc.BravoMethodFile = method.BravoMethodFile;
                mc.IsPublic        = method.IsPublic;
                mc.MethodID        = method.MethodID;
                mc.OwnerID         = method.OwnerID;

                wgDB.UpdateMethod(mc);
            }
        }
Ejemplo n.º 2
0
        public void Configure(ImagingParameters iParams, ProjectContainer project, PlateContainer plate, ExperimentContainer experiment,
                              MethodContainer method,
                              MaskContainer mask, PlateTypeContainer plateType,
                              ObservableCollection <ExperimentIndicatorContainer> indicatorList,
                              ObservableCollection <ExperimentCompoundPlateContainer> compoundPlateList,
                              ObservableCollection <Tuple <int, int> > controlSubtractionWellList,
                              int numFoFrames,
                              ExperimentIndicatorContainer dynamicRatioNumerator,
                              ExperimentIndicatorContainer dynamicRatioDenominator)
        {
            m_iParams                    = iParams;
            m_project                    = project;
            m_experimentPlate            = plate;
            m_experiment                 = experiment;
            m_method                     = method;
            m_mask                       = mask;
            m_plateType                  = plateType;
            m_indicatorList              = indicatorList;
            m_compoundPlateList          = compoundPlateList;
            m_controlSubtractionWellList = controlSubtractionWellList;
            m_numFoFrames                = numFoFrames;
            m_dynamicRatioNumerator      = dynamicRatioNumerator;
            m_dynamicRatioDenominator    = dynamicRatioDenominator;


            m_vworksProtocolFilename = m_method.BravoMethodFile;

            ChartArray.BuildChartArray(mask.Rows, mask.Cols, m_iParams.HorzBinning, m_iParams.VertBinning, m_indicatorList);

            Dictionary <int, ImageDisplay> idDictionary = ChartArray.GetImageDisplayDictionary();

            m_displayPipeline = m_imager.CreateDisplayPipeline(m_uiTask, idDictionary);


            m_storagePipeline = m_imager.CreateImageStoragePipeline(GlobalVars.CompressionAlgorithm, m_iParams.imageWidth, m_iParams.imageHeight);

            int numerID = 0;
            int denomID = 0;

            if (m_dynamicRatioNumerator != null)
            {
                numerID = m_dynamicRatioNumerator.ExperimentIndicatorID;
            }
            if (m_dynamicRatioDenominator != null)
            {
                denomID = m_dynamicRatioDenominator.ExperimentIndicatorID;
            }

            m_analysisPipeline = m_imager.CreateAnalysisPipeline(ChartArray, m_mask, m_iParams.imageWidth,
                                                                 m_iParams.imageHeight, m_iParams.HorzBinning, m_iParams.VertBinning,
                                                                 m_iParams.ExperimentIndicatorID, m_controlSubtractionWellList, m_numFoFrames,
                                                                 numerID, denomID);


            if (m_histogram != null)
            {
                m_histogramPipeline = m_imager.CreateHistogramPipeline(m_uiTask, m_histogram);
            }
        }
Ejemplo n.º 3
0
        private void xamDataGrid_EditModeEnded(object sender, Infragistics.Windows.DataPresenter.Events.EditModeEndedEventArgs e)
        {
            // use this method to update a record after one of the cells of the record has been edited

            if (((string)e.Cell.Record.Tag) == "AddRecord")
            {
                return;                                              // not updating the AddRecord here
            }
            if (e.Cell.Record.DataItem.GetType() == typeof(MethodItem))
            {
                MethodItem mi = (MethodItem)e.Cell.Record.DataItem;

                if (mi.MethodID != 0)
                {
                    MethodContainer mc = new MethodContainer();

                    mc.MethodID        = mi.MethodID;
                    mc.Description     = mi.Description;
                    mc.BravoMethodFile = mi.BravoMethodFile;
                    mc.OwnerID         = mi.OwnerID;
                    mc.IsPublic        = mi.IsPublic;

                    bool success = wgDB.UpdateMethod(mc);
                }
            }
            else if (e.Cell.Record.DataItem.GetType() == typeof(IndicatorItem))
            {
                IndicatorItem ii = (IndicatorItem)e.Cell.Record.DataItem;

                if (ii.IndicatorID != 0)
                {
                    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 succcess = wgDB.UpdateIndicator(ic);
                }
            }
            else if (e.Cell.Record.DataItem.GetType() == typeof(CompoundPlateItem))
            {
                CompoundPlateItem cpi = (CompoundPlateItem)e.Cell.Record.DataItem;

                if (cpi.CompoundPlateID != 0)
                {
                    CompoundPlateContainer cpc = new CompoundPlateContainer();
                    cpc.CompoundPlateID = cpi.CompoundPlateID;
                    cpc.MethodID        = cpi.MethodID;
                    cpc.Description     = cpi.Description;

                    bool success = wgDB.UpdateCompoundPlate(cpc);
                }
            }
        }
Ejemplo n.º 4
0
 public GameEvent(string name, DateTime response_time, Periodicity periodicity, int periodicity_value, MethodContainer method, bool restart = false)
 {
     Name               = name;
     ResponseTime       = response_time;
     InitialPeriodicity = periodicity;
     Periodicity        = periodicity;
     PeriodicityValue   = periodicity_value;
     Method             = method;
     Restart            = restart;
 }
Ejemplo n.º 5
0
    public void MoveToPlayerDeck(GameObject playerDeck)
    {
        transform.parent     = playerDeck.transform;
        OnAnimationFinished += new MethodContainer(playerDeck.GetComponent <PlayerDeck>().OnGot);

        var parentPos = playerDeck.transform.position;

        transform.position = new Vector3(transform.position.x - parentPos.x, transform.position.y - parentPos.y, transform.position.z - parentPos.z + 0.3f);

        AddAnimationMoveToPlayerDeck(playerDeck.GetComponent <PlayerDeck>().GetPosition(this));
        GetComponent <Animation>().Play("MoveToPlayerDeckAnimation");
    }
Ejemplo n.º 6
0
    public void MoveToPlayerDeck(GameObject playerDeck)
    {
        transform.parent = playerDeck.transform;
        OnAnimationFinished += new MethodContainer(playerDeck.GetComponent<PlayerDeck>().OnGot);

        var parentPos = playerDeck.transform.position;

        transform.position = new Vector3(transform.position.x - parentPos.x, transform.position.y - parentPos.y, transform.position.z - parentPos.z + 0.3f);

        AddAnimationMoveToPlayerDeck(playerDeck.GetComponent<PlayerDeck>().GetPosition(this));
        GetComponent<Animation>().Play("MoveToPlayerDeckAnimation");
    }
Ejemplo n.º 7
0
        public void ExecuteWithStaticMethod() {
            // Arrange
            MethodContainer container = new MethodContainer();
            object[] parameters = new object[0];
            MethodInfo methodInfo = typeof(MethodContainer).GetMethod("StaticMethod");
            MethodDispatcher dispatcher = new MethodDispatcher(methodInfo);

            // Act
            object returnValue = dispatcher.Execute(container, parameters);

            // Assert
            Assert.AreEqual(89, returnValue);
        }
        public void ExecuteWithStaticMethod()
        {
            // Arrange
            MethodContainer container = new MethodContainer();

            object[]         parameters = new object[0];
            MethodInfo       methodInfo = typeof(MethodContainer).GetMethod("StaticMethod");
            MethodDispatcher dispatcher = new MethodDispatcher(methodInfo);

            // Act
            object returnValue = dispatcher.Execute(container, parameters);

            // Assert
            Assert.AreEqual(89, returnValue);
        }
Ejemplo n.º 9
0
        public void ExecuteWithVoidInstanceMethod() {
            // Arrange
            MethodContainer container = new MethodContainer();
            object[] parameters = new object[] { 5, "some string", new DateTime(2001, 1, 1) };
            MethodInfo methodInfo = typeof(MethodContainer).GetMethod("VoidMethod");
            MethodDispatcher dispatcher = new MethodDispatcher(methodInfo);

            // Act
            object returnValue = dispatcher.Execute(container, parameters);

            // Assert
            Assert.IsNull(returnValue);
            Assert.AreEqual(5, container._i);
            Assert.AreEqual("some string", container._s);
            Assert.AreEqual(new DateTime(2001, 1, 1), container._dt);
        }
        public void ExecuteWithVoidInstanceMethod()
        {
            // Arrange
            MethodContainer container = new MethodContainer();

            object[]         parameters = new object[] { 5, "some string", new DateTime(2001, 1, 1) };
            MethodInfo       methodInfo = typeof(MethodContainer).GetMethod("VoidMethod");
            MethodDispatcher dispatcher = new MethodDispatcher(methodInfo);

            // Act
            object returnValue = dispatcher.Execute(container, parameters);

            // Assert
            Assert.IsNull(returnValue);
            Assert.AreEqual(5, container._i);
            Assert.AreEqual("some string", container._s);
            Assert.AreEqual(new DateTime(2001, 1, 1), container._dt);
        }
Ejemplo n.º 11
0
        void SetIsPublicOnMethod(MethodItem method, bool isPublic)
        {
            method.IsPublic = isPublic;

            if (wgDB == null)
            {
                wgDB = new WaveguideDB();
            }

            MethodContainer mc = new MethodContainer();

            mc.Description     = method.Description;
            mc.BravoMethodFile = method.BravoMethodFile;
            mc.IsPublic        = method.IsPublic;
            mc.MethodID        = method.MethodID;
            mc.OwnerID         = method.OwnerID;

            wgDB.UpdateMethod(mc);
        }
Ejemplo n.º 12
0
 public QueryConfigurationUniversal()
 {
     Methods = new MethodContainer();
 }
Ejemplo n.º 13
0
        void LoadSimulationConfiguration()
        {
            //  m_iParams = iParams;
            //  m_project = project;
            //  m_experimentPlate = plate;
            //  m_method = method;
            //  m_mask = mask;
            //  m_plateType = plateType;
            //  m_indicatorList = indicatorList;
            //  m_compoundPlateList = compoundPlateList;
            //  m_controlSubtractionWellList = controlSubtractionWellList;
            //m_numFoFrames = numFoFrames;
            //m_dynamicRatioNumerator = dynamicRatioNumerator;
            //m_dynamicRatioDenominator = dynamicRatioDenominator;

            //ChartArray.BuildChartArray(mask.Rows, mask.Cols, m_indicatorList);

            ////////////////////////
            // set up project
            m_project = null;
            bool success = m_wgDB.GetAllProjects(false);

            foreach (ProjectContainer project in m_wgDB.m_projectList)
            {
                if (project.Description.Equals("Debug", StringComparison.OrdinalIgnoreCase))
                {
                    m_project = project;
                    break;
                }
            }
            if (m_project == null) // not found in database, so create it
            {
                m_project             = new ProjectContainer();
                m_project.Description = "Debug";
                m_project.TimeStamp   = DateTime.Now;
                m_project.Archived    = false;
                success = m_wgDB.InsertProject(ref m_project);
            }


            ////////////////////////
            // set up plateType
            m_plateType = null;
            success     = m_wgDB.GetAllPlateTypes();
            if (m_wgDB.m_plateTypeList.Count() > 0)
            {
                m_plateType = m_wgDB.m_plateTypeList.ElementAt(0);
            }
            else
            {
                // create a new plateType
                m_plateType             = new PlateTypeContainer();
                m_plateType.Cols        = 24;
                m_plateType.Description = "Debug";
                m_plateType.IsDefault   = false;
                m_plateType.Rows        = 16;
                success = m_wgDB.InsertPlateType(ref m_plateType);
            }



            ////////////////////////
            // set up experiment plate
            m_experimentPlate = null;
            success           = m_wgDB.GetAllPlatesForProject(m_project.ProjectID);
            if (m_wgDB.m_plateList.Count() > 0)
            {
                m_experimentPlate = m_wgDB.m_plateList.ElementAt(0);
            }
            else
            {
                // create a new plate
                m_experimentPlate             = new PlateContainer();
                m_experimentPlate.Barcode     = "12345678";
                m_experimentPlate.Description = "Debug";
                m_experimentPlate.IsPublic    = true;
                m_experimentPlate.OwnerID     = GlobalVars.UserID;
                m_experimentPlate.PlateTypeID = m_plateType.PlateTypeID;
                m_experimentPlate.ProjectID   = m_project.ProjectID;

                success = m_wgDB.InsertPlate(ref m_experimentPlate);
            }



            ////////////////////////
            // set up method
            m_method = null;
            success  = m_wgDB.GetAllMethodsForUser(GlobalVars.UserID);
            foreach (MethodContainer method in m_wgDB.m_methodList)
            {
                if (method.Description.Equals("Debug", StringComparison.OrdinalIgnoreCase))
                {
                    m_method = method;
                    break;
                }
            }
            if (m_method == null)
            {
                m_method = new MethodContainer();
                m_method.BravoMethodFile = "";
                m_method.Description     = "Debug";
                m_method.IsPublic        = true;
                m_method.OwnerID         = GlobalVars.UserID;
                success = m_wgDB.InsertMethod(ref m_method);
            }
            success = m_wgDB.GetAllIndicatorsForMethod(m_method.MethodID);
            if (m_wgDB.m_indicatorList.Count < 1)
            {
                // create indicators for this new method
                IndicatorContainer ind = new IndicatorContainer();
                ind.Description              = "Debug";
                ind.EmissionsFilterPosition  = 6;
                ind.ExcitationFilterPosition = 4;
                ind.MethodID   = m_method.MethodID;
                ind.SignalType = SIGNAL_TYPE.UP;
                success        = m_wgDB.InsertIndicator(ref ind);
            }



            ////////////////////////
            // set up experiment
            m_experiment = null;
            ObservableCollection <ExperimentContainer> expList;

            success = m_wgDB.GetAllExperimentsForPlate(m_experimentPlate.PlateID, out expList);
            if (expList.Count() > 0)
            {
                m_experiment = expList.ElementAt(0);
            }
            else
            {
                m_experiment              = new ExperimentContainer();
                m_experiment.Description  = "Debug";
                m_experiment.HorzBinning  = 1;
                m_experiment.MethodID     = m_method.MethodID;
                m_experiment.PlateID      = m_experimentPlate.PlateID;
                m_experiment.ROI_Height   = GlobalVars.PixelHeight;
                m_experiment.ROI_Width    = GlobalVars.PixelWidth;
                m_experiment.ROI_Origin_X = 1;
                m_experiment.ROI_Origin_Y = 1;
                m_experiment.TimeStamp    = DateTime.Now;
                m_experiment.VertBinning  = 1;
                success = m_wgDB.InsertExperiment(ref m_experiment);
            }


            ////////////////////////
            // set up mask
            m_mask  = null;
            success = m_wgDB.GetAllMasksForPlateType(m_experimentPlate.PlateTypeID);
            if (m_wgDB.m_maskList.Count() > 0)
            {
                m_mask = m_wgDB.m_maskList.ElementAt(0);
            }
            else
            {
                // create a new mask
                m_mask                    = new MaskContainer();
                m_mask.Angle              = 0.0;
                m_mask.Cols               = 24;
                m_mask.Description        = "Debug";
                m_mask.IsDefault          = false;
                m_mask.NumEllipseVertices = 24;
                m_mask.PlateTypeID        = m_experimentPlate.PlateTypeID;
                m_mask.ReferenceImageID   = 0;
                m_mask.Rows               = 16;
                m_mask.Shape              = 0;
                m_mask.XOffset            = 28;
                m_mask.XSize              = 28;
                m_mask.XStep              = 41.522;
                m_mask.YOffset            = 190;
                m_mask.YSize              = 28;
                m_mask.YStep              = 41.467;
                success                   = m_wgDB.InsertMask(ref m_mask);
            }



            ////////////////////////////////////
            // setup test indicator(s)
            m_indicatorList = new ObservableCollection <ExperimentIndicatorContainer>();
            ObservableCollection <ExperimentIndicatorContainer> expIndList;

            success = m_wgDB.GetAllExperimentIndicatorsForExperiment(m_experiment.ExperimentID, out expIndList);
            if (expIndList.Count > 0)
            {
                foreach (ExperimentIndicatorContainer ex in expIndList)
                {
                    m_indicatorList.Add(ex);
                }
            }
            else
            {
                success = m_wgDB.GetAllIndicatorsForMethod(m_method.MethodID);
                foreach (IndicatorContainer ind in m_wgDB.m_indicatorList)
                {
                    ExperimentIndicatorContainer exInd = new ExperimentIndicatorContainer();
                    exInd.Description = ind.Description;

                    FilterContainer filter;
                    success = m_wgDB.GetExcitationFilterAtPosition(ind.ExcitationFilterPosition, out filter);
                    exInd.ExcitationFilterDesc = filter.Description;
                    success = m_wgDB.GetEmissionFilterAtPosition(ind.EmissionsFilterPosition, out filter);
                    exInd.EmissionFilterDesc = filter.Description;

                    exInd.EmissionFilterPos   = ind.EmissionsFilterPosition;
                    exInd.ExcitationFilterPos = ind.ExcitationFilterPosition;
                    exInd.ExperimentID        = m_experiment.ExperimentID;
                    exInd.Exposure            = 150;
                    exInd.Gain       = 5;
                    exInd.MaskID     = m_mask.MaskID;
                    exInd.SignalType = SIGNAL_TYPE.UP;
                    exInd.Verified   = true;
                    success          = m_wgDB.InsertExperimentIndicator(ref exInd);
                    m_indicatorList.Add(exInd);
                }
            }


            ////////////////////////////////////
            // compound plates
            m_compoundPlateList = new ObservableCollection <ExperimentCompoundPlateContainer>();


            ////////////////////////////////////
            // control subtraction well list
            m_controlSubtractionWellList = new ObservableCollection <Tuple <int, int> >();
            // all wells in last row = control wells
            for (int c = 0; c < m_mask.Cols; c++)
            {
                m_controlSubtractionWellList.Add(Tuple.Create(m_mask.Rows - 1, c));
            }

            ////////////////////////////////////
            //m_numFoFrames = numFoFrames;
            m_numFoFrames = 5;


            if (m_indicatorList.Count() > 1)
            {
                ////////////////////////////////////
                //m_dynamicRatioNumerator = dynamicRatioNumerator;
                m_dynamicRatioNumerator = m_indicatorList.ElementAt(0);
                ////////////////////////////////////
                //m_dynamicRatioDenominator = dynamicRatioDenominator;
                m_dynamicRatioDenominator = m_indicatorList.ElementAt(1);
            }
            else
            {
                m_dynamicRatioNumerator = new ExperimentIndicatorContainer();
                m_dynamicRatioNumerator.ExperimentIndicatorID = 0;
                m_dynamicRatioDenominator = new ExperimentIndicatorContainer();
                m_dynamicRatioDenominator.ExperimentIndicatorID = 0;
            }


            if (m_iParams == null)
            {
                m_iParams = new ImagingParameters();
            }


            m_iParams.maxPixelValue               = GlobalVars.MaxPixelValue;
            m_iParams.imageWidth                  = GlobalVars.PixelWidth;
            m_iParams.imageHeight                 = GlobalVars.PixelHeight;
            m_iParams.Image_StartCol              = 1;
            m_iParams.Image_EndCol                = GlobalVars.PixelWidth;
            m_iParams.Image_StartRow              = 1;
            m_iParams.Image_EndRow                = GlobalVars.PixelHeight;
            m_iParams.BravoMethodFilename         = "";
            m_iParams.CameraTemperature           = GlobalVars.CameraTargetTemperature;
            m_iParams.HorzBinning                 = 1;
            m_iParams.VertBinning                 = 1;
            m_iParams.EmissionFilterChangeSpeed   = GlobalVars.FilterChangeSpeed;
            m_iParams.ExcitationFilterChangeSpeed = GlobalVars.FilterChangeSpeed;
            m_iParams.LightIntensity              = 100;
            m_iParams.NumImages     = 1000000; // artificial limit on number of images
            m_iParams.NumIndicators = m_indicatorList.Count;
            m_iParams.SyncExcitationFilterWithImaging = true;

            m_iParams.CycleTime             = new int[m_indicatorList.Count];
            m_iParams.EmissionFilter        = new byte[m_indicatorList.Count];
            m_iParams.ExcitationFilter      = new byte[m_indicatorList.Count];
            m_iParams.Exposure              = new float[m_indicatorList.Count];
            m_iParams.Gain                  = new int[m_indicatorList.Count];
            m_iParams.ExperimentIndicatorID = new int[m_indicatorList.Count];
            m_iParams.IndicatorName         = new string[m_indicatorList.Count];
            m_iParams.LampShutterIsOpen     = new bool[m_indicatorList.Count];


            int i = 0;

            foreach (ExperimentIndicatorContainer ind in m_indicatorList)
            {
                m_iParams.CycleTime[i]             = 1000;
                m_iParams.EmissionFilter[i]        = (byte)ind.EmissionFilterPos;
                m_iParams.ExcitationFilter[i]      = (byte)ind.ExcitationFilterPos;
                m_iParams.Exposure[i]              = (float)ind.Exposure / 1000;
                m_iParams.Gain[i]                  = ind.Gain;
                m_iParams.ExperimentIndicatorID[i] = 0; // created by the RunExperiment object when the experiment is run
                m_iParams.IndicatorName[i]         = ind.Description;
                m_iParams.LampShutterIsOpen[i]     = true;
                m_iParams.ExperimentIndicatorID[i] = ind.ExperimentIndicatorID;

                i++;
            }
        }
Ejemplo n.º 14
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);
                    }
                }
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Привязка к событию мыши
 /// </summary>
 /// <param name="method"></param>
 public void AttachToMouseAction(MethodContainer method)
 {
     CallMouseEvent += method;
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Привязка к нажатию клавиши
 /// </summary>
 /// <param name="method"></param>
 public void AttachToKeyDown(MethodContainer method)
 {
     CallKeyDown += method;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Привязка к отпусканию клавиши
 /// </summary>
 /// <param name="method"></param>
 public void AttachToKeyUp(MethodContainer method)
 {
     CallKeyUp += method;
 }
Ejemplo n.º 18
0
        /// <summary>Sets the exceptions.</summary>
        /// <param name="exceptions">The exceptions.</param>
        public void SetExceptions(MethodContainer methodContainer, IEnumerable<ThrownException> exceptions)
        {
            this.MethodContainer = methodContainer;
            this.Exceptions = exceptions;

            if (this.ObjectChanged != null)
            {
                this.ObjectChanged(this, new MethodContainerEventArgs(this.MethodContainer));
            }

            this.UpdateList();
        }
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            #region lab 3 execution
            //грузы
            CCargo cargo1 = new CCargo("Machinegun", "light");
            CCargo cargo2 = new CCargo("Tank", "Heavy");

            //вагоны
            CCarriage carriage1 = new CCarriage(1, "For light cargo");
            CCarriage carriage2 = new CCarriage(2, "For heavy cargo");

            cargo1.setCargoCarriage(carriage1);
            carriage1.setCargo(cargo1);
            cargo2.setCargoCarriage(carriage2);
            carriage2.setCargo(cargo2);

            //массив вагонов 1 + поезд1
            CCarriage[] carriagesHeavy = new CCarriage[2];
            carriagesHeavy[0] = carriage2;
            carriagesHeavy[1] = carriage2;
            CTrain train1 = new CTrain(1, "MINSK-MOSCOV", carriagesHeavy);

            //массив вагонов 2 + поезд 2
            CCarriage[] carriagesLight = new CCarriage[3];
            carriagesLight[0] = carriage1;
            carriagesLight[1] = carriage1;
            carriagesLight[2] = carriage1;
            CTrain train2 = new CTrain(2, "МИНСК-ЮРМАЛА", carriagesLight);

            //композиция(массив вагонов trainCarriages создаётся при создании поезда)
            CTrain train3 = new CTrain();


            //массив поездов, для станции
            CTrain[] trains = new CTrain[3];
            trains[0] = train1;
            trains[1] = train2;
            trains[2] = train3;
            //станция
            CStation station = new CStation("Station1", "Minsk", trains);

            station.print();
            #endregion

            CTrain tr1 = new CTrain();
            tr1.onDeparture += CTrain.Tr1_onDeparture; //подписываемся на событие
            tr1.onArrival   += CTrain.Tr1_onArrival;   //подписываемся на событие
            tr1.TakeTime(DateTime.Parse("19.03.2019 06:30:00"));
            tr1.TakeTime(DateTime.Parse("19.03.2019 08:30:00"));



            MethodContainer container = delegate(CTrain x)  //определяем переменную делегата и передаём ей delegate - анонимный метод с параметром
            {
                Console.WriteLine("\nДанные из анонимного метода: " + x.trainInfo());
            };                                              // надо ставить ;
            container(tr1);                                 //вызываем делегат и передаём ему объект

            MethodContainer2 container2 = (CTrain x) => "\nДанные из лямбда-выражения: " + x.getTrainNumber().ToString() + " " + x.getTrainName();
            Console.WriteLine(container2(tr1));

            CTrain.MethodContainer3 myDel = new CTrain.MethodContainer3(tr1.infoChanger);
            myDel(7, "My train");
            Console.WriteLine(tr1.trainInfo());
        }