In WMP, I have been shown buttons on the taskbar thumbnail. How can I make them for my winforms app in C#?
The WindowsAPICodePack contains a control called ThumbnailToolBarButton that you can use to get this functionality going.
You'll need to make sure you have icons for each of the buttons (as I don't believe you can put text on them), and then it should be a simple matter of creating new controls and adding relevant event handlers.
Sourced from here.
XAML
<Window.TaskbarItemInfo>
<TaskbarItemInfo>
<TaskbarItemInfo.ThumbButtonInfos>
<ThumbButtonInfo ImageSource="/IconProgressDemo;component/Icon1.ico" Description="Play!" Click="ThumbButtonInfo_Click" />
<ThumbButtonInfo ImageSource="/IconProgressDemo;component/Icon2.ico" Description="Stop!" Click="ThumbButtonInfo_Click" />
</TaskbarItemInfo.ThumbButtonInfos>
</TaskbarItemInfo>
</Window.TaskbarItemInfo>
C#
private void ThumbButtonInfo_Click(object sender, EventArgs e)
{
MessageBox.Show((sender as System.Windows.Shell.ThumbButtonInfo).Description);
}
I haven't tried this hope this will be helpful.
and refer these links.
http://www.zayko.net/post/Adding-Buttons-to-Window-Thumbnail-in-WPF-4-for-Windows-7-(C).aspx
http://msdn.microsoft.com/en-us/windows7trainingcourse_win7taskbarmanaged_topic2.aspx
http://msdn.microsoft.com/en-us/magazine/dd942846.aspx
and there is Taskbar API available you can try with that.
Related
I have made an app that implements a hub control and on the app there is a way to add information on the top.
Each time information is added it would be added to a textblock on the bottom part of the page. The problem is when the textblock gets filled up and goes off the page. The hub section isn't scrollable and the information cant be seen.
Is there a way to make a hub section scrollable as more information is added to a textblock? This is what my code looks like now for the add button event.
private void abtnAddHours_Click(object sender, RoutedEventArgs e)
{
string hoursData;
hoursData = string.Format("{0}:{1}\n{2:d}\n\n", tbHours.Text, tbMinutes.Text, dtpkrHoursDate.Date);
txtblkHoursData.Text += hoursData;
}
any help is appreciated thank you so much.
Wrap your controls inside <ScrollViewer />
https://msdn.microsoft.com/en-us/library/ms750665%28v=vs.110%29.aspx
https://msdn.microsoft.com/en-us/library/windows/apps/hh202907%28v=vs.105%29.aspx
I am working on an alternative browser for Internet Explorer Mobile on Windows Phone. My problem is that I also want a progress bar displaying how far a page has loaded just like Internet Explorer mobile has but I cannot find any property or event on the WebBrowser control that tells me how far a page has loaded. Is there something that I can do?
PS. This project is mainly for Windows Phone 8 so some WP 8 exclusive apis can be used but WP7 support would also be nice.
A loading bar is as simple as determining the total number of kb's to be downloaded at the start of the request and then updating the progress bar with the current downloaded kb's (as a percentage).
Luckily, you can just add a progressbar like this:
<ProgressBar Foreground="Green" x:Name="ProgBar" Visibility="Collapsed" IsIndeterminate="True" Height="10" HorizontalAlignment="Left" Margin="10,66,0,0" VerticalAlignment="Bottom" Width="460" />
You then need to modify your main page.cs to incorporate the event:
void Browser_Navigating(object sender, NavigatingEventArgs e)
{
ProgBar.Visibility = Visibility.Visible;
}
void Browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
ProgBar.Visibility = Visibility.Collapsed;
}
You can read how this all works ON THIS LINK. (This link shows a tutorial which will exactly explain to you how to accomplish this progress bar)
What you could also do is make use of the Windows phone 8 Progress Indicator as they do in this example.
Mind you that in general, in C#, (or any programming language) you can ask for the total number of kb's (e.g. with WebClient) like this. Then you could write a timer that checks the current amount of downloaded kb's and update the progress bar every 0.x seconds.
I hope that helps you out. Good luck!
Update
If you search for page loading bar c# you get multiple useful links that show you how to build a loading bar for a webbrowser.
For example:
http://code.msdn.microsoft.com/wpapps/Custom-Indeterminate-833d783d
http://github.hubspot.com/pace/docs/welcome/
How to make progress bar works while web browser navigating?
How to show progressbar until WP8 WebBrowser control loaded the URL?
But especially this one could be very useful:
http://tekkieblog.com/develop-simple-web-browser-with-progress-bar-using-csharp/
It states that you can use the built-in Status Strip control to get the required loading bar. The step to windows phone shouldn't be all that big from this C# snippet.
The proposed method is:
This simple Tutorial will help in adding up a Progress Bar to your Web browser using C#. In the design view, drag and drop the Status Strip control from the Tool box. The Status Strip control will be displayed at the bottom of your Form. Select the Status Strip control on the form. Click the Drop Down list and select Progress Bar. The progress bar control will be displayed in your Form.
Right click the Web Browser Control in the design mode and select Properties and then select events in the Properties window and move to Progress Changed event and double click it. Add the following code snippet:
private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
ProgressBar.Maximum = Convert.ToInt32(e.MaximumProgress);
ProgressBar.Value = Convert.ToInt32(e.CurrentProgress);
}
So what they basically do is convert the current progress to a number such that you get control over the percentage.
You can also do it differently:
I HIGHLY RECOMMEND you watch this link: http://www.youtube.com/watch?v=KHQCtunR2QI
That video must definitely answer your question!
void Browser_Navigating(object sender, NavigatingEventArgs e)
{
ProgBar.Visibility = Visibility.Visible;
}
void Browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
ProgBar.Visibility = Visibility.Collapsed;
}
you have to collapse visiblity of progressbar for more events
navigation_failed event
browser loaded event not navigated event
App I am trying to create in WPF/C# has quite a few buttons in a layout with a "TV screen" type panel above (its actually an FMS emulator for commercial aircraft). Many of the buttons change the layout, which are numerous TEXTBOXs on the tv screen. My question is: is there a provision to encapsulate the layouts in different classes/files and load them into the "tv screen" at the selection of the various buttons? In other words, user hits the Flight Plan button and the layout of the 355x355 box (screen) above loads the XAML "flight_plan" layout/file/class. Each layout has different TEXTBOX sizes & locations and there are in excess of 30 different "pages", which would make encapsulating them desirable.
I am very new to WPF and c#, but have written win apps in c++ all the way back to Turbo C & OWL. I also may be trying to do something that isn't possible due to working lately in Android/Java and am confusing capabilities.
Thanks in advance.
Edit
Thanks to #adityaswami89 and everyone else who got me on the right track, I have found the solution. I added the pages via a new "WPF Page" in VS2012. Then changed the "screen" to a navigation frame and it was truly simple from there. Below is the simple project I created to test it.
public partial class MainWindow : Window
{
NavRad navrad = new NavRad();
FPlan fplan = new FPlan();
public MainWindow() {..}
private void Frame_Navigated_1(object sender, NavigationEventArgs e) {..}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Screen_Frame.Navigate(fplan);
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
Screen_Frame.Navigate(navrad);
}
You can also use the concept of Frames for the intended functionality , if that can be an option you are looking.
You can refer the below link for the same.
http://msdn.microsoft.com/en-us/library/ms750478.aspx#Frame_in_Standalone_Applications
You can abstract the different UI Layout Sets within different User Controls and load them according your UI logic. One way to do this is using an MVVM framework, for example, Caliburn Micro makes this a pretty simple task as doing:
ActivateItem(UILayoutViewModel);
And this call can be called from any method.
See more of Caliburn Screens and Composition at official source.
Ok, I have the following problem:
I would like to scroll an overflowing ListBox up and down.
I would like to do it programatically in a custom control inheriting from ListBox. I've seen and tested things such as scrollIntoView. However I would like to have a scrolling similar to what you can have when using the mouse's wheel.
I don't want to have the mouse involved at all (I'm developing for the Kinect, and since there are 2 cursors, I don't want to use the Mouse event args)
a google search didn't turn up much: I've read plenty of thread on how to scroll in code behind using scrollIntoView, or putting a scrollbar and such.
I think this will involve two steps:
Find the scrollViewer control inside listBox template
Perform the actual scrolling in that scrollViewer
For the first step implementation please take a look here. Here is the code snippet extracted from there:
this.Loaded += MainWindow_Loaded;
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
var scrollViewer = listbox.Template.FindName("Scroller", listbox);
}
And for the second step you should use one of the methods from here, LineDown or PageDown probably.
P.S.: I haven't tested this approach at all since I do not have VS installed so feel free to add the needed code here.
I'm attempting to use the ScintillaNET control in an application I am working on. I drag and drop the control into my form and run form. The control appears on the form. This is good. In addition, if I set any of the properties in the control's properties editor (ConfigurationManager.Language, for example), I am able to type in that language and see syntax highlighting occur.
Where I run into problems is when I attempt to change properties programmatically. For example, I attempt to load text from a file into the form (I'm doing this in the form's Load). The text doesn't display. I also can't seem to show the line numbers or do any other number of tasks (including programmatically change the Language).
Any idea what I may be doing wrong? Even something as simple as the code below doesn't seem to work:
private void scintilla1_Load(object sender, EventArgs e)
{
scintilla1.ConfigurationManager.Language = "xml";
}
Simply add scintilla1.ConfigurationManager.Configure();
private void scintilla1_Load(object sender, EventArgs e)
{
scintilla1.ConfigurationManager.Language = "xml";
scintilla1.ConfigurationManager.Configure();
}
After spending some time playing around with the different events, it appears that I cannot affect the Scintilla control until after it is already visible. Hence, the "Load" event does not let me make any programmatic changes to the control until I've set it visible.
It's a little strange, and seems sort of pointless to me to have the Load event at all, but I just wanted to let everybody know what is happening in case someone else ran into the same problem.