Click here to Skip to main content
12,303,777 members (69,427 online)
Click here to Skip to main content

Stats

130.9K views
14.7K downloads
133 bookmarked
Posted

Simple Metro Style Panorama Control for WPF

, 20 Oct 2013 CPOL
A simple Metro style Panorama control for WPF.
AlternativePanorama
PanoramaControl
Properties
Themes
WpfApplication1.suo
WpfApplication1
Application.ico
DemoServices
Images
Add.png
Adobe.png
Android.png
Author.png
Blogger.png
Copy.png
Delete.png
Digg.png
Edit.png
Facebook.png
GMail.png
RSS.png
Save.png
Search.png
Trash.png
Twitter.png
VisualStudio.png
Wordpress.png
Yahoo.png
YouTube.png
Properties
ViewModels
WpfApplication1.csproj.user
WpfApplication1.suo
Application.ico
Add.png
Adobe.png
Android.png
Author.png
Blogger.png
Copy.png
Delete.png
Digg.png
Edit.png
Facebook.png
GMail.png
RSS.png
Save.png
Search.png
Trash.png
Twitter.png
VisualStudio.png
Wordpress.png
Yahoo.png
YouTube.png
Lib
GrayscaleEffect.dll
MahApps.Metro.dll
MahApps.Metro.Resources.dll
WpfApplication1.csproj.user
Panorama
PanoramaControl
Properties
Themes
WpfApplication1.suo
WpfApplication1
Application.ico
DemoServices
Images
Add.png
Adobe.png
Android.png
Author.png
Blogger.png
Copy.png
Delete.png
Digg.png
Edit.png
Facebook.png
GMail.png
RSS.png
Save.png
Search.png
Trash.png
Twitter.png
VisualStudio.png
Wordpress.png
Yahoo.png
YouTube.png
Properties
ViewModels
WpfApplication1.csproj.user
WpfApplication1.suo
Application.ico
Add.png
Adobe.png
Android.png
Author.png
Blogger.png
Copy.png
Delete.png
Digg.png
Edit.png
Facebook.png
GMail.png
RSS.png
Save.png
Search.png
Trash.png
Twitter.png
VisualStudio.png
Wordpress.png
Yahoo.png
YouTube.png
Lib
GrayscaleEffect.dll
MahApps.Metro.dll
MahApps.Metro.Resources.dll
WpfApplication1.csproj.user
TouchPanorama
PanoramaControl
Properties
Themes
WpfApplication1.suo
WpfApplication1
Application.ico
DemoServices
Images
Add.png
Adobe.png
Android.png
Author.png
Blogger.png
Copy.png
Delete.png
Digg.png
Edit.png
Facebook.png
GMail.png
RSS.png
Save.png
Search.png
Trash.png
Twitter.png
VisualStudio.png
Wordpress.png
Yahoo.png
YouTube.png
Properties
ViewModels
WpfApplication1.csproj.user
WpfApplication1.suo
Application.ico
Add.png
Adobe.png
Android.png
Author.png
Blogger.png
Copy.png
Delete.png
Digg.png
Edit.png
Facebook.png
GMail.png
RSS.png
Save.png
Search.png
Trash.png
Twitter.png
VisualStudio.png
Wordpress.png
Yahoo.png
YouTube.png
Lib
GrayscaleEffect.dll
MahApps.Metro.dll
MahApps.Metro.Resources.dll
WpfApplication1.csproj.user
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using PanoramaControl;
using System.Windows.Data;
using System.Windows.Threading;

namespace WpfApplication1
{
    public class MainWindowViewModel : INPCBase
    {
        private Random rand = new Random(DateTime.Now.Millisecond);
        private List<DummyTileData> dummyData = new List<DummyTileData>();
        private IMessageBoxService messageBoxService;



        public MainWindowViewModel(IMessageBoxService messageBoxService)
        {
            this.messageBoxService = messageBoxService;

            //create some dummy data
            dummyData.Add(new DummyTileData("Add", @"Images/Add.png"));
            dummyData.Add(new DummyTileData("Adobe", @"Images/Adobe.png"));
            dummyData.Add(new DummyTileData("Android", @"Images/Android.png"));
            dummyData.Add(new DummyTileData("Author", @"Images/Author.png"));
            dummyData.Add(new DummyTileData("Blogger", @"Images/Blogger.png"));
            dummyData.Add(new DummyTileData("Copy", @"Images/Copy.png"));
            dummyData.Add(new DummyTileData("Delete", @"Images/Delete.png"));
            dummyData.Add(new DummyTileData("Digg", @"Images/Digg.png"));
            dummyData.Add(new DummyTileData("Edit", @"Images/Edit.png"));
            dummyData.Add(new DummyTileData("Facebook", @"Images/Facebook.png"));
            dummyData.Add(new DummyTileData("GMail", @"Images/GMail.png"));
            dummyData.Add(new DummyTileData("RSS", @"Images/RSS.png"));
            dummyData.Add(new DummyTileData("Save", @"Images/Save.png"));
            dummyData.Add(new DummyTileData("Search", @"Images/Search.png"));
            dummyData.Add(new DummyTileData("Trash", @"Images/Trash.png"));
            dummyData.Add(new DummyTileData("Twitter", @"Images/Twitter.png"));
            dummyData.Add(new DummyTileData("VisualStudio", @"Images/VisualStudio.png"));
            dummyData.Add(new DummyTileData("Wordpress", @"Images/Wordpress.png"));
            dummyData.Add(new DummyTileData("Yahoo", @"Images/Yahoo.png"));
            dummyData.Add(new DummyTileData("YouTube", @"Images/YouTube.png"));

            //Great some dummy groups
            List<PanoramaGroup> data = new List<PanoramaGroup>();
            List<IPanoramaTile> tiles = new List<IPanoramaTile>();

            for (int i = 0; i < 4; i++)
            {
                tiles.Add(CreateTile(true));
				tiles.Add(CreateTile(true));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(true));

				tiles.Add(CreateTile(true));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));

				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));

				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
            }

			data.Add(new PanoramaGroup("Settings", CollectionViewSource.GetDefaultView(tiles)));

			tiles = new List<IPanoramaTile>();

			for (int i = 0; i < 4; i++)
			{
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(true));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(true));

				tiles.Add(CreateTile(true));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(true));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));

				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));

				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
				tiles.Add(CreateTile(false));
			}

			data.Add(new PanoramaGroup("Settings 2", CollectionViewSource.GetDefaultView(tiles)));

            PanoramaItems = data;

        }


        private PanoramaTileViewModel CreateTile(bool isDoubleWidth)
        {
            DummyTileData dummyTileData = dummyData[rand.Next(dummyData.Count)];
            return new PanoramaTileViewModel(messageBoxService, 
                dummyTileData.Text, dummyTileData.ImageUrl, isDoubleWidth);
        }


        private IEnumerable<PanoramaGroup> panoramaItems;

        public IEnumerable<PanoramaGroup> PanoramaItems
        {
            get { return this.panoramaItems; }

            set
            {
                if (value != this.panoramaItems)
                {
                    this.panoramaItems = value;
                    NotifyPropertyChanged("CompanyName");
                }
            }
        }
    }




    public class DummyTileData
    {
        public string Text { get; private set; }
        public string ImageUrl { get; private set; }

        public DummyTileData(string text, string imageUrl)
        {
            this.Text = text;
            this.ImageUrl = imageUrl;
        }
    }
}

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 The Code Project Open License (CPOL)

Share

About the Author

Sacha Barber
Software Developer (Senior)
United Kingdom United Kingdom
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)

- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence

Both of these at Sussex University UK.

Award(s)

I am lucky enough to have won a few awards for Zany Crazy code articles over the years

  • Microsoft C# MVP 2016
  • Codeproject MVP 2016
  • Microsoft C# MVP 2015
  • Codeproject MVP 2015
  • Microsoft C# MVP 2014
  • Codeproject MVP 2014
  • Microsoft C# MVP 2013
  • Codeproject MVP 2013
  • Microsoft C# MVP 2012
  • Codeproject MVP 2012
  • Microsoft C# MVP 2011
  • Codeproject MVP 2011
  • Microsoft C# MVP 2010
  • Codeproject MVP 2010
  • Microsoft C# MVP 2009
  • Codeproject MVP 2009
  • Microsoft C# MVP 2008
  • Codeproject MVP 2008
  • And numerous codeproject awards which you can see over at my blog

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160530.1 | Last Updated 20 Oct 2013
Article Copyright 2012 by Sacha Barber
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid