The following is an example using the CxHmiFac FacNavBar object in CygNet Studio.
|
| FacNavBar Example |
For a useful example of a Facility Navigation Bar implemented in a pre-designed screen, open FacNavBar_GrpGrid.csf in the APPS SCREXAMP folder.
|
'(Declarations)
Sub UpdateUI()
eboLevels.Text = FacNavBar.X.Levels - 1 eboInitialFilter.Text = FacNavBar.X.InitialFilter If FacNavBar.X.RuntimeCfgAutoPersist Then ckbRTimeCfgAutoPersist.Check = 1 Else ckbRTimeCfgAutoPersist.Check = 0 End If
btnNext.Enable = FacNavBar.X.CanSelNext(eboLevel.Text, ckbWrap.Value) btnPrev.Enable = FacNavBar.X.CanSelPrev(eboLevel.Text, ckbWrap.Value)
btnNavNext.Enable = FacNavBar.X.CanNavNext(ckbNavWrap.Value) btnNavPrev.Enable = FacNavBar.X.CanNavPrev(ckbNavWrap.Value)
End Sub
Sub LoadGrid()
Dim arrUdcList Dim iLowerBound Dim iUpperBound Dim strFacTag
Dim strUis strUis = FacNavBar.X.SiteService
strFacTag = FacNavBar.X.GetSelectedTargetFacTag()
If strUis = "" Then msgbox "Set the Site.Service" Exit Sub End If
If strFacTag = "" Then msgbox "Invalid FacilityTag (" + strFacTag + ")" Exit Sub End If
Dim aryFacTag, strFacility aryFacTag = Split(strFacTag, "::") strFacility = aryFacTag(1)
' ' Get the udc list for this facility. ' GetUdcList strFacTag, arrUdcList
iLowerBound = 0 iUpperBound = ubound(arrUdcList)
' ' Load up the grid rows/columns ' Dim i, j, itemid
CxGrpGrid.x.Stop CxGrpGrid.x.ClearRows
CxGrpGrid.x.Columns = 4 For j=0 To 3 CxGrpGrid.x.ColSiteService(j) = strUis CxGrpGrid.x.ColFacility(j) = strFacility Next
CxGrpGrid.x.ColLabelText(0) = "Description" CxGrpGrid.x.ColDisplayItem(0) = 10007
CxGrpGrid.x.ColLabelText(1) = "Value" CxGrpGrid.x.ColDisplayItem(1) = 10001
CxGrpGrid.x.ColLabelText(2) = "Units" CxGrpGrid.x.ColDisplayItem(2) = 10008
CxGrpGrid.x.ColLabelText(3) = "Time" CxGrpGrid.x.ColDisplayItem(3) = 10002
For i=iLowerBound To iUpperBound CxGrpGrid.x.RowUdc(i) = arrUdcList(i) CxGrpGrid.x.RowLabelText(i) = CxGrpGrid.x.RowUdc(i) Next
CxGrpGrid.x.Start
End Sub
Sub ListInitialFilterRules()
lboEnabledRules.ResetContent lboDisabledRules.ResetContent
Dim aryEnabledRules, aryDisabledRules FacNavBar.X.GetInitialFilterRuleNames aryEnabledRules, aryDisabledRules
Dim i For i = 0 To UBound(aryEnabledRules) lboEnabledRules.AddString(aryEnabledRules(i)) Next
For i = 0 To UBound(aryDisabledRules) lboDisabledRules.AddString(aryDisabledRules(i)) Next
End Sub
'End of (Declarations)
'(GlobalDeclarations)
'End of (GlobalDeclarations)
Sub btnDisableRule_EventClick() Dim This : Set This = btnDisableRule
If lboEnabledRules.GetCurSel() < 0 Then Exit Sub End If
FacNavBar.X.EnableInitialFilterRule lboEnabledRules.GetText(lboEnabledRules.GetCurSel()), False
ListInitialFilterRules()
ckbEnableAllInitialFilterRules.Check = 2
End Sub
Sub btnEnableRule_EventClick() Dim This : Set This = btnEnableRule
If lboDisabledRules.GetCurSel() < 0 Then Exit Sub End If
FacNavBar.X.EnableInitialFilterRule lboDisabledRules.GetText(lboDisabledRules.GetCurSel()), True
ListInitialFilterRules()
ckbEnableAllInitialFilterRules.Check = 2
End Sub
Sub btnNavNext_EventClick() Dim This : Set This = btnNavNext
Dim iLevel iLevel = FacNavBar.X.NavNext(ckbNavWrap.Value)
UpdateUI() LoadGrid()
End Sub
Sub btnNavPrev_EventClick() Dim This : Set This = btnNavPrev
Dim iLevel iLevel = FacNavBar.X.NavPrev(ckbNavWrap.Value)
UpdateUI() LoadGrid()
End Sub
Sub btnNext_EventClick() Dim This : Set This = btnNext
Dim iRet iRet = FacNavBar.X.SelNext(eboLevel.Text, ckbWrap.Value)
UpdateUI() LoadGrid()
End Sub
Sub btnPersistRTimeCfg_EventClick() Dim This : Set This = btnPersistRTimeCfg
FacNavBar.X.PersistRunTimeCfg
End Sub
Sub btnPrev_EventClick() Dim This : Set This = btnPrev
Dim iRet iRet = FacNavBar.X.SelPrev(eboLevel.Text, True)
UpdateUI() LoadGrid()
End Sub
Sub btnRestoreDTimeCfg_EventClick() Dim This : Set This = btnRestoreDTimeCfg
FacNavBar.X.RestoreDesignTimeCfg
UpdateUI() ListInitialFilterRules() LoadGrid()
End Sub
Sub btnRestoreRTimeCfg_EventClick() Dim This : Set This = btnRestoreRTimeCfg
FacNavBar.X.RestoreRunTimeCfg()
UpdateUI() ListInitialFilterRules() LoadGrid()
End Sub
Sub btnSetInitialFilter_EventClick() Dim This : Set This = btnSetInitialFilter
FacNavBar.X.InitialFilter = eboInitialFilter.Text
UpdateUI() ListInitialFilterRules()
End Sub
Sub btnSetLevelCnt_EventClick() Dim This : Set This = btnSetLevelCnt
FacNavBar.X.Levels = eboLevels.Text
End Sub
Sub btnSetSiteService_EventClick() Dim This : Set This = btnSetSiteService
TheView.SiteService = eboSiteService.Text TheView.Restart
End Sub
Sub ckbEnableAllInitialFilterRules_EventChange() Dim This : Set This = ckbEnableAllInitialFilterRules
If ckbEnableAllInitialFilterRules.Check <> 2 Then FacNavBar.X.EnableAllInitialFilterRules ckbEnableAllInitialFilterRules.Check() ListInitialFilterRules() End If
End Sub
Sub ckbNavWrap_EventChange() Dim This : Set This = ckbNavWrap
UpdateUI()
End Sub
Sub ckbRTimeCfgAutoPersist_EventChange() Dim This : Set This = ckbRTimeCfgAutoPersist
FacNavBar.X.RuntimeCfgAutoPersist = ckbRTimeCfgAutoPersist.Check
End Sub
Sub ckbWrap_EventChange() Dim This : Set This = ckbWrap
UpdateUI()
End Sub
Sub eboLevel_EventChange() Dim This : Set This = eboLevel
If eboLevel.Text <> "" Then btnNext.Enable = FacNavBar.X.CanSelNext(eboLevel.Text, ckbWrap.Value) btnPrev.Enable = FacNavBar.X.CanSelPrev(eboLevel.Text, ckbWrap.Value) Else btnNext.Enable = False btnPrev.Enable = False End If
End Sub
Sub eboLevel_EventInitialize() Dim This : Set This = eboLevel
eboLevel.Text = FacNavBar.X.Levels - 1
End Sub
Sub eboSiteService_EventInitialize() Dim This : Set This = eboSiteService
eboSiteService.Text = TheView.SiteService
End Sub
Sub FacNavBar_EventInitialize() Dim This : Set This = FacNavBar
UpdateUI()
End Sub
Sub FacNavBar_EventOnSelChangeLevel(Level) Dim This : Set This = FacNavBar
LoadGrid()
End Sub
Sub TheView_EventInitialize() Dim This : Set This = TheView
FacNavBar.X.SiteService = TheView.SiteService
ckbEnableAllInitialFilterRules.Check 0
ListInitialFilterRules() LoadGrid()
End Sub
Sub TheView_EventRestarted() Dim This : Set This = TheView
FacNavBar.X.SiteService = TheView.SiteService eboSiteService.Text = TheView.SiteService
ListInitialFilterRules() LoadGrid()
End Sub |