﻿/*
    This file is part of "Muffelsausen Code of Points".

    Copyright 2017 Lutz Mager

    "Muffelsausen Code of Points" is free software: you can redistribute
    it and/or modify it under the terms of the GNU Affero General Public
    License as published by the Free Software Foundation, either version
    3 of the License, or (at your option) any later version.

    "Muffelsausen Code of Points" is distributed in the hope that it
    will be useful, but WITHOUT ANY WARRANTY; without even the implied
    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public
    License along with "Muffelsausen Code of Points".  If not, see
    <http://www.gnu.org/licenses/>.
*/

using Muffelsausen.MuffelsausenApp.ViewModels.ResultsManagement;
using System.Windows;
using System.Windows.Controls;

namespace Muffelsausen.MuffelsausenApp.Views.ResultsManagement
{
    sealed class ResultsManagementTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var element = container as FrameworkElement;
            if (element != null && item != null)
            {
                if (item is ResultsViewModel)
                {
                    return element.FindResource("ResultsListViewTemplate") as DataTemplate;
                }
                else if (item is PrintingViewModel)
                {
                    return element.FindResource("PrintingViewTemplate") as DataTemplate;
                }
                else
                {
                    return element.FindResource("EmptyPlaceholderDataTempalte") as DataTemplate;
                }
            }

            return null;
        }
    }
}
