Exemple #1
0
        public override void OnClick()
        {
            if (Yutai.ArcGIS.Common.Editor.Editor.CheckIsEdit(_menuStrip.TableView.FeatureLayer))
            {
                ITable          pTable = _menuStrip.TableView.VirtualGridView.FeatureLayer.FeatureClass as ITable;
                IField          pField = pTable.Fields.Field[_menuStrip.ColumnIndex];
                FieldCalculator frm    = new FieldCalculator(_menuStrip.TableView.FeatureLayer.FeatureClass.Fields, pField);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        ICalculator pCalculator = new CalculatorClass();
                        ICursor     pCursor     = pTable.Search(null, false);
                        pCalculator.Cursor     = pCursor;
                        pCalculator.Field      = pField.Name;
                        pCalculator.Expression = frm.Expression;

                        pCalculator.Calculate();
                        Marshal.ReleaseComObject(pCursor);
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.Message);
                    }
                    _menuStrip.TableView.VirtualGridView.ShowTable(null);
                }
            }
            else
            {
                MessageBox.Show(@"未启动编辑", Caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            //csharp-4
            FIFACupStats f = new FIFACupStats();

            int                   nationality    = f.NationalityDistinctCount();
            int                   club           = f.ClubDistinctCount();
            List <string>         players        = f.First20Players();
            List <string>         playersAge     = f.Top10PlayersByAge();
            List <string>         playersRelease = f.Top10PlayersByReleaseClause();
            Dictionary <int, int> ageCount       = f.AgeCountMap();

            //csharp-6
            Carteira carteira = new Carteira();

            carteira.Salary = new decimal(-20);
            carteira.Shop   = new decimal(-10);
            carteira.Dsr    = new decimal(-10);
            carteira.Study  = new decimal(0);

            FieldCalculator fc = new FieldCalculator();

            decimal soma        = fc.Addition(carteira);
            decimal subtraction = fc.Subtraction(carteira);
            decimal total       = fc.Total(carteira);
        }
        public void ReCalculate(List <CalculationFieldTemplate> calculationFieldsTemplate, List <DataFieldResult> dataFieldResultList)
        {
            var fieldCalculator         = new FieldCalculator();
            var calculationFieldResults = new List <CalculationFieldResult>();

            foreach (var item in calculationFieldsTemplate)
            {
                calculationFieldResults.Add(fieldCalculator.CompareExpressionResults(item, dataFieldResultList));
            }

            ShowExtractedCalculationFields(calculationFieldResults);
        }
        private void btnCreateRule_Click(object sender, EventArgs e)
        {
            if (_pointLayerInfo?.FeatureClass == null)
            {
                return;
            }
            int idxCodeField = _pointLayerInfo.FeatureClass.FindField(cmbCodeField.SelectedItem.ToString());

            if (idxCodeField < 0)
            {
                return;
            }
            FieldCalculator frm = new FieldCalculator(_pointLayerInfo.FeatureClass.Fields);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                txtRule.Text = frm.Expression;
                _expression  = frm.Expression;
                _length      = frm.Length;
            }
        }
        private void ExtractParameters(InitializationParameters parameters)
        {
            storage = parameters.CostStorage;
            var com = parameters.ComCostFactory.GetCalculator(storage,
                                                              parameters.CellsPerSectionSingleDim, parameters.ParticleReductionFactor);

            fieldCalculator       = new FieldCalculator(com, new ConstSolveCostCalculator(storage));
            simulationInitializer = new SimulationInitializer(new Random(0), parameters.CoreFactory,
                                                              parameters.SectionFactory);
            var sortingCostCalculator = new SortingCostCalculator(parameters.ParticleReductionFactor, storage);

            sorter = parameters.SorterFactory.GetSorter(sortingCostCalculator);
            mover  =
                parameters.ParticleMoverFactory.GetIParticleMover(new MovementCostCalculator(storage,
                                                                                             parameters.ParticleReductionFactor));
            stepSize  = parameters.TimeStep;
            steps     = parameters.TotalSteps;
            structure = simulationInitializer.InitializeSimulation(mover, parameters);
            var visualizationBuilder = new VisualizationBuilder(parameters.VisualizationParameters);

            stepVisualizer  = visualizationBuilder.GetStepVisualizer(storage);
            finalVisualizer = visualizationBuilder.GetFinalVisualizer(storage);
        }
        private static void Main(string[] args)
        {
            // input argument: directory to scan
            var searchPath = args[0];
            // Input files are put in this directory after they have been processed.
            var processedPath = args[1];

#if false
            // Usage: TLCalc <SearchPath> <ProcessedPath>
            while (true)
            {
                var files = Directory.GetFiles(searchPath, "*.bellhop");
                foreach (var file in files)
                {
                    var runFile = BellhopRunFile.Load(file);
                    var outputFileName = Path.Combine(Path.GetDirectoryName(file),
                                                      Path.GetFileNameWithoutExtension(file) + ".tlf");
                    var fieldCalculator = new FieldCalculator()
                                              {
                                                  OutputFileName = outputFileName,
                                                  RunFile = runFile,
                                              };
                    fieldCalculator.ComputeField();

                    var destFileName = Path.Combine(processedPath, Path.GetFileName(file));
                    File.Delete(destFileName);
                    File.Move(file, destFileName);
                }
                Thread.Sleep(1000);
            }
            // Usage: TLCalc <SearchPath> <ProcessedPath> <EnvironmentFile> <OutputFile>
            var environmentFile = args[2];
            var outputFile = args[3];
            #region create transmission loss job. the new base class for all acoustic simulations!

            var transmissionLossJob = new TransmissionLossJob
                                          {
                                              AcousticProperties = new AcousticProperties
                                                                       {
                                                                           SourceDepth_meters = 5,
                                                                           VerticalBeamWidth_degrees = 10,
                                                                           DepressionElevationAngle_degrees =
                                                                               (float)20.2,
                                                                           LowFrequency_Hz = 50,
                                                                           HighFrequency_Hz = 10000,
                                                                       },
                                              NewAnalysisPoint = new NewAnalysisPoint
                                                                     {
                                                                         IDField = 1,
                                                                         Location = new EarthCoordinate(26, -76.8),
                                                                         RadialBearing = 0,
                                                                         RadialCount = 16,

                                                                     },
                                              Radius = 50000,
                                              MaxDepth = 3000,
                                          };

            #endregion

            #region create bellhop run file from tlj (and stuff)

            var environmentInformation = new EnvironmentInformation
                                             {
                                                 Bathymetry = new Bathymetry(environmentFile),
                                                 SoundSpeedField = new SoundSpeedField(environmentFile),
                                                 Sediment = SedimentTypes.SedimentArray[0],
                                             };

            var transmissionLossSettings = new TransmissionLossSettings()
                                               {
                                                   DepthCellSize = 50,
                                                   RangeCellSize = 50,
                                               };

            var bellhopRunFile = BellhopRunFile.Create(transmissionLossJob, environmentInformation, transmissionLossSettings);

            // things transmissionLossJob currently doesn't include: a radialList, transmissionLossField.


            #endregion



            #region serialize bellhop run file object to file.

            bellhopRunFile.Save(outputFile);

            #endregion

            #region deserialize bellhop run file from file to new object -- inside a timer tick with logic?

            var newRunFile = BellhopRunFile.Load(outputFile);

            #endregion

            #region run bellhop on new run file object.
            //ComputeField(newRunFile, @"C:\tests\bellhop\50kmbahamas.tlf");

            #endregion
#endif

        }