本文整理汇总了C#中MainViewModel.AddOption方法的典型用法代码示例。如果您正苦于以下问题:C# MainViewModel.AddOption方法的具体用法?C# MainViewModel.AddOption怎么用?C# MainViewModel.AddOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainViewModel
的用法示例。
在下文中一共展示了MainViewModel.AddOption方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessOption
private void ProcessOption(MainViewModel model, Dictionary<string, AreaOption> areas, Category shellCategory,
Category shellSubCategory, OptionBaseType option)
{
if (option is UIOptionType)
{
var uiOption = option as UIOptionType;
if (!ShouldOptionBeVisible(uiOption, model.AppModel.IsAdmin))
{
return;
}
var shellOption = CreateShellOption(shellSubCategory, uiOption);
if (shellOption != null)
{
shellOption.IsEnabled = ShouldOptionBeEnabled(uiOption, model.AppModel.IsAdmin);
shellOption.Category = shellCategory;
shellOption.SubCategory = shellSubCategory;
if (!string.IsNullOrEmpty(uiOption.Area))
{
if (!areas.ContainsKey(uiOption.Area))
{
var area = new AreaOption
{
Name = uiOption.Area,
DisplayName = uiOption.DisplayText,
Description = uiOption.DisplayText,
Category = shellCategory,
SubCategory = shellSubCategory
};
areas.Add(uiOption.Area, area);
}
areas[uiOption.Area].AddSubOption(shellOption, uiOption.PolicyScope);
}
else
{
model.AddOption(shellOption);
}
}
}
else if (option is UIOptionGroupType)
{
shellSubCategory.ContainsInstances = true;
var optionGroup = option as UIOptionGroupType;
foreach (var instance in optionGroup.OptionGroupInstances)
{
model.AddOption(CreateShellOptionGroupInstance(shellSubCategory, instance));
}
}
}
示例2: OptionModelToUIModel
/// <summary>
/// Map Workshare.Option.ObjectModel to WCM UI data model.
/// </summary>
/// <param name = "model">UI data model to be changed</param>
/// <param name = "optionsRoot">Option object model to convert from</param>
/// <param name = "bAdmin">Switch Admin / User mode</param>
private void OptionModelToUIModel(MainViewModel model)
{
var areas = new Dictionary<string, AreaOption>();
model.Options.Clear();
model.Categories.Clear();
foreach (var category in _optionsRoot.Categories)
{
ProcessCategory(model, areas, category);
}
foreach (var item in areas)
{
model.AddOption(item.Value);
}
foreach (Category cat in model.Categories)
{
cat.SubCategories.Sort(item => item.Order);
}
model.BuildCompositeOptions();
}
示例3: ProcessInternalOptions
private void ProcessInternalOptions(MainViewModel model, UIOptionSubCategoryType subCategory)
{
var docProvs = subCategory.Options.Find(op => op.Name == "DocumentProviders") as UIOptionGroupType;
var defaultDocProv = subCategory.Options.Find(op => op.Name == "DefaultDocumentProvider") as UIOptionType;
StringOption defaultDocProvOpt = CreateShellOption(null, defaultDocProv) as StringOption;
model.AddOption(defaultDocProvOpt);
foreach (UIOptionGroupInstanceType instance in docProvs.OptionGroupInstances)
{
if (instance.Name == DefaultXmlReadVisitor.InstanceTemplateName)
{
continue;
}
if (instance.Name == "Offline Document Provider")
{
continue;
}
OptionGroupInstance shelloptiongroup = CreateShellOptionGroupInstance(null, instance);
BoolOption enabledOpt =
(from x in shelloptiongroup.SubOptions where x.Name == "Enabled" select x).FirstOrDefault() as BoolOption;
model.AddOption(enabledOpt);
if (IsFeatureEnabled(instance) || model.AppModel.IsAdmin)
{
DMSEnableOption newOpt = new DMSEnableOption(instance.Name, enabledOpt, defaultDocProvOpt)
{
Category = model.GetCategory("DMS"),
SubCategory = model.GetSubCategory("DMS", "General")
};
newOpt.IsEnabled = ShouldOptionBeEnabled(newOpt, model.AppModel.IsAdmin);
model.AddOption(newOpt);
}
}
}