public void Process(Isolate source, IsolateViewModel destination) { var sending = source.Sending; destination.SamplingLocation = sending.SamplingLocation == SamplingLocation.Other ? sending.OtherSamplingLocation : EnumEditor.GetEnumDescription(sending.SamplingLocation); destination.Material = EnumEditor.GetEnumDescription(sending.Material); destination.Invasive = EnumEditor.GetEnumDescription(sending.Invasive); destination.PatientAgeAtSampling = source.PatientAgeAtSampling(); destination.EpsilometerTestViewModels = EpsilometerTestsModelToViewModel(source.EpsilometerTests); destination.SamplingDate = source.Sending.SamplingDate.ToReportFormat(); destination.ReceivingDate = source.Sending.ReceivingDate.ToReportFormat(); destination.PatientId = source.Sending.Patient.PatientId; destination.Patient = source.Sending.Patient.ToReportFormat(); destination.PatientBirthDate = source.Sending.Patient.BirthDate.ToReportFormat(); destination.PatientPostalCode = source.Sending.Patient.PostalCode; destination.SenderLaboratoryNumber = source.Sending.SenderLaboratoryNumber; destination.EvaluationString = source.Evaluation.ToReportFormat(); var interpretationResult = isolateInterpretation.Interpret(source); destination.Interpretation = interpretationResult.Interpretation; destination.InterpretationPreliminary = interpretationResult.InterpretationPreliminary; destination.InterpretationDisclaimer = interpretationResult.InterpretationDisclaimer; var sender = db.Senders.Find(source.Sending.SenderId); destination.SenderName = sender.Name; destination.SenderStreet = sender.StreetWithNumber; destination.SenderCity = $"{sender.PostalCode} {sender.City}"; }
protected override List <QueryRecord> QueryRecords() { var query = NotDeletedSendings().Select(x => new { x.MeningoSendingId, x.Isolate.MeningoIsolateId, x.Isolate.ReportStatus, x.Isolate.ReportDate, x.Patient.Initials, x.Patient.BirthDate, x.Isolate.StemNumber, x.ReceivingDate, x.SamplingLocation, x.OtherInvasiveSamplingLocation, x.OtherNonInvasiveSamplingLocation, x.Isolate.YearlySequentialIsolateNumber, x.Isolate.Year, x.SenderLaboratoryNumber, x.MeningoPatientId, PatientPostalCode = x.Patient.PostalCode, SenderPostalCode = db.Senders.FirstOrDefault(s => s.SenderId == x.SenderId).PostalCode, }); var queryRecords = query.ToList().Select(x => { var invasive = MeningoSending.IsInvasive(x.SamplingLocation) ? YesNo.Yes : YesNo.No; var samplingLocation = x.SamplingLocation == MeningoSamplingLocation.OtherInvasive ? Server.HtmlEncode(x.OtherInvasiveSamplingLocation) : x.SamplingLocation == MeningoSamplingLocation.OtherNonInvasive ? Server.HtmlEncode(x.OtherNonInvasiveSamplingLocation) : EnumEditor.GetEnumDescription(x.SamplingLocation); var laboratoryNumber = ReportFormatter.ToLaboratoryNumber(x.YearlySequentialIsolateNumber, x.Year, DatabaseType.Meningococci); return(new QueryRecord { SendingId = x.MeningoSendingId, IsolateId = x.MeningoIsolateId, PatientId = x.MeningoPatientId, Initials = x.Initials, BirthDate = x.BirthDate, StemNumber = x.StemNumber.ToStemNumberWithPrefix(DatabaseType.Meningococci), ReceivingDate = x.ReceivingDate, SamplingLocation = samplingLocation, Invasive = EnumEditor.GetEnumDescription(invasive), LaboratoryNumber = x.Year * 10000 + x.YearlySequentialIsolateNumber, LaboratoryNumberString = laboratoryNumber, ReportStatus = x.ReportStatus, PatientPostalCode = x.PatientPostalCode, SenderPostalCode = x.SenderPostalCode, SenderLaboratoryNumber = x.SenderLaboratoryNumber, FullTextSearch = string.Join(" ", x.Initials, x.BirthDate.ToReportFormat(), x.StemNumber.ToStemNumberWithPrefix(DatabaseType.Meningococci), x.ReceivingDate.ToReportFormat(), invasive, samplingLocation, laboratoryNumber, x.PatientPostalCode, x.SenderPostalCode, x.SenderLaboratoryNumber, x.MeningoPatientId) .ToLower() }); }).ToList(); return(queryRecords); }
protected override IEnumerable <Sending> SendingsMatchingExportQuery(FromToQuery query, ExportType exportType) { var samplingLocations = exportType == ExportType.Rki || exportType == ExportType.Iris ? new List <SamplingLocation> { SamplingLocation.Blood, SamplingLocation.Liquor } : new List <SamplingLocation> { SamplingLocation.Blood, SamplingLocation.Liquor, SamplingLocation.Other }; var filteredSendings = NotDeletedSendings() .Include(s => s.Patient) .Where (s => samplingLocations.Contains(s.SamplingLocation) && ((s.SamplingDate == null && s.ReceivingDate >= query.From && s.ReceivingDate <= query.To) || (s.SamplingDate >= query.From && s.SamplingDate <= query.To)) ); if (exportType == ExportType.Iris) { var overseas = EnumEditor.GetEnumDescription(State.Overseas); filteredSendings = filteredSendings.Where(s => !s.Patient.County.Equals(overseas)); var nonHaemophilus = new List <Evaluation> { Evaluation.HaemophilusParainfluenzae, Evaluation.NoGrowth, Evaluation.NoHaemophilusSpecies, Evaluation.HaemophilusSpeciesNoHaemophilusInfluenzae, Evaluation.NoHaemophilusInfluenzae }; filteredSendings = filteredSendings.Where(s => !nonHaemophilus.Contains(s.Isolate.Evaluation)); } return(filteredSendings.OrderBy(s => s.Isolate.StemNumber).ToList()); }
protected override void CreateToolbarExtensions() { base.CreateToolbarExtensions(); CustomerFilter = AddEqualityFilter <CustomerEditor>(Fields.CustomerID); AddDateRangeFilter(Fields.OrderDate); shippingState = AddEqualityFilter <EnumEditor>(Fields.ShippingState, options: new EnumEditorOptions { EnumKey = "Northwind.OrderShippingState" }); AddEqualityFilter <LookupEditor>(Fields.ShipVia, options: new LookupEditorOptions { LookupKey = ShipperRow.LookupKey }); AddEqualityFilter <LookupEditor>(Fields.ShipCountry, options: new LookupEditorOptions { LookupKey = "Northwind.OrderShipCountry" }); AddEqualityFilter <LookupEditor>(Fields.ShipCity, options: new LookupEditorOptions { LookupKey = "Northwind.OrderShipCity", CascadeFrom = Fields.ShipCountry }); AddEqualityFilter <LookupEditor>(Fields.EmployeeID, options: new LookupEditorOptions { LookupKey = EmployeeRow.LookupKey }); }
protected static object ExportToStringIfEnum <T>(T value) { if (value != null && value.GetTypeOrNullableType().IsEnum) { return(EnumEditor.GetEnumDescription(value)); } return(value); }
private string ExportRiskFactors<T>(T clinicalInformation, Func<string> otherClinicalInformation, Func<T, bool> isOther) { var riskFactors = EnumEditor.GetEnumDescription(clinicalInformation); if (isOther(clinicalInformation)) { riskFactors = riskFactors.Replace( EnumEditor.GetEnumDescription(RiskFactors.Other), otherClinicalInformation()); } return riskFactors; }
protected string ExportClinicalInformation <T>(T clinicalInformation, Func <string> otherClinicalInformation, Func <T, bool> isOther) { var clinicalInformationAsString = EnumEditor.GetEnumDescription(clinicalInformation); if (isOther(clinicalInformation)) { clinicalInformationAsString = clinicalInformationAsString.Replace( EnumEditor.GetEnumDescription(ClinicalInformation.Other), otherClinicalInformation()); } return(clinicalInformationAsString); }
public override MeningoIsolateViewModel ModelToViewModel(MeningoIsolate isolate) { var isolateViewModel = Mapper.Map <MeningoIsolateViewModel>(isolate); var sending = isolate.Sending; isolateViewModel.Material = EnumEditor.GetEnumDescription(sending.Material); isolateViewModel.Invasive = EnumEditor.GetEnumDescription(sending.Invasive); if (isolateViewModel.NeisseriaPubMlstIsolate == null) { isolateViewModel.NeisseriaPubMlstIsolate = new NeisseriaPubMlstIsolate(); } return(isolateViewModel); }
public void Process(MeningoIsolate source, MeningoIsolateViewModel destination) { var sending = source.Sending; ParseAndMapLaboratoryNumber(source, destination); destination.SamplingLocation = sending.SamplingLocation == MeningoSamplingLocation.OtherInvasive ? sending.OtherInvasiveSamplingLocation : sending.SamplingLocation == MeningoSamplingLocation.OtherNonInvasive ? sending.OtherNonInvasiveSamplingLocation : EnumEditor.GetEnumDescription(sending.SamplingLocation); destination.Material = EnumEditor.GetEnumDescription(sending.Material); destination.Invasive = EnumEditor.GetEnumDescription(sending.Invasive); destination.PatientAgeAtSampling = source.PatientAgeAtSampling(); destination.EpsilometerTestViewModels = EpsilometerTestsModelToViewModel(source.EpsilometerTests); //Report fields destination.SamplingDate = source.Sending.SamplingDate.ToReportFormat(); destination.ReceivingDate = source.Sending.ReceivingDate.ToReportFormat(); destination.PatientId = source.Sending.Patient.PatientId; destination.Patient = source.Sending.Patient.ToReportFormat(); destination.PatientBirthDate = source.Sending.Patient.BirthDate.ToReportFormat(); destination.PatientPostalCode = source.Sending.Patient.PostalCode; destination.SenderLaboratoryNumber = source.Sending.SenderLaboratoryNumber; //destination.EvaluationString = source.Evaluation.ToReportFormat(); var isolateInterpretation = new MeningoIsolateInterpretation(); isolateInterpretation.Interpret(source); destination.Report = isolateInterpretation.Result.Report; destination.Typings = isolateInterpretation.Typings; destination.Comment = isolateInterpretation.Result.Comment; var sender = db.Senders.Find(source.Sending.SenderId); if (sender != null) // special case for Meningo as old senders were not imported { destination.SenderName = sender.Name; destination.SenderStreet = sender.StreetWithNumber; destination.SenderCity = $"{sender.PostalCode} {sender.City}"; } }
protected static string ExportToString <T>(T value) { if (value == null) { return(string.Empty); } var type = value.GetTypeOrNullableType(); if (type.IsEnum) { var enumDescription = EnumEditor.GetEnumDescription(value); if ((int)(object)value == 0 && enumDescription.Equals("0")) { return(null); } return(enumDescription); } return(value.ToString()); }
public static EpsilometerTestReportModel CreateFromViewModel( EpsilometerTestViewModel epsilometerTestViewModel) { var reportModel = new EpsilometerTestReportModel { Antibiotic = EnumEditor.GetEnumDescription(epsilometerTestViewModel.Antibiotic), Measurement = FloatToString(epsilometerTestViewModel.Measurement), Result = EnumEditor.GetEnumDescription(epsilometerTestViewModel.Result), MicBreakpointResistent = FloatToString(epsilometerTestViewModel.MicBreakpointResistent), MicBreakpointSusceptible = FloatToString(epsilometerTestViewModel.MicBreakpointSusceptible), ValidFromYear = epsilometerTestViewModel.ValidFromYear.ToString(), }; if (epsilometerTestViewModel.Result == EpsilometerTestResult.NotDetermined) { reportModel.MicBreakpointResistent = "---"; reportModel.MicBreakpointSusceptible = "---"; reportModel.ValidFromYear = "---"; } return(reportModel); }
public IAssetPropertyEditor CreateEditor(IAsset asset) { if (Property.PropertyType.IsEnum) { var enumEditor = new EnumEditor(); enumEditor.Initialize(asset, Property); return(enumEditor); } foreach (var type in ThundershockPlatform.GetAllTypes <IAssetPropertyEditor>()) { if (type.GetConstructor(Type.EmptyTypes) == null) { continue; } var attr = type.GetCustomAttributes(false).OfType <PropertyEditorAttribute>().FirstOrDefault(); if (attr == null) { continue; } if (attr.Type == this.Property.PropertyType) { var e = (IAssetPropertyEditor)Activator.CreateInstance(type, null); e.Initialize(asset, this.Property); return(e); } } var bad = new BadPropertyEditor(); bad.Initialize(asset, this.Property); return(bad); }
//protected void AddPorAAndFetAFields(ExportDefinition<MeningoSending> export, string porAVr1Header = null, string evaluationHeaderParameter = null) //{ // export.AddField(s => ExportToString(s.Isolate.PorAVr1)); // AddField(s => s.GetIsolate().FetAVr == ExportToString(s.Isolate.PorAVr2)); // AddField(s => ExportToString(s.Isolate.FetAVr)); // var antibioticName = ExportToString(antibiotic); // var measurementHeader = measurementHeaderParameter ?? string.Format("{0} MHK", antibioticName); // var evaluationHeader = evaluationHeaderParameter ?? string.Format("{0} Bewertung", antibioticName); // export.AddField(s => FindEpsilometerTestMeasurement(s, antibiotic), measurementHeader); // if(!skipEvaluation) export.AddField(s => ExportToString(FindEpsilometerTestEvaluation(s, antibiotic)), evaluationHeader); //} protected static string ExportGender(Gender?gender) { return(gender == null ? "?" : EnumEditor.GetEnumDescription(gender).Substring(0, 1)); }
private async Task <DependencyObject> GetEditorForType(object originalObject, object value, Type memberType, string propertyPath, string memberName, Type declaringTypeToIgnore) { DependencyObject result = null; if (memberType.IsEnum) { var editor = new EnumEditor { EnumType = memberType, PropertyName = propertyPath, Title = memberName, Value = value }; editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <object> >(e => this.UpdateProperty(e.PropertyName, value, e.Value, originalObject, editor), true); result = editor; } else if (memberType == typeof(string)) { var editor = new StringEditor { PropertyName = propertyPath, Title = memberName, Value = (string)value }; editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <string> >(e => this.UpdateProperty(e.PropertyName, (string)value, e.Value, originalObject, editor), true); result = editor; } else if (memberType == typeof(int)) { var editor = new IntEditor { PropertyName = propertyPath, Title = memberName, Value = (int)value }; editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <int> >(e => this.UpdateProperty(e.PropertyName, (int)value, e.Value, originalObject, editor), true); result = editor; } else if (memberType == typeof(float)) { var editor = new FloatEditor { PropertyName = propertyPath, Title = memberName, Value = (float)value }; editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <float> >(e => this.UpdateProperty(e.PropertyName, (float)value, e.Value, originalObject, editor), true); result = editor; } else if (memberType == typeof(bool)) { var editor = new BoolEditor { PropertyName = propertyPath, Title = memberName, Value = (bool)value }; editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <bool> >(e => this.UpdateProperty(e.PropertyName, (bool)value, e.Value, originalObject, editor), true); result = editor; } else if (memberType == typeof(Vector2)) { var editor = new VectorEditor { PropertyName = propertyPath, Title = memberName, Value = (Vector2)value }; editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <Vector2> >(e => this.UpdateProperty(e.PropertyName, (Vector2)value, e.Value, originalObject, editor), true); result = editor; } else if (memberType == typeof(Microsoft.Xna.Framework.Point)) { var editor = new PointEditor { PropertyName = propertyPath, Title = memberName, Value = (Microsoft.Xna.Framework.Point)value }; editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <Microsoft.Xna.Framework.Point> >(e => this.UpdateProperty(e.PropertyName, (Microsoft.Xna.Framework.Point)value, e.Value, originalObject, editor), true); result = editor; } else if (memberType == typeof(Microsoft.Xna.Framework.Color)) { var editor = new ColorEditor { PropertyName = propertyPath, Title = memberName, Value = (Microsoft.Xna.Framework.Color)value }; editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <Microsoft.Xna.Framework.Color> >(e => this.UpdateProperty(e.PropertyName, (Microsoft.Xna.Framework.Color)value, e.Value, originalObject, editor), true); result = editor; } else if (memberType == typeof(Sprite)) { var editor = new SpriteEditor { PropertyName = propertyPath, Title = memberName, Value = value as Sprite }; if (value is Sprite sprite) { var spriteWrappers = this._projectService.CurrentProject.AssetFolder.GetAssetsOfType <SpriteWrapper>(); editor.SpriteWrapper = spriteWrappers.FirstOrDefault(x => x.Sprite.Id == sprite.Id); } editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <Sprite> >(e => this.UpdateProperty(e.PropertyName, value as Sprite, e.Value, originalObject, editor), true); editor.SelectSpriteCommand = new RelayCommand(() => { var asset = this._dialogService.ShowSelectAssetDialog(this._projectService.CurrentProject, AssetType.Image | AssetType.Sprite, AssetType.Sprite); if (asset is SpriteWrapper spriteWrapper) { editor.SpriteWrapper = spriteWrapper; } }, true); result = editor; } else if (memberType == typeof(AudioClip)) { var editor = new AudioClipEditor { PropertyName = propertyPath, Title = memberName, Value = value as AudioClip }; editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <AudioClip> >(e => this.UpdateProperty(e.PropertyName, value as AudioClip, e.Value, originalObject, editor), true); editor.SelectAudioClipCommand = new RelayCommand(() => { var asset = this._dialogService.ShowSelectAssetDialog(this._projectService.CurrentProject, AssetType.Audio, AssetType.Audio); if (asset is AudioAsset audioAsset) { editor.Value = audioAsset.AudioClip; } }, true); result = editor; } else if (memberType == typeof(SpriteAnimation)) { var editor = new SpriteAnimationEditor { PropertyName = propertyPath, Title = memberName, Value = value as SpriteAnimation }; if (value is SpriteAnimation animation) { var spriteAnimationAssets = this._projectService.CurrentProject.AssetFolder.GetAssetsOfType <SpriteAnimationAsset>(); editor.Asset = spriteAnimationAssets.FirstOrDefault(x => x.SavableValue.Id == animation.Id); } editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <SpriteAnimation> >(e => this.UpdateProperty(e.PropertyName, value as SpriteAnimation, e.Value, originalObject, editor), true); editor.SelectSpriteAnimationCommand = new RelayCommand(() => { var asset = this._dialogService.ShowSelectAssetDialog(this._projectService.CurrentProject, AssetType.SpriteAnimation, AssetType.SpriteAnimation); if (asset is SpriteAnimationAsset spriteAnimationAsset) { editor.Asset = spriteAnimationAsset; editor.Value = spriteAnimationAsset.SavableValue; } }, true); result = editor; } else if (memberType == typeof(Font)) { var editor = new FontEditor { PropertyName = propertyPath, Title = memberName, Value = value as Font }; if (value is Font font) { var fontAssets = this._projectService.CurrentProject.AssetFolder.GetAssetsOfType <FontAsset>(); editor.Asset = fontAssets.FirstOrDefault(x => x.SavableValue.Id == font.Id); } editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <Font> >(e => this.UpdateProperty(e.PropertyName, value as Font, e.Value, originalObject, editor), true); editor.SelectFontCommand = new RelayCommand(() => { var asset = this._dialogService.ShowSelectAssetDialog(this._projectService.CurrentProject, AssetType.Font, AssetType.Font); if (asset is FontAsset fontAsset) { editor.Asset = fontAsset; editor.Value = fontAsset.SavableValue; } }, true); result = editor; } else if (memberType == typeof(Collider)) { var colliderTypes = await this._assemblyService.LoadTypes(typeof(Collider)); colliderTypes.Remove(typeof(PolygonCollider)); // TODO: Eventually allow PolygonCollider. var editor = new ColliderEditor { ColliderTypes = colliderTypes, PropertyName = propertyPath, Title = memberName, Value = (Collider)value }; editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <Collider> >(e => this.UpdateProperty(e.PropertyName, (Collider)value, e.Value, originalObject, editor), true); result = editor; } else if (memberType == typeof(LineCollider)) { var colliderTypes = await this._assemblyService.LoadTypes(typeof(Collider)); var editor = new LineColliderEditor { PropertyName = propertyPath, Title = memberName, Value = (LineCollider)value }; editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <LineCollider> >(e => this.UpdateProperty(e.PropertyName, (LineCollider)value, e.Value, originalObject, editor), true); result = editor; } else if (memberType == typeof(RectangleCollider)) { var colliderTypes = await this._assemblyService.LoadTypes(typeof(Collider)); var editor = new RectangleColliderEditor { PropertyName = propertyPath, Title = memberName, Value = (RectangleCollider)value }; editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <RectangleCollider> >(e => this.UpdateProperty(e.PropertyName, (RectangleCollider)value, e.Value, originalObject, editor), true); result = editor; } else if (memberType.IsSubclassOf(typeof(BaseComponent))) { // TODO: Allow user to select a component. } else { // TODO: I don't know, this should probably work when value is null if (value != null) { var editor = new GenericValueEditor { DeclaringType = declaringTypeToIgnore, PropertyName = propertyPath, Title = memberName, Value = value }; editor.ValueChangedCommand = new RelayCommand <EditableValueChangedEventArgs <object> >(e => this.UpdateProperty(e.PropertyName, value, e.Value, originalObject, editor), true); result = editor; } } return(result); }
public override void OnInspectorGUI() { // base.OnInspectorGUI(); m_Target.Update(); GUILayout.Space(10f); var style = new GUIStyle(GUI.skin.button); GUI.backgroundColor = new Color(0.3f, 0.8f, 0.3f); if (GUILayout.Button("ADD SOUND")) { if (m_Source.m_Datas == null) { m_Source.m_Datas = new List <AudioDataField>(); } //m_Source.m_Datas.Clear(); EditorGUI.BeginChangeCheck(); m_Source.m_Datas.Add(new AudioDataField()); m_Target.ApplyModifiedProperties(); } GUI.backgroundColor = Color.white; GUILayout.Space(25f); if (m_Source.m_Datas != null && m_Source.m_Datas.Count > 0) { for (int i = 0; i < m_DatasProp.arraySize; ++i) { EditorGUI.BeginChangeCheck(); SerializedProperty currentFieldProp = m_DatasProp.GetArrayElementAtIndex(i); SerializedProperty enumFieldNameRef = currentFieldProp.FindPropertyRelative("m_EnumFieldName"); SerializedProperty audioEventRef = currentFieldProp.FindPropertyRelative("m_AudioEvent"); EditorGUILayout.LabelField(enumFieldNameRef.stringValue, EditorStyles.boldLabel); AudioDataField curField = m_Source.m_Datas[i]; enumFieldNameRef.stringValue = EditorGUILayout.TextField("Sound name :", enumFieldNameRef.stringValue); EditorGUILayout.PropertyField(audioEventRef); GUI.backgroundColor = new Color(0.9f, 0.4f, 0.4f); GUI.contentColor = Color.white; if (GUILayout.Button("REMOVE")) { m_DatasProp.DeleteArrayElementAtIndex(i); m_Target.ApplyModifiedProperties(); } GUI.backgroundColor = Color.white; m_Target.ApplyModifiedProperties(); GUILayout.Space(10f); } } GUILayout.Space(25f); if (GUILayout.Button("SAVE")) { List <string> enumValues = new List <string>(); foreach (var field in m_Source.m_Datas) { enumValues.Add(field.m_EnumFieldName); } EnumEditor.WriteToEnum(m_FilePath, m_FileName, enumValues); //GUI.contentColor = Color.green; //EditorGUILayout.HelpBox("File " + m_FileName + ".cs created at " + m_FilePath, MessageType.Info); } GUI.contentColor = Color.red; EditorGUILayout.HelpBox("Don't forget to save when you modify the database!", MessageType.Info); m_Target.ApplyModifiedProperties(); }
public static string ToReportFormat(this Evaluation evaluation) { return(EvaluationHaemophilus.Contains(evaluation) ? "Haemophilus influenzae" : EnumEditor.GetEnumDescription(evaluation)); }
private PropertyItem CreatePropertyItem(PropertyDescriptor property, object instance, PropertyGrid grid) { PropertyItem propertyItem = new PropertyItem(instance, property, grid); var binding = new Binding(property.Name) { Source = instance, ValidatesOnExceptions = true, ValidatesOnDataErrors = true, Mode = propertyItem.IsWriteable ? BindingMode.TwoWay : BindingMode.OneWay }; if (instance is ICustomTypeDescriptor) { binding.Source = (instance as ICustomTypeDescriptor).GetPropertyOwner(property); } propertyItem.SetBinding(PropertyItem.ValueProperty, binding); ITypeEditor editor = null; foreach (Attribute attr in propertyItem.PropertyDescriptor.Attributes) { if (attr is EditorAttribute) { editor = Activator.CreateInstance(Type.GetType((attr as EditorAttribute).EditorTypeName)) as ITypeEditor; if (editor != null) { editor.Attach(propertyItem); propertyItem.Editor = editor.ResolveEditor(); if (property is CustomizePropertyDescriptor) { propertyItem.Editor.IsEnabled = (property as CustomizePropertyDescriptor).IsEnabled; } return(propertyItem); } } } //check for custom editor if (CustomTypeEditors.Count > 0) { //first check if the custom editor is type based ICustomTypeEditor customEditor = CustomTypeEditors[propertyItem.PropertyType]; if (customEditor == null) { //must be property based customEditor = CustomTypeEditors[propertyItem.Name]; } if (customEditor != null) { editor = customEditor.Editor; } } try { //no custom editor found if (editor == null) { if (propertyItem.IsReadOnly) { editor = new TextBlockEditor(); } else if (propertyItem.PropertyType == typeof(bool) || propertyItem.PropertyType == typeof(bool?)) { editor = new CheckBoxEditor(); } else if (propertyItem.PropertyType == typeof(decimal) || propertyItem.PropertyType == typeof(decimal?)) { editor = new DecimalUpDownEditor(); } else if (propertyItem.PropertyType == typeof(double) || propertyItem.PropertyType == typeof(double?)) { editor = new DoubleUpDownEditor(); } else if (propertyItem.PropertyType == typeof(int) || propertyItem.PropertyType == typeof(int?)) { editor = new IntegerUpDownEditor(); } else if (propertyItem.PropertyType == typeof(DateTime) || propertyItem.PropertyType == typeof(DateTime?)) { editor = new DateTimeUpDownEditor(); } else if ((propertyItem.PropertyType == typeof(Color))) { editor = new ColorEditor(); } else if (propertyItem.PropertyType.IsEnum) { editor = new EnumEditor(); } else if (propertyItem.PropertyType == typeof(FontFamily) || propertyItem.PropertyType == typeof(FontWeight) || propertyItem.PropertyType == typeof(FontStyle) || propertyItem.PropertyType == typeof(FontStretch)) { editor = new FontComboBoxEditor(); } else if (propertyItem.PropertyType.IsGenericType) { if (propertyItem.PropertyType.GetInterface("IList") != null) { var t = propertyItem.PropertyType.GetGenericArguments()[0]; if (!t.IsPrimitive && !t.Equals(typeof(String))) { editor = new Microsoft.Windows.Controls.PropertyGrid.Editors.CollectionEditor(); } else { editor = new Microsoft.Windows.Controls.PropertyGrid.Editors.PrimitiveTypeCollectionEditor(); } } else { editor = new TextBlockEditor(); } } else { editor = new TextBoxEditor(); } } } catch (Exception ex) { //TODO: handle this some how } editor.Attach(propertyItem); propertyItem.Editor = editor.ResolveEditor(); if (property is CustomizePropertyDescriptor) { propertyItem.Editor.IsEnabled = (property as CustomizePropertyDescriptor).IsEnabled; } return(propertyItem); }
private static string CreateReportGeneratedIcon(ReportStatus reportStatus) { var color = "#CC0000"; var icon = "glyphicon-remove-sign"; if (reportStatus == ReportStatus.Preliminary) { color = "#FFCC00"; icon = "glyphicon-time"; } else if (reportStatus == ReportStatus.Final) { color = "#00CC00"; icon = "glyphicon-ok-sign"; } return($"<span style=\"color:{color}\" class=\"glyphicon {icon}\" aria-hidden=\"true\" title=\"{EnumEditor.GetEnumDescription(reportStatus)}\"></span>"); }
public InterpretationResult Interpret(IsolateBase isolate) { var serotypePcr = isolate.SerotypePcr; var serotypePcrDescription = EnumEditor.GetEnumDescription(serotypePcr); var agglutination = isolate.Agglutination; var agglutinationDescription = EnumEditor.GetEnumDescription(agglutination); var bexA = isolate.BexA; var growth = isolate.Growth; var interpretation = "Diskrepante Ergebnisse, bitte Datenbankeinträge kontrollieren."; var interpretationPreliminary = "Diskrepante Ergebnisse, bitte Datenbankeinträge kontrollieren."; var interpretationDisclaimer = string.Empty; if (agglutination == SerotypeAgg.Negative) { if (bexA == TestResult.Negative) { if (serotypePcr == SerotypePcr.Negative || serotypePcr == SerotypePcr.NotDetermined) { interpretation = TypingNotPossiblePlural; } else if (serotypePcr != SerotypePcr.NotDetermined) { interpretation = $"{TypingNotPossiblePlural2} Ein vorhandener genetischer Kapsellocus für Polysaccharide des Serotyps {serotypePcrDescription} wird nicht exprimiert."; } } else if (bexA == TestResult.NotDetermined && serotypePcr == SerotypePcr.NotDetermined) { interpretationPreliminary = TypingNotPossibleSingular; interpretation = $"{TypingNotPossibleSingular} Eine molekularbiologische Typisierung wurde aus epidemiologischen und Kostengründen nicht durchgeführt."; } interpretationDisclaimer = string.Format(DisclaimerTemplate, "Haemophilus influenzae, unbekapselt"); } if (SpecificAgglutination.Contains(agglutination) && (bexA == TestResult.Positive || bexA == TestResult.NotDetermined) && (agglutination.ToString() == serotypePcr.ToString() || serotypePcr == SerotypePcr.NotDetermined)) { if (serotypePcr == SerotypePcr.NotDetermined && bexA == TestResult.NotDetermined) { interpretationPreliminary = $"Das Ergebnis spricht für eine Infektion mit Haemophilus influenzae des Serotyp {agglutinationDescription} (Hi{agglutinationDescription})."; } if (bexA == TestResult.Positive) { interpretation = $"Die Ergebnisse sprechen für eine Infektion mit Haemophilus influenzae des Serotyp {agglutinationDescription} (Hi{agglutinationDescription})."; } interpretationDisclaimer = string.Format(DisclaimerTemplate, $"Haemophilus influenzae, Serotyp {agglutinationDescription}"); } if (agglutination == SerotypeAgg.NotDetermined && serotypePcr == SerotypePcr.NotDetermined && bexA == TestResult.NotDetermined && growth != YesNoOptional.NotStated) { if (growth == YesNoOptional.Yes) { interpretation = "Der eingesendete Stamm konnte nicht angezüchtet werden. Um Wiedereinsendung wird gebeten."; interpretationDisclaimer = "Eine telefonische Vorabmitteilung ist erfolgt."; } else if (growth == YesNoOptional.No) { var evaluation = EnumEditor.GetEnumDescription(isolate.Evaluation); interpretation = "Kein Nachweis von Haemophilus influenzae."; interpretationDisclaimer = $"Beim eingesendeten Isolat handelt es sich am ehesten um {evaluation}."; } } return new InterpretationResult { Interpretation = interpretation, InterpretationPreliminary = interpretationPreliminary, InterpretationDisclaimer = interpretationDisclaimer }; }
public GraphNode(IFilter filter) { InitializeComponent(); _filter = filter; _filter.OnPinsChanged += OnPinsChanged; _filter.OnProcessingProgressChanged += OnProcessingProgressChanged; _filter.OnProcessingStateChanged += OnProcessingStateChanged; UpdateSize(_filter); var table = new TableLayoutPanel { Size = new Size(Width - 2, _filter.Properties.Count * PropertyHeight), Location = new Point(1, HeaderHeight + 2) }; table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); for (int i = 0; i < _filter.Properties.Count; i++) { IFilterProperty property = _filter.Properties.Skip(i).First().Value; BasePropertyEditor editor; switch (property.Type) { case FilterPropertyType.String: editor = new PathEditor { Value = property.Value }; break; case FilterPropertyType.Float: case FilterPropertyType.Integer: editor = new NumericEditor((INumericProperty)property) { Value = Convert.ToDecimal(property.Value) }; break; case FilterPropertyType.Size: case FilterPropertyType.Point: editor = new PointEditor((IPointProperty)property) { Value = property.Value }; break; case FilterPropertyType.Enum: editor = new EnumEditor((IEnumProperty)property) { Value = property.Value }; break; default: throw new ArgumentOutOfRangeException(); } editor.Dock = DockStyle.Fill; editor.Margin = new Padding(0); editor.OnValueChanged += newValue => { property.Value = newValue; }; table.RowStyles.Add(new RowStyle(SizeType.AutoSize)); table.SetRow(editor, i); table.SetColumn(editor, 1); var label = new Label { Text = property.Name, Margin = new Padding(0), Dock = DockStyle.Right, AutoSize = true, Anchor = AnchorStyles.Right }; table.SetRow(label, i); table.SetColumn(label, 0); table.Controls.Add(label); table.Controls.Add(editor); } Controls.Add(table); }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { string Property = e.Link.LinkData as string; PropertyInfo info = action.GetType().GetProperty(Property); if (info == null) { MessageBox.Show("Property " + Property + " Does not exist for " + action.GetType().Name); return; } DialogResult result = DialogResult.Cancel; string valueResult = ""; if (info.PropertyType == typeof(NumberValue)) { VariableEditor editor = new VariableEditor(); if (Variables != null) { editor.SetVariable(Variables.Select(x => x.Name)); } else { editor.SetVariable(new string[] { }); } NumberValue val = info.GetMethod.Invoke(action, new object[] { }) as NumberValue; editor.SetDefault(val == null ? "" : val.ToString()); editor.Text = "Variable Editor - " + Property; result = editor.ShowDialog(); if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { new NumberValue(valueResult) }); } } if (info.PropertyType == typeof(TargetKey)) { TargetKeyEditor editor = new TargetKeyEditor(); editor.SetPresets(ActionContext); editor.VariableList = Variables; TargetKey t = info.GetMethod.Invoke(action, new object[] { }) as TargetKey; if (t == null) { t = new TargetKey(); } editor.Target = t; result = editor.ShowDialog(); if (result == DialogResult.OK) { TargetKey target = editor.Target; info.SetMethod.Invoke(action, new object[] { target }); } } //It's an Enum! if (typeof(Enum).IsAssignableFrom(info.PropertyType)) { Enum enumValue = info.GetMethod.Invoke(action, new object[] { }) as Enum; //Find out if it's a flag and open the flag editor if (info.PropertyType.GetCustomAttribute <FlagsAttribute>() != null) { FlagCheckBoxEditor editor = new FlagCheckBoxEditor(); editor.EnumValue = enumValue; result = editor.ShowDialog(); enumValue = editor.EnumValue; } else { EnumEditor editor = new EnumEditor(); editor.EnumValue = enumValue; result = editor.ShowDialog(); enumValue = editor.EnumValue; } if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { enumValue }); valueResult = enumValue.ToString(); } } if (typeof(bool) == info.PropertyType) { bool val = (bool)info.GetMethod.Invoke(action, new object[] { }); BoolEditor editor = new BoolEditor(); editor.Value = val; result = editor.ShowDialog(); if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { editor.Value }); } } if (typeof(string) == info.PropertyType) { string val = (string)info.GetMethod.Invoke(action, new object[] { }); TextPrompt editor = new TextPrompt(); editor.Text = Property; editor.PromptText = val; result = editor.ShowDialog(); if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { editor.PromptText }); } } if (typeof(ActionCollection) == info.PropertyType) { ActionCollection actions = info.GetMethod.Invoke(action, new object[] { }) as ActionCollection; ActionListEditor editor = new ActionListEditor(); if (actions == null) { actions = new ActionCollection(Property); } editor.ActionContext = ActionContext; editor.Variables = Variables; editor.Actions = actions; result = editor.ShowDialog(); if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { editor.Actions }); } } if (result == DialogResult.OK) { UpdateLinkTexts(); } if (LinkClicked != null) { LinkClicked.Invoke(this, new LinkClickedEventArgs(e.Link.LinkData as string)); } }