private void ItemList_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "BarcodeSymbology") { PrintBarcode_Base _base = (PrintBarcode_Base)sender; if (_base.BarcodeSymbology == ZintNet.Symbology.DataMatrix) { _base = new PrintBarcode_DataMatric(_base); } else if (_base.BarcodeSymbology == ZintNet.Symbology.QRCode) { _base = new PrintBarcode_QRCode(_base); } else { _base = new PrintBarcode_Base(_base); } PrintObject_List[PrintObject_List.IndexOf((PrintObject_Base)sender)] = _base; } _children.Clear(); _children.Add(CreateObjectDrawingVisual(PrintObject_List)); if (_children.Contains(DashRect)) { _children.Remove(DashRect); } }
private void ButtonNewCode_Click(object sender, RoutedEventArgs e) { PrintBarcode_Base barcode_Base = new PrintBarcode_Base() { BarcodeSymbology = ZintNet.Symbology.Code128, Width = 1f, Height = 5f, Data = "ABCDEFG", Location = new Point(10, 10) }; Labels.PrintObject_List.Add(barcode_Base); }
public PrintBarcode_QRCode(PrintBarcode_Base printBarcode_Base) { var sourceProps = typeof(PrintBarcode_Base).GetProperties().Where(x => x.CanRead).ToList(); var destProps = typeof(PrintBarcode_DataMatric).GetProperties() .Where(x => x.CanWrite) .ToList(); foreach (var sourceProp in sourceProps) { if (destProps.Any(x => x.Name == sourceProp.Name)) { var p = destProps.First(x => x.Name == sourceProp.Name); if (p.CanWrite) { // check if the property can be set or no. p.SetValue(this, sourceProp.GetValue(printBarcode_Base, null), null); } } } }