private void ShowFormatOptions(QueryCriteriaViewModel field) { if (string.IsNullOrWhiteSpace(field.Field.Format)) { InfoBox.Show("There are no formatting options available for this field", "No formatting options", this); return; } switch (field.Field.Format.ToLower()) { case "date": var datefrm = new DateFormattingOptions(field.FormatOption); datefrm.Owner = this.FindParentWindow(); datefrm.WindowStartupLocation = WindowStartupLocation.CenterOwner; if (datefrm.ShowDialog().ValueOrFalse()) { field.FormatOption = datefrm.FormatOption; } break; case "latitude": case "longitude": var coordType = (CoordinateType)Enum.Parse(typeof(CoordinateType), field.Field.Format); var coordfrm = new CoordinateFormattingOptions(coordType, field.FormatOption); coordfrm.Owner = this.FindParentWindow(); if (coordfrm.ShowDialog().ValueOrFalse()) { field.FormatOption = coordfrm.FormatSpecifier; } break; default: throw new Exception("Unhandled data format type: " + field.Field.Format); } CurrentLabelSet.Delimited = BuildDelimitedFields(lvwSelectedFields.ItemsSource as ObservableCollection <QueryCriteriaViewModel>); }
void LabelManagerControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { var selected = e.NewValue as LabelSetViewModel; if (selected != null) { CurrentItemSetID = selected.ID; var itemlist = _allItems.FindAll((item) => { return(item.SetID == selected.ID); }); var list = new List <LabelSetItemViewModel>(itemlist.Select((m) => { return(new LabelSetItemViewModel(m)); })); list.Sort(new Comparison <LabelSetItemViewModel>((vm1, vm2) => { return(vm1.PrintOrder - vm2.PrintOrder); })); _itemModel = new ObservableCollection <LabelSetItemViewModel>(list); foreach (LabelSetItemViewModel item in _itemModel) { item.DataChanged += new DataChangedHandler((vm) => { Host.RegisterUniquePendingChange(new UpdateLabelSetItemCommand((vm as LabelSetItemViewModel).Model)); }); } lvw.ItemsSource = _itemModel; // Set Selected export fields... var fieldStr = selected.Delimited; var model = new ObservableCollection <QueryCriteriaViewModel>(); if (!string.IsNullOrEmpty(fieldStr)) { char delim = (char)1; if (fieldStr.StartsWith(V_1_5_PREFIX)) { fieldStr = fieldStr.Substring(V_1_5_PREFIX.Length); } else { delim = ','; } var fields = fieldStr.Split(delim); foreach (string field in fields) { string strField = null; string strFormat = null; if (field.Contains((char)2)) { var bits = field.Split((char)2); strField = bits[0]; strFormat = bits[1]; } else { strField = field; strFormat = ""; } var fieldDesc = FindField(strField); if (fieldDesc != null) { var selectedField = new QueryCriteria { Field = fieldDesc, FormatOption = strFormat, Output = true }; var viewModel = new QueryCriteriaViewModel(selectedField); model.Add(viewModel); } } } lvwSelectedFields.ItemsSource = model; } }