void updateUIElement(FormItem item) { //String styleKey = item.ControlType + "Edited"; //Style style = (Style)App.resources[styleKey]; //if (style == null) // Debug.WriteLine("Der Style mit dem Key \"" + styleKey + "\" fehlt!"); //else // ((FrameworkElement)this.FindName(item.ID)).Style = style; }
public CheckBox giveMeACheckBox(FormItem item) { CheckBox checkBox = new CheckBox(); setDefaultValues(checkBox, item); checkBox.Content = item.Header; checkBox.Unchecked += FormPage.changeStateToEdited; checkBox.Checked += FormPage.changeStateToEdited; return(checkBox); }
public void handleTap(object sender, System.Windows.Input.GestureEventArgs e) { FrameworkElement element = (FrameworkElement)sender; FormItem item = order.getFormItem(element.Name); if (item == null) { Debug.WriteLine("UIElement ist keiner Instanz von FormItem zuweisbar!"); return; } if (item.ID == itemID) { itemID = ""; hideOpenPoint.Begin(); ((FrameworkElement)sender).LayoutUpdated -= updateOpenPoint; } if (sender.GetType() == typeof(TextBlock) && item.ControlType == FormItemType.TextBox.ToString()) { elementFactory.selectedTextBlock((TextBlock)sender, false); } if (item.State != FormItemState.Selected.ToString()) { if (sender.GetType() == typeof(TextBox)) { ((TextBox)sender).SelectAll(); ((TextBox)sender).Hold -= makeANote; } changeStateToSelected(sender, e); } if (sender.GetType() == typeof(OwnListPicker)) { ((OwnListPicker)sender).HandleTap(e); if (((OwnListPicker)sender).State == OwnListPickerState.IsOpen) { changeStateToSelected(sender, e); } else if (((OwnListPicker)sender).State == OwnListPickerState.IsClosed) { changeStateToEdited(sender, e); } } if (item.State == FormItemState.Selected.ToString() && sender.GetType() == typeof(ListPicker)) { changeStateToEdited(sender, e); } }
private void setDefaultValues(FrameworkElement element, FormItem item) { //guck nach, ob es die Informationen zu diesem Formularelement shcon gibt //Debug.WriteLine("Der Zustand des Items " + item.ID + " ist " + item.State); if (EnumerationMatcher.StringToFormItemState(item.State) != FormItemState.Edited) { bool found = false; foreach (OrderInformation info in FormPage.order.Information) { if (info.ID == item.ID || info.ID == (FormPage.formID + item.ID)) { Debug.WriteLine("Die Information zu " + item.ID + " ist bereits vorhanden: " + info.Information); item.Input = info.Information; found = true; } } if (found) { FormPage.order.setStateOfFormItem(item.ID, FormItemState.Edited); } } if ((Style)resources[item.ControlType + item.State] == null) { Debug.WriteLine("Style für " + item.ControlType + " im Zustand " + item.State + " fehlt!"); } else { element.Style = (Style)resources[item.ControlType + item.State]; } if (FormPage != null) { //element.GotFocus += FormPage.changeStateToSelected; element.LostFocus += FormPage.changeStateToEdited; if (element.GetType() == typeof(TextBox)) { element.LostFocus += FormPage.showApplicationBar; element.GotFocus += FormPage.hideApplicationBar; } element.Tap += FormPage.handleTap; element.Hold += FormPage.makeANote; } else { Debug.WriteLine("Page fehlt für EventHandler"); } element.Name = item.ID; }
public FormItem getFormItem(String id) { FormItem ItemExist = null; foreach (FormItem item in FormItemList) { if (item.ID == id) { ItemExist = item; break; } } return(ItemExist); }
public FormItem getFormItem(String id) { FormItem ItemExist = null; foreach (FormPage page in FormPageList) { ItemExist = page.getFormItem(id); if (ItemExist != null) { break; } } return(ItemExist); }
public FormItem getFormItem(String id) { FormItem ItemExist = null; foreach (Form form in FormList) { ItemExist = form.getFormItem(id); if (ItemExist != null) { break; } } return(ItemExist); }
public FormItem setStateOfFormItem(String id, FormItemState state) { FormItem ItemExist = null; foreach (FormPage page in FormPageList) { ItemExist = page.setStateOfFormItem(id, state); checkMyState(); if (ItemExist != null) { break; } } return(ItemExist); }
public FormItem setStateOfFormItem(String id, FormItemState state) { FormItem ItemExist = null; foreach (Form form in FormList) { ItemExist = form.setStateOfFormItem(id, state); if (ItemExist != null) { break; } } return(ItemExist); }
public FormItem setStateOfFormItem(String id, FormItemState state) { FormItem ItemExist = null; foreach (FormItem item in FormItemList) { if (item.ID == id) { ItemExist = item; item.State = state.ToString(); checkMyState(); break; } } return(ItemExist); }
public OwnListPicker giveMeAListPicker(FormItem item) { if (resources == null) { setResourceDictionary(); } OwnListPicker listPicker = new OwnListPicker(); setDefaultValues(listPicker, item); Style tbStyle = (Style)resources["ListBlank"]; List <TextBlock> tbList = new List <TextBlock>(); foreach (string s in item.ControlList) { TextBlock tb = new TextBlock(); tb.Text = s; if (tbStyle != null) { tb.Style = tbStyle; } if (item.Input != "" && item.Input == s) { listPicker.AddAsSelected(tb); } else { listPicker.Add(tb); } } if (tbStyle == null) { Debug.WriteLine("Fehler: Entweder gibt es keinen Style mehr für TextBlocks in ListPicker, oder er heißt nicht mehr \"List\"!"); } TextBlock header = new TextBlock(); header.Style = tbStyle; header.Text = item.Header; listPicker.SetHeader(header); return(listPicker); }
public FrameworkElement giveMeATextBoxOrTextBlock(FormItem item) { if (resources == null) { setResourceDictionary(); } TextBox textBox = new TextBox(); setDefaultValues(textBox, item); textBox.Text = item.Input; if (item.Input == "") { textBox.Text = item.Header; } textBox.KeyDown += FormPage.textChangedEvent; return(textBox); }
public void openPage(object sender, EventArgs e) { FrameworkElement element = (FrameworkElement)sender; if (element.Name == itemID) { itemID = ""; hideOpenPoint.Begin(); } FormItem item = order.setStateOfFormItem(element.Name, FormItemState.Edited); if (item == null) { Debug.WriteLine("UIElement ist keiner Instanz von FormItem zuweisbar!"); return; } NavigationService.Navigate(new Uri(string.Format("/" + item.Link + "?OrderID=" + order.OrderID + "&PageID=" + page.FormPageID), UriKind.Relative)); }
public Button giveMeAPhotoButton(FormItem item) { Button button = new Button(); Image image = new Image(); if (item.State == FormItemState.Blank.ToString()) { image.Source = App.formHandler.getPhotoFromIsolatedStorage(item.ID + "Template"); } else { image.Source = App.formHandler.getPhotoFromIsolatedStorage(FormPage.order.OrderID + FormPage.page.FormPageID + item.ID); FormPage.order.setStateOfFormItem(item.ID, FormItemState.Edited); } image.Name = item.ID; button.Content = image; button.Click += FormPage.makeAPhoto; setDefaultValues(button, item); return(button); }
public Button giveMeAPhoto(FormItem item) { Button button = new Button(); Image image = new Image(); Style style = (Style)resources["OverviewPhoto"]; if (style == null) { Debug.WriteLine("Fehler: Der Style \"OverviewPhoto\" fehlt!"); } else { button.Style = style; } image.Source = App.formHandler.getPhotoFromIsolatedStorage(SignPage.order.OrderID + SignPage.FormPage.FormPageID + item.ID); image.Name = item.ID; button.Content = image; //setDefaultValues(button, item); return(button); }
public void changeStateToSelected(object sender, EventArgs e) { FrameworkElement element = (FrameworkElement)sender; FormItem item = order.setStateOfFormItem(element.Name, FormItemState.Selected); if (item == null) { Debug.WriteLine("UIElement ist keiner Instanz von FormItem zuweisbar!"); return; } //String styleKey = item.ControlType + "Selected"; //if (sender.GetType() == typeof(TextBox)) ((TextBox)sender).SelectAll(); //if (sender.GetType() == typeof(ListPicker)) ((ListPicker)sender).Open(); //Style style = (Style)App.resources[styleKey]; //if (style == null) // Debug.WriteLine("Der Style mit dem Key \"" + styleKey + "\" fehlt!"); //else // element.Style = style; }
public void noteFinished(object sender, EventArgs e) { //this.Focus(); TextBox textBox = (TextBox)sender; FormItem item = order.getFormItem((String)textBox.Tag); if (item == null) { Debug.WriteLine("Konnte kein Item zu Notiz mit dem Tag " + (String)textBox.Tag + " finden."); return; } item.Note = textBox.Text; if (textBox.Text == "") { ((StackPanel)((FrameworkElement)this.FindName(item.ID)).Parent).Children.Remove(textBox); } else { elementFactory.editedTextBox(textBox, true); } }
public TextBlock giveMeASubheader(FormItem item) { if (resources == null) { setResourceDictionary(); } TextBlock textBlock = new TextBlock(); textBlock.Text = item.Header; Style style = (Style)resources["Fact"]; if (style == null) { Debug.WriteLine("Fehler: Der Style \"Fact\" fehlt!"); } else { textBlock.Style = style; } textBlock.Name = item.ID; return(textBlock); }
public TextBlock giveMeACheckedCheckBox(FormItem item) { if (resources == null) { setResourceDictionary(); } TextBlock textBlock = new TextBlock(); textBlock.Text = item.Input; Style style = (Style)resources["OverviewEdit"]; if (style == null) { Debug.WriteLine("Fehler: Der Style \"OverviewEdit\" fehlt!"); } else { textBlock.Style = style; } textBlock.Name = item.ID; return(textBlock); }
private void photoCompleted(object sender, PhotoResult e) { if (e.TaskResult == TaskResult.OK) { FormItem item = order.setStateOfFormItem(elementName, FormItemState.Edited); if (item == null) { Debug.WriteLine("UIElement ist keiner Instanz von FormItem zuweisbar!"); return; } if (App.formHandler.savePhotoToIsolatedStorage(e.ChosenPhoto, (order.OrderID + page.FormPageID + elementName) + ".jpg")) { Debug.WriteLine("Foto erfolgreich als " + (order.OrderID + page.FormPageID + elementName) + ".jpg gespeichert"); } else { order.setStateOfFormItem(elementName, FormItemState.Blank); } App.formHandler.saveData(order); } setUpPage(); lookUpState(); }
public override FrameworkElement getFrameworkElementFromItem(FormItem item, PhoneApplicationPage sender) { FormPage = (EditPage)sender; try { FormItemType type = EnumerationMatcher.StringToFormItemType(item.ControlType); switch (type) { case FormItemType.Subheader: return(giveMeATextBlock(item)); case FormItemType.TextBox: return(giveMeATextBoxOrTextBlock(item)); case FormItemType.ListPicker: return(giveMeAListPicker(item)); case FormItemType.Photo: return(giveMeAPhotoButton(item)); case FormItemType.CheckBox: return(giveMeACheckBox(item)); case FormItemType.PageLink: return(giveMeAPageLink(item)); case FormItemType.Listing: return(giveMeAList(item)); } return(null); } catch { return(null); } }
public override FrameworkElement getFrameworkElementFromItem(FormItem item, PhoneApplicationPage sender) { SignPage = (SignPages)sender; try { FormItemType type = EnumerationMatcher.StringToFormItemType(item.ControlType); switch (type) { case FormItemType.Header: return(giveMeAHeader(item)); case FormItemType.Subheader: return(giveMeASubheader(item)); case FormItemType.TextBox: return(giveMeATextBoxAsTextBlock(item)); case FormItemType.ListPicker: return(giveMeATextBoxAsTextBlock(item)); case FormItemType.Photo: return(giveMeAPhoto(item)); case FormItemType.CheckBox: return(giveMeACheckedCheckBox(item)); case FormItemType.Listing: return(giveMeASignableList(item)); } return(null); } catch { return(null); } }
public TextBlock giveMeATextBlock(FormItem item) { if (resources == null) { setResourceDictionary(); } TextBlock textBlock = new TextBlock(); textBlock.Text = item.Header; Style style = (Style)resources[item.ControlType]; if (style == null) { Debug.WriteLine("Fehler: Der Style für " + item.ControlType + " fehlt!"); } else { textBlock.Style = style; } FormPage.order.setStateOfFormItem(item.ID, FormItemState.Disabled); textBlock.Name = item.ID; return(textBlock); }
public virtual FrameworkElement getFrameworkElementFromItem(FormItem item, PhoneApplicationPage sender) { return(null); }
private void validateData(Order data) { if (data.OrderID == "") { Debug.WriteLine("Warnung---> ID des Auftrags fehlt!"); data.OrderID = "000000"; } else if (data.FormList.Count > 0) { Debug.WriteLine("In dem Auftrag (" + data.OrderID + ") ist ..."); } int i = 0; while (i < data.FormList.Count) { Form form = data.FormList[i]; if (form.FormID == "") { Debug.WriteLine("Warnung---> ID für das " + (i + 1) + ". Formular fehlt!"); data.FormList[i].FormID = "Form" + i; } else { Debug.WriteLine("... das Formular " + form.FormID + " enthalten"); } int j = 0; while (j < form.FormPageList.Count) { FormPage page = form.FormPageList[j]; if (page.FormPageID == "") { Debug.WriteLine("Warnung---> ID für die " + (j + 1) + ". Formularseite fehlt!"); data.FormList[i].FormPageList[j].FormPageID = "FormPage" + i + "_" + j; } else { Debug.WriteLine(" mit der Formularseite: " + page.FormPageID); } int k = 0; while (k < page.FormItemList.Count) { FormItem item = page.FormItemList[k]; if (item.ID == "") { Debug.WriteLine("Warnung---> ID für das " + (k + 1) + ". Formularelement fehlt!"); data.FormList[i].FormPageList[j].FormItemList[k].ID = "FormItem" + i + "_" + j + "_" + k; } else { Debug.WriteLine(" Formularelement: " + item.ID); } if (item.ControlType == "") { Debug.WriteLine("Warnung---> Typ für das " + (k + 1) + ". Formularelement fehlt!"); data.FormList[i].FormPageList[j].FormItemList[k].ControlType = defaultFormItemType; } k++; } j++; } i++; } }
public StackPanel giveMeAList(FormItem item) { StackPanel stackPanel = new StackPanel(); if (item.ID == "DamageList") { List <DamageEntry> list = new List <DamageEntry>(); list.AddRange(FormPage.order.DamageList); int canvasWidth = 333; int canvasHeight = 250; int pointSize = 10; if (list.Count == 0) { FormItem subheader = new FormItem(); subheader.Header = "keine Schäden"; subheader.ID = "NoDamageListSubheader"; subheader.ControlType = "Subheader"; stackPanel.Children.Add(giveMeATextBlock(subheader)); } else { while (list.Count > 0) { FormItem subheader = new FormItem(); String location = list[0].Location; subheader.Header = location; subheader.ID = location + "DamageListSubheader"; subheader.ControlType = "Subheader"; //stackPanel.Children.Add(UIElementControler.giveMeATextBlock(subheader)); List <DamageEntry> entryToThisLocation = new List <DamageEntry>(); Canvas canvas = new Canvas(); ImageBrush brush = new ImageBrush(); brush.ImageSource = new BitmapImage(new Uri("/CarScheme/" + location + ".png", UriKind.Relative)); brush.Stretch = Stretch.Uniform; canvas.Background = brush; canvas.Style = (Style)resources["DamageCanvas"]; Border border = new Border(); border.Style = (Style)resources["DamageBorder"]; int j = 0; while (j < list.Count) { if (list[j].Location == location) { Ellipse ellipse = new Ellipse(); ellipse.Style = (Style)resources["DamagePoint"]; ellipse.SetValue(Canvas.LeftProperty, (((double)list[j].RelativeLocationX * canvas.Width) - pointSize * 0.5)); ellipse.SetValue(Canvas.TopProperty, (((double)list[j].RelativeLocationY * canvas.Height) - pointSize * 0.5)); canvas.Children.Add(ellipse); list.RemoveAt(j); } else { j++; } } border.Child = canvas; //Button button = new Button(); //button.BorderThickness = new Thickness(0); //button.Content = border; //button.Tag = location; //button.Click += FormPage.navigateToDamageSite; border.Tag = location; border.Tap += FormPage.navigateToDamageSite; stackPanel.Children.Add(border); } } } FormPage.order.setStateOfFormItem(item.ID, FormItemState.Disabled); stackPanel.Name = item.ID; return(stackPanel); }
public void changeStateToEdited(object sender, EventArgs e) { Debug.WriteLine("Lost Focus"); if (sender.GetType() == typeof(TextBox)) { TextBox textBox = (TextBox)sender; FormItem item = order.getFormItem(textBox.Name); if (item == null) { Debug.WriteLine("UIElement ist keiner Instanz von FormItem zuweisbar!"); return; } if (textBox.Text != item.Header) { order.setStateOfFormItem(textBox.Name, FormItemState.Edited); if (textBox.Text == "") { item.Input = "(" + item.Header + ")"; } else { item.Input = textBox.Text; } textBox.LostFocus -= changeStateToEdited; if (item.IsEditedStateHeader && item.ShortHeader != "" && textBox.Parent.GetType() == typeof(StackPanel) && this.FindName(item.ID + "ShortHeader") == null) { if (textBox.Text == "") { item.Input = "XXX"; } StackPanel ShortHeaderElement = new StackPanel(); ShortHeaderElement.Orientation = System.Windows.Controls.Orientation.Horizontal; TextBlock ShortHeader = new TextBlock(); Style tbStyle = (Style)App.resources["ShortHeader" + item.ShortHeaderSide]; if (tbStyle != null) { ShortHeader.Style = tbStyle; } else { Debug.WriteLine("Der Style für ShortHeaders ist nicht \"ShortHeader" + item.ShortHeaderSide + "\""); } ShortHeader.Text = item.ShortHeader; ShortHeader.Name = item.ID + "ShortHeader"; ShortHeader.Foreground = (SolidColorBrush)App.resources["ColorShortHeaderEdited"]; StackPanel Parent = (StackPanel)textBox.Parent; Parent.Children.Insert(Parent.Children.IndexOf(textBox), ShortHeaderElement); Parent.Children.Remove(textBox); ShortHeaderElement.Children.Add(textBox); if (item.ShortHeaderSide == FormItemShortHeaderSide.Left.ToString()) { ShortHeaderElement.Children.Insert(0, ShortHeader); } if (item.ShortHeaderSide == FormItemShortHeaderSide.Right.ToString()) { ShortHeaderElement.Children.Add(ShortHeader); } } App.formHandler.saveData(order); elementFactory.editedTextBox(textBox, false); } else { order.setStateOfFormItem(textBox.Name, FormItemState.Blank); textBox.Hold += makeANote; } } else { FrameworkElement element = (FrameworkElement)sender; FormItem item = order.setStateOfFormItem(element.Name, FormItemState.Edited); if (item == null) { Debug.WriteLine("UIElement ist keiner Instanz von FormItem zuweisbar!"); return; } try { Style style = (Style)App.resources[item.ControlType + FormItemState.Edited.ToString()]; if (style != null) { element.Style = style; } } catch { Debug.WriteLine("fehler beim zuweisen von Edited-Style zu " + item.ControlType); } if (sender.GetType() == typeof(OwnListPicker)) { item.Input = ((OwnListPicker)sender).GetSelectionAsString(); ((OwnListPicker)sender).Close(); } if (sender.GetType() == typeof(CheckBox)) { if ((bool)((CheckBox)sender).IsChecked) { item.Input = item.Header; } else { item.Input = "kein(e) " + item.Header; } } App.formHandler.saveData(order); updateUIElement(item); } lookUpState(); this.Focus(); }
public FrameworkElement giveMeATextBoxAsTextBlock(FormItem item) { StackPanel panel = new StackPanel(); panel.Orientation = Orientation.Horizontal; if (resources == null) { setResourceDictionary(); } if (item.Input == "(" + item.Header + ")") { TextBlock textBlock = new TextBlock(); textBlock.Text = "XXX"; Style style = (Style)resources["OverviewEdit"]; if (style == null) { Debug.WriteLine("Fehler: Der Style \"OverviewEdit\" fehlt!"); } else { textBlock.Style = style; } textBlock.Name = item.ID; panel.Children.Add(textBlock); TextBlock headerBlock = new TextBlock(); headerBlock.Text = "(" + item.Header + ")"; if (style == null) { Debug.WriteLine("Fehler: Der Style \"OverviewEdit\" fehlt!"); } else { headerBlock.Style = style; } headerBlock.Name = item.ID; headerBlock.Foreground = (SolidColorBrush)resources["ColorShortHeaderEdited"]; panel.Children.Add(headerBlock); return(panel); } else { TextBlock textBlock = new TextBlock(); textBlock.Text = item.Input; Style style = (Style)resources["OverviewEdit"]; if (style == null) { Debug.WriteLine("Fehler: Der Style \"OverviewEdit\" fehlt!"); } else { textBlock.Style = style; } textBlock.Name = item.ID; panel.Children.Add(textBlock); if (item.ShortHeader != "") { TextBlock headerBlock = new TextBlock(); if (item.IsEditedStateHeader) { headerBlock.Text = "(" + item.ShortHeader + ")"; } else { headerBlock.Text = item.ShortHeader; } if (style == null) { Debug.WriteLine("Fehler: Der Style \"OverviewEdit\" fehlt!"); } else { headerBlock.Style = style; } headerBlock.Name = item.ID; if (item.IsEditedStateHeader) { headerBlock.Foreground = (SolidColorBrush)resources["ColorShortHeaderEdited"]; } panel.Children.Add(headerBlock); } return(panel); } }
public override void editedTextBox(TextBox textBox, bool isANote) { Debug.WriteLine("zu nem TextBlock"); TextBlock textBlock = new TextBlock(); if (isANote) { textBlock.Style = (Style)resources["NoteEdited"]; } else { textBlock.Style = (Style)resources["OverviewEdit"]; } textBlock.Text = textBox.Text; String name = textBox.Name; if (isANote) { textBlock.Tag = textBox.Tag; } textBlock.Name = textBox.Name + "Temp"; FormItem item = FormPage.order.setStateOfFormItem(textBox.Name, FormItemState.Edited); if (item == null && !isANote) { Debug.WriteLine("Der TextBox " + textBox.Name + " kann kein FormItem zugeordnet werden!"); return; } else { if (!isANote) { if (textBlock.Text == "") { textBlock.Text = "(" + item.Header + ")"; } } } if (textBox.Parent != null) { if (textBox.Parent.GetType() == typeof(StackPanel)) { StackPanel parent = (StackPanel)textBox.Parent; int index = parent.Children.IndexOf(textBox); parent.Children.Remove(textBox); textBox.Name = ""; parent.Children.Insert(index, textBlock); textBlock.Name = name; if (!isANote) { textBlock.Tap += FormPage.handleTap; textBlock.Hold += FormPage.makeANote; } } else { Debug.WriteLine("Die Umwandlung der TextBox in ein TextBlock ist nicht möglich, da ihr Parent kein StackPanel ist."); } } }