Exemple #1
0
        public void checkMyState()
        {
            FormState myState = EnumerationMatcher.StringToFormState(this.State);

            if (myState == FormState.Signed)
            {
                State = FormState.Signed.ToString();
                return;
            }

            if (myState == FormState.Uploaded)
            {
                State = FormState.Uploaded.ToString();
                return;
            }

            bool signable = true;

            foreach (FormPage page in FormPageList)
            {
                page.checkMyState();
                FormPageState state = EnumerationMatcher.StringToFormPageState(page.State);
                if (state == FormPageState.Disabled || state == FormPageState.PartlyEdited)
                {
                    signable = false;
                }
            }

            if (signable)
            {
                State = FormState.Signable.ToString();
                return;
            }
            State = FormState.Open.ToString();
        }
Exemple #2
0
        private void loadControl(object sender, EventArgs e)
        {
            int startIndex = 0;

            currentOrder = App.formHandler.loadOrderFromIsolatedStorage(orderID);
            OrderState state = EnumerationMatcher.StringToOrderState(currentOrder.State);

            switch (state)
            {
            case OrderState.Overview:
                startIndex = 2;
                break;

            case OrderState.Journey:
                startIndex = 3;
                break;

            case OrderState.Acceptance:
                startIndex = 4;
                break;

            case OrderState.Route:
                startIndex = 5;
                break;

            case OrderState.Giving:
                startIndex = 6;
                break;

            case OrderState.Retour:
                startIndex = 7;
                break;
            }
            myTimeLineControl.setStartIndex(startIndex);
        }
Exemple #3
0
        public void checkMyState()
        {
            bool fullyEdited  = true;
            bool partlyEdited = false;

            foreach (FormItem item in FormItemList)
            {
                FormItemState state = EnumerationMatcher.StringToFormItemState(item.State);
                if (state == FormItemState.Edited)
                {
                    partlyEdited = true;
                }
                if (state == FormItemState.Blank && item.Important)
                {
                    fullyEdited = false;
                }
            }

            if (fullyEdited)
            {
                State = FormPageState.FullyEdited.ToString();
            }
            else
            if (partlyEdited)
            {
                State = FormPageState.PartlyEdited.ToString();
            }
            else
            {
                State = FormPageState.Disabled.ToString();
            }
        }
Exemple #4
0
        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;
        }
Exemple #5
0
        private void openDynamic(object sender, EventArgs e)
        {
            if (sender.GetType() == typeof(Button))
            {
                String tag = ((Button)sender).Tag.ToString();

                if (EnumerationMatcher.StringToFormPageType(tag) == FormPageType.None)
                {
                    Debug.WriteLine("Die Tag-Eigenschaft des Buttons \"" + tag + "\" enthält keinen gültigen FormPageType!");
                }
                else
                {
                    NavigationService.Navigate(new Uri(string.Format("/EditPage.xaml?EditPage=" + tag + "&OrderID=" + orderID + "&FormID=Giving"), UriKind.Relative));
                }
            }
        }
Exemple #6
0
        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);
            }
        }
Exemple #8
0
        private void setUpPages(object sender, EventArgs e)
        {
            Pivot.Items.Clear();
            foreach (Form form in order.FormList)
            {
                //if (Pivot.Items.Count > order.FormList.IndexOf(form))
                //{
                PivotItem pivotItem = new PivotItem();
                Pivot.Items.Add(pivotItem);
                pivotItem.Header = form.FormHeader;
                StackPanel panel  = new StackPanel();
                ListBox    viewer = new ListBox();
                panel.Tag = form.FormID;
                viewer.Items.Add(panel);
                pivotItem.Content = viewer;
                bool signable = true;
                foreach (FormPage page in form.FormPageList)
                {
                    StackPanel pagePanel = new StackPanel();
                    FormPage = page;
                    foreach (FormItem item in page.FormItemList)
                    {
                        if (EnumerationMatcher.StringToFormItemState(item.State) != FormItemState.Edited)
                        {
                            bool found = false;
                            foreach (OrderInformation info in order.Information)
                            {
                                if (info.ID == item.ID || info.ID == (form.FormID + item.ID))
                                {
                                    Debug.WriteLine("Die Information zu " + item.ID + " ist bereits vorhanden: " + info.Information);
                                    item.Input = info.Information;
                                    found      = true;
                                }
                            }
                            if (found)
                            {
                                order.setStateOfFormItem(item.ID, FormItemState.Edited);
                            }
                        }

                        if (item.State == FormItemState.Edited.ToString() || item.Input != "" || item.ControlType == FormItemType.Header.ToString() || item.ControlType == FormItemType.Subheader.ToString() || item.ControlType == FormItemType.Listing.ToString() || item.ControlType == FormItemType.PageLink.ToString())
                        {
                            FrameworkElement element = elementFactory.getFrameworkElementFromItem(item, this);
                            if (element != null)
                            {
                                pagePanel.Children.Add(element);
                            }
                        }
                        else
                        if (item.Important)
                        {
                            signable = false;
                            if ((item.Input == "" || item.State == FormItemState.Blank.ToString()))
                            {
                                TextBlock textBlock = new TextBlock();
                                textBlock.Text = item.Header + " (?)";
                                Style style = (Style)App.resources["OverviewBlank"];
                                if (style == null)
                                {
                                    Debug.WriteLine("Fehler: Der Style \"OverviewBlank\" fehlt!");
                                }
                                else
                                {
                                    textBlock.Style = style;
                                }
                                textBlock.Name = item.ID;
                                pagePanel.Children.Add(textBlock);
                            }
                        }
                    }
                    pagePanel.Tag = page.FormPageID;
                    if (form.State == FormState.Open.ToString() || form.State == FormState.Signable.ToString())
                    {
                        pagePanel.DoubleTap += JumpToEditFormPage;
                    }
                    panel.Children.Add(pagePanel);
                }

                TextBlock SignumHeader = new TextBlock();
                SignumHeader.Text  = "Unterschriften";
                SignumHeader.Style = (Style)App.resources["Subheader"];
                panel.Children.Add(SignumHeader);

                bool   OtherSigned = false;
                bool   ISigned     = false;
                string Person1     = "";
                if (form.FormOtherHaveToSign)
                {
                    foreach (OrderInformation info in order.Information)
                    {
                        if (info.ID == "GivingPersonName")
                        {
                            Person1 = info.Information;
                        }
                    }
                    if (Person1 != "")
                    {
                        if (!GlobalSettings.HasSignedList.Contains(Person1 + form.FormID) && ((form.State == FormState.Open.ToString() || form.State == FormState.Signable.ToString())))
                        {
                            Image image = new Image();
                            MakeABackground(Person1, (form.State == FormState.Signable.ToString() && signable));
                            BitmapSource source = App.formHandler.getSignumOf(Person1 + "Button");
                            if (source != null)
                            {
                                image.Source = source;
                            }
                            else
                            {
                                Debug.WriteLine("Buttonbild sollte da sein, wurde als Bild aber nicht gefunden.");
                            }
                            Button button = new Button();
                            button.Width               = 655 / 2;
                            button.Height              = 480 / 2;
                            button.BorderThickness     = new Thickness(0);
                            button.Tag                 = form.FormID;
                            button.Name                = "SignOther" + form.FormID;
                            button.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                            if (!(form.State == FormState.Signable.ToString() && signable))
                            {
                                button.IsEnabled = false;
                            }
                            button.Click  += JumpToSignumPage;
                            button.Content = image;
                            panel.Children.Add(button);
                        }
                        else
                        {
                            OtherSigned = true;
                            BitmapSource source = App.formHandler.getSignumOf(Person1 + form.FormID);
                            if (source != null)
                            {
                                Image image = new Image();
                                image.Source = source;
                                image.Width  = 655 / 2;
                                image.Height = 480 / 2;
                                panel.Children.Add(image);
                            }
                            else
                            {
                                Debug.WriteLine("Signum sollte da sein, wurde als Bild aber nicht gefunden.");
                            }
                        }
                    }
                }
                else
                {
                    OtherSigned = true;
                }

                if (form.FormIHaveToSign)
                {
                    Person1 = GlobalSettings.myName;
                    if (Person1 != "")
                    {
                        if (!GlobalSettings.HasSignedList.Contains(Person1 + form.FormID) && ((form.State == FormState.Open.ToString() || form.State == FormState.Signable.ToString())))
                        {
                            Image image = new Image();
                            MakeABackground(Person1, (form.State == FormState.Signable.ToString() && signable));
                            BitmapSource source = App.formHandler.getSignumOf(Person1 + "Button");
                            if (source != null)
                            {
                                image.Source = source;
                            }
                            else
                            {
                                Debug.WriteLine("Buttonbild sollte da sein, wurde als Bild aber nicht gefunden.");
                            }
                            Button button = new Button();
                            button.Width               = 655 / 2;
                            button.Height              = 480 / 2;
                            button.BorderThickness     = new Thickness(0);
                            button.Tag                 = form.FormID;
                            button.Name                = "SignMe" + form.FormID;
                            button.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                            if (!(form.State == FormState.Signable.ToString() && signable))
                            {
                                button.IsEnabled = false;
                            }
                            button.Click  += JumpToSignumPage;
                            button.Content = image;
                            panel.Children.Add(button);
                        }
                        else
                        {
                            ISigned = true;
                            BitmapSource source = App.formHandler.getSignumOf(Person1 + form.FormID);
                            if (source != null)
                            {
                                Image image = new Image();
                                image.Source = source;
                                image.Width  = 655 / 2;
                                image.Height = 480 / 2;
                                panel.Children.Add(image);
                            }
                            else
                            {
                                Debug.WriteLine("Signum sollte da sein, wurde als Bild aber nicht gefunden.");
                            }
                        }
                    }
                }
                else
                {
                    ISigned = true;
                }
                if (OtherSigned && ISigned)
                {
                    form.State = FormState.Signed.ToString();
                    if (ApplicationBar != null)
                    {
                        ApplicationBar.IsVisible = true;
                    }
                    App.formHandler.saveData(order);
                }
                pivotItem.Visibility = System.Windows.Visibility.Visible;
            }
            //          if (GlobalSettings.focusElement != null)
            //            focusOnElement(GlobalSettings.focusElement);
        }