How to add /png image and use it as button in C#? - c#

I am currently creating an OS using Cosmos Kit. I have created the GUI, and now I want to add a menu bar. I have created an image of how it should like but I don't know how to add that image to top-left corner and use it as a button. And secondly, add some text to that.
IMPORTANT:
I don't work in Windows Forms Application, so I only program it.
Thanks, Joe.

Related

Dynamic form with resizing in C# .net

As a learning project in C# .net I am re-creating a Gnome 3 plugin for seeing who of the streamers you follow on Twitch is live. I have the settings form done, I am now working on the interface that is viewed from a click on the taskbar.
This is a rough image of what I want the interface to look like. When two or more streamers are live the interface would add another block and resize the form vertically similar to the menu for selecting a Wifi network in Windows.
What would be the best way for me to complete this?
My current thought is to maybe create a custom control and just place those inside a FlowLayoutPanel with some kind of code to change the vertical size of the form to match the added entries. Maybe this can be done without a custom control and be done with code inside a FlowLayoutPanel? I'm not too sure.
Ideally I would also have a click event in the panel for each streamer so I could then open a browser to their channel. A slight highlight would also be a plus (maybe change the background colour based on mouse hover).
Thanks in advance for any suggestions!

How to show animated gif in tree views?

I need to use a blinking icon as an image for a specific item in a tree view. For this, i tried to add an animated gif file including two frames, one including the image and one an empty frame. I could add the image to the image list in designer. But it doesn't blink. I tried to figure out what's the problem, but i couldn't.
Any idea?
Default Windows Form does not support any animation, that's why gif file look like static image, when we use it in windows forms. If you are using windows form, then use timer control to redraw the treeview. Or use integrated wpf content in windows form(my choice)

Creating a slideshow in windows phone 8 without using pivot app

I'm writing a windows 8 app wich basically does nothing when you open it (everything is done in background task and the user doesn't see it) so I need to display a kind of slideshow on the main page of the app just so it looks like something and not just a blank page.
My problem is I can't use the pivot app template, I need to start from a blank template.
So I'd like to know what is the most simple way of doing this ? By the way, I need the slideshow to switch between the images automatically (with a timer that I can set) but the user can switch himself if he wants to
Thank you :)
You say You can't use the pivot app template and want to start using a blank template.
You can however add pivot as a control once you start with a blank template.
If Not using pivot is your aim, then try panorama.
Start from a blank template and add panorama control to it. Panorama can also help you to get a nice sliding effect like in a slideshow.
you can have images in stackpanel and detect Flick Gestures whether left to right or viceversa through HorizontalVelocity of Flick events.

How to create a custom button for Windows Store app?

I want to make a custom button in shape of a picture with C# for a Windows Store App?
Is there a way to do that from xaml? So far I've made a button and assigned a circle as a background image, but the problem is that even if I click outside the image the button works.
Also I do not believe that Image class has an event for click unfortunately.
I just recently implemented the WinRT XAML toolkit and it works wonder for me. It has an imagebutton control that might do what you want to do. http://winrtxamltoolkit.codeplex.com/
With the help of google: Walkthrough: Create a Button by Using XAML
You should have a look into Expression Blend. You can do all manualy in the XAML-Code but Blend is a huge help if you like to customize your project look and feel. Look at the MSDN-Examples.

Embedding Video in a WinForms app

I need to be able to embed and control the playback of an AVI file in a WinForms app, using C#. The video needs to be embedded in the form, not launched in a separate media player window.
What's the best approach to do this? I found the System.Media namespace, which sounded promising, but it appears that is only useful for sound.
Do I use DirectX to do this? MCI? Or some other approach?
You can use Media Player inside your Winform. This would been an easy way to do it.
The way i did it was, and I quote:
Right-click the Toolbox, and click Choose Items.
Note: If you do not see the Toolbox, click Toolbox on the View menu to
open it. The Customize Toolbox Items dialog box opens.
On the COM Components tab, select the Windows Media Player check box,
and then click OK.
The Windows Media Player control appears on the current Toolbox tab.
When you add the Windows Media Player control to the Toolbox, Visual
Studio automatically adds references to two libraries: AxWMPLib and
WMPLib. The next step is to add the control to the Windows Form.
To add the Windows Media Player control to a Windows Form
Drag the Windows Media Player control from the Toolbox to the Windows
Form.
In the Properties window, set the Dock property to Fill. You can do
this by clicking the center square.
Double-click the title bar of the form to add the default Load event
in the Code Editor.
Add the following code to the Form_Load event handler to load a video
when the application opens.
axWindowsMediaPlayer1.URL =
#"http://go.microsoft.com/fwlink/?LinkId=95772";
http://msdn.microsoft.com/en-us/library/bb383953(v=vs.90).aspx
I highly recommend this library:
http://directshownet.sourceforge.net/
It is a .NET wrapper around the DirectShow API.
(The sample apps should get you going very quickly.)
--Bruce
The suggestions from Daok and Brian Genisio are both good options. Let me add a third: DirectShow. Used to be part of DirectX but has now been promoted to the Windows SDK. There are many good C# sample applications to look at, and it gives complete control of the playback.
I would consider using the WPF media controls and just use the ElementHost to put your WPF control inside your WinForms app. I think you will get a much more rich experience.
See System.Windows.Forms.Integration for more information

Categories