/// <summary>
        /// Encode the specified batches.
        /// </summary>
        /// <returns>The encode.</returns>
        /// <param name="batches">Batches.</param>
        public byte[] Encode(IEnumerable <Batch> batches)
        {
            var batchList = new BatchList();

            batchList.Batches.AddRange(batches);
            return(batchList.ToByteArray());
        }
Exemple #2
0
        private void SortReprintGrid(string value)
        {
            if (SortedColumn != value)
            {
                GridSortOrder = string.Empty;
            }

            GridSortOrder = string.IsNullOrEmpty(GridSortOrder) ? SortOrder.ASC : GridSortOrder.Equals(SortOrder.ASC) ? SortOrder.DESC : SortOrder.ASC;
            switch (value)
            {
            default:
            case BatchGridColumnsTagName.BatchId:
                BatchList = GridSortOrder.Equals(SortOrder.ASC) ? BatchList.OrderBy(x => x.BatchID).ToList() : BatchList.OrderByDescending(x => x.BatchID).ToList();
                break;

            case BatchGridColumnsTagName.Date:
                BatchList = GridSortOrder.Equals(SortOrder.ASC) ? BatchList.OrderBy(x => x.CreattionDate).ToList() : BatchList.OrderByDescending(x => x.CreattionDate).ToList();
                break;

            case BatchGridColumnsTagName.Records:
                BatchList = GridSortOrder.Equals(SortOrder.ASC) ? BatchList.OrderBy(x => x.RecordsCount).ToList() : BatchList.OrderByDescending(x => x.RecordsCount).ToList();
                break;
            }
            SortedColumn = value;
        }
Exemple #3
0
        protected override void SelectPartidaAction()
        {
            BatchList lista;

            lista = BatchList.GetListBySerieAndStock(_serie.Oid, true, false, true);

            BatchSelectForm form = new BatchSelectForm(this, _serie, lista);

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                _partida  = form.Selected as BatchInfo;
                _producto = ProductInfo.Get(_partida.OidProducto, false, true);

                _entity.CopyFrom(_partida, _producto);

                AsignaPrecio();

                Datos_Partida.DataSource = _partida;

                EnableKilos();

                if (_entity.FacturacionBulto)
                {
                    Pieces_NTB.Focus();
                }
                else
                {
                    Kilos_NTB.Focus();
                }
            }
        }
Exemple #4
0
 //Add  multiple items to the BatchList.
 public void Add(IList lines)
 {
     foreach (var line in lines)
     {
         BatchList.Add(line);
     }
 }
Exemple #5
0
        /// <summary>
        /// To GetPaymentRequestByHHID details
        /// </summary>
        /// <param name="ProjectId"></param>
        /// <param name="HHID"></param>
        /// <returns></returns>
        public BatchList GetPaymentRequestByHHID(int ProjectId, int HHID)
        {
            OracleConnection cnn = new OracleConnection(con);
            OracleCommand    cmd;

            string proc = "USP_TRN_GET_PAPS_BY_HHID";

            cmd             = new OracleCommand(proc, cnn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("HHID_", HHID);
            cmd.Parameters.Add("ProjectId_", ProjectId);
            cmd.Parameters.Add("Sp_recordset", Oracle.DataAccess.Client.OracleDbType.RefCursor).Direction = ParameterDirection.Output;

            cmd.Connection.Open();
            OracleDataReader dr         = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            BatchBO          oBatchBO   = null;
            BatchList        oBatchList = new BatchList();

            while (dr.Read())
            {
                oBatchBO = new BatchBO();
                oBatchBO = MapData(dr);
                oBatchList.Add(oBatchBO);
            }

            dr.Close();

            return(oBatchList);
        }
        public ActionResult saveDataBase()
        {
            helper.DBReturnCode code = helper.DBReturnCode.NOT_EXIST;
            try
            {
                int         uID       = int.Parse(Request.Params.Get("UID"));
                string      stationID = Request.Params.Get("stationID");
                bool        rtype     = Request.Params.Get("ReportType") == "Rain" ? true : false;
                bool        trans     = Request.Params.Get("TransType") == "ByDay" ? true : false;
                string      stime     = Request.Params.Get("startTime");
                string      etime     = Request.Params.Get("endTime");
                BatchList   record    = BatchService.FindBatchRecord(uID);
                List <rain> rainList  = new List <rain>();
                for (int i = 0; i < record.Bdata.Count; i++)
                {
                    rainList.Add(new rain
                    {
                        //stationid = record.Bdata[i].
                    });
                }
                //TODO:暂时搁置
                //code = DAL.RainService.SaveBatchData(record);
            }
            catch (Exception)
            {
                return(Json(helper.DBHelper.SerializeDBReturnCode(helper.DBReturnCode.BAD_REQUEST), JsonRequestBehavior.AllowGet));
            }

            string json = helper.DBHelper.SerializeDBReturnCode(code);

            return(Json(json, JsonRequestBehavior.AllowGet));
        }
Exemple #7
0
        public void SortReprintGrid(string value)
        {
            if (SortedColumn != value)
            {
                GridSortOrder = string.Empty;
            }

            GridSortOrder      = string.IsNullOrEmpty(GridSortOrder) ? SortOrder.ASC : GridSortOrder.Equals(SortOrder.ASC) ? SortOrder.DESC : SortOrder.ASC;
            AllControlsEnabled = false;
            switch (value)
            {
            default:
            case BatchGridColumnsTagName.BatchId:
                BatchList = GridSortOrder.Equals(SortOrder.ASC) ? BatchList.OrderBy(x => x.RequestPrintedBatchID).ToList() : BatchList.OrderByDescending(x => x.RequestPrintedBatchID).ToList();
                break;

            case BatchGridColumnsTagName.Date:
                BatchList = GridSortOrder.Equals(SortOrder.ASC) ? BatchList.OrderBy(x => x.DateRequestPrinted).ToList() : BatchList.OrderByDescending(x => x.DateRequestPrinted).ToList();
                break;

            case BatchGridColumnsTagName.Records:
                BatchList = GridSortOrder.Equals(SortOrder.ASC) ? BatchList.OrderBy(x => x.BatchCount).ToList() : BatchList.OrderByDescending(x => x.BatchCount).ToList();
                break;
            }
            AllControlsEnabled = true;
            SortedColumn       = value;
        }
        protected virtual void LoadPartidasAction()
        {
            try
            {
                if (Cache.Instance.Get(typeof(BatchList)) != null)
                {
                    return;
                }

                PgMng.Reset(3, 1, Face.Resources.Messages.LOADING_DATA, this);
                PgMng.Grow();

                Batch_BS.DataSource = BatchList.GetByProductList(EntityInfo.Oid, false);
                Cache.Instance.Save(typeof(BatchList), Batch_BS.DataSource as BatchList);
                PgMng.Grow();

                HideComponentes(Partidas_TP);

                ControlsMng.UpdateBinding(Batch_BS);
            }
            finally
            {
                PgMng.FillUp();
            }
        }
        protected override void RefreshMainData()
        {
            PgMng.Grow(string.Empty, "Partida");

            _selectedOid = ActiveOID;

            switch (DataType)
            {
            case EntityMngFormTypeData.Default:
                if (moleQule.Common.ModulePrincipal.GetUseActiveYear())
                {
                    List = BatchList.GetList(moleQule.Common.ModulePrincipal.GetActiveYear().Year, false);
                }
                else
                {
                    List = BatchList.GetList(false);
                }
                break;

            case EntityMngFormTypeData.ByParameter:
                _sorted_list = List.GetSortedList();
                break;
            }
            PgMng.Grow(string.Empty, "Lista de Partidas");
        }
Exemple #10
0
        //private BatchService client;

        //public BatchService Client
        //{
        //    get
        //    {
        //        if (client == null)
        //        {
        //            client = new BatchService(grpcClient);
        //        }
        //        return client;
        //    }
        //}

        public BatchList GetBatchMag(int uID, string sID, bool rtype, bool trans, string stime, string etime, string gprsNum)
        {
            try
            {
                BatchRequest request = new BatchRequest {
                    StationId = sID, ReportType = rtype, TransType = trans, StartTime = stime, EndTime = etime, Gprsid = gprsNum
                };

                BatchList info = grpcClient.ListBatchData(request);

                if (batchRecordsDic.ContainsKey(uID))
                {
                    batchRecordsDic[uID] = info;
                }
                else
                {
                    batchRecordsDic.Add(uID, info);
                }

                return(info);
            }
            catch (Exception exp)
            {
                Debug.WriteLine("RPC failed" + exp);
                throw;
            }
        }
        //GET:/export/saveText
        public FileResult saveText()
        {
            string appendix, content = "";

            try
            {
                int uID = int.Parse(Request.Params.Get("UID"));

                BatchList record = BatchService.FindBatchRecord(uID);
                content += "站号:" + record.StationId +
                           "/t站类:" + (record.SType == 0 ? "雨量站" : "水情站") +
                           "/t传输方式:" + (record.TType == BatchList.Types.transType.Byday ? "按日传输" : "按小时传输") +
                           "/n/n返回信息:" + record.RawInfo +
                           "/n";

                foreach (var temp in record.Bdata)
                {
                    content += "/n" + temp.BatchTime + " : " + temp.BatchValue;
                }

                content += "/n/n";

                //文件后缀名。可以用不同的方法名区分,也可以作为一个参数输入。
                appendix = "txt";
            }
            catch (Exception)
            {
                return(null);
            }
            //返回结果
            byte[] data = Encoding.UTF8.GetBytes(content);
            return(File(data, "text/plain", "批量传输" + "." + appendix));
        }
Exemple #12
0
        /// <summary>
        /// To Get Payment Pending Batch details
        /// </summary>
        /// <param name="projectID"></param>
        /// <param name="BatchNo"></param>
        /// <returns></returns>
        public BatchList GetPaymentPendingBatch(int projectID, int BatchNo)
        {
            OracleConnection cnn = new OracleConnection(con);
            OracleCommand    cmd;

            string proc = "USP_TRN_GET_PENDING_BATCH_BYID";

            cmd             = new OracleCommand(proc, cnn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("PROJECTID_", projectID);
            cmd.Parameters.Add("cmp_batchno_", BatchNo);
            cmd.Parameters.Add("Sp_recordset", Oracle.DataAccess.Client.OracleDbType.RefCursor).Direction = ParameterDirection.Output;

            cmd.Connection.Open();
            OracleDataReader dr         = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            BatchBO          objBatchBO = null;
            BatchList        oBatchList = new BatchList();

            while (dr.Read())
            {
                objBatchBO = new BatchBO();
                objBatchBO = MapData(dr);

                oBatchList.Add(objBatchBO);
            }

            dr.Close();

            return(oBatchList);
        }
Exemple #13
0
        public void BatchList_SplitMultiBatchList()
        {
            const int batchSize = 2;
            var       list      = new List <WApiV3.Product>
            {
                new WApiV3.Product
                {
                    name = "asd"
                },
                new WApiV3.Product(),

                new WApiV3.Product(),
                new WApiV3.Product(),

                new WApiV3.Product
                {
                    name = "lkj"
                }
            };

            var batchList = new BatchList <WApiV3.Product>(list, batchSize).ToList();

            var firstBatch  = batchList.First().ToList();
            var secondBatch = batchList.Skip(1).First().ToList();
            var thirdBatch  = batchList.Skip(2).First().ToList();
            var fourthBatch = batchList.Skip(3).FirstOrDefault();

            Assert.AreEqual(batchSize, firstBatch.Count);
            Assert.AreEqual(list.First().name, firstBatch.First().name);
            Assert.AreEqual(batchSize, secondBatch.Count);
            Assert.AreEqual(list.Count - batchSize * 2, thirdBatch.Count);
            Assert.AreEqual(list.Last().name, thirdBatch.First().name);
            Assert.IsNull(fourthBatch);
        }
Exemple #14
0
        private void StockDetallado_TI_Click(object sender, EventArgs e)
        {
            BatchList lista = BatchList.GetListBySerieAndStock((long)ESerie.GENERICA, false, false);

            FormMng.OpenForm(BatchMngForm.ID, new object[2] {
                lista, StockDetallado_TI.Text
            });
        }
Exemple #15
0
        internal void AddBatchList(Grid targetGrid, IEnumerable <object> batchList)
        {
            BatchList listElement = new BatchList();

            listElement.MainList.ItemsSource = batchList;

            targetGrid.Children.Add(listElement);
        }
        public BatchSelectForm(Form parent, SerieInfo serie, BatchList lista)
            : base(true, parent, serie, lista)
        {
            InitializeComponent();
            _view_mode = molView.Select;

            _action_result = DialogResult.Cancel;
        }
Exemple #17
0
        public void BatchList_SplitEmptyList()
        {
            var listEmpty = new List <WApiV3.Product>();

            var batchList = new BatchList <WApiV3.Product>(listEmpty, 10);

            Assert.IsEmpty(batchList);
        }
Exemple #18
0
 public void MoveTextureToEnd(Texture2D texture)
 {
     if (texture != null && textureBatches.ContainsKey(texture))
     {
         BatchList batches = textureBatches[texture];
         batchesToRender.Remove(batches);
         batchesToRender.Add(batches);
     }
 }
        protected override void RefreshMainData()
        {
            if (_entity == null)
            {
                return;
            }

            Datos.DataSource = _entity;

            _product = ProductInfo.Get(_entity.OidProducto, false);
            PgMng.Grow();

            switch (_product_type)
            {
            case ETipoProducto.Almacen:
            {
                BatchList lista;

                if (_delivery.Rectificativo)
                {
                    lista = BatchList.GetListBySerie(_serie.Oid, false, true);
                }
                else
                {
                    lista = BatchList.GetListBySerieAndStock(_serie.Oid, false, true);
                }

                _batch = lista.GetItem(_entity.OidPartida);

                //Caso extraño de que se vaya a modificar un concepto de un producto con stock 0
                if (_batch == null)
                {
                    _batch = BatchInfo.Get(_entity.OidPartida, false);
                }

                Batch_BS.DataSource = _batch;

                _batch.StockBultos += _entity.CantidadBultos;
                _batch.StockKilos  += _entity.CantidadKilos;
                PgMng.Grow();
            }
            break;

            case ETipoProducto.Libres:
            {
                _batch = null;

                Products_BS.DataSource = _product;
                PgMng.Grow();
            }
            break;
            }

            base.RefreshMainData();

            EnableKilos();
        }
        /// <summary>
        /// Sends a batch list to the validator
        /// </summary>
        /// <returns>The batch list async.</returns>
        /// <param name="batchList">Batch list.</param>
        public async Task <ClientBatchSubmitResponse> SubmitBatchAsync(BatchList batchList)
        {
            var request = new ClientBatchSubmitRequest();

            request.Batches.AddRange(batchList.Batches);

            var response = await SendAsync(request.Wrap(Message.Types.MessageType.ClientBatchSubmitRequest), CancellationToken.None);

            return(response.Unwrap <ClientBatchSubmitResponse>());
        }
        public override void PrintList()
        {
            PgMng.Reset(3, 1, Face.Resources.Messages.LOADING_DATA, this);
            ExpedientReportMng reportMng = new ExpedientReportMng(AppContext.ActiveSchema, this.Text, FilterValues);

            PgMng.Grow(Face.Resources.Messages.BUILDING_REPORT);
            PartidaListRpt report = reportMng.GetPartidaListReport(BatchList.GetList(Datos.DataSource as IList <BatchInfo>));

            PgMng.FillUp();
            ShowReport(report);
        }
        // GET: Class/Create
        public ActionResult Create()
        {
            BatchList    Batchlist = new BatchList();     //Khởi tạo biếm có giá trị là class được khai báo trong models/batch
            LevelList    Levellist = new LevelList();
            List <batch> obj       = Batchlist.ListAll(); //Gọi hàm listall khai báo trong class trong models lấy ra danh sách batch
            List <level> obj1      = Levellist.ListAll();

            ViewBag.batchCode = new SelectList(obj, "code", "name"); //Đưa viewBag vào view
            ViewBag.levelCode = new SelectList(obj1, "code", "name");
            return(View());
        }
Exemple #23
0
        /// <summary>
        /// Batch subscribe or unsubscribe list members.
        /// </summary>
        public async Task <BatchListResponse> BatchAsync(BatchList batchList, string listId)
        {
            using (var client = CreateMailClient($"lists/{listId}"))
            {
                var response = await client.PostAsJsonAsync(string.Empty, batchList).ConfigureAwait(false);

                await response.EnsureSuccessMailChimpAsync().ConfigureAwait(false);

                return(await response.Content.ReadAsAsync <BatchListResponse>().ConfigureAwait(false));
            }
        }
Exemple #24
0
 public void RegisterTexture(Texture2D texture)
 {
     if (texture != null && !textureBatches.ContainsKey(texture))
     {
         BatchList batches = new BatchList();
         batches.texture = texture;
         batches.batches.Add(new VertexPositionColorTexture[maxPrimitivesPerBatch * 3]);
         batches.batchCurrent = -1;
         textureBatches.Add(texture, batches);
         batchesToRender.Add(batches);
     }
 }
Exemple #25
0
        protected void SelectProducto()
        {
            BatchList lista = BatchList.GetListByFamiliaNoKits(_familia.Oid, false);

            BatchSelectForm form = new BatchSelectForm(this, null, lista);

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                _batch     = form.Selected as BatchInfo;
                _expedient = (_batch.OidExpediente == 1) ? _almacen : _expedientes.GetItem(_batch.OidExpediente);
                Datos_Partida.DataSource = _batch;
            }
        }
Exemple #26
0
        protected override void RefreshMainData()
        {
            if (_entity == null)
            {
                return;
            }

            Datos.DataSource = _entity;

            _producto = ProductInfo.Get(_entity.OidProducto, false);
            PgMng.Grow();

            switch (_tipo)
            {
            case ETipoProducto.Almacen:
            {
                BatchList lista;

                lista = BatchList.GetListBySerieAndStock(_serie.Oid, false, true);

                _partida = lista.GetItem(_entity.OidPartida);

                //Caso extraño de que se vaya a modificar un concepto de un producto con stock 0
                if (_partida == null)
                {
                    _partida = BatchInfo.Get(_entity.OidPartida, false);
                }

                Datos_Partida.DataSource = _partida;

                _partida.StockBultos += _entity.CantidadBultos;
                _partida.StockKilos  += _entity.CantidadKilos;
                PgMng.Grow();
            }
            break;

            case ETipoProducto.Libres:
            {
                _partida = null;

                Datos_Productos.DataSource = _producto;
                PgMng.Grow();
            }
            break;
            }

            base.RefreshMainData();

            EnableKilos();
        }
        public override void UpdateList()
        {
            switch (_current_action)
            {
            case molAction.Add:
                if (_entity == null)
                {
                    return;
                }
                List.AddItem(_entity.GetInfo(false));
                if (FilterType == IFilterType.Filter)
                {
                    BatchList listA = BatchList.GetList(_filter_results);
                    listA.AddItem(_entity.GetInfo(false));
                    _filter_results = listA.GetSortedList();
                }
                break;

            case molAction.Edit:
            case molAction.Lock:
            case molAction.Unlock:
                if (_entity == null)
                {
                    return;
                }
                ActiveItem.CopyFrom(_entity);
                break;

            case molAction.Delete:
                if (ActiveItem == null)
                {
                    return;
                }
                List.RemoveItem(ActiveOID);
                if (FilterType == IFilterType.Filter)
                {
                    BatchList listD = BatchList.GetList(_filter_results);
                    listD.RemoveItem(ActiveOID);
                    _filter_results = listD.GetSortedList();
                }
                break;
            }

            RefreshSources();
            if (_entity != null)
            {
                Select(_entity.Oid);
            }
            _entity = null;
        }
Exemple #28
0
        protected virtual void SelectBatchAction()
        {
            BatchList list = BatchList.GetByProductStockList(_product.Oid, _provider.OidAcreedor, _provider.ETipoAcreedor, false);

            BatchSelectForm form = new BatchSelectForm(this, _serie, list);

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                BatchInfo batch = form.Selected as BatchInfo;
                _entity.CopyFrom(_delivery, batch);

                SetStore(StoreInfo.Get(_entity.OidAlmacen, false, true));
                SetExpedient(ExpedientInfo.Get(_entity.OidExpediente, false, true));
            }
        }
        public void TestThrottleWork1(int timeSec, int elemntPerSec)
        {
            var throttleWork = Sys.ActorOf(Props.Create(() => new ThrottleWork(elemntPerSec, timeSec)));

            throttleWork.Tell(new SetTarget(probe));

            int totalBatchCount = 10;                                   //총 테스트 개수
            int expectedTestSec = (totalBatchCount / elemntPerSec) + 2; //완료최대예상시간

            List <object> batchDatas = new List <object>();

            //테스트 데이터 준비
            for (int i = 0; i < totalBatchCount; i++)
            {
                batchDatas.Add(new BatchData()
                {
                    Data = $"test-{i}"
                });
            }

            var batchList = new BatchList(batchDatas.ToImmutableList());

            Within(TimeSpan.FromSeconds(expectedTestSec), () =>
            {
                // 데이터를 한꺼번에 큐에 넣는다.
                throttleWork.Tell(batchList);

                BatchData lastMessage = null;
                for (int i = 0; i < totalBatchCount; i++)
                {
                    var batchData = probe.ExpectMsg <BatchData>();

                    // 초당 5개씩 처리되는것 확인
                    string strResult = $"{DateTime.Now.ToString()} {batchData.Data as string}";
                    Console.WriteLine(strResult);

                    if (i == totalBatchCount - 1)
                    {
                        lastMessage = batchData;
                    }
                }
                //마지막 메시지 검사
                Assert.Equal($"test-{totalBatchCount-1}", lastMessage.Data as string);
            });
        }
Exemple #30
0
        public override void DeleteObject(long oid)
        {
            //if (ProgressInfoMng.ShowQuestion(moleQule.Face.Resources.Messages.DELETE_CONFIRM) == DialogResult.Yes)
            //{
            BatchList partidas = BatchList.GetListByAlmacen(oid, false);

            if (partidas.Count > 0)
            {
                PgMng.ShowInfoException("El almacén tiene productos asociados");

                _action_result = DialogResult.Ignore;
                return;
            }

            Almacen.Delete(oid);
            _action_result = DialogResult.OK;
            //}
        }
Exemple #31
0
        private BatchList GetData(string query)
        {
            string conString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
            SqlCommand cmd = new SqlCommand(query);
            using (SqlConnection con = new SqlConnection(conString))
            {
                using (SqlDataAdapter sda = new SqlDataAdapter())
                {
                    cmd.Connection = con;

                    sda.SelectCommand = cmd;

                    using (BatchList dsCustomers = new BatchList())
                    {
                        sda.Fill(dsCustomers, "DataTable1");
                        return dsCustomers;
                    }
                }
            }
        }
Exemple #32
0
        public void AddGeometryTriStrip(VertexPositionColorTexture[] verts, int numVerts, Texture2D texture, Matrix? world)
        {
            if (verts == null)
                throw new ArgumentNullException("RenderBatch.AddGeometryTriStrip requries non-null vertices array");

            int maxVertsPerBatch = maxPrimitivesPerBatch * 3;

            BatchList batches;
            if (!textureStripBatches.ContainsKey(texture))
            {
                batches = new BatchList();
                batches.texture = texture;
                batches.batches.Add(new VertexPositionColorTexture[maxVertsPerBatch]);
                batches.batchCurrent = 0;
                textureStripBatches.Add(texture, batches);
                batchesToRender.Add(batches);
            }
            else
            {
                batches = textureStripBatches[texture];
                if (batches.batchCurrent < 0)
                {
                    batches.batchCurrent = 0;
                    if (batches.batches.Count == 0)
                        batches.batches.Add(new VertexPositionColorTexture[maxVertsPerBatch]);
                }
            }

            VertexPositionColorTexture[] batch = batches.batches[batches.batchCurrent];

            int vertsLeft = numVerts;
            int vertPos = 0;

            // Add over multiple batches if needed
            if (vertsLeft > maxVertsPerBatch - batches.batchPos)
            {
                while (vertsLeft > maxVertsPerBatch - batches.batchPos)
                {
                    // Use up the curent batch and add a new one
                    int count = maxVertsPerBatch - batches.batchPos;
                    CopyTransformed(verts, vertPos, batch, batches.batchPos, count, world);

                    vertPos += count;
                    vertsLeft -= count;

                    if (batches.batchCurrent == batches.batches.Count - 1)
                    {
                        batches.batches.Add(new VertexPositionColorTexture[maxVertsPerBatch]);
                    }
                    batches.batchCurrent++;
                    batch = batches.batches[batches.batchCurrent];
                    batches.batchPos = 0;

                    // Started a new batch. Ensure strip is continuous
                    // copy last two verts across
                    if (vertsLeft > 0)
                    {
                        CopyTransformed(verts, vertPos - 2, batch, 0, 2, world);
                        batches.batchPos = 2;
                    }
                }
            }

            // Copy remaining verts to the current batch
            CopyTransformed(verts, vertPos, batch, batches.batchPos, vertsLeft, world);

            batches.batchPos += vertsLeft;

            hasTriangles = true;
        }
Exemple #33
0
 public void RegisterTexture(Texture2D texture)
 {
     if (texture != null && !textureBatches.ContainsKey(texture))
     {
         BatchList batches = new BatchList();
         batches.texture = texture;
         batches.batches.Add(new VertexPositionColorTexture[maxPrimitivesPerBatch * 3]);
         batches.batchCurrent = -1;
         textureBatches.Add(texture, batches);
         batchesToRender.Add(batches);
     }
 }
Exemple #34
0
        public void AddGeometry(VertexPositionColorTexture[] verts, Texture2D texture, Matrix? world, int startIndex, int amountToCopy)
        {
            if (verts == null)
                throw new ArgumentNullException("RenderBatch.AddGeometry requries non-null vertices array");

            int maxVertsPerBatch = maxPrimitivesPerBatch * 3;

            BatchList batches;
            if (!textureBatches.ContainsKey(texture))
            {
                batches = new BatchList();
                batches.texture = texture;
                batches.batches.Add(new VertexPositionColorTexture[maxVertsPerBatch]);
                batches.batchCurrent = 0;
                textureBatches.Add(texture, batches);
                batchesToRender.Add(batches);

                System.Diagnostics.Debug.WriteLine("Adding new texture to renderbatch");
            }
            else
            {
                batches = textureBatches[texture];
                if (batches.batchCurrent < 0)
                {
                    batches.batchCurrent = 0;
                    if (batches.batches.Count == 0)
                    {
                        batches.batches.Add(new VertexPositionColorTexture[maxVertsPerBatch]);

                        System.Diagnostics.Debug.WriteLine("Adding batch to renderbatch (1)");
                    }
                }
            }

            VertexPositionColorTexture[] batch = batches.batches[batches.batchCurrent];

            int vertsLeft = amountToCopy;
            int vertPos = startIndex;

            // Add over multiple batches if needed
            if (vertsLeft > maxVertsPerBatch - batches.batchPos)
            {
                while (vertsLeft > maxVertsPerBatch - batches.batchPos)
                {
                    // Use up the curent batch and add a new one
                    int count = maxVertsPerBatch - batches.batchPos;
                    CopyTransformed(verts, vertPos, batch, batches.batchPos, count, world);

                    vertPos += count;
                    vertsLeft -= count;

                    if (batches.batchCurrent == batches.batches.Count - 1)
                    {
                        batches.batches.Add(new VertexPositionColorTexture[maxVertsPerBatch]);

                        System.Diagnostics.Debug.WriteLine("Adding batch to renderbatch ({0})", batches.batches.Count);
                    }
                    batches.batchCurrent++;
                    batch = batches.batches[batches.batchCurrent];
                    batches.batchPos = 0;
                }
            }

            // Copy remaining verts to the current batch
            CopyTransformed(verts, vertPos, batch, batches.batchPos, vertsLeft, world);

            batches.batchPos += vertsLeft;

            hasTriangles = true;
        }