当前位置: 首页>>代码示例>>C#>>正文


C# System.IO.MemoryStream.WriteTo方法代码示例

本文整理汇总了C#中System.IO.MemoryStream.WriteTo方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.MemoryStream.WriteTo方法的具体用法?C# System.IO.MemoryStream.WriteTo怎么用?C# System.IO.MemoryStream.WriteTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.MemoryStream的用法示例。


在下文中一共展示了System.IO.MemoryStream.WriteTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BackupCompradoresLinkButton_Click

        protected void BackupCompradoresLinkButton_Click(object sender, EventArgs e)
        {
            if (CedWebRN.Fun.NoEstaLogueadoUnUsuarioPremium((CedWebEntidades.Sesion)Session["Sesion"]))
            {
                ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Esta funcionalidad es exclusiva del SERVICIO PREMIUM.  Contáctese con Cedeira Software Factory para acceder al servicio.');</script>");
            }
            else
            {
                List<CedWebEntidades.Comprador> compradores = CedWebRN.Comprador.Lista(((CedWebEntidades.Sesion)Session["Sesion"]).Cuenta, (CedEntidades.Sesion)Session["Sesion"], false);
                if (compradores.Count == 0)
                {
                    ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('No hay datos de Compradores para descargar.');</script>");
                }
                else
                {
                    System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(compradores.GetType());
                    System.IO.MemoryStream m = new System.IO.MemoryStream();
                    System.Xml.XmlWriter writerdememoria = new System.Xml.XmlTextWriter(m, System.Text.Encoding.GetEncoding("ISO-8859-1"));
                    x.Serialize(writerdememoria, compradores);
                    m.Seek(0, System.IO.SeekOrigin.Begin);
                    string nombreArchivo = "eFact-Compradores-" + ((CedWebEntidades.Sesion)Session["Sesion"]).Cuenta.Id.Replace(".", String.Empty).ToUpper() + ".xml";
                    System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath(@"~/Temp/" + nombreArchivo), System.IO.FileMode.Create);
                    m.WriteTo(fs);
                    fs.Close();
                    Server.Transfer("~/DescargaTemporarios.aspx?archivo=" + nombreArchivo, false);
                }

            }
        }
开发者ID:pjeconde,项目名称:eFact,代码行数:29,代码来源:Backup.aspx.cs

示例2: btn_FileSave_Click

        private void btn_FileSave_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Title = "파일 저장 대화상자 예제";
            dlg.CreatePrompt = true;
            dlg.OverwritePrompt = true;
            dlg.FileName = "default";
            dlg.DefaultExt = "rtf";
            dlg.InitialDirectory = "c:\\";
            dlg.Filter = "RichText files (*.rtf)|*.rtf";

            System.IO.MemoryStream memstream = new System.IO.MemoryStream();
            this.richTextBox1.SaveFile(memstream, RichTextBoxStreamType.RichText);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    System.IO.Stream fs = dlg.OpenFile();
                    memstream.Position = 0;
                    memstream.WriteTo(fs);
                    fs.Close();
                    this.textBox1.Text = dlg.FileName + " [[파일저장]]";
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:31,代码来源:Form1.cs

示例3: BackupVendedorLinkButton_Click

 protected void BackupVendedorLinkButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (CedWebRN.Fun.NoEstaLogueadoUnUsuarioPremium((CedWebEntidades.Sesion)Session["Sesion"]))
         {
             ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('Esta funcionalidad es exclusiva del SERVICIO PREMIUM.  Contáctese con Cedeira Software Factory para acceder al servicio.');</script>");
         }
         else
         {
             CedWebEntidades.Vendedor vendedor = new CedWebEntidades.Vendedor();
             vendedor.IdCuenta = ((CedWebEntidades.Sesion)Session["Sesion"]).Cuenta.Id;
             CedWebRN.Vendedor.Leer(vendedor, (CedEntidades.Sesion)Session["Sesion"]);
             System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(vendedor.GetType());
             System.IO.MemoryStream m = new System.IO.MemoryStream();
             System.Xml.XmlWriter writerdememoria = new System.Xml.XmlTextWriter(m, System.Text.Encoding.GetEncoding("ISO-8859-1"));
             x.Serialize(writerdememoria, vendedor);
             m.Seek(0, System.IO.SeekOrigin.Begin);
             string nombreArchivo = "eFact-Vendedor-" + ((CedWebEntidades.Sesion)Session["Sesion"]).Cuenta.Id.Replace(".", String.Empty).ToUpper() + ".xml";
             System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath(@"~/Temp/" + nombreArchivo), System.IO.FileMode.Create);
             m.WriteTo(fs);
             fs.Close();
             Server.Transfer("~/DescargaTemporarios.aspx?archivo=" + nombreArchivo, false);
         }
     }
     catch (Microsoft.ApplicationBlocks.ExceptionManagement.Validaciones.ElementoInexistente)
     {
         ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('No hay datos del Vendedor para descargar.');</script>");
     }
     catch (Exception ex)
     {
         ClientScript.RegisterStartupScript(GetType(), "Message", "<SCRIPT LANGUAGE='javascript'>alert('" + ex.Message.ToString() + "');</script>");
     }
 }
开发者ID:pjeconde,项目名称:eFact,代码行数:34,代码来源:Backup.aspx.cs

示例4: CopyFileStream

 private void CopyFileStream(byte[] srcBuffer, string fileName)
 {
     using (var target = System.IO.File.Create(fileName))
     {
         using (var src = new System.IO.MemoryStream(srcBuffer, false))
         {
             src.WriteTo(target);
         }
     }
 }
开发者ID:eriawan,项目名称:Open-XML-SDK,代码行数:10,代码来源:MCSupport.cs

示例5: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ClearContent();
            // squirt it out
            context.Response.BufferOutput = false;

            System.Data.SqlClient.SqlConnection m_sqlConnection;

            string connStr = System.Configuration.ConfigurationManager.ConnectionStrings["picConnect"].ConnectionString;

            m_sqlConnection = new System.Data.SqlClient.SqlConnection(connStr);

            m_sqlConnection.Open();

            // prepare the statement
            System.Data.SqlClient.SqlCommand insertCmd = new System.Data.SqlClient.SqlCommand("getPicRange", m_sqlConnection);
            insertCmd.CommandType = CommandType.StoredProcedure;

            System.Data.SqlClient.SqlDataReader read = insertCmd.ExecuteReader();

            System.IO.MemoryStream gif=new System.IO.MemoryStream();

            BumpKit.GifEncoder encoder = new GifEncoder(gif);

            encoder.FrameDelay = System.TimeSpan.FromMilliseconds(250);

            while (read.Read())
            {
                using (System.IO.MemoryStream image = new System.IO.MemoryStream((byte[])read.GetSqlBinary(read.GetOrdinal("pic"))))
                {
                    encoder.AddFrame(System.Drawing.Image.FromStream(image));
                }

            }

            context.Response.AddHeader("Content-Length", System.Convert.ToString(gif.Length));
            context.Response.AddHeader("Content-Type", "image/gif");

            gif.WriteTo(context.Response.OutputStream);

            m_sqlConnection.Close();
        }
开发者ID:barneyman,项目名称:rpi-webcam,代码行数:42,代码来源:jpgHandler.cs

示例6: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            var response = context.HttpContext.Response;
            response.Clear();
            response.Cache.SetCacheability(HttpCacheability.NoCache);
            response.ContentType = ContentType;

            //Check to see if this is done from bytes or physical location
            //  If you're really paranoid you could set a true/false flag in
            //  the constructor.
            if (ImageBytes != null)
            {
                var stream = new System.IO.MemoryStream(ImageBytes);
                stream.WriteTo(response.OutputStream);
                stream.Dispose();
            }
            else
            {
                response.TransmitFile(SourceFilename);
            }
        }
开发者ID:kyallbarrows,项目名称:LifeguardServer,代码行数:21,代码来源:ImageResult.cs

示例7: downloadFile

        /// <summary>
        /// Download a file
        /// Documentation: https://developers.google.com/drive/v3/web/manage-downloads
        /// </summary>
        /// <param name="_service">a Valid authenticated DriveService</param>
        /// <param name="_fileResource">File resource of the file to download</param>
        /// <param name="_saveTo">location of where to save the file including the file name to save it as.</param>
        /// <returns></returns>

        public static Boolean downloadFile(DriveService _service, File _fileResource, string _saveTo)
        {
            var request = _service.Files.Get(_fileResource.Id);
            var stream = new System.IO.MemoryStream();

            request.Download(stream);
            System.IO.FileStream file = new System.IO.FileStream(_saveTo, System.IO.FileMode.Create, System.IO.FileAccess.Write);
            try
            {
                stream.WriteTo(file);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                file.Close();
                stream.Close();
            }
            return true;
        }
开发者ID:m4rcelpl,项目名称:Google-Drive-Dotnet-v3-API,代码行数:31,代码来源:DaimtoGoogleDriveHelper.cs

示例8: OnSaveAs

        private void OnSaveAs(object sender, ExecuteEventArgs e)
        {
            using (SaveFileDialog dialog = new SaveFileDialog())
            {
                dialog.Filter = "Shader file (*.sh)|*.sh|All files (*.*)|*.*";
                dialog.FilterIndex = 0;
                dialog.RestoreDirectory = true;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    using (var stream = dialog.OpenFile())
                    {
                        using (var xmlStream = new System.IO.MemoryStream())
                        {
                            var nodeGraph = ModelConversion.ToShaderPatcherLayer(graphControl);
                            var serializer = new System.Runtime.Serialization.DataContractSerializer(
                                typeof(ShaderPatcherLayer.NodeGraph));
                            var settings = new System.Xml.XmlWriterSettings()
                            {
                                Indent = true,
                                IndentChars = "\t",
                                Encoding = System.Text.Encoding.ASCII
                            };

                                // write the xml to a memory stream to begin with
                            using (var writer = System.Xml.XmlWriter.Create(xmlStream, settings))
                            {
                                serializer.WriteObject(writer, nodeGraph);
                            }

                                // we hide the memory stream within a comment, and write
                                // out a hlsl shader file
                                // The HLSL compiler doesn't like UTF files... It just wants plain ASCII encoding

                            using (var sw = new System.IO.StreamWriter(stream, System.Text.Encoding.ASCII))
                            {
                                var shader = ShaderPatcherLayer.NodeGraph.GenerateShader(nodeGraph, System.IO.Path.GetFileNameWithoutExtension(dialog.FileName));
                                sw.Write(shader);

                                sw.Write("/* **** **** NodeEditor **** **** \r\nNEStart{");
                                sw.Flush();
                                xmlStream.WriteTo(stream);
                                sw.Write("}NEEnd\r\n **** **** */\r\n");
                            }

                        }
                    }
                }
            }
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:50,代码来源:ExampleForm.cs

示例9: OnInit

            /// <summary>
            /// Initialization event.
            /// </summary>
            /// <param name="e"></param>
            protected override void OnInit(EventArgs e)
            {
                System.Web.HttpRequest request = Context.Request;
                System.Web.HttpResponse response = Context.Response;
                if (request.Params["PlotSurface2D_" + this.ClientID] != null)
                {
                    // retrieve the bitmap and display
                    response.Clear();
                    try
                    {
                        response.ContentType = "Image/Png";
                        System.Drawing.Bitmap bmp = (System.Drawing.Bitmap) Context.Session[prefix()+"PNG"];

                        // don't ask why, but if I write directly to the response
                        // I have a GDI+ error, if I first write to a MemoryStream and
                        // then to the response.OutputStream I don't get an error.
                        System.IO.MemoryStream s = new System.IO.MemoryStream();
                        bmp.Save( s, System.Drawing.Imaging.ImageFormat.Png);
                        s.WriteTo(response.OutputStream);
                        Context.Session.Remove(prefix()+"PNG");
                    }
                    catch (Exception ex)
                    {
                        response.ContentType = "Text/HTML";
                        response.Write(	ex.Message );
                    }
                    finally
                    {
                        response.Flush();
                        response.End();
                    }
                }

                this.plotUrl = this.buildPlotURL();
                base.OnInit (e);
            }
开发者ID:Amichai,项目名称:ComputationalPhysics,代码行数:40,代码来源:Web.PlotSurface2D.cs

示例10: Page_Load

		private void Page_Load(object sender, System.EventArgs e)
		{
		
			_questionId = 
				Information.IsNumeric(Request["QuestionId"]) ? int.Parse(Request["QuestionId"]) : -1;
			_filterId = 
				Information.IsNumeric(Request["FilterId"]) ? int.Parse(Request["FilterId"]) : -1;
			_sortOrder =
				Request["SortOrder"] == null ? "ans" : Request["SortOrder"];

			if (_questionId == -1)
			{
				Response.End();
			}
			else if (!NSurveyUser.Identity.IsAdmin &&
				!NSurveyUser.Identity.HasAllSurveyAccess)
			{
				if (!new Question().CheckQuestionUser(_questionId, NSurveyUser.Identity.UserId))
				{
					Response.End();
				}
			}

			ChartEngine engine = new ChartEngine();
			ChartCollection charts = new ChartCollection(engine);

			engine.Size = new Size(700, 500);
			engine.Charts = charts;
			
			WebChart.ColumnChart chart = new WebChart.ColumnChart();
			chart.Fill.Color = Color.FromArgb(98,94,238);
			chart.MaxColumnWidth = 80;
			chart.DataLabels.Visible = true;
			chart.DataLabels.Position = DataLabelPosition.Bottom;
            chart.DataLabels.ForeColor = Color.White;
			chart.Shadow.Visible = true;
			chart.DataLabels.NumberFormat ="0.00";
            chart.ShowLineMarkers = true;

			SetQuestionData(engine, chart);
			SetMoreProperties(engine);

			charts.Add(chart);


			// send chart to browser
			Bitmap bmp;
			System.IO.MemoryStream memStream = new System.IO.MemoryStream();
			bmp = engine.GetBitmap();
			bmp.Save(memStream, System.Drawing.Imaging.ImageFormat.Png);
			memStream.WriteTo(Response.OutputStream);
			Response.End();

		}
开发者ID:ChrisNelsonPE,项目名称:surveyproject_main_public,代码行数:54,代码来源:BarChartReport.aspx.cs

示例11: Page_Load

		private void Page_Load(object sender, System.EventArgs e)
		{
		
			_questionId = 
				Information.IsNumeric(Request["QuestionId"]) ? int.Parse(Request["QuestionId"]) : -1;
			_filterId = 
				Information.IsNumeric(Request["FilterId"]) ? int.Parse(Request["FilterId"]) : -1;
			_sortOrder =
				Request["SortOrder"] == null ? "ans" : Request["SortOrder"];

			if (_questionId == -1)
			{
				Response.End();
			}
			else if (!NSurveyUser.Identity.IsAdmin &&
				!NSurveyUser.Identity.HasAllSurveyAccess)
			{
				if (!new Question().CheckQuestionUser(_questionId, NSurveyUser.Identity.UserId))
				{
					Response.End();
				}
			}

			ChartEngine engine = new ChartEngine();
			ChartCollection charts = new ChartCollection(engine);
			engine.Size = new Size(700, 500);
			engine.Charts = charts;
			
			
			PieChart pie = new PieChart();
			//pie.Colors = new Color[]{ Color.Red};

			ChartLegend legend = new ChartLegend();
			legend.Position = LegendPosition.Right;
			legend.Width = 200;
			legend.Background.Color = Color.FromArgb(245,249,251);
			
			pie.DataLabels.NumberFormat ="0.00";
			pie.Explosion = 6; 
			pie.Shadow.Visible = true; 
			pie.Shadow.Color=Color.LightGray; 
			pie.Shadow.OffsetY = 5; 
			engine.HasChartLegend = true;
			engine.Legend = legend;
			engine.GridLines = GridLines.None;


			SetQuestionData(engine, pie);
			SetMoreProperties(engine);

			charts.Add(pie);


			// send chart to browser
			Bitmap bmp;
			System.IO.MemoryStream memStream = new System.IO.MemoryStream();
			bmp = engine.GetBitmap();
			bmp.Save(memStream, System.Drawing.Imaging.ImageFormat.Png);
			memStream.WriteTo(Response.OutputStream);
			Response.End();

		}
开发者ID:ChrisNelsonPE,项目名称:surveyproject_main_public,代码行数:62,代码来源:PieChartReport.aspx.cs

示例12: RenderUsers


//.........这里部分代码省略.........
                dsUsers.Tables.Add("Users");
                DataTable dt = dsUsers.Tables["Users"];
                dt.Columns.Add("Id");
                dt.Columns.Add("Name");

                for(int i =0;i<ids_arr.GetUpperBound(0);i++)
                {
                    if( ids_arr[i] != "")
                    {
                        DataRow dr;
                        dr = dsUsers.Tables["Users"].NewRow();
                        dr["Id"] = ids_arr[i];
                        dr["Name"] = names_arr[i];
                        dsUsers.Tables["Users"].Rows.Add(dr);
                    }
                }

                wcEng = new ChartEngine();
                ChartCollection wcCharts = new ChartCollection(wcEng);
                wcEng.Charts = wcCharts;

                SetProperties(ref wcEng);

                DataSet dsXGames = new DataSet("XGames");
                FillXGames(ref dsXGames);

                int n = 0;
                DataSet dsUserPos = new DataSet("UserPos");
                foreach(DataRow dri in dsUsers.Tables["Users"].Rows)
                {
                    FillUserPos(ref dsUserPos,Convert.ToInt32(dri["id"]));
                    Chart lch = new WebChart.SmoothLineChart();
                    bool bNeedToShift = false;

                    //foreach (DataRow drxg in dsXGames.Tables[0].Rows)
                    //{
                    //    if (dsUserPos.Tables[0].Rows.Contains(drxg[0]))
                    //    {
                    //        DataRow drup = dsUserPos.Tables[0].Rows.Find(drxg[0]);
                    //        lch.Data.Add(new ChartPoint(ShiftGameName(drxg[0].ToString(), bNeedToShift), Convert.ToSingle(drup[1])));
                    //    }
                    //    else
                    //    {
                    //        DataRow drup = dsUserPos.Tables[0].Rows.Find(drxg[0]);
                    //        lch.Data.Add(new ChartPoint(ShiftGameName(drxg[0].ToString(), bNeedToShift), 30));
                    //    }

                    //    lch.DataLabels.Visible = true;
                    //    lch.DataLabels.ForeColor = Color.LightGray;
                    //    //bNeedToShift = !bNeedToShift;
                    //}

                    int nRowCount = dsXGames.Tables[0].Rows.Count;
                    //for(int z=nRowCount;z==1;z--)
                    for (int z = nRowCount - 1; z >= 0; z = z - 1)
                    //DataRow drxg in dsXGames.Tables[0].Rows)
                    {
                        DataRow drxg = dsXGames.Tables[0].Rows[z];
                        if (dsUserPos.Tables[0].Rows.Contains(drxg[0]))
                        {
                            DataRow drup = dsUserPos.Tables[0].Rows.Find(drxg[0]);
                            lch.Data.Add(new ChartPoint(ShiftGameName(drxg[0].ToString(), bNeedToShift), Convert.ToSingle(drup[1])));
                        }
                        else
                        {
                            //DataRow drup = dsUserPos.Tables[0].Rows.Find(drxg[0]);
                            //lch.Data.Add(new ChartPoint(ShiftGameName(drxg[0].ToString(), bNeedToShift), -1));
                        }
                        lch.DataLabels.Visible = true;
                        lch.DataLabels.ForeColor = Color.LightGray;
                        //bNeedToShift = !bNeedToShift;
                    }

                    lch.Line.Color = user_color[n%10];
                    n++;
                    lch.DataLabels.Visible=true;

                    Font dlFont = new Font("verdana",5);
                    lch.DataLabels.Font = dlFont;

                    lch.Legend = dri["name"].ToString();
                    lch.DataLabels.ForeColor = Color.Black;
                    lch.LineMarker = new CircleLineMarker(3, lch.Line.Color, lch.Line.Color);

                    wcEng.YCustomEnd  = Convert.ToInt32(Session["chart_Ycount"]);
                    wcEng.Charts.Add(lch);
                }

                Bitmap bmp;
                System.IO.MemoryStream memStream = new System.IO.MemoryStream();
                bmp = wcEng.GetBitmap();
                bmp.Save(memStream, System.Drawing.Imaging.ImageFormat.Png);
                memStream.WriteTo(Response.OutputStream);
                Response.End();
            }
            catch (Exception exc)
            {
                Response.Write(exc.Message);
            }
        }
开发者ID:avf2001,项目名称:tote,代码行数:101,代码来源:chart_img.aspx.cs

示例13: Page_Load

 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!((Request.QueryString["rating"] == null) | Request.QueryString["rating"].Equals("NaN")))
     {
         double ratingpoints = Convert.ToDouble(Request.QueryString["rating"]);
         int maxImageLength = 0;
         int maxImageHeight = 0;
         maxImageHeight = 10;
         //// pixels
         maxImageLength = 112;
         //// pixels
         int ratingValue = 0;
         ratingValue = Convert.ToInt32((ratingpoints / 5) * maxImageLength);
         Bitmap objBitmap = new Bitmap(maxImageLength, maxImageHeight);
         Graphics objGraphics = Graphics.FromImage(objBitmap);
         SolidBrush objBrushRating = new SolidBrush(this.foreColor);
         SolidBrush objBrushBorder = new SolidBrush(this.backColor);
         SolidBrush objBrushNoRate = new SolidBrush(this.ratingBackColor);
         SolidBrush objBrushRatingHighBorder = new SolidBrush(Color.FromArgb(this.MaxInt(Convert.ToInt32(this.foreColor.R) + 150), this.MaxInt(Convert.ToInt32(this.foreColor.G) + 150), this.MaxInt(Convert.ToInt32(this.foreColor.B) + 150)));
         SolidBrush objBrushRatingLowBorder = new SolidBrush(Color.FromArgb(this.MaxInt(Convert.ToInt32(this.foreColor.R) - 60), this.MaxInt(Convert.ToInt32(this.foreColor.G) - 60), this.MaxInt(Convert.ToInt32(this.foreColor.B) - 60)));
         SolidBrush objBrushBorderDark = new SolidBrush(Color.FromArgb(this.MaxInt(Convert.ToInt32(this.backColor.R) - 60), this.MaxInt(Convert.ToInt32(this.backColor.G) - 60), this.MaxInt(Convert.ToInt32(this.backColor.B) - 60)));
         objGraphics.FillRectangle(objBrushBorderDark, 0, 0, maxImageLength, maxImageHeight);
         objGraphics.FillRectangle(objBrushBorder, 1, 1, maxImageLength - 2, maxImageHeight - 2);
         objGraphics.FillRectangle(objBrushNoRate, 2, 2, maxImageLength - 3, maxImageHeight - 4);
         objGraphics.FillRectangle(objBrushRating, 2, 2, ratingValue - 3, maxImageHeight - 4);
         objGraphics.FillRectangle(objBrushRatingHighBorder, 2, 2, ratingValue - 3, 1);
         objGraphics.FillRectangle(objBrushRatingHighBorder, 2, 2, 1, maxImageHeight - 5);
         objGraphics.FillRectangle(objBrushRatingLowBorder, 2, maxImageHeight - 3, ratingValue - 3, 1);
         objGraphics.FillRectangle(objBrushRatingLowBorder, ratingValue - 2, 3, 1, maxImageHeight - 5);
         ////objGraphics.FillRectangle(objBrushBorder, 0, 0, 2 , MaxImageHeight)
         objGraphics.FillRectangle(objBrushBorder, 22, 1, 2, maxImageHeight - 2);
         objGraphics.FillRectangle(objBrushBorder, 44, 1, 2, maxImageHeight - 2);
         objGraphics.FillRectangle(objBrushBorder, 66, 1, 2, maxImageHeight - 2);
         objGraphics.FillRectangle(objBrushBorder, 88, 1, 2, maxImageHeight - 2);
         objGraphics.FillRectangle(objBrushBorder, 110, 1, 1, maxImageHeight - 2);
         Response.ContentType = "image/png";
         System.IO.MemoryStream imageStream = new System.IO.MemoryStream();
         objBitmap.Save(imageStream, ImageFormat.Png);
         imageStream.WriteTo(Response.OutputStream);
         objBitmap.Dispose();
         objGraphics.Dispose();
     }
     else
     {
         Bitmap objBitmap = new Bitmap(1, 1);
         Graphics objGraphics = Graphics.FromImage(objBitmap);
         SolidBrush objBrushRating = new SolidBrush(Color.Transparent);
         objGraphics.FillRectangle(objBrushRating, 0, 0, 1, 1);
         Response.ContentType = "image/png";
         System.IO.MemoryStream imageStream = new System.IO.MemoryStream();
         objBitmap.Save(imageStream, ImageFormat.Png);
         imageStream.WriteTo(Response.OutputStream);
         objBitmap.Dispose();
         objGraphics.Dispose();
     }
 }
开发者ID:JosephAllen,项目名称:DNNWiki,代码行数:61,代码来源:RatingBar.aspx.cs

示例14: WriteWavHeader

        /// <summary>
        /// A bare bones WAV file header writer
        /// </summary>        
        private static void WriteWavHeader(System.IO.Stream stream, int dataLength)
        {
            //We need to use a memory stream because the BinaryWriter will close the underlying stream when it is closed
            using (var memStream = new System.IO.MemoryStream(64))
            {
                int cbFormat = 18; //sizeof(WAVEFORMATEX)
                WAVEFORMATEX format = new WAVEFORMATEX()
                {
                    wFormatTag = 1,
                    nChannels = 1,
                    nSamplesPerSec = 16000,
                    nAvgBytesPerSec = 32000,
                    nBlockAlign = 2,
                    wBitsPerSample = 16,
                    cbSize = 0
                };

                using (var bw = new System.IO.BinaryWriter(memStream))
                {
                    //RIFF header
                    WriteString(memStream, "RIFF");
                    bw.Write(dataLength + cbFormat + 4); //File size - 8
                    WriteString(memStream, "WAVE");
                    WriteString(memStream, "fmt ");
                    bw.Write(cbFormat);

                    //WAVEFORMATEX
                    bw.Write(format.wFormatTag);
                    bw.Write(format.nChannels);
                    bw.Write(format.nSamplesPerSec);
                    bw.Write(format.nAvgBytesPerSec);
                    bw.Write(format.nBlockAlign);
                    bw.Write(format.wBitsPerSample);
                    bw.Write(format.cbSize);

                    //data header
                    WriteString(memStream, "data");
                    bw.Write(dataLength);
                    memStream.WriteTo(stream);
                }
            }
        }
开发者ID:seshadrs,项目名称:Kinect-as-a-Speech-Recorder,代码行数:45,代码来源:KinectAudioRecorder.cs

示例15: ProcessRequest

 public void ProcessRequest(HttpContext context)
 {
     string root_abs_path = VirtualPathUtility.ToAbsolute("~/");
     string archive_file_vpath = "~/" + context.Request.RawUrl.Substring(root_abs_path.Length).Replace(".fa.aspx?", "?");
     archive_file_vpath = archive_file_vpath.Substring(0, archive_file_vpath.IndexOf("?"));
     string archive_file = context.Server.MapPath(archive_file_vpath);
     string filename = (!string.IsNullOrEmpty(context.Request.QueryString["n"]) ? context.Request.QueryString["n"] : "");
     string requesttype = (!string.IsNullOrEmpty(context.Request.QueryString["t"]) ? context.Request.QueryString["t"] : "");
     string hashcode = (!string.IsNullOrEmpty(context.Request.QueryString["u"]) ? context.Request.QueryString["u"] : "");
     string width = (!string.IsNullOrEmpty(context.Request.QueryString["w"]) ? context.Request.QueryString["w"] : "");
     string fixed_height = (!string.IsNullOrEmpty(context.Request.QueryString["fh"]) ? context.Request.QueryString["fh"] : "t");
     string watermark = (!string.IsNullOrEmpty(context.Request.QueryString["wm"]) ? context.Request.QueryString["wm"] : "0");
     try
     {
         if (Security.CheckSecurity(hashcode))
         {
             FileArchiverCore core = new FileArchiverCore(archive_file);
             if (requesttype == "thumb")
             {
                 context.Response.ContentType = "image/png";
                 Bitmap thumb = core.GetIcon(filename, width, fixed_height);
                 System.IO.MemoryStream memresult = new System.IO.MemoryStream();
                 thumb.Save(memresult, System.Drawing.Imaging.ImageFormat.Png);
                 memresult.WriteTo(context.Response.OutputStream);
                 thumb.Dispose();
                 memresult.Dispose();
                 thumb = null;
                 memresult = null;
             }
             if (requesttype == "full")
             {
                 byte[] contents = core.GetFileContents(filename);
                 AddWatermark(ref contents);
                 context.Response.BinaryWrite(contents);
                 context.Response.ContentType = MimeTypes.GetMimeType(System.IO.Path.GetExtension(filename));
             }
             if (requesttype == "down")
             {
                 byte[] contents = core.GetFileContents(filename);
                 AddWatermark(ref contents);
                 context.Response.BinaryWrite(contents);
                 context.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
             }
             if (requesttype == "up")
             {
                 if (context.Request.Files.Count > 0)
                 {
                     core.AddFile(
                         context.Request.Files[0].FileName,
                         context.Request.Files[0].InputStream);
                     context.Response.Write("{status:'success'}");
                 }
             }
             if (requesttype == "del")
             {
                 core.RemoveFile(filename);
                 context.Response.Write("{status:'success'}");
             }
             if (requesttype == "list")
             {
                 string files = "";
                 for (int i = 0; i < core.Files.Length; i++)
                     files += core.Files[i].Name + "|";
                 if (files.EndsWith("|")) files = files.Remove(files.Length - 1);
                 context.Response.Write(files);
             }
         }
         else
         {
             throw new Exception("Not logged in.");
         }
     }
     catch (Exception ex)
     {
         context.Response.Write("{status:'error',msg:'" + ex.Message.Replace("'", "\\'").Replace("\\", "\\\\") + "',detail:'" + ex.ToString().Replace("'", "\\'").Replace("\\", "\\\\") + "'}");
     }
 }
开发者ID:rezaabiat,项目名称:BinaryArchiver,代码行数:77,代码来源:HttpHandler.cs


注:本文中的System.IO.MemoryStream.WriteTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。