protected override object CreateSpecificView(ViewModel mdl, ControlKind kind) { IView view = (IView)base.CreateSpecificView(mdl, kind); view.SetModel(mdl); return(view); }
public Key(TypeRef vmd, Toolkit tk, ControlKind ck) { this.vmd = vmd.ExportGuid; this.tk = tk; this.ck = ck != null ? ck.ExportGuid : Guid.Empty; }
void LauncherPage_Init(object sender, EventArgs e) { var mdl = ZetboxContextManagerModule.ViewModelFactory .CreateViewModel <WorkspaceViewModel.Factory>().Invoke(ZetboxContextManagerModule.ZetboxContext, null); ControlKind launcher = Zetbox.NamedObjects.Gui.ControlKinds.Zetbox_App_GUI_LauncherKind.Find(ZetboxContextManagerModule.ZetboxContext); ZetboxContextManagerModule.ViewModelFactory.CreateSpecificView(mdl, launcher, ctrlMainContent); }
public OpenDataObjectCommand(IViewModelDependencies appCtx, Func <IZetboxContext> ctxFactory, IZetboxContext dataCtx, ViewModel parent, ControlKind reqWorkspaceKind, ControlKind reqEditorKind ) : base(appCtx, dataCtx, parent, CommonCommandsResources.OpenDataObjectCommand_Name, CommonCommandsResources.OpenDataObjectCommand_Tooltip) { this.ctxFactory = ctxFactory; this._requestedWorkspaceKind = reqWorkspaceKind; this._requestedEditorKind = reqEditorKind; }
public static void ToString(ControlKind kind, MethodReturnEventArgs<string> e) { if (kind == null) { e.Result = "(null)"; return; } e.Result = kind.Name; }
public ColumnDisplayModel(string header, string name, ControlKind kind, ControlKind gridPreviewKind, ColumnType type, WidthHint requestedWidth, int? requestedWidthAbsolute) { this.Header = header; this.Name = name; this.ControlKind = kind; this.GridPreEditKind = gridPreviewKind ?? kind; this.Type = type; this.RequestedWidth = requestedWidth; this.RequestedWidthAbsolute = requestedWidthAbsolute; }
public ColumnDisplayModel(string header, string name, ControlKind kind, ControlKind gridPreviewKind, ColumnType type, WidthHint requestedWidth, int?requestedWidthAbsolute) { this.Header = header; this.Name = name; this.ControlKind = kind; this.GridPreEditKind = gridPreviewKind ?? kind; this.Type = type; this.RequestedWidth = requestedWidth; this.RequestedWidthAbsolute = requestedWidthAbsolute; }
public static void ToString(ControlKind kind, MethodReturnEventArgs <string> e) { if (kind == null) { e.Result = "(null)"; return; } e.Result = kind.Name; }
private void RemoveWindowViewModel(WindowViewModel windowViewModel, ControlKind controlKind) { var views = _windowViews[windowViewModel]; views.Remove(controlKind); if (views.Count == 0) { _windowViews.Remove(windowViewModel); } }
public ReadOnlyCollection <ViewDescriptor> GetDescriptors(ControlKind c) { if (_vdCache.ContainsKey(c.ExportGuid)) { return(_vdCache[c.ExportGuid]); } else { return(EmptyList); } }
public void ShowModel(ViewModel mdl, ControlKind kind, bool activate) { if (kind == null) { ShowModel(mdl, activate); } else { ShowInView(mdl, CreateSpecificView(mdl, kind), activate, false); } }
public static List <ControlKind> AndParents(this ControlKind ck) { var result = new List <ControlKind>(); result.Add(ck); var parent = ck.Parent; while (parent != null) { result.Add(parent); parent = parent.Parent; } return(result); }
private static DataTemplate SelectTemplate(ViewModel mdl, ControlKind controlKind, IFrozenContext frozenCtx) { var tr = GetTypeRef(mdl, frozenCtx); if (tr == null) return null; ViewModelDescriptor pmd = tr.GetViewModelDescriptor(); if (pmd == null) { Logging.Log.ErrorFormat("No matching ViewModelDescriptor found for {0}", mdl.GetType()); return null; } return CreateTemplate(pmd.GetViewDescriptor(Toolkit.WPF, controlKind)); }
public static DialogCreator AddString(this DialogCreator c, string label, ControlKind requestedKind) { if (c == null) { throw new ArgumentNullException("c"); } var mdl = new ClassValueModel <string>(label, "", false, false); var vmdl = c.ViewModelFactory.CreateViewModel <ClassValueViewModel <string> .Factory>().Invoke(c.DataContext, null, mdl); vmdl.RequestedKind = requestedKind; c.ValueModels.Add(vmdl); return(c); }
private void InstallRemovalHandler(WindowViewModel windowViewModel, ControlKind controlKind) { PropertyChangedEventHandler handler = null; handler = (object sender, PropertyChangedEventArgs e) => { if (e.PropertyName == "Show" && !windowViewModel.Show) { RemoveWindowViewModel(windowViewModel, controlKind); windowViewModel.PropertyChanged -= handler; } }; windowViewModel.PropertyChanged += handler; }
/// <summary> /// Creates a specific View for the given ViewModel. /// </summary> /// <param name="mdl">the model to be viewed</param> /// <param name="kind">the kind of view to create</param> /// <returns>the configured view</returns> protected virtual object CreateSpecificView(ViewModel mdl, ControlKind kind) { if (mdl == null) { throw new ArgumentNullException("mdl"); } if (kind == null) { throw new ArgumentNullException("kind"); } ViewModelDescriptor pmd = mdl.GetType().ToRef(FrozenContext) .GetViewModelDescriptor(); var vDesc = pmd.GetViewDescriptor(Toolkit, kind); return(CreateSpecificView(mdl, vDesc)); }
public void Show(string[] args) { if (args == null) { throw new ArgumentNullException("args"); } if (args.Contains("-installperfcounter")) { if (perfCounter != null) { perfCounter.Install(); } } else if (args.Contains("-uninstallperfcounter")) { if (perfCounter != null) { perfCounter.Install(); } } else if (args.Length > 0) { var appGuid = new Guid(args[0]); LaunchApplication(appGuid); } else if (cfg.Client.Application != null && cfg.Client.Application != Guid.Empty) { LaunchApplication(cfg.Client.Application.Value); } else { var ws = mdlFactory.CreateViewModel <WorkspaceViewModel.Factory>().Invoke(ctxFactory(ClientIsolationLevel.MergeServerData), null); ControlKind launcher = Zetbox.NamedObjects.Gui.ControlKinds.Zetbox_App_GUI_LauncherKind.Find(frozenCtx); mdlFactory.ShowModel(ws, launcher, true); } //var ctxDebugger = mdlFactory.CreateViewModel<ZetboxDebuggerAsViewModel.Factory>().Invoke(ctxFactory()); //mdlFactory.ShowModel(ctxDebugger, true); //var cacheDebugger = mdlFactory.CreateViewModel<CacheDebuggerViewModel.Factory>().Invoke(ctxFactory()); //mdlFactory.ShowModel(cacheDebugger, true); }
private static DataTemplate SelectTemplate(ViewModel mdl, ControlKind controlKind, IFrozenContext frozenCtx) { var tr = GetTypeRef(mdl, frozenCtx); if (tr == null) { return(null); } ViewModelDescriptor pmd = tr.GetViewModelDescriptor(); if (pmd == null) { Logging.Log.ErrorFormat("No matching ViewModelDescriptor found for {0}", mdl.GetType()); return(null); } return(CreateTemplate(pmd.GetViewDescriptor(Toolkit.WPF, controlKind))); }
internal static ConvertedControlKind ConvertToLocalType(this ControlKind source) { return(source.Convert <ControlKind, ConvertedControlKind>()); }
//// Steps for resolving a ViewModel to View //// 1. Find all ViewModel requested Views matching the ControlKind //// 2. Find all Views supporting the ViewModel matching the ControlKind //// 3. Find all Views supporting the ViewModel without ControlKind /// <summary> /// Look up the ViewDescriptor for this presentable model and ControlKind /// </summary> /// <param name="self"></param> /// <param name="tk"></param> /// <param name="requestedControlKind"></param> /// <returns></returns> public static ViewDescriptor GetViewDescriptor( this ViewModelDescriptor self, Toolkit tk, ControlKind requestedControlKind) { // Checks if (self == null) throw new ArgumentNullException("self"); #region Cache Management PrimeCaches(tk, self.ReadOnlyContext); var key = new ViewDescriptorCache.Key(self.ViewModelTypeRef, tk, requestedControlKind); if (_viewDescriptorCache.ContainsKey(key)) return _viewDescriptorCache[key]; #endregion // If the ViewModel has a more specific DefaultKind respect its choice if (self.DefaultEditorKind != null && requestedControlKind != null && self.DefaultEditorKind.AndParents().Select(i => i.ExportGuid).Contains(requestedControlKind.ExportGuid)) { if (requestedControlKind != self.DefaultEditorKind) { Logging.Log.DebugFormat("Using more specific default kind: {0} -> {1}", requestedControlKind.Name, self.DefaultEditorKind.Name); } requestedControlKind = self.DefaultEditorKind; } else { requestedControlKind = self.SecondaryControlKinds .FirstOrDefault( sck => sck.AndParents() .Select(i => i.ExportGuid) .Contains(requestedControlKind.ExportGuid) ) ?? requestedControlKind; } ViewDescriptor result = null; ICollection<ViewDescriptor> candidates; if (requestedControlKind != null) { candidates = _viewCaches[tk].GetDescriptors(requestedControlKind); } else { candidates = _viewCaches[tk].GetDescriptors(); } if (candidates.Count == 0) { // Try parent var type = Type.GetType(self.ViewModelTypeRef); var parent = type != null && type.BaseType != null ? type.BaseType.GetViewModelDescriptor(self.ReadOnlyContext) : null; if (parent != null) { result = GetViewDescriptor(parent, tk, requestedControlKind); } else { Logging.Log.WarnFormat("Couldn't find View for '{1}' matching ControlKind: '{0}'", requestedControlKind, self.ViewModelTypeRef); } } else if (candidates.Count == 1) { result = candidates.First(); } else { var allTypes = GetAllTypes(self); // As allTypes is sorted from most specific to least specific, so first or default is perfect. var match = allTypes.SelectMany(vmType => candidates.Where(candidate => { var viewType = Type.GetType(candidate.ControlTypeRef, throwOnError: false); if (viewType == null) return false; var supportedViewModels = viewType.GetInterfaces() .Where(ifType => ifType.IsGenericType && ifType.GetGenericTypeDefinition() == typeof(IHasViewModel<>)) .Select(ifType => ifType.GetGenericArguments().Single()); return supportedViewModels.Contains(vmType); })).FirstOrDefault(); // Log a warning if nothing found if (match == null) { Logging.Log.WarnFormat("Couldn't find View for '{1}' matching ControlKind: '{0}'", requestedControlKind, self.ViewModelTypeRef); } result = match; } _viewDescriptorCache[key] = result; return result; }
public static DateRangeFilterModel Create(IFrozenContext frozenCtx, string label, IFilterValueSource valueSource, ControlKind requestedKind, bool setYearDefault, bool setQuaterDefault, bool setMonthDefault) { if (frozenCtx == null) { throw new ArgumentNullException("frozenCtx"); } var mdl = new DateRangeFilterModel(); mdl.Label = label; mdl.ValueSource = valueSource; mdl.ViewModelType = ViewModelDescriptors.Zetbox_Client_Presentables_FilterViewModels_DateRangeFilterViewModel.Find(frozenCtx); mdl.RequestedKind = requestedKind; var fromMdl = new DateTimeValueModel(FilterModelsResources.From, "", true, false, DateTimeStyles.Date); var toMdl = new DateTimeValueModel(FilterModelsResources.To, "", true, false, DateTimeStyles.Date); mdl.FilterArguments.Add(new FilterArgumentConfig( fromMdl, /*cfg.ArgumentViewModel ?? */ ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableDateTimePropertyViewModel.Find(frozenCtx))); mdl.FilterArguments.Add(new FilterArgumentConfig( toMdl, /*cfg.ArgumentViewModel ?? */ ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableDateTimePropertyViewModel.Find(frozenCtx))); if (setYearDefault) { // Defaults to this month fromMdl.Value = DateTime.Today.FirstYearDay(); toMdl.Value = DateTime.Today.LastYearDay(); } else if (setQuaterDefault) { // Defaults to this month fromMdl.Value = DateTime.Today.FirstQuaterDay(); toMdl.Value = DateTime.Today.LastQuaterDay(); } else if (setMonthDefault) { // Defaults to this month fromMdl.Value = DateTime.Today.FirstMonthDay(); toMdl.Value = DateTime.Today.LastMonthDay(); } return(mdl); }
public static RangeFilterModel Create(IFrozenContext frozenCtx, string label, string predicate, Type type, ControlKind requestedKind, ControlKind requestedArgumentKind) { return(Create(frozenCtx, label, FilterValueSource.FromExpression(predicate), type, requestedKind, requestedArgumentKind)); }
public static SingleValueFilterModel Create(IFrozenContext frozenCtx, string label, IFilterValueSource predicate, Type propType, ControlKind requestedKind, ControlKind requestedArgumentKind) { if (frozenCtx == null) { throw new ArgumentNullException("frozenCtx"); } if (propType == null) { throw new ArgumentNullException("propType"); } var fmdl = new SingleValueFilterModel() { Label = label, ValueSource = predicate, Operator = FilterOperators.Equals, ViewModelType = ViewModelDescriptors.Zetbox_Client_Presentables_FilterViewModels_SingleValueFilterViewModel.Find(frozenCtx), RequestedKind = requestedKind, RefreshOnFilterChanged = false, }; ViewModelDescriptor vDesc = null; BaseValueModel mdl = null; if (propType == typeof(decimal)) { vDesc = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableDecimalPropertyViewModel.Find(frozenCtx); mdl = new DecimalValueModel(label, "", true, false, requestedArgumentKind); } else if (propType == typeof(int)) { vDesc = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableStructValueViewModel_1_System_Int32_.Find(frozenCtx); mdl = new NullableStructValueModel <int>(label, "", true, false, requestedArgumentKind); } else if (propType == typeof(double)) { vDesc = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableStructValueViewModel_1_System_Double_.Find(frozenCtx); mdl = new NullableStructValueModel <double>(label, "", true, false, requestedArgumentKind); } else if (propType == typeof(bool)) { vDesc = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableBoolPropertyViewModel.Find(frozenCtx); fmdl.RefreshOnFilterChanged = true; if (requestedArgumentKind == null) { requestedArgumentKind = NamedObjects.Gui.ControlKinds.Zetbox_App_GUI_DropdownBoolKind.Find(frozenCtx); } mdl = new BoolValueModel(label, "", true, false, requestedArgumentKind); } else if (propType == typeof(string)) { vDesc = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_ClassValueViewModel_1_System_String_.Find(frozenCtx); mdl = new ClassValueModel <string>(label, "", true, false, requestedArgumentKind); fmdl.Operator = FilterOperators.Contains; } else { throw new NotSupportedException(string.Format("Singlevalue filters of Type {0} are not supported yet", propType.Name)); } fmdl.FilterArguments.Add(new FilterArgumentConfig(mdl, vDesc)); return(fmdl); }
public static SingleValueFilterModel Create(IFrozenContext frozenCtx, string label, IEnumerable <Property> props, ControlKind requestedKind, ControlKind requestedArgumentKind) { var predicate = FilterValueSource.FromProperty(props); var last = props.Last(); if (last is DecimalProperty) { return(Create(frozenCtx, label, predicate, typeof(decimal), requestedKind, requestedArgumentKind)); } else if (last is IntProperty) { return(Create(frozenCtx, label, predicate, typeof(int), requestedKind, requestedArgumentKind)); } else if (last is DoubleProperty) { return(Create(frozenCtx, label, predicate, typeof(double), requestedKind, requestedArgumentKind)); } else if (last is StringProperty) { return(Create(frozenCtx, label, predicate, typeof(string), requestedKind, requestedArgumentKind)); } else if (last is BoolProperty) { return(Create(frozenCtx, label, predicate, typeof(bool), requestedKind, requestedArgumentKind)); } else if (last is EnumerationProperty) { return(Create(frozenCtx, label, predicate, ((EnumerationProperty)last).Enumeration.ExportGuid, requestedKind, requestedArgumentKind)); } else if (last is ObjectReferenceProperty) { return(Create(frozenCtx, label, predicate, ((ObjectReferenceProperty)last).GetReferencedObjectClass(), requestedKind, requestedArgumentKind)); } else if (last is CompoundObjectProperty) { return(Create(frozenCtx, label, predicate, ((CompoundObjectProperty)last).CompoundObjectDefinition, requestedKind, requestedArgumentKind)); } else { throw new NotSupportedException(string.Format("Singlevalue filters of Property Type {0} are not supported yet", last.GetType().Name)); } }
public ColumnDisplayModel(string header, string name, ControlKind kind, ControlKind gridPreviewKind) : this(header, name, kind, gridPreviewKind, ColumnType.PropertyModel, WidthHint.Default, null) { }
/// <summary> /// Creates a ColumnDisplayModel for a view model property or path to a property /// </summary> /// <param name="header">Label for the list header</param> /// <param name="kind">The requested editor kind or null if default should be used</param> /// <param name="vmPropPath">Path to the viewmodels property</param> /// <returns>a ready configurated ColumnDisplayModel</returns> public static ColumnDisplayModel Create(string header, ControlKind kind, string vmPropPath) { return Create(header, kind, null, WidthHint.Default, null, vmPropPath); }
public static DialogCreator AddString(this DialogCreator c, string label, ControlKind requestedKind) { if (c == null) throw new ArgumentNullException("c"); var mdl = new ClassValueModel<string>(label, "", false, false); var vmdl = c.ViewModelFactory.CreateViewModel<ClassValueViewModel<string>.Factory>().Invoke(c.DataContext, null, mdl); vmdl.RequestedKind = requestedKind; c.ValueModels.Add(vmdl); return c; }
public ControlKindViewModel(IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, ControlKind obj) : base(dependencies, dataCtx, parent, obj) { Kind = obj; }
/// <summary> /// Creates a ColumnDisplayModel for a view model property or path to a property /// </summary> /// <param name="header">Label for the list header</param> /// <param name="kind">The requested editor kind or null if default should be used</param> /// <param name="gridPreviewKind">The requested preview kind or null if default should be used</param> /// <param name="requestedWidth">Requested list column width</param> /// <param name="requestedWidthAbsolute">Requested list column width in absolute toolkit units</param> /// <param name="vmPropPath">Path to the viewmodels property</param> /// <returns>a ready configurated ColumnDisplayModel</returns> public static ColumnDisplayModel Create(string header, ControlKind kind, ControlKind gridPreviewKind, WidthHint requestedWidth, int? requestedWidthAbsolute, string vmPropPath) { return new ColumnDisplayModel() { Header = header, Path = vmPropPath, Type = ColumnDisplayModel.ColumnType.ViewModelProperty, RequestedWidth = requestedWidth, RequestedWidthAbsolute = requestedWidthAbsolute, ControlKind = kind, GridPreEditKind = gridPreviewKind ?? kind, }; }
/// <summary> /// Creates a ColumnDisplayModel for a view model property or path to a property /// </summary> /// <param name="header">Label for the list header</param> /// <param name="kind">The requested editor kind or null if default should be used</param> /// <param name="requestedWidthAbsolute">Requested list column width in absolute toolkit units</param> /// <param name="vmPropPath">Path to the viewmodels property</param> /// <returns>a ready configurated ColumnDisplayModel</returns> public static ColumnDisplayModel Create(string header, ControlKind kind, int? requestedWidthAbsolute, string vmPropPath) { return Create(header, kind, null, WidthHint.Default, requestedWidthAbsolute, vmPropPath); }
/// <summary> /// Creates a ColumnDisplayModel for a view model property or path to a property /// </summary> /// <param name="header">Label for the list header</param> /// <param name="kind">The requested editor kind or null if default should be used</param> /// <param name="requestedWidth">Requested list column width</param> /// <param name="vmPropPath">Path to the viewmodels property</param> /// <returns>a ready configurated ColumnDisplayModel</returns> public static ColumnDisplayModel Create(string header, ControlKind kind, WidthHint requestedWidth, string vmPropPath) { return Create(header, kind, null, requestedWidth, null, vmPropPath); }
//// Steps for resolving a ViewModel to View //// 1. Find all ViewModel requested Views matching the ControlKind //// 2. Find all Views supporting the ViewModel matching the ControlKind //// 3. Find all Views supporting the ViewModel without ControlKind /// <summary> /// Look up the ViewDescriptor for this presentable model and ControlKind /// </summary> /// <param name="self"></param> /// <param name="tk"></param> /// <param name="requestedControlKind"></param> /// <returns></returns> public static ViewDescriptor GetViewDescriptor( this ViewModelDescriptor self, Toolkit tk, ControlKind requestedControlKind) { // Checks if (self == null) throw new ArgumentNullException("self"); #region Cache Management PrimeCaches(tk, self.ReadOnlyContext); var key = new ViewDescriptorCache.Key(self.ViewModelRef, tk, requestedControlKind); if (_viewDescriptorCache.ContainsKey(key)) return _viewDescriptorCache[key]; #endregion // If the ViewModel has a more specific DefaultKind respect its choice if (self.DefaultEditorKind != null && requestedControlKind != null && self.DefaultEditorKind.AndParents().Select(i => i.ExportGuid).Contains(requestedControlKind.ExportGuid)) { if (requestedControlKind != self.DefaultEditorKind) { Logging.Log.DebugFormat("Using more specific default kind: {0} -> {1}", requestedControlKind.Name, self.DefaultEditorKind.Name); } requestedControlKind = self.DefaultEditorKind; } else { requestedControlKind = self.SecondaryControlKinds .FirstOrDefault( sck => sck.AndParents() .Select(i => i.ExportGuid) .Contains(requestedControlKind.ExportGuid) ) ?? requestedControlKind; } ViewDescriptor result = null; ICollection<ViewDescriptor> candidates; if (requestedControlKind != null) { candidates = _viewCaches[tk].GetDescriptors(requestedControlKind); } else { candidates = _viewCaches[tk].GetDescriptors(); } if (candidates.Count == 0) { // Try parent var parent = self.ViewModelRef.Parent != null ? self.ViewModelRef.Parent.GetViewModelDescriptor() : null; if (parent != null) { result = GetViewDescriptor(parent, tk, requestedControlKind); } else { Logging.Log.WarnFormat("Couldn't find ViewDescriptor for '{1}' matching ControlKind: '{0}'", requestedControlKind, self.ViewModelRef); } } else if (candidates.Count == 1) { result = candidates.First(); } else { var allTypes = GetAllTypes(self); // As allTypes is sorted from most specific to least specific first or default is perfect. var match = allTypes.SelectMany(t => candidates.Where(c => c.SupportedViewModels.Contains(t))).FirstOrDefault(); // Try the most common if (match == null) { match = allTypes.SelectMany(t => candidates.Where(c => c.SupportedViewModels.Count == 0)).FirstOrDefault(); } // Log a warning if nothing found if (match == null) { Logging.Log.WarnFormat("Couldn't find ViewDescriptor for '{1}' matching ControlKind: '{0}'", requestedControlKind, self.GetType().FullName); } result = match; } _viewDescriptorCache[key] = result; return result; }
public ColumnDisplayModel(string header, string name, ControlKind kind, ColumnType type) : this(header, name, kind, null, type, WidthHint.Default, null) { }
public ReadOnlyCollection<ViewDescriptor> GetDescriptors(ControlKind c) { if (_vdCache.ContainsKey(c.ExportGuid)) { return _vdCache[c.ExportGuid]; } else { return EmptyList; } }
protected override object CreateSpecificView(ViewModel mdl, ControlKind kind) { IView view = (IView)base.CreateSpecificView(mdl, kind); view.SetModel(mdl); return view; }
public static SingleValueFilterModel Create(IFrozenContext frozenCtx, string label, IFilterValueSource predicate, CompoundObject cpObj, ControlKind requestedKind, ControlKind requestedArgumentKind) { if (frozenCtx == null) { throw new ArgumentNullException("frozenCtx"); } var fmdl = new SingleCompoundValueFilterModel() { Label = label, ValueSource = predicate, Operator = FilterOperators.Equals, ViewModelType = ViewModelDescriptors.Zetbox_Client_Presentables_FilterViewModels_SingleValueFilterViewModel.Find(frozenCtx), RequestedKind = requestedKind, RefreshOnFilterChanged = true, CompoundObjectDefinition = cpObj, }; fmdl.FilterArguments.Add(new FilterArgumentConfig( new CompoundObjectValueModel(label, "", true, false, requestedArgumentKind, cpObj), cpObj.DefaultPropertyViewModelDescriptor ?? ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_CompoundObjectPropertyViewModel.Find(frozenCtx))); return(fmdl); }
public ColumnDisplayModel(string header, string name, ControlKind kind, int requestedWidthAbsoulte) : this(header, name, kind, null, ColumnType.PropertyModel, WidthHint.Default, requestedWidthAbsoulte) { }
public static SingleValueFilterModel Create(IFrozenContext frozenCtx, string label, Property prop, ControlKind requestedKind, ControlKind requestedArgumentKind) { return(Create(frozenCtx, label, new[] { prop }, requestedKind, requestedArgumentKind)); }
public ColumnDisplayModel(string header, string name, ControlKind kind, WidthHint requestedWidth) : this(header, name, kind, null, ColumnType.PropertyModel, requestedWidth, null) { }
public static YearValueFilterModel Create(IFrozenContext frozenCtx, string label, IFilterValueSource valueSource, bool setDefault, ControlKind requestedKind) { if (frozenCtx == null) { throw new ArgumentNullException("frozenCtx"); } var valMdl = new NullableStructValueModel <int>(label, "", true, false); var mdl = new YearValueFilterModel(); mdl.Label = label; mdl.ValueSource = valueSource; mdl.ViewModelType = ViewModelDescriptors.Zetbox_Client_Presentables_FilterViewModels_SingleValueFilterViewModel.Find(frozenCtx); mdl.RequestedKind = requestedKind; mdl.FilterArguments.Add(new FilterArgumentConfig( valMdl, /*cfg.ArgumentViewModel ?? */ ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableStructValueViewModel_1_System_Int32_.Find(frozenCtx))); if (setDefault) { // Defaults to this month valMdl.Value = DateTime.Today.FirstYearDay().Year; } return(mdl); }
public ColumnDisplayModel(string header, string name, ControlKind kind) : this(header, name, kind, ColumnType.PropertyModel) { }
public static RangeFilterModel Create <T>(IFrozenContext frozenCtx, string label, string predicate, ControlKind requestedKind, ControlKind requestedArgumentKind) where T : struct { return(Create(frozenCtx, label, predicate, typeof(T), requestedKind, requestedArgumentKind)); }
public static DialogCreator AddString(this DialogCreator c, object key, string label, string value = null, bool allowNullInput = false, bool isReadOnly = false, ControlKind requestedKind = null, ViewModelDescriptor vmdesc = null, string description = null, string helpText = null) { if (c == null) throw new ArgumentNullException("c"); if (key == null) throw new ArgumentNullException("key"); var mdl = new ClassValueModel<string>(label, description, allowNullInput, isReadOnly); mdl.Value = value; mdl.HelpText = helpText; BaseValueViewModel vmdl; if (vmdesc != null) vmdl = c.ViewModelFactory.CreateViewModel<StringValueViewModel.Factory>(vmdesc).Invoke(c.DataContext, null, mdl); else vmdl = c.ViewModelFactory.CreateViewModel<StringValueViewModel.Factory>().Invoke(c.DataContext, null, mdl); if (requestedKind != null) vmdl.RequestedKind = requestedKind; c.Add(key, vmdl); return c; }
public static RangeFilterModel Create(IFrozenContext frozenCtx, string label, IFilterValueSource predicate, Type type, ControlKind requestedKind, ControlKind requestedArgumentKind) { if (frozenCtx == null) { throw new ArgumentNullException("frozenCtx"); } if (type == null) { throw new ArgumentNullException("type"); } var rfmdl = new RangeFilterModel() { Label = label, ValueSource = predicate, ViewModelType = ViewModelDescriptors.Zetbox_Client_Presentables_FilterViewModels_RangeFilterViewModel.Find(frozenCtx), RequestedKind = requestedKind, }; ViewModelDescriptor vDesc = null; BaseValueModel mdl1 = null; BaseValueModel mdl2 = null; if (type == typeof(decimal)) { vDesc = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableDecimalPropertyViewModel.Find(frozenCtx); mdl1 = new DecimalValueModel("", "", true, false, requestedArgumentKind); mdl2 = new DecimalValueModel("", "", true, false, requestedArgumentKind); } else if (type == typeof(int)) { vDesc = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableStructValueViewModel_1_System_Int32_.Find(frozenCtx); mdl1 = new NullableStructValueModel <int>("", "", true, false, requestedArgumentKind); mdl2 = new NullableStructValueModel <int>("", "", true, false, requestedArgumentKind); } else if (type == typeof(double)) { vDesc = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableStructValueViewModel_1_System_Double_.Find(frozenCtx); mdl1 = new NullableStructValueModel <double>("", "", true, false, requestedArgumentKind); mdl2 = new NullableStructValueModel <double>("", "", true, false, requestedArgumentKind); } else if (type == typeof(DateTime)) { vDesc = ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableDateTimePropertyViewModel.Find(frozenCtx); mdl1 = new DateTimeValueModel("", "", true, false, DateTimeStyles.Date, requestedArgumentKind); mdl2 = new DateTimeValueModel("", "", true, false, DateTimeStyles.Date, requestedArgumentKind); } else { throw new NotSupportedException(string.Format("Rangefilters of Type {0} are not supported yet", type.Name)); } rfmdl.FilterArguments.Add(new FilterArgumentConfig(mdl1, vDesc)); rfmdl.FilterArguments.Add(new FilterArgumentConfig(mdl2, vDesc)); return(rfmdl); }
public static OptionalPredicateFilterModel Create(IFrozenContext frozenCtx, string label, string predicate, ControlKind requestedKind, ControlKind requestedArgumentKind) { if (frozenCtx == null) { throw new ArgumentNullException("frozenCtx"); } var fmdl = new OptionalPredicateFilterModel() { Label = label, ValueSource = FilterValueSource.FromExpression(predicate), ViewModelType = ViewModelDescriptors.Zetbox_Client_Presentables_FilterViewModels_OptionalPredicateFilterViewModel.Find(frozenCtx), RequestedKind = requestedKind, }; var valueMdl = new BoolValueModel(label, "", false, false, requestedArgumentKind); valueMdl.Value = false; fmdl.FilterArguments.Add(new FilterArgumentConfig(valueMdl, ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_NullableBoolPropertyViewModel.Find(frozenCtx))); return(fmdl); }
public static void GetName(ControlKind kind, MethodReturnEventArgs<string> e) { e.Result = "Gui.ControlKinds." + Regex.Replace(kind.Name, "\\W", "_"); }
public static SingleValueFilterModel Create(IFrozenContext frozenCtx, string label, string predicate, Guid enumDef, ControlKind requestedKind, ControlKind requestedArgumentKind) { return(Create(frozenCtx, label, FilterValueSource.FromExpression(predicate), enumDef, requestedKind, requestedArgumentKind)); }
public DataObjectViewModel ShowObject(IDataObject obj, ControlKind requestedKind = null, bool activate = true) { obj = obj == null || obj.Context == DataContext ? obj : DataContext.Find(obj.Context.GetInterfaceType(obj), obj.ID); var vm = DataObjectViewModel.Fetch(ViewModelFactory, DataContext, this, obj); if (!Items.Contains(vm)) { vm.RequestedKind = requestedKind; AddItem(vm); } if (activate) { SelectedItem = vm; } return vm; }
public static SingleValueFilterModel Create(IFrozenContext frozenCtx, string label, string predicate, ObjectClass referencedClass, ControlKind requestedKind, ControlKind requestedArgumentKind) { return(Create(frozenCtx, label, FilterValueSource.FromExpression(predicate), referencedClass, requestedKind, requestedArgumentKind)); }
public Key( TypeRef vmd, Toolkit tk, ControlKind ck) { this.vmd = vmd.ExportGuid; this.tk = tk; this.ck = ck != null ? ck.ExportGuid : Guid.Empty; }
public static SingleValueFilterModel Create(IFrozenContext frozenCtx, string label, IFilterValueSource predicate, ObjectClass referencedClass, ControlKind requestedKind, ControlKind requestedArgumentKind) { if (frozenCtx == null) { throw new ArgumentNullException("frozenCtx"); } var fmdl = new SingleValueFilterModel() { Label = label, ValueSource = predicate, Operator = FilterOperators.Equals, ViewModelType = ViewModelDescriptors.Zetbox_Client_Presentables_FilterViewModels_SingleValueFilterViewModel.Find(frozenCtx), RequestedKind = requestedKind, RefreshOnFilterChanged = true, }; fmdl.FilterArguments.Add(new FilterArgumentConfig( new ObjectReferenceValueModel(label, "", true, false, requestedArgumentKind, referencedClass), ViewModelDescriptors.Zetbox_Client_Presentables_ValueViewModels_ObjectReferenceViewModel.Find(frozenCtx))); return(fmdl); }
private static DataTemplate SelectTemplate(ViewModel mdl, ControlKind controlKind, IFrozenContext frozenCtx) { ViewModelDescriptor pmd = GuiExtensions.GetViewModelDescriptor(mdl, frozenCtx); if (pmd == null) return null; return CreateTemplate(pmd.GetViewDescriptor(Toolkit.WPF, controlKind)); }
/// <summary> /// Creates a ColumnDisplayModel for a zetbox object property or property path /// </summary> /// <param name="mode">Requested mode (readonly, editable)</param> /// <param name="header">Label for the list header</param> /// <param name="kind">The requested editor kind or null if default should be used</param> /// <param name="gridPreviewKind">The requested preview kind or null if default should be used</param> /// <param name="requestedWidth">Requested list column width</param> /// <param name="requestedWidthAbsolute">Requested list column width in absolute toolkit units</param> /// <param name="p">list of properties to build column for</param> /// <returns>a ready configurated ColumnDisplayModel</returns> public static ColumnDisplayModel Create(GridDisplayConfiguration.Mode mode, string header, ControlKind kind, ControlKind gridPreviewKind, WidthHint requestedWidth, int? requestedWidthAbsolute, params Property[] p) { var colMdl = Create(mode, p); colMdl.Header = header; colMdl.ControlKind = kind; colMdl.GridPreEditKind = gridPreviewKind ?? kind; colMdl.RequestedWidth = requestedWidth; colMdl.RequestedWidthAbsolute = requestedWidthAbsolute; return colMdl; }
public static void GetName(ControlKind kind, MethodReturnEventArgs <string> e) { e.Result = "Gui.ControlKinds." + Regex.Replace(kind.Name, "\\W", "_"); }
public static object CreateSpecificView(this IViewModelFactory self, ViewModel mdl, ControlKind kind, Control container) { if (self == null) { throw new ArgumentNullException("self"); } return AddControl(container, null /*self.CreateSpecificView(mdl, kind) */); }