本文整理汇总了C#中ProgressBar.Update方法的典型用法代码示例。如果您正苦于以下问题:C# ProgressBar.Update方法的具体用法?C# ProgressBar.Update怎么用?C# ProgressBar.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.Update方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getRestaurants
public void getRestaurants()
{
HtmlNode docNode = getDocumentNode(URLPage1);
int NumRestaurants = getNumberofRestaurants(docNode);
docNode = null;
if (NumRestaurants > 0)
{
Console.WriteLine("Getting {0} Restaurants...", NumRestaurants);
Restaurants = new List<Restaurant>(NumRestaurants);
byte numPages = (byte)(NumRestaurants / RESTAURANTS_PER_PAGE);
if ((NumRestaurants % RESTAURANTS_PER_PAGE) != 0) numPages = (byte)(numPages + 1);
ProgressBar pb = new ProgressBar(numPages);
for (int pageCount = 0; pageCount < numPages; pageCount++)
{
Console.Write(pb.Update(pageCount+1));
var currentPage = getDocumentNode(URLBase + @"?page=" + (pageCount + 1).ToString());
var allRestaurantsOnPage = currentPage.CssSelect("#search-results > article").ToArray();
byte onPage = (byte)allRestaurantsOnPage.Length;
Task[] resTasks = new Task[onPage];
List<Restaurant> resOut = new List<Restaurant>(onPage);
for (int currentRestaurantCounter = 0; currentRestaurantCounter < onPage; currentRestaurantCounter += 1)
{
var currentRestaurantNode = allRestaurantsOnPage[currentRestaurantCounter];
resTasks[currentRestaurantCounter] = Task.Factory.StartNew(() =>
{
Restaurant currentRestaurant = processRestaurant(currentRestaurantNode);
if (currentRestaurant != null) { resOut.Add(currentRestaurant); }
});
}
Task.WaitAll(resTasks);
Restaurants.AddRange(resOut);
}
}
}
示例2: FormMain
public FormMain()
{
Form progressBar = new ProgressBar();
try
{
progressBar.StartPosition = FormStartPosition.CenterScreen;
progressBar.Show();
progressBar.Update();
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
InitSessionContext();
SetDefaultInputs();
CustomInit();
SetFormStartPosition();
bindEvent();
progressBar.Hide();
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
finally
{
progressBar.Dispose();
}
}
示例3: getReviews
public void getReviews()
{
int NumReviews;
if (int.TryParse(NumberOfReviews, out NumReviews) == false) NumReviews = -1;
if (NumReviews > 0)
{
HtmlNode docNode = getDocumentNode(reviewsURL + @"?reviewsPage=1");
var AddressNodes = docNode.CssSelect(".address > a > span").ToArray();
docNode = null;
Address = AddressNodes[1].InnerText.Trim();
Address = Address.Replace(" ", " ");
Address = Address.Replace(Environment.NewLine, "");
Console.WriteLine("Getting {0} Reviews...", NumReviews);
Reviews = new List<Review>(NumReviews);
byte numPages = (byte)(NumReviews / REVIEWS_PER_PAGE);
if ((NumReviews % REVIEWS_PER_PAGE) != 0) numPages = (byte)(numPages + 1);
ProgressBar pb = new ProgressBar(numPages);
for (int pageCount = 0; pageCount < numPages; pageCount++)
{
Console.Write(pb.Update(pageCount + 1));
var currentPage = getDocumentNode(reviewsURL + @"?reviewsPage=" + (pageCount + 1).ToString());
var allReviewsOnPage = currentPage.CssSelect("#diner-reviews-list > article[itemProp='review']").ToArray();
byte onPage = (byte)allReviewsOnPage.Length;
Task[] revTasks = new Task[onPage];
List<Review> revOut = new List<Review>(onPage);
for (int currentReviewCounter = 0; currentReviewCounter < onPage; currentReviewCounter += 1)
{
var currentReviewNode = allReviewsOnPage[currentReviewCounter];
string reviewNumber = new string('0', NumberOfReviews.Length);
reviewNumber = reviewNumber + ((pageCount * REVIEWS_PER_PAGE) + currentReviewCounter).ToString();
reviewNumber = reviewNumber.Substring(reviewNumber.Length - NumberOfReviews.Length);
revTasks[currentReviewCounter] = Task.Factory.StartNew(() =>
{
Review currentReview = processReview(currentReviewNode, reviewNumber);
if (currentReview != null) { revOut.Add(currentReview); }
});
}
Task.WaitAll(revTasks);
Reviews.AddRange(revOut);
}
}
}
示例4: setProgressBarValue
public void setProgressBarValue(ProgressBar bar, int new_value)
{
if(bar.InvokeRequired) {
bar.BeginInvoke(new setProgressBarValueDelegate(setProgressBarValue),new Object[] {bar,new_value});
} else {
lock(bar) {
if(new_value>bar.Maximum)
bar.Value = bar.Maximum;
else if(new_value<bar.Minimum)
bar.Value = bar.Minimum;
else
bar.Value = new_value;
bar.Update();
}
}
}
示例5: setProgressBarStyle
public void setProgressBarStyle(ProgressBar bar, ProgressBarStyle new_style)
{
if(bar.InvokeRequired) {
bar.Invoke(new setProgressBarStyleDelegate(setProgressBarStyle),new Object[] {bar,new_style});
} else {
lock(bar) {
bar.Style = new_style;
bar.Update();
}
}
}
示例6: setProgressBarMin
public void setProgressBarMin(ProgressBar bar, int new_min)
{
if(bar.InvokeRequired) {
bar.BeginInvoke(new setProgressBarMinDelegate(setProgressBarMin),new Object[] {bar,new_min});
} else {
lock(bar) {
bar.Minimum = new_min;
bar.Update();
}
}
}
示例7: setProgressBarMax
public void setProgressBarMax(ProgressBar bar, int new_max)
{
if(bar.InvokeRequired) {
bar.BeginInvoke(new setProgressBarMaxDelegate(setProgressBarMax),new Object[] {bar,new_max});
} else {
lock(bar) {
bar.Maximum = new_max;
bar.Update();
}
}
}
示例8: performStep
public void performStep(ProgressBar bar)
{
if(bar.InvokeRequired) {
bar.BeginInvoke(new performStepDelegate(performStep), new Object[] { bar });
} else {
lock(bar) {
bar.Increment(1);
bar.Update();
}
}
}
示例9: MainTest
static void MainTest()
{
UIScene currentElement;
Table myElement, myOtherElement, ThirdElement;
FW.Buffer buffer;
ProgressBar pb;
UIManager.Initialize(ConsoleColor.White);
myElement = new Table(new string[][] {new string[] {
"Left 1", "Right 1"},
new string[] {"Left 2", "Right 2"},
new string[] {"Left 3", "Right 3 Looong"},
new string[] {"Left 444444554545454444", "t"},
new string[] {"i", "asdasdasdasdasdasdasdasd"},
new string[] {"Level", "9001"}}, 30, null, ConsoleColor.Red, TableMode.LeftHeader);
myOtherElement = new Table(new string[][] { // So sieht der Quellcode aus
new string[] {"This", "Here"},
new string[] {"is", "be"},
new string[] {"the", "data"},
new string[] {"title", "00"},
new string[] {"line", "000"},
new string[] {"!", "0000"}}, 30, null, ConsoleColor.Red, TableMode.LeftHeader);
ThirdElement = new Table(new string[][] {new string[] {
"Name", "OP"},
new string[] {"OP?", "OP"},
new string[] {",,,,,,,,", "......"},
new string[] {" Needs trimming", "9002"},
new string[] {"Intelligenz", "Really does "},
new string[] {"Level", "Colorful console game thingy"}}, 61, null, ConsoleColor.Red, TableMode.TopHeader);
pb = new ProgressBar(0, 61);
currentElement = new UIScene(new IRenderable[] { myElement, myOtherElement, ThirdElement, pb },
new int[][] { new int[] { 1, 1 }, new int[] { 1, 32 }, new int[] { 8, 1 }, new int[] { 15, 1 } },
new string[] { "Spieler 1", "Spieler 2", "OMG Gegner", "Progress" }, 17, 63, ConsoleColor.Green, null);
UIManager.setScene(currentElement);
UIManager.Render();
UIManager.DrawFrame();
Console.ReadKey();
pb.Update(0.5);
UIManager.Render();
UIManager.DrawFrame();
Console.ReadKey();
pb.Update(0.3);
UIManager.Render();
UIManager.DrawFrame();
Console.ReadKey();
pb.Update(1);
UIManager.Render();
UIManager.DrawFrame();
Console.ReadKey();
currentElement = new UIScene(new IRenderable[] { myOtherElement, myElement, ThirdElement },
new int[][] { new int[] { 1, 1 }, new int[] { 1, 32 }, new int[] { 8, 1 } },
new string[] { "Spieler 1", "Spieler 2", "OMG Gegner" }, 15, 63, ConsoleColor.Green, null);
UIManager.setScene(currentElement);
UIManager.Render();
UIManager.DrawFrame();
Console.ReadKey();
buffer = new FW.Buffer(myElement, new FireworkEngine.Margin { Top = 3, Left = 6, Bottom = 3, Right = 7 }, ' ');
currentElement = new UIScene(new[] { buffer }, new[] { new[] { 1, 1 } }, new[] { "Buffer Test" }, 14, 45);
UIManager.setScene(currentElement);
UIManager.Render();
UIManager.DrawFrame();
Console.ReadKey();
}