/// ------------------------------------------------------------------------------------------------
 /// Name		AddTypedCell
 ///
 /// <summary>	Adds the paragraph to the stacklayout after save function is executed in paragraphViewcell
 /// </summary>
 ///  <param name="sRiActionParagraph">		The paragraph being entered.</param>
 /// <remarks>
 /// </remarks>
 /// ------------------------------------------------------------------------------------------------
 private void AddTypedCell(SRiActionParagraph sRiActionParagraph)
 {
     if (sRiActionParagraph.PlainText.Contains("^IN"))
     {
         // TblSec_ParagraphList.Add(new ParagraphInputViewCell() { BindingContext = sRiActionParagraph });
     }
     else
     {
         var customCell = AppData.PropertyModel.SelectedAction.Action.Paragraphs.FirstOrDefault(x => x == sRiActionParagraph);
         if (customCell != null)/* customCell.CellType = CellTypes.Custom;*/
         {
             TblSec_ParagraphList.Add(new ParagraphCustomViewCell()
             {
                 BindingContext = sRiActionParagraph
             });
         }
     }
     //else if (sRiActionParagraph.PlainText.Contains("^IN"))
     //{
     //    TblSec_ParagraphList.Add(new ParagraphInputViewCell() { BindingContext = sRiActionParagraph });
     //}
     //else
     //{
     //    TblSec_ParagraphList.Add(new ParagraphNormalViewCell() { BindingContext = sRiActionParagraph });
     //}
 }
        /// ------------------------------------------------------------------------------------------------

        #region public Functions

        /// ------------------------------------------------------------------------------------------------
        ///
        /// ------------------------------------------------------------------------------------------------
        /// ------------------------------------------------------------------------------------------------
        /// Name		OnDelete
        ///
        /// <summary>	Delete's the row on the click event
        /// </summary>
        /// <param name="sRiActionParagraph"> </param>
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------

        public async void OnDelete(SRiActionParagraph sRiActionParagraph)
        {
            if (await DisplayAlert("Delete", "Do you want to delete this item?", "Yes", "No"))
            {
                Paralist.Remove(sRiActionParagraph);
                RefreshList();
                if (Paralist.Count == 0)
                {
                    IsEditable = false;
                }
            }
        }
Exemple #3
0
        /// ------------------------------------------------------------------------------------------------
        /// Name		AddTypedCell
        ///
        /// <summary>	Adds the paragraph to the stacklayout after save function is executed in paragraphViewcell
        /// </summary>
        ///  <param name="sRiActionParagraph">		The paragraph being entered.</param>
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        private void AddTypedCell(SRiActionParagraph sRiActionParagraph)
        {
            try
            {
                Tblvw_StandardParagraph.IsVisible = true;
                if (Device.OS == TargetPlatform.Android)
                {
                    var address = sRiActionParagraph.Text?.Replace("\r",
                                                                   Environment.NewLine);
                    sRiActionParagraph.Text = address;
                }

                if (sRiActionParagraph.PlainText.Contains("^IN"))
                {
                    //sRiActionParagraph.IsCellEditable = true;
                    //sRiActionParagraph.IsEditable = true;
                    TblSec_ParagraphList.Add(new ParagraphInputViewCell()
                    {
                        BindingContext = sRiActionParagraph
                    });
                }
                else if (sRiActionParagraph.PlainText == ParagraphViewModel.CUSTOM_PLACEHOLDER ||
                         sRiActionParagraph.CellType == CellTypes.Custom)
                {
                    var customCell = AppData.PropertyModel.SelectedAction.Action.Paragraphs.FirstOrDefault(x => x == sRiActionParagraph);
                    if (customCell != null)
                    {
                        customCell.CellType = CellTypes.Custom;
                        if (customCell.Text == ParagraphViewModel.CUSTOM_PLACEHOLDER)
                        {
                            customCell.Text = ParagraphViewModel.TAP_CUSTOM_PLACEHOLDER;
                        }
                    }
                    TblSec_ParagraphList.Add(new ParagraphCustomViewCell()
                    {
                        BindingContext = sRiActionParagraph
                    });
                }
                else
                {
                    TblSec_ParagraphList.Add(new ParagraphNormalViewCell()
                    {
                        BindingContext = sRiActionParagraph
                    });
                }
                TblSection = TblSec_ParagraphList;
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
            }
        }
        /// ------------------------------------------------------------------------------------------------

        /// ------------------------------------------------------------------------------------------------
        #region Private Function
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		OnBindingContextChanged
        ///
        /// <summary>
        ///             Bind the value
        /// </summary>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        private void OnBindingContextChanged(object sender, EventArgs e)
        {
            try
            {
                var objsender = (SRiActionParagraph)BindingContext;
                if (objsender != null)
                {
                    _sRiActionParagraph = objsender;
                }
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
            }
        }
Exemple #5
0
        /// ------------------------------------------------------------------------------------------------

        /// ------------------------------------------------------------------------------------------------
        #region public Functions



        /// ------------------------------------------------------------------------------------------------
        ///
        /// ------------------------------------------------------------------------------------------------
        /// ------------------------------------------------------------------------------------------------
        /// Name		OnDelete
        ///
        /// <summary>	Delete's the row on the click event
        /// </summary>
        /// <param name="sRiActionParagraph"> </param>
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------

        public async void OnDelete(SRiActionParagraph sRiActionParagraph)
        {
            try
            {
                if (await LockScreen.ToDisplayAlert(this, "Delete", "Do you want to delete this item?", "Yes", "No"))
                {
                    Paralist.Remove(sRiActionParagraph);
                    OnEditPropertyChanged();
                    if (Paralist.Count == 0)
                    {
                        IsEditable     = false;
                        IsCellEditable = false;
                        Tblvw_StandardParagraph.IsVisible = false;
                    }
                }
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
            }
        }
        ///
        #endregion
        /// ------------------------------------------------------------------------------------------------

        /// ------------------------------------------------------------------------------------------------
        #region Private Functions
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		OnBindingContextChanged
        ///
        /// <summary>
        /// Bind the values
        /// </summary>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        private void OnBindingContextChanged(object sender, EventArgs e)
        {
            try
            {
                if (_isChanged)
                {
                    _sRiActionParagraph = BindingContext as SRiActionParagraph;


                    if (_sRiActionParagraph != null)
                    {
                        _insertValues   = _sRiActionParagraph.InsertsList;
                        _splittedString = _sRiActionParagraph.PlainText.Split(new[] { VisitActionDetailsPage.INSERT_MARKER }, StringSplitOptions.None).ToList();
                        SetValues();
                    }
                }
                _isChanged = false;
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
            }
        }
        /// ------------------------------------------------------------------------------------------------
        /// Name		OnSave
        ///
        /// <summary>	Saves the data and Dismisses the popup on clicking Save button.
        /// </summary>
        /// <param name="sender"> </param>
        ///   /// <param name="e"> event arguments</param>
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        private void OnSave(object sender, EventArgs e)
        {
            try
            {
                var pts = ParaViewModel;
                pts.SelectedParagraphs.RemoveAt(pts.SelectedParagraphs.Count - 1);
                // Check all paragraphs have a Type and paragraph set
                foreach (TypedParagraph pc in pts.SelectedParagraphs)
                {
                    if (pc.Type == "Type" || pc.Paragraph.ParagraphText == "Paragraph")
                    {
                        if (Device.OS == TargetPlatform.iOS)
                        {
                            DependencyService.Get <IDisplayAlertPopup>().ShowAlertParagraph();
                        }
                        else
                        {
                            SplitView.DisplayAlert("Error", "All items must have both Type and Paragraph set.", "OK", null);
                        }
                        AddNewCell();
                        return;
                    }
                }
                //
                // Save paragraphs back to action
                foreach (TypedParagraph pc in pts.SelectedParagraphs)
                {
                    var pi = new SRiActionParagraph
                    {
                        ParagraphType = pc.Type,
                        Text          = pc.Paragraph.ParagraphText
                    };
                    // Don't add the made up code from "Insert Custom Text" option
                    if (pc.Paragraph.Code != ParagraphViewModel.CustomCode)
                    {
                        pi.ParagraphCodeInserts = pc.Paragraph.Code;
                    }
                    pi.ActionKeyVal = AppData.PropertyModel.SelectedAction.Action.KeyVal;

                    // Insert new paragraph at the end of this TypeCode group
                    var paras = AppData.PropertyModel.SelectedAction.Action.Paragraphs;
                    var i     = paras.Count - 1;
                    while ((i >= 0) && (string.CompareOrdinal(paras[i].ParagraphType, pi.ParagraphType) > 0))
                    {
                        i--;
                    }

                    // Might as well set the sequance here. I'm also tempted to (re)set all sequence values it in VisitActionEditView.cmdSave_Click
                    if ((i >= 0) && (paras[i].ParagraphType == pi.ParagraphType) && (paras[i].Sequence.HasValue))
                    {
                        pi.Sequence = paras[i].Sequence.Value + 1;
                    }
                    else
                    {
                        pi.Sequence = 0;
                    }

                    paras.Insert(i + 1, pi);
                }
                VisitActionDetailsPage.CenterPopup.DismisPopup();
                Refresh();
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
            }
        }