public object createCompleteDatePickerWithClass(clsDatePicker clsDp) { Grid datePickerGrid = (Grid)createGrid(); datePickerGrid.Name = "DatePicker"; datePickerClass = clsDp; datePickerGrid.DataContext = datePickerClass; datePickerGrid.Children.Add((DatePicker)createDatePicker()); object senddatePickerGridAsObject = (object)datePickerGrid; return(senddatePickerGridAsObject); }
public object createCompleteDatePicker(string dicEntryKey, int inputId) { Grid datePickerGrid = (Grid)createGrid(); datePickerGrid.Name = "DatePicker"; datePickerClass = new clsDatePicker(); datePickerClass["propId"] = Guid.NewGuid(); datePickerClass["propName"] = inputId.ToString(); //textBoxClass["propName"] = dicEntryKey; datePickerGrid.DataContext = datePickerClass; datePickerGrid.Children.Add((DatePicker)createDatePicker()); object senddatePickerGridAsObject = (object)datePickerGrid; return(senddatePickerGridAsObject); }
public void loadDesignedTemplate(clsListViewDesignBackground lv) { XDocument xmlDocument = XDocument.Load(designXmlFilePath); IEnumerable <XElement> designRoot = xmlDocument.Descendants("Design") .Where(mi => mi.Attribute("id").Value == templateId) .Elements(); foreach (XElement control in designRoot) { if (control.Name == "Background") { lv["propBackground"] = (SolidColorBrush)(new BrushConverter().ConvertFrom(control.Value)); } else { string id = control.Attribute("id").Value; string type = control.Attribute("type").Value; switch (type) { case "ComboBox": XElement cboxRoot = xmlDocument.Descendants(type + "es").FirstOrDefault(); XElement cboxDetails = cboxRoot.Descendants(type).Where(mi => mi.Attribute("id").Value == id).FirstOrDefault(); comboboxClass = new clsComboBox(); comboboxClass["propId"] = new Guid(id); comboboxClass["propName"] = cboxDetails.Element("Name").Value; comboboxClass["propInputType"] = cboxDetails.Element("DataType").Value; comboboxClass["propMargin"] = cboxDetails.Element("Margin").Value == "NaN" ? convertToDoubleFromNaN(cboxDetails.Element("Margin").Value) : convertToDouble(cboxDetails.Element("Margin").Value); comboboxClass["propHeight"] = cboxDetails.Element("Height").Value == "NaN" ? convertToDoubleFromNaN(cboxDetails.Element("Height").Value) : convertToDouble(cboxDetails.Element("Height").Value); Grid comboboxGrid = (Grid)controlCreator.createCompleteComboboxWithClass(cboxDetails.Element("ComboboxItem").Value.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList(), comboboxClass); objectClass = new clsObject(); objectClass["controlObject"] = comboboxGrid; objectCollection.addObject(objectClass); break; case "TextBox": XElement tboxRoot = xmlDocument.Descendants(type + "es").FirstOrDefault(); XElement tboxDetails = tboxRoot.Descendants(type).Where(mi => mi.Attribute("id").Value == id).FirstOrDefault(); textBoxClass = new clsTextBox(); textBoxClass["propId"] = new Guid(id); textBoxClass["propName"] = tboxDetails.Element("Name").Value; textBoxClass["propContent"] = tboxDetails.Element("Content").Value; textBoxClass["propHeight"] = tboxDetails.Element("Height").Value == "NaN" ? convertToDoubleFromNaN(tboxDetails.Element("Height").Value) : convertToDouble(tboxDetails.Element("Height").Value); textBoxClass["propMargin"] = tboxDetails.Element("Margin").Value == "NaN" ? convertToDoubleFromNaN(tboxDetails.Element("Margin").Value) : convertToDouble(tboxDetails.Element("Margin").Value); textBoxClass["propWidth"] = tboxDetails.Element("Width").Value == "NaN" ? convertToDoubleFromNaN(tboxDetails.Element("Width").Value) : convertToDouble(tboxDetails.Element("Width").Value); textBoxClass["propAlignment"] = tboxDetails.Element("HorizontalAlignment").Value; textBoxClass["propInputDataType"] = tboxDetails.Element("DataType").Value; Grid textBoxGrid = (Grid)controlCreator.createCompleteTextBoxWithClass(textBoxClass); objectClass = new clsObject(); objectClass["controlObject"] = textBoxGrid; objectCollection.addObject(objectClass); break; case "TextBlock": XElement tblockRoot = xmlDocument.Descendants(type + "s").FirstOrDefault(); XElement tblockDetails = tblockRoot.Descendants(type).Where(mi => mi.Attribute("id").Value == id).FirstOrDefault(); textBlockClass = new clsTextblock(); textBlockClass["propId"] = new Guid(id); textBlockClass["propContent"] = tblockDetails.Element("Text").Value; textBlockClass["propAlignment"] = tblockDetails.Element("HorizontalAlignment").Value; textBlockClass["propFontFamily"] = tblockDetails.Element("FontFamily").Value; textBlockClass["propFontSize"] = double.Parse(tblockDetails.Element("FontSize").Value); textBlockClass["propForeground"] = (SolidColorBrush)(new BrushConverter().ConvertFrom(tblockDetails.Element("Foreground").Value)); textBlockClass["propMargin"] = tblockDetails.Element("Margin").Value == "NaN" ? convertToDoubleFromNaN(tblockDetails.Element("Margin").Value) : convertToDouble(tblockDetails.Element("Margin").Value);; Grid textBlockGrid = (Grid)controlCreator.createCompleteTextblockWithClass(textBlockClass); objectClass = new clsObject(); objectClass["controlObject"] = textBlockGrid; objectCollection.addObject(objectClass); break; case "Button": XElement buttonRoot = xmlDocument.Descendants(type + "s").FirstOrDefault(); XElement buttonDetails = buttonRoot.Descendants(type).Where(mi => mi.Attribute("id").Value == id).FirstOrDefault(); buttonClass = new clsButton(); buttonActionClass = new clsButtonAction(); buttonClass["propId"] = new Guid(id); buttonClass["propContent"] = buttonDetails.Element("Content").Value; buttonClass["propBtnBackground"] = (SolidColorBrush)(new BrushConverter().ConvertFrom(buttonDetails.Element("Background").Value)); buttonClass["propForeground"] = (SolidColorBrush)(new BrushConverter().ConvertFrom(buttonDetails.Element("Foreground").Value)); buttonClass["propAlignment"] = buttonDetails.Element("HorizontalAlignment").Value; buttonClass["propFontFamily"] = buttonDetails.Element("FontFamily").Value; buttonClass["propHeight"] = buttonDetails.Element("Height").Value == "NaN" ? convertToDoubleFromNaN(buttonDetails.Element("Height").Value) : convertToDouble(buttonDetails.Element("Height").Value); buttonClass["propMargin"] = buttonDetails.Element("Margin").Value == "NaN" ? convertToDoubleFromNaN(buttonDetails.Element("Margin").Value) : convertToDouble(buttonDetails.Element("Margin").Value); buttonClass["propWidth"] = buttonDetails.Element("Width").Value == "NaN" ? convertToDoubleFromNaN(buttonDetails.Element("Width").Value) : convertToDouble(buttonDetails.Element("Width").Value);; buttonClass["propFontSize"] = double.Parse(buttonDetails.Element("FontSize").Value); //To do - open action class - assign the value Grid buttonGrid = (Grid)controlCreator.createCompleteButtonWithClass(buttonClass, buttonActionClass); objectClass = new clsObject(); objectClass["controlObject"] = buttonGrid; objectCollection.addObject(objectClass); break; case "DatePicker": XElement datePickerRoot = xmlDocument.Descendants(type + "s").FirstOrDefault(); XElement datePickerDetails = datePickerRoot.Descendants(type).Where(mi => mi.Attribute("id").Value == id).FirstOrDefault(); datePickerClass = new clsDatePicker(); datePickerClass["propId"] = new Guid(id); datePickerClass["propName"] = datePickerDetails.Element("Name").Value; datePickerClass["propInputType"] = datePickerDetails.Element("DataType").Value; datePickerClass["propHeight"] = datePickerDetails.Element("Height").Value == "NaN" ? convertToDoubleFromNaN(datePickerDetails.Element("Height").Value) : convertToDouble(datePickerDetails.Element("Height").Value); datePickerClass["propWidth"] = datePickerDetails.Element("Width").Value == "NaN" ? convertToDoubleFromNaN(datePickerDetails.Element("Width").Value) : convertToDouble(datePickerDetails.Element("Width").Value); Grid datePickerGrid = (Grid)controlCreator.createCompleteDatePickerWithClass(datePickerClass); objectClass = new clsObject(); objectClass["controlObject"] = datePickerGrid; objectCollection.addObject(objectClass); break; case "Image": XElement imageRoot = xmlDocument.Descendants(type + "s").FirstOrDefault(); XElement imageDetails = imageRoot.Descendants(type).Where(mi => mi.Attribute("id").Value == id).FirstOrDefault(); imageClass = new clsImage(); imageClass["propId"] = new Guid(id); imageClass["propMargin"] = imageDetails.Element("Margin").Value == "NaN" ? convertToDoubleFromNaN(imageDetails.Element("Margin").Value) : convertToDouble(imageDetails.Element("Margin").Value); imageClass["propImageHeight"] = imageDetails.Element("Height").Value == "NaN" ? convertToDoubleFromNaN(imageDetails.Element("Height").Value) : convertToDouble(imageDetails.Element("Height").Value); imageClass["propImageWidth"] = imageDetails.Element("Width").Value == "NaN" ? convertToDoubleFromNaN(imageDetails.Element("Width").Value) : convertToDouble(imageDetails.Element("Width").Value); imageClass["propAlignment"] = imageDetails.Element("HorizontalAlignment").Value; imageClass["propImageData"] = imageDetails.Element("ImageData").Value; imageClass["propImageLocation"] = imageDetails.Element("ImageLocation").Value; Grid imageGrid = (Grid)controlCreator.createCompleteImageWithClass(imageClass); objectClass = new clsObject(); objectClass["controlObject"] = imageGrid; objectCollection.addObject(objectClass); break; } } } }