//// This code is part of Document Solutions for PDF .NET demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingGrapeCity.Documents.Pdf;usingGrapeCity.Documents.Pdf.AcroForms;usingGrapeCity.Documents.Pdf.Actions;usingGrapeCity.Documents.Pdf.Annotations;usingGrapeCity.Documents.Text;usingSystem.Drawing;usingSystem.IO; namespaceDsPdfWeb.Demos{// This sample creates a PDF with some pushbuttons, // and associates each button's MouseDown event // with an ActionSound that plays a sound file.publicclassActionSound1 {publicintCreatePDF(Stream stream) {string[] soundPaths = {Path.Combine("Resources", "Sounds", "ding.aiff"),Path.Combine("Resources", "Sounds", "dong.wav"), };var doc = newGcPdfDocument();var page = doc.NewPage(); var rc = Common.Util.AddNote("This sample creates a PDF with some pushbuttons, " +"and associates each button's MouseDown event " +"with an ActionSound that plays a sound file.", page); var resolution = page.Graphics.Resolution;var g = page.Graphics;var tf = newTextFormat() { Font = StandardFonts.Times, FontSize = 14 };// Prep a simple layout:var ip = newPointF(resolution, rc.Bottom + resolution / 2);var fldOffset = resolution * 2.5f;var fldHeight = tf.FontSize * 1.2f;var dY = resolution * 0.4f; // Add the buttons with ActionSound on MouseDown events:foreach (var soundPath in soundPaths) {var btn = newPushButtonField(); btn.Widget.Page = page; btn.Widget.Rect = newRectangleF(ip.X + fldOffset, ip.Y, resolution, fldHeight); btn.Widget.ButtonAppearance.Caption = Path.GetFileNameWithoutExtension(soundPath);var sound = newActionSound(SoundObject.FromFile(soundPath)) {// Adjust sound properties if/as needed:Volume = 0.5f, }; btn.Widget.Events.MouseDown = sound; btn.Widget.Highlighting = HighlightingMode.Invert; doc.AcroForm.Fields.Add(btn); ip.Y += dY; } // Done: doc.Save(stream);return doc.Pages.Count; } }}