本文整理汇总了C#中Media类的典型用法代码示例。如果您正苦于以下问题:C# Media类的具体用法?C# Media怎么用?C# Media使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Media类属于命名空间,在下文中一共展示了Media类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:elrute,项目名称:Triphulcas,代码行数:35,代码来源:ImageHomeSlider.ascx.cs
示例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;
}
开发者ID:Database-2015-Team-Chlorine,项目名称:Teamwork,代码行数:29,代码来源:MongoModels.cs
示例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"));
}
开发者ID:kevinrjones,项目名称:mblog,代码行数:7,代码来源:ShowMediaViewModelTest.cs
示例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;
}
开发者ID:afrog33k,项目名称:eAd,代码行数:34,代码来源:WidgetsFactory.cs
示例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;
}
});
}
开发者ID:nnovic,项目名称:GetFacts,代码行数:33,代码来源:RegularViewer-PORT26.cs
示例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;
}
}
开发者ID:nnovic,项目名称:GetFacts,代码行数:28,代码来源:FileFetcher.cs
示例7: OnRender
public override void OnRender(Media.DrawingContext dc)
{
if (_pts != null)
{
dc.DrawPolygon(Fill, Stroke, _pts);
}
}
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:7,代码来源:Polygon.cs
示例8: MediaExport
public MediaExport(Media media, TimeSpan startTC, TimeSpan duration, decimal audioVolume)
{
this.Media = media;
this.StartTC = startTC;
this.Duration = duration;
this.AudioVolume = audioVolume;
}
开发者ID:jstarpl,项目名称:PlayoutAutomation,代码行数:7,代码来源:MediaExport.cs
示例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();
}
}
开发者ID:eoutvik,项目名称:Waffel_AutoCompress,代码行数:32,代码来源:WaffelImageCompressor.cs
示例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;
}
开发者ID:bartlomiejmucha,项目名称:Dianoga,代码行数:30,代码来源:OptimizingMediaCache.cs
示例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);
}
}
开发者ID:kevinrjones,项目名称:mblog,代码行数:25,代码来源:MediaService.cs
示例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);
}
开发者ID:krutika22,项目名称:My_Follow,代码行数:30,代码来源:MediaController.cs
示例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);
}
}
开发者ID:markgmarkg,项目名称:googleads-dotnet-lib,代码行数:38,代码来源:UploadMediaBundle.cs
示例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();
}
开发者ID:karppa1,项目名称:Olio-ohjelmointi,代码行数:26,代码来源:Program.cs
示例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;
}
开发者ID:jstarpl,项目名称:PlayoutAutomation,代码行数:60,代码来源:ServerDirectory.cs
示例16: CopyDataTo
public override Media CopyDataTo(Media media, bool copyCollections = true)
{
var copy = (MediaImage)base.CopyDataTo(media, copyCollections);
copy.Caption = Caption;
copy.ImageAlign = ImageAlign;
copy.Width = Width;
copy.Height = Height;
copy.CropCoordX1 = CropCoordX1;
copy.CropCoordY1 = CropCoordY1;
copy.CropCoordX2 = CropCoordX2;
copy.CropCoordY2 = CropCoordY2;
copy.OriginalWidth = OriginalWidth;
copy.OriginalHeight = OriginalHeight;
copy.OriginalSize = OriginalSize;
copy.OriginalUri = OriginalUri;
copy.IsOriginalUploaded = IsOriginalUploaded;
copy.PublicOriginallUrl = PublicOriginallUrl;
copy.ThumbnailWidth = ThumbnailWidth;
copy.ThumbnailHeight = ThumbnailHeight;
copy.ThumbnailSize = ThumbnailSize;
copy.ThumbnailUri = ThumbnailUri;
copy.IsThumbnailUploaded = IsThumbnailUploaded;
copy.PublicThumbnailUrl = PublicThumbnailUrl;
return copy;
}
开发者ID:vivekmalikymca,项目名称:BetterCMS,代码行数:27,代码来源:MediaImage.cs
示例17: MediaFile
public MediaFile(Media.MediaFile mediaFile)
: this()
{
_mediaFile = mediaFile;
txtAlias.Text = _mediaFile.Alias;
lblFileType.Text = string.Format("Type: {0} / {1}", _mediaFile.ResourceFileType.ToString(), _mediaFile.FileType.ToString());
lblFileName.Text = string.Format("File: {0}", _mediaFile.FileName.ToString());
lblResourceId.Text = string.Format("Resource: {0}", (_mediaFile.ResourceIdentifier != null ? _mediaFile.ResourceIdentifier.ToString() : "<n/a>"));
txtVolAll.Text = _mediaFile.VolumeAll.ToString();
txtVolLeft.Text = _mediaFile.VolumeLeft.ToString();
txtVolRight.Text = _mediaFile.VolumeRight.ToString();
chkMuteAll.Checked = _mediaFile.MuteAll;
chkMuteLeft.Checked = _mediaFile.MuteLeft;
chkMuteRight.Checked = _mediaFile.MuteRight;
txtBalance.Text = _mediaFile.Balance.ToString();
trackBalance.Value = _mediaFile.Balance;
txtTreble.Text = _mediaFile.VolumeTreble.ToString();
txtBass.Text = _mediaFile.VolumeBass.ToString();
chkLoop.Checked = _mediaFile.Looping;
}
开发者ID:Isthimius,项目名称:Gondwana,代码行数:26,代码来源:MediaFile.cs
示例18: SetTags
public static void SetTags(IRepository repository, Media sourceMedia, Media destinationMedia)
{
var destination = destinationMedia;
var source = sourceMedia;
if (destination == null || source == null)
{
return;
}
if (destination.MediaTags != null)
{
var tagsToRemove = destination.MediaTags.ToList();
tagsToRemove.ForEach(repository.Delete);
}
if (source.MediaTags == null)
{
return;
}
source.MediaTags.ForEach(destination.AddTag);
if (destination.MediaTags != null)
{
foreach (var mediaTag in destination.MediaTags)
{
mediaTag.Media = destinationMedia;
}
}
}
开发者ID:vivekmalikymca,项目名称:BetterCMS,代码行数:30,代码来源:MediaHelper.cs
示例19: SetCategories
public static void SetCategories(IRepository repository, Media sourceMedia, Media destinationMedia)
{
var destination = destinationMedia as ICategorized;
var source = sourceMedia as ICategorized;
if (destination == null || source == null)
{
return;
}
if (destination.Categories != null)
{
var categoriesToRemove = destination.Categories.ToList();
categoriesToRemove.ForEach(repository.Delete);
}
if (source.Categories == null)
{
return;
}
source.Categories.ForEach(destination.AddCategory);
if (destination.Categories != null)
{
destination.Categories.ForEach(e => e.SetEntity(destinationMedia));
}
}
开发者ID:vivekmalikymca,项目名称:BetterCMS,代码行数:27,代码来源:MediaHelper.cs
示例20: btnSubir_Click
protected void btnSubir_Click(object sender, EventArgs e)
{
string upload = System.IO.Path.GetFileName(FileUploadExaminar.PostedFile.FileName);
string nameFileOrignal = upload;
if (upload != "")
{
char[] seps = { '.' };
String[] values = upload.Split(seps);
if (values[1] == "jpg" || values[1] == "jpeg" || values[1] == "wmv")
{
path = path + "Clientes\\";
media = new Media()
{
nombre = txtContenido.Text,
ext = values[1],
creadoPor = "samuel",
modiificado = "samuel",
fileOriginal = nameFileOrignal.ToString()
};
context.AddToMedia(media);
int resul = context.SaveChanges();
if (resul == 1)
{
Int32 id = media.id;
if ((FileUploadExaminar.PostedFile != null) && (FileUploadExaminar.PostedFile.ContentLength > 0))
{
upload = id + "." + values[1];
path = path + upload;
GridView1.DataBind();
try
{
FileUploadExaminar.PostedFile.SaveAs(path);
txtContenido.Text = "";
}
catch (Exception ex)
{
Response.Write("Error: " + ex.Message);
}
}
else
{
Response.Write("Seleccione un archivo que cargar.");
}
}
}
else
{
Response.Write("formato no permitido");
}
}
}
开发者ID:GrupoAura-Samuel,项目名称:AMP,代码行数:59,代码来源:listar.aspx.cs
注:本文中的Media类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论