本文整理汇总了C#中Media类的典型用法代码示例。如果您正苦于以下问题:C# Media类的具体用法?C# Media怎么用?C# Media使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Media类属于命名空间,在下文中一共展示了Media类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCachedMedia
public Media[] GetCachedMedia()
{
if (Cache["allImages"] == null)
{
string[] userNames = Roles.GetUsersInRole("Triphulcas");
RelationType type = RelationType.GetByAlias("userMedia");
var _allImages = new List<Media>();
foreach (string userName in userNames)
{
var member = Member.GetMemberByName(userName, false);
if (member != null && member.Length > 0)
{
var relations = Relation.GetRelations(member[0].Id, type);
if (relations != null && relations.Length > 0)
{
foreach (var relation in relations)
{
var media = new Media(relation.Child.Id);
_allImages.Add(media);
}
}
}
}
//kludgy & clumsy fast approach for popup-viewer
Cache["allImages"] = _allImages;
}
Random rnd = new Random();
return (Cache["allImages"] as List<Media>).ToArray<Media>().OrderBy(x => rnd.Next()).ToArray();
//return (Cache["allImages"] as List<Media>).ToArray();
}
示例2: GetFromMongo
public IEnumerable<MediaDistributor> GetFromMongo()
{
var result = new List<MediaDistributor>();
foreach (var distributor in this.distributors.FindAll())
{
var distributorSql = new MediaDistributor()
{
Name = distributor.Name
};
foreach (var media in distributor.Medias)
{
var mediaSql = new Media()
{
Name = media.Name,
PriceSubscriptionPerMonth = media.PriceSubscriptionPerMonth,
DepartmentId = 1,
Type = media.Type
};
distributorSql.Medias.Add(mediaSql);
}
result.Add(distributorSql);
}
return result;
}
示例3: WhenANewMediaViewModelIsCreated_ThenTheClassStringIsSetProperly
public void WhenANewMediaViewModelIsCreated_ThenTheClassStringIsSetProperly()
{
var media = new Media
{Size = (int) Media.ValidSizes.Fullsize, Alignment = (int) Media.ValidAllignments.Left};
var model = new ShowMediaViewModel(media);
Assert.That(model.ClassString, Is.EqualTo("img-fullsize img-align-left"));
}
示例4: CreateFrom
public static Media CreateFrom(RegionOptions regionOptions)
{
UserControl widget = null;
Media Backing = new Media(regionOptions.Width,regionOptions.Height,regionOptions.Top,regionOptions.Left);
switch (regionOptions.Name)
{
case "CarInfo":
widget = new CarInfo();
break;
case "BatteryInfo":
widget = new BatteryInfo();
break;
case "LocationInfo":
widget = new Location();
break;
case "PersonalInfo":
widget = new Profile();
break;
default:
break;
}
widget.Width = regionOptions.Width;
widget.Height = regionOptions.Height;
//MediaGrid.Width = Width;
//MediaGrid.Height = Height;
widget.HorizontalAlignment = HorizontalAlignment.Center;
widget.VerticalAlignment = VerticalAlignment.Center;
widget.Margin = new Thickness(0, 0, 0, 0);
Backing.MediaCanvas.Children.Add(widget);
Backing.HasOnLoaded = true;
return Backing;
}
示例5: MediaDownloadStarted
public void MediaDownloadStarted(Media m)
{
notificationsFlowLayoutPanel.BeginInvoke((MethodInvoker)delegate
{
if( mediaBeingDownloaded[m] ==null)
{
StringBuilder sb = new StringBuilder();
sb.Append(GetFacts.Resources.GFResources.GetString("DOWNLOADING_MEDIA_CAPTION")); // "Downloading media"
sb.AppendLine();
sb.Append("URI=");
sb.Append(m.Uri);
sb.AppendLine();
sb.Append("Type=");
sb.Append(m.Type);
sb.AppendLine();
sb.Append("Priority=");
sb.Append(m.Priority);
sb.AppendLine();
sb.Append("Guid=");
sb.Append(m.Guid);
sb.AppendLine();
PictureBox pictureBox = new PictureBox();
pictureBox.Size = new Size(70, 70);
pictureBox.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox.Image = GetFacts.Plugins.Properties.Resources.media_downloading;
pictureBox.Margin = new Padding(10);
notificationsFlowLayoutPanel.Controls.Add(pictureBox);
mediaDownloadToolTip.SetToolTip(pictureBox, sb.ToString());
mediaBeingDownloaded[m] = pictureBox;
}
});
}
示例6: Fetch
public string Fetch(Media m)
{
media = m;
string fileName = Path.GetTempFileName();
try
{
using (webClient = new WebClient())
{
webClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wc_DownloadFileCompleted);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
lock (_download_lock_)
{
webClient.DownloadFileAsync(m.Uri, fileName);
Monitor.Wait(_download_lock_);
if (downloadSuccessful == false)
{
throw new OperationCanceledException();
}
}
}
return fileName;
}
catch
{
File.Delete(fileName);
throw;
}
}
示例7: OnRender
public override void OnRender(Media.DrawingContext dc)
{
if (_pts != null)
{
dc.DrawPolygon(Fill, Stroke, _pts);
}
}
示例8: MediaExport
public MediaExport(Media media, TimeSpan startTC, TimeSpan duration, decimal audioVolume)
{
this.Media = media;
this.StartTC = startTC;
this.Duration = duration;
this.AudioVolume = audioVolume;
}
示例9: compressImage
public static void compressImage(Media sender)
{
//Get settings file
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(HttpContext.Current.Server.MapPath("~/config/WaffelAutoCompress.config"));
var propertyAlias = xmlDoc.GetElementsByTagName("propertyalias")[0].InnerText;
var mediaTypes = xmlDoc.GetElementsByTagName("mediatypes")[0].InnerText;
bool allowedMediaType = mediaTypes.Split(',').Contains(sender.ContentType.Alias.ToString());
//Check if settings allow current mediatype and if upload property has value
if (allowedMediaType && sender.getProperty(propertyAlias).Value.ToString().Length != 0)
{
var triggerSize = xmlDoc.GetElementsByTagName("triggersize")[0].InnerText;
var fileTypes = xmlDoc.GetElementsByTagName("filetypes")[0].InnerText;
//Get uploaded file
string targetFilePath = HttpContext.Current.Server.MapPath(sender.getProperty(propertyAlias).Value.ToString());
var file = File.Open(targetFilePath, FileMode.Open, FileAccess.ReadWrite);
string fileName = file.Name.ToString();
var ext = fileName.Substring(fileName.LastIndexOf(".") + 1, fileName.Length - fileName.LastIndexOf(".") - 1).ToLower();
int maxFileSize = System.Convert.ToInt32(triggerSize) * 1024; // if above image is downscaled
bool allowedExt = fileTypes.Split(',').Contains(ext);
//Check if file type is allowed and if size is above triggersize
if (maxFileSize <= file.Length && allowedExt)
{
ImageDownscale(file, sender, ext);
}
else file.Dispose();
}
}
示例10: AddStream
public override bool AddStream(Media media, MediaOptions options, MediaStream stream, out MediaStream cachedStream)
{
/* STOCK METHOD (Decompiled) */
Assert.ArgumentNotNull(media, "media");
Assert.ArgumentNotNull(options, "options");
Assert.ArgumentNotNull(stream, "stream");
cachedStream = null;
if (!CanCache(media, options))
return false;
MediaCacheRecord cacheRecord = CreateCacheRecord(media, options, stream);
if (cacheRecord == null) return false;
cachedStream = cacheRecord.GetStream();
if (cachedStream == null) return false;
AddToActiveList(cacheRecord);
/* END STOCK */
// we store the site context because on the background thread: without the Sitecore context saved (on a worker thread), that disables the media cache
var currentSite = Context.Site;
cacheRecord.PersistAsync((() => OnAfterPersist(cacheRecord, currentSite)));
return true;
}
示例11: WriteMedia
public Media WriteMedia(string fileName, int userId, string contentType, Stream inputStream, int contentLength)
{
var mediaToCreate = new Media(fileName, userId, contentType, inputStream, contentLength);
try
{
Media media = _mediaRepository.GetMedia(userId, mediaToCreate.Year, mediaToCreate.Month,
mediaToCreate.Day,
mediaToCreate.LinkKey);
if (media == null)
{
mediaToCreate = _mediaRepository.WriteMedia(mediaToCreate);
return mediaToCreate;
}
throw new MBlogInsertItemException("Unable to add media. The media already exists in the database");
}
catch (MBlogInsertItemException)
{
throw;
}
catch (Exception e)
{
throw new MBlogException("Could not create media", e);
}
}
示例12: Create
public ActionResult Create(Media media,int id)
{
foreach (var file in media.Images)
{
if(file.ContentLength>0)
{
var filename = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/Images/"), filename);
file.SaveAs(path);
ViewBag.Path = path;
}
Media m = new Media()
{
UpdatesID = id,
Images = media.Images,
Video = media.Video
};
db.Media.Add(m);
db.SaveChanges();
return RedirectToAction("Index", new { id = media.UpdatesID });
}
return View(media);
}
示例13: Run
/// <summary>
/// Runs the code example.
/// </summary>
/// <param name="user">The AdWords user.</param>
public void Run(AdWordsUser user) {
// Get the MediaService.
MediaService mediaService = (MediaService) user.GetService(
AdWordsService.v201509.MediaService);
try {
// Create HTML5 media.
byte[] html5Zip = MediaUtilities.GetAssetDataFromUrl("https://goo.gl/9Y7qI2");
// Create a media bundle containing the zip file with all the HTML5 components.
Media[] mediaBundle = new Media[] {
new MediaBundle() {
data = html5Zip,
type = MediaMediaType.MEDIA_BUNDLE
}};
// Upload HTML5 zip.
mediaBundle = mediaService.upload(mediaBundle);
// Display HTML5 zip.
if (mediaBundle != null && mediaBundle.Length > 0) {
Media newBundle = mediaBundle[0];
Dictionary<MediaSize, Dimensions> dimensions =
CreateMediaDimensionMap(newBundle.dimensions);
Console.WriteLine("HTML5 media with id \"{0}\", dimensions \"{1}x{2}\", and MIME type " +
"\"{3}\" was uploaded.", newBundle.mediaId, dimensions[MediaSize.FULL].width,
dimensions[MediaSize.FULL].height, newBundle.mimeType
);
} else {
Console.WriteLine("No HTML5 zip was uploaded.");
}
} catch (Exception e) {
throw new System.ApplicationException("Failed to upload HTML5 zip file.", e);
}
}
示例14: Main
static void Main(string[] args)
{
Media media1 = new Media("Kirja", "Olio-ohjelmointi");
Media media2 = new Media("Lehti", "Mikrobitti");
Levy levy1 = new Levy("CD", "Lost Society", 66);
Levy levy2 = new Levy("DVD", "Hellraiser", 93);
Laite laite1 = new Laite("Puhelin", "Luuri", "Samsung");
Laite laite2 = new Laite("Kannettava", "Läppäri", "Asus");
media1.printData();
media2.printData();
levy1.printData();
levy2.printData();
laite1.printData();
laite2.printData();
media2.Nimi = "Tekniikan Maailma";
laite2.Tyyppi = "Tabletti";
laite2.Nimi = "Tab2";
laite2.Valmistaja = "Samsung";
media2.printData();
laite2.printData();
Console.ReadLine();
}
示例15: GetServerMedia
public ServerMedia GetServerMedia(Media media, bool searchExisting = true)
{
if (media == null)
return null;
ServerMedia fm = null;
_files.Lock.EnterUpgradeableReadLock();
try
{
fm = (ServerMedia)FindMedia(media);
if (fm == null || !searchExisting)
{
_files.Lock.EnterWriteLock();
try
{
fm = (new ServerMedia()
{
_mediaName = media.MediaName,
_folder = string.Empty,
_fileName = (media is IngestMedia) ? (VideoFileTypes.Any(ext => ext == Path.GetExtension(media.FileName).ToLower()) ? Path.GetFileNameWithoutExtension(media.FileName) : media.FileName) + DefaultFileExtension(media.MediaType) : media.FileName,
MediaType = (media.MediaType == TMediaType.Unknown) ? (StillFileTypes.Any(ve => ve == Path.GetExtension(media.FullPath).ToLowerInvariant()) ? TMediaType.Still : TMediaType.Movie) : media.MediaType,
_mediaStatus = TMediaStatus.Required,
_tCStart = media.TCStart,
_tCPlay = media.TCPlay,
_duration = media.Duration,
_durationPlay = media.DurationPlay,
_videoFormat = media.VideoFormat,
_audioChannelMapping = media.AudioChannelMapping,
_audioVolume = media.AudioVolume,
_audioLevelIntegrated = media.AudioLevelIntegrated,
_audioLevelPeak = media.AudioLevelPeak,
KillDate = (media is PersistentMedia) ? (media as PersistentMedia).KillDate : ((media is IngestMedia && (media.Directory as IngestDirectory).MediaRetnentionDays > 0) ? DateTime.Today + TimeSpan.FromDays(((IngestDirectory)media.Directory).MediaRetnentionDays) : default(DateTime)),
DoNotArchive = (media is ServerMedia && (media as ServerMedia).DoNotArchive)
|| media is IngestMedia && ((media as IngestMedia).Directory as IngestDirectory).MediaDoNotArchive,
HasExtraLines = media is ServerMedia && (media as ServerMedia).HasExtraLines,
_mediaCategory = media.MediaCategory,
_parental = media.Parental,
idAux = (media is PersistentMedia) ? (media as PersistentMedia).idAux : string.Empty,
idFormat = (media is PersistentMedia) ? (media as PersistentMedia).idFormat : 0L,
idProgramme = (media is PersistentMedia) ? (media as PersistentMedia).idProgramme : 0L,
_mediaGuid = fm == null ? media.MediaGuid : Guid.NewGuid(), // in case file with the same GUID already exists and we need to get new one
OriginalMedia = media,
Directory = this,
});
}
finally
{
_files.Lock.ExitWriteLock();
}
fm.PropertyChanged += MediaPropertyChanged;
}
else
if (fm.MediaStatus == TMediaStatus.Deleted)
fm.MediaStatus = TMediaStatus.Required;
}
finally
{
_files.Lock.ExitUpgradeableReadLock();
}
return fm;
}