123 lines
3.9 KiB
C#
Executable File
123 lines
3.9 KiB
C#
Executable File
/* ElementPickerViewModel.cs
|
|
* part of zaaReloaded2
|
|
*
|
|
* Copyright 2015 Daniel Kraus
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Bovender.Mvvm;
|
|
using Bovender.Mvvm.Messaging;
|
|
using Bovender.Mvvm.ViewModels;
|
|
using System.Collections.ObjectModel;
|
|
using zaaReloaded2.Controller.Elements;
|
|
|
|
namespace zaaReloaded2.ViewModels
|
|
{
|
|
/// <summary>
|
|
/// View model that presents a list of zaaReloaded2.Contorller.Elements.ElementBase
|
|
/// classes to choose from.
|
|
/// </summary>
|
|
class ElementPickerViewModel : ViewModelBase
|
|
{
|
|
#region Properties
|
|
|
|
/// <summary>
|
|
/// A two-dimensional tree
|
|
/// </summary>
|
|
public IList<CategoryViewModel> AvailableElements { get; private set; }
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
public ElementPickerViewModel(SettingsViewModel caller, bool allowControlElements)
|
|
{
|
|
_caller = caller;
|
|
AvailableElements = new List<CategoryViewModel>();
|
|
if (allowControlElements)
|
|
{
|
|
AvailableElements.Add(
|
|
new CategoryViewModel(
|
|
"Kontroll-Elemente",
|
|
new Collection<ViewModelBase>()
|
|
{
|
|
CreateControlElementViewModel(new SelectFirstDay()),
|
|
CreateControlElementViewModel(new SelectLastDay()),
|
|
CreateControlElementViewModel(new SelectEachDay())
|
|
}
|
|
)
|
|
);
|
|
}
|
|
AvailableElements.Add(
|
|
new CategoryViewModel(
|
|
"Ausgabe-Elemente",
|
|
new Collection<ViewModelBase>()
|
|
{
|
|
CreateFormatElementViewModel("Laborparameter", new Items()),
|
|
CreateFormatElementViewModel("Beliebiger Text", new CustomText()),
|
|
}
|
|
)
|
|
);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private methods
|
|
|
|
/// <summary>
|
|
/// Creates a new ControlElementViewModel that wraps a ControlElementBase
|
|
/// object. The display string of the ControlElementViewModel is taken
|
|
/// from the canonical Label of the control element.
|
|
/// </summary>
|
|
ViewModelBase CreateControlElementViewModel(ControlElementBase element)
|
|
{
|
|
ControlElementViewModel vm = new ControlElementViewModel(element);
|
|
vm.DisplayString = element.Label;
|
|
return vm;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a new FormatElementViewModel that wraps a FormatElementBase
|
|
/// object and has a custom display string. The custom display string
|
|
/// is necessary because format elements do not have a canonical label.
|
|
/// </summary>
|
|
ViewModelBase CreateFormatElementViewModel(string name, FormatElementBase element)
|
|
{
|
|
FormatElementViewModel vm = new FormatElementViewModel(element);
|
|
vm.DisplayString = name;
|
|
return vm;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Implementation ov ViewModelBase
|
|
|
|
public override object RevealModelObject()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Fields
|
|
|
|
SettingsViewModel _caller;
|
|
|
|
#endregion
|
|
}
|
|
}
|