ProgressBar: Difference between revisions
(Created page with "right|50px|link=User Interface Category:SDK This object is used to display a progress bar in the host program while doing time consuming tasks. ==Constr...") |
|||
Line 39: | Line 39: | ||
===:Finished()=== | ===:Finished()=== | ||
This should always be called when you are finished with a progress bar. | This should always be called when you are finished with a progress bar. | ||
<nowiki>function ProgressAmount(TotalRecords, Record) -- | <nowiki>function ProgressAmount(TotalRecords, Record) -- Calculates the percent amount of progression based on total process | ||
--[[ | --[[ | ||
local MyProgressBar | local MyProgressBar | ||
MyProgressBar = ProgressBar("Working", ProgressBar.LINEAR) -- Setup Type of progress | MyProgressBar = ProgressBar("Working", ProgressBar.LINEAR) -- Setup Type of progress bar | ||
MyProgressBar:SetPercentProgress(0) -- Sets progress | MyProgressBar:SetPercentProgress(0) -- Sets progress bar to zero | ||
MyProgressBar:SetPercentProgress(ProgressAmount(Door.Records, myRecord)) -- sends percent of process progress | MyProgressBar:SetPercentProgress(ProgressAmount(Door.Records, myRecord)) -- sends percent of process progress bar (adds to the bar) | ||
MyProgressBar:SetPercentProgress(ProgressAmount(12000, 416)) -- sends percent of process progress | MyProgressBar:SetPercentProgress(ProgressAmount(12000, 416)) -- sends percent of process progress bar (adds to the bar) | ||
MyProgressBar:SetText("Compete") -- Sets the | MyProgressBar:SetText("Compete") -- Sets the label to Complete | ||
MyProgressBar:Finished() -- Close Progress Bar | MyProgressBar:Finished() -- Close Progress Bar | ||
]] | ]] | ||
Line 61: | Line 61: | ||
[[File:Back.jpg|right|50px|link=User Interface]] | [[File:Back.jpg|right|50px|link=User Interface]] | ||
==References== | ==References== | ||
'''Please Note:''' The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 2.05, published September 12, 2018. by Vectric Ltd. Most current document from Vertric can be downloaded at [https://gadgets.vectric.com/developerinfo.html Vertric Developer Information] | '''Please Note:''' The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 2.05, published September 12, 2018. by Vectric Ltd. Most current document from Vertric can be downloaded at [https://gadgets.vectric.com/developerinfo.html Vertric Developer Information] |
Revision as of 21:20, 3 August 2021
This object is used to display a progress bar in the host program while doing time consuming tasks.
Constructor
ProgressBar(string text, ProgressBarMode progress_bar_mode)
Creates a new progress bar and displays it in the host program.
text (string) The text displayed to the left of the progress bar. progress_bar_mode (integer) Type of progresss bar to create.
- Valid values are:
- ProgressBar.LINEAR Use this when you can compute your percentage progress while processing.
- ProgressBar.PINGPONG Use this when you cannot compute your percentage progress.
Methods
:SetPercentProgress(integer percent)
Call this moderately frequently to update the progress bar with your percentage progress. Should be used in conjunction with ProgressBar.LINEAR percent (integer) The percentage task completion between 0 and 100, does not have to be monotonically increasing in value. Progress bars can be reappropriated for different tasks by using SetText().
:StepProgress()
Call this moderately frequently to update the progress bar when you cant complete your percentage progress. Should be used in conjunction with ProgressBar.PINGPONG
:SetText(string text)
Sets the text displayed to the left of the progress bar. text (String) The text to be displayed.
:Finished()
This should always be called when you are finished with a progress bar.
function ProgressAmount(TotalRecords, Record) -- Calculates the percent amount of progression based on total process --[[ local MyProgressBar MyProgressBar = ProgressBar("Working", ProgressBar.LINEAR) -- Setup Type of progress bar MyProgressBar:SetPercentProgress(0) -- Sets progress bar to zero MyProgressBar:SetPercentProgress(ProgressAmount(Door.Records, myRecord)) -- sends percent of process progress bar (adds to the bar) MyProgressBar:SetPercentProgress(ProgressAmount(12000, 416)) -- sends percent of process progress bar (adds to the bar) MyProgressBar:SetText("Compete") -- Sets the label to Complete MyProgressBar:Finished() -- Close Progress Bar ]] local X1 = (100.0 / TotalRecords) local X2 = X1 * Record local X3 = math.abs(X2) local X4 = (math.floor(X3)) return (math.floor(math.abs((100.0 / TotalRecords) * Record))) end -- function end
Example Code:
References
Please Note: The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 2.05, published September 12, 2018. by Vectric Ltd. Most current document from Vertric can be downloaded at Vertric Developer Information