How can I get progress bar to increment by one block till end of bar? Visual Basic 2010 - vb.net

How I could get a progress bar to increment by one block each time the correct button is clicked, till eventually the progress bar is filled. I have tried, but didn't work, so thought I would ask on here for guidance on how to achieve this or go about this.
Not worked much with progress bars and not worried about maximum values at the moment or minimum, if that is any help.
Hope I have explained my problem with enough detail and any help will greatly be appreciated.

Based on your question i have created a sample. Please try this will some times helps you. Please share your code. So that we can help more
private void Form1_Load(object sender, EventArgs e)
{
progressBar1.Minimum = 0;
progressBar1.Maximum = 10; // Maximum should be based on your value
}
private void button1_Click(object sender, EventArgs e)
{
if (progressBar1.Value < progressBar1.Maximum)
{
progressBar1.Value += 1;
}
}

Related

Manipulation events of MediaElement not fire when on FullWindows mode

When I set player not in fullscreen (player.IsFullWindows = false), event work normally but when change player to full screen all manipulation event not work. Anyone have solution?
<MediaElement Name="player"
Margin="10,5" ManipulationCompleted="player_ManipulationCompleted"
ManipulationDelta="Grid_ManipulationDelta"
ManipulationMode="TranslateX"
>
I can reproduce this scenario by enabling both the IsFullWindow="True" and the AreTransportControlsEnabled="True". I think it makes sense, because when we are in the Full Window mode, it will go to the new layer named FullWindowMediaRoot instead of the MediaElement. Inside the FullWindowMediaRoot, it is the MediaTransportControls. You can see that clearly by using the Live Visual Tree as following:
So when we are in the Full Window mode, we need to handle the manipulation event of the TransportControls instead of the manipulation event of the MediaElement as following:
public MainPage()
{
this.InitializeComponent();
player.TransportControls.ManipulationMode = ManipulationModes.TranslateX;
player.TransportControls.ManipulationDelta += TransportControls_ManipulationDelta;
player.TransportControls.ManipulationCompleted += TransportControls_ManipulationCompleted;
}
private void TransportControls_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
}
private void TransportControls_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
}
Thanks.

Back button on WP8.1

I try to add code to Hardware Back Button on WP8.1
Private Sub onBackPressed(sender As Object, e As BackPressedEventArgs)
some code
End Sub
But when I press Back - my app just closes.
onBackPressed event is not happening at all, how can I fixed it?
Did you register for that event?
You need to first add this youself
HardwareButtons.BackPressed += HardwareButtons_BackPressed; ( sorry c# )
cfr http://invokeit.wordpress.com/2014/04/14/backbutton-handling-with-winprt-and-windows-phone-8-1-wpdev/
I know that for C# its easy.
Add this to the constructor:
HardwareButtons.BackPressed += this.Hardware_BackButton_Pressed;
And use:
public void Hardware_BackButton_Pressed(object sender, BackPressedEventArgs e)
{
// do things here..
}

How to navigate from one page to another in Windows phone 8 using XAML?

I am trying to make my first WP8 app but, i got a problem. I try to navigate to another page using the code below, but VS12 throws a error.
What am I doing wrong?
private void btnBMIBereken_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/BMI_Bereken.xaml", UriKind.Relative));
}
Your code is correct for navigating, just make sure the Page 'BMI_Bereken.xaml' actual exists at the root of your project.
Clean solution first and then rebuild again (right click on project/solution -> clean)
Then if it still crashes, try to use System.Windows.RoutedEventArgs e instead of RoutedEventArgs e
Guys i found the problem.
I use a self made button style for my buttons and i got on the visualstate pressed some wrong code. In fact I was trying to set the background collor of the button in the place of the name target name.
See the code below for what i did wrong.
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="#FF009AD3">
I know very stupid, but I want to thank everyone for the help.
Try this
private void btnBMIBereken_Click(object sender, RoutedEventArgs e)
{
Dispatcher.BeginInvoke(() =>
{
this.NavigationService.Navigate(new Uri("/BMI_Bereken.xaml", UriKind.Relative));
});
}
You could do something like this:
private void btnLogin_Click(object sender, RoutedEventArgs e)
{
if (txtDriverId.Text == "D0001" && txtPassword.Password == "open")
{
Frame.Navigate(typeof(VehicleCondition));
}
}

Number of Touchpoints in GestureRecognizer

I am using the GestureRecognizer to detect drag and pinch gestures.
The ManipulationStarted, ManipulationUpdated and ManipulationCompleted events provide the translation and scale values that are needed to pinch and drag.
However I cant figure out how to distinguish between drag (1 touch point) and pinch (2 touch points) gestures. There is no information about the number of touchpoints in GestureRecognizer.
How can I distinguish between drag and pinch with the GestureRecognizer?
Well, I feel it is very hacky (as most solutions seem to be for a useable WinRT app) but you can create a List<uint> to keep track of the number of pointers that are currently down on the screen. You would have to handle the PointerPressed event on whatever control you are interacting with (Let's say you are using a Canvas) to "capture" the pointers as they are pressed. That is where you would populate the List<uint>. Don't forget to clear the list at the end of the ManipulationCompleted event as well as any event that would fire upon the end of any gestures (like PointerReleased, PointerCanceled, and PointerCaptureLost). Maybe it would be a good idea to make sure the list is cleared in the ManipulationStarted event. Perhaps you can try that and see how that works for you.
In the ManipulationCompleted event, you can check if your List contains exactly 2 elements (PointerIds). If so, then you know it is a pinch/zoom.
Here is what it could look like:
private void Canvas_PointerPressed(object sender, PointerRoutedEventArgs e)
{
var ps = e.GetIntermediatePoints(null);
if (ps != null && ps.Count > 0)
{
this.gestureRecognizer.ProcessDownEvent(ps[0]);
this.pointerList.Add(e.Pointer.PointerId);
e.Handled = true;
}
}
private void gestureRecognizer_ManipulationCompleted(GestureRecognizer sender, ManipulationCompletedEventArgs args)
{
if (this.pointerList.Count == 2)
{
// This could be your pinch or zoom.
}
else
{
// This could be your drag.
}
// Don't forget to clear the list.
this.pointerList.Clear();
}
// Make sure you clear your list in whatever events make sense.
private void Canvas_PointerReleased(object sender, PointerRoutedEventArgs e)
{
this.pointerList.Clear();
}
private void Canvas_PointerCanceled(object sender, PointerRoutedEventArgs e)
{
this.pointerList.Clear();
}
I have been struggling with the same question for a few hours now and it looks WinRT platform does not provide that. What it instead provides is Delta.Rotation and Delta.Scale values in addition to Delta.Translation with the arguments to ManipulationUpdated callback.
If Delta.Rotation is 0 (or very close to zero - because it is a float value) and Delta.Scale is 1 (or very close to 1), you can conclude that a pinch operation is not the case and a drag operation is being carried otherwise it is a pinch operation. It is not the best you can get but it looks it is the only availability for the time being.

SQL stored procedure equivalent to ODS e.InputParamters[] = x?

Morning all, hope everyone is ok.
I have an ODS that uses a combination of query string and Selecting event parameters.
For the ODS, I'd input a paramater in the selection event a la:
protected void oDs_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
e.InputParameters["memberid"] = memberid;
}
How would I do something along the same lines in a SQL data source?
I have tried the following but without success:
protected void SQL_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
e.Command.Parameters.Add(memberid);
}
Can anyone point out, the no doubt stupid, error in my ways?
Any help gratefully received.
Sorted - being lazy - sorry.
Stuck this into the page load event instead : )
sqlSPSuppliers.SelectParameters["MemberId"].DefaultValue = memberid;