Ejemplo n.º 1
0
        public void OpenFuseOrCBList(object sender, EventArgs e)
        {
            UIButton btnFuseOrCBSearch = (UIButton)sender;
            ScreenUtils scnUtils = new ScreenUtils ();
            scnUtils.GetAbsolutePosition (btnFuseOrCBSearch);
            float iTop = scnUtils.GetPositionTop ();
            float iLeft = scnUtils.GetPositionLeft ();
            int iBtnTagId = btnFuseOrCBSearch.Tag;
            int iPwrIdRow = iBtnTagId / iBankFuseOrCBSearchTagId;
            int iStringRow = iBtnTagId - (iPwrIdRow * iBankFuseOrCBSearchTagId);
            int iSectionCounterTagId = iStringRowSectionCounterTagId * iPwrIdRow  + iStringRow;
            UILabel hfSectionCounter = (UILabel)View.ViewWithTag (iSectionCounterTagId);
            int iSectionCounterId = Convert.ToInt32 (hfSectionCounter.Text);

            clsTabletDB.ITPBatteryFuseTypes ITPFuseTypes = new clsTabletDB.ITPBatteryFuseTypes();
            string[] sBatteryFuseOrCBs = ITPFuseTypes.GetBatteryFuseTypes();

            //Create a list and convert the string array to the list. Why the system cannot take a simple string array is beyond me!!!
            List<string> listFuseOrCB = new List<string> ();
            Array.ForEach (sBatteryFuseOrCBs, value => listFuseOrCB.Add (value.ToString ()));

            TableViewSource tabdata = new TableViewSource (listFuseOrCB, true);
            tabdata.SetFont("Verdana",10f);
            UITableView cmbFuseOrCB = new UITableView ();

            //If the bottom of the frame would be outside the main content frame make it go upwards instead of downwards
            UILabel hfContentHeight = (UILabel)View.ViewWithTag (3);
            int iContentHeight = Convert.ToInt32 (hfContentHeight.Text);
            if (iTop + 190f > (float)iContentHeight)
            {
                cmbFuseOrCB.Frame = new RectangleF(iLeft, iTop - 190f, 90f, 100f);
            }
            else
            {
                cmbFuseOrCB.Frame = new RectangleF(iLeft, iTop, 90f, 100f);
            }

            tabdata.SetParent(cmbFuseOrCB);
            tabdata.SetUpdateFieldType("UILabel");
            UILabel lblVwUpdate = (UILabel)View.ViewWithTag (iBankFuseOrCBTagId * (iPwrIdRow) + (iStringRow));
            tabdata.SetLabelViewToUpdate(lblVwUpdate);
            UIView vwUnsaved = (UIView)View.ViewWithTag (60);
            tabdata.SetUnsavedChangesView(vwUnsaved);
            tabdata.SetShowUnsavedOnChange(true);
            UILabel hfRowStatus = (UILabel)View.ViewWithTag (iStringRowStatusTagId * (iPwrIdRow) + (iStringRow));
            tabdata.SetFusePostUpdate(7, hfRowStatus);
            //Also set the section flag to 1 that it has changed and the overall flag that it has changed
            UILabel lblUnsavedFlag = (UILabel)View.ViewWithTag (80);
            tabdata.SetUnsavedChangesHiddenLabel(lblUnsavedFlag);
            UILabel lblUnsavedSectionFlag = (UILabel)View.ViewWithTag ((iSectionCounterId + 1) * iSectionStatusTagId);
            tabdata.SetUnsavedChangesSectionHiddenLabel(lblUnsavedSectionFlag);

            cmbFuseOrCB.Source = tabdata;
            iUtils.SESTable thistable = new iUtils.SESTable();
            string sSelectedValue = lblVwUpdate.Text;
            thistable.SetTableSelectedText(cmbFuseOrCB, sSelectedValue, sBatteryFuseOrCBs, true);

            //Get the main scroll view
            UIScrollView scrollVw = (UIScrollView)View.ViewWithTag (2);
            scrollVw.AddSubview(cmbFuseOrCB);
        }