Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version
Go to top

Silverlight Media Player

, 6 Apr 2009
Has some cool features like sliding menus with animation and Drag N Drop from menu
SilverLightMediaPlayer.zip
SilverLightMediaPlayer
MediaPlayer
Bin
Debug
de
System.Xml.Linq.resources.dll
es
System.Xml.Linq.resources.dll
fr
System.Xml.Linq.resources.dll
it
System.Xml.Linq.resources.dll
ja
System.Xml.Linq.resources.dll
ko
System.Xml.Linq.resources.dll
MediaPlayer.dll
MediaPlayer.xap
System.Xml.Linq.dll
zh-Hans
System.Xml.Linq.resources.dll
zh-Hant
System.Xml.Linq.resources.dll
MediaPlayer.csproj.user
Properties
v1.jpg
v2.jpg
MediaPlayerLive
App_Data
bin
de
System.Web.Silverlight.resources.dll
es
System.Web.Silverlight.resources.dll
fr
System.Web.Silverlight.resources.dll
it
System.Web.Silverlight.resources.dll
ja
System.Web.Silverlight.resources.dll
ko
System.Web.Silverlight.resources.dll
MediaPlayerLive.dll
MediaPlayerLive.pdb
System.Web.Silverlight.dll
zh-Hans
System.Web.Silverlight.resources.dll
zh-Hant
System.Web.Silverlight.resources.dll
ClientBin
MediaPlayer.xap
MediaPlayerLive.csproj.user
Properties
SilverLightMediaPlayer.suo
using System;
using System.Windows;
using System.Xml.Linq;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Media.Imaging;


namespace MediaPlayer
{
    public partial class HorizontalGallery : UserControl
    {
        public enum GalleryCount : int
        {
            Big = 6,
            Small = 3
        }
        int vidPointer = 0;
        XDocument xDoc;
        int btnClickedFlag = 1;
        private GalleryCount galleryMode;

        public GalleryCount GalleryMode
        {
            get { return galleryMode; }
            set
            {
                galleryMode = value;
                if (galleryMode == GalleryCount.Big)
                {
                    GalleryHeight = 50;
                }
                else
                {
                    GalleryHeight = 100;
                }
            }
        }

        double galleryHeight = 50;
        double GalleryHeight
        {
            get { return galleryHeight; }
            set
            {
                galleryHeight = value;
                ucHGallery.Height = value;
            }
        }

        public HorizontalGallery()
        {
            InitializeComponent();
        }

        private void Button_LClick(object sender, RoutedEventArgs e)
        {
            if (vidPointer == 0)
                return;
            rect.Visibility = Visibility.Visible;
            hideMenu.Begin();
            btnClickedFlag = -1;

        }

        private void Button_RClick(object sender, RoutedEventArgs e)
        {
            if (vidPointer + (int)GalleryMode >= GetTotalCount())
                return;
            rect.Visibility = Visibility.Visible;
            hideMenu.Begin();
            btnClickedFlag = 1;
        }

        private void DoubleAnimation_Completed(object sender, EventArgs e)
        {
            ShowNext();
            showMenu.Begin();
        }

        private int GetTotalCount()
        {
            var xVids = from v in xDoc.Descendants("Video")
                        where v.Attribute("img").Value.Length > 0 && v.Attribute("vid").Value.Length > 0
                        select v;
            return xVids.Count();
        }

        private void ShowNext()
        {
            vidPointer = vidPointer + (btnClickedFlag * (int)GalleryMode);
            if (vidPointer < 0)
                vidPointer = 0;
            var xVids = from v in xDoc.Descendants("Video")
                        where System.Convert.ToInt32(v.Attribute("id").Value) >= vidPointer
                        && v.Attribute("img").Value.Length > 0 && v.Attribute("vid").Value.Length > 0
                        && System.Convert.ToInt32(v.Attribute("id").Value) < (vidPointer + (int)GalleryMode)
                        select new
                        {
                            img = v.Attribute("img").Value,
                            vid = v.Attribute("vid").Value,
                            id = v.Attribute("id").Value
                        };
            imgGallery.Children.Clear();
            foreach (var v in xVids)
            {
                Image img = new Image();
                img.Source = new BitmapImage(new Uri(v.img, UriKind.Relative));
                img.Height = galleryHeight;
                img.Margin = new Thickness(1, 0, 1, 0);
                imgGallery.Children.Add(img);
            }
        }

        public void HGalleryInit()
        {
            xDoc = XDocument.Load("Data.xml");
            var xVids = from v in xDoc.Descendants("Video")
                        where System.Convert.ToInt32(v.Attribute("id").Value) >= vidPointer
                        && v.Attribute("img").Value.Length > 0 && v.Attribute("vid").Value.Length > 0
                        && System.Convert.ToInt32(v.Attribute("id").Value) < (vidPointer + (int)GalleryMode)
                        select new
                        {
                            img = v.Attribute("img").Value,
                            vid = v.Attribute("vid").Value,
                            id = v.Attribute("id").Value
                        };
            imgGallery.Children.Clear();
            foreach (var v in xVids)
            {
                Image img = new Image();
                img.Source = new BitmapImage(new Uri(v.img, UriKind.Relative));
                img.Height = galleryHeight;
                img.Margin = new Thickness(1, 0, 1, 0);
                imgGallery.Children.Add(img);
            }
        }

        private void DoubleAnimation_Completed_1(object sender, EventArgs e)
        {
            rect.Visibility = Visibility.Collapsed;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication

Share

About the Author

sunit_82
Software Developer (Senior) Geometric
India India
B.E. in Information Technology
MCTS(.NET 2.0 )

| Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 6 Apr 2009
Article Copyright 2009 by sunit_82
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid