Writing to the Windows 7 "preview" window area - c#

How can I write or draw controls to the Windows 7 preview area using C#? For an example of what I am talking about, open Windows Media Player in Windows 7 and play a song. While the song is playing, minimize Windows Media player, then hover your mouse over the Windows Media Player icon and you will see a pause, rewind and fast forward button just below the actual Media Player preview window. How can I duplicate this kind of behavior in C#?

You're looking for Windows 7 Thumbnail Toolbars:
Thumbnail toolbars provide a mini
"remote-control" opportunity for a
window from its thumbnail. For
example, to switch to the next song in
Windows Media Player you don't need to
use the clumsy Media Player desk band
or to switch to the Media Player
application. Instead, you can use the
thumbnail toolbar directly to perform
this task, without interrupting your
work flow by jumping to another
application.
Copied shamelessly from that MSDN article:
//In your window procedure:
switch (msg) {
case g_wmTBC://TaskbarButtonCreated
THUMBBUTTON buttons[2];
buttons[0].dwMask = THB_ICON|THB_TOOLTIP|THB_FLAGS;
buttons[0].iId = 0;
buttons[0].hIcon = GetIconForButton(0);
wcscpy(buttons[0].szTip, L"Tooltip 1");
buttons[0].dwFlags = THBF_ENABLED;
buttons[1].dwMask = THB_ICON|THB_TOOLTIP|THB_FLAGS;
buttons[1].iId = 1;
buttons[1].hIcon = GetIconForButton(1);
wcscpy(buttons[0].szTip, L"Tooltip 2");
buttons[1].dwFlags = THBF_ENABLED;
VERIFY(ptl->ThumbBarAddButtons(hWnd, 2,buttons));
break;
case WM_COMMAND:
if (HIWORD(wParam) == THBN_CLICKED)
{
if (LOWORD(wParam) == 0)
MessageBox(L"Button 0 clicked", ...);
if (LOWORD(wParam) == 1)
MessageBox(L"Button 1 clicked", ...);
}
break;
}

Since this had the C# tag I'm guessing you would like to do this in managed code. Take a look at the Windows API Code Pack which includes samples of live thumbnails, thumbnail buttons, clipped thumbnails, tabbed thumbnails etc. It is thumbnail buttons that you are looking for and two or three lines of code will take care of it.
BTW, the preview area is what you get in Windows explorer when you select say a .txt file and can see the content to the right. Most office files have previewers and you can write your own too.

Related

Icons in FreshTabbedNavigationContainer tabs bar are giant in IOS

I am trying to show 4 icons for 4 tabs in the bar of my FreshTabbedNavigationContainer using FreshMVVM and Xamarin.Forms of course, they look as they should when I execute the app on an Android emulator, but when I use my Mac and emulate the app on an IOS emulator, these icons become gargantuan, just as you see in this picture.
Here is my code:
FreshTabbedNavigationContainer Code:
private static FreshTabbedNavigationContainer TabbedPageContainer = null;
TabbedPageContainer = new FreshTabbedNavigationContainer(navigation.ToString());
Products = TabbedPageContainer.AddTab<HomeViewModel>(null, "IconHomeInverted.ico", null);
Discover = TabbedPageContainer.AddTab<HomeViewModel>(null, "IconMagnifyingGlassInverted.ico", null);
Account = TabbedPageContainer.AddTab<HomeViewModel>(null, "IconUserInverted.ico", null);
Settings = TabbedPageContainer.AddTab<HomeViewModel>(null, "IconSettingsInverted.ico", null);
#region UI
//Dissables swipe only in android because in IOS can not be done
TabbedPageContainer.On<Xamarin.Forms.PlatformConfiguration.Android>().SetIsSwipePagingEnabled(false);
TabbedPageContainer.BarTextColor = Color.FromHex("#FFFFFF");
#endregion
page.CoreMethods.SwitchOutRootNavigation(navigation.ToString());
My icons are located in "MyProject.IOS", they are not in the resources folder or anything like that.
That is all, if you need more information I will provide it as soon as I see your request. I hope all of you have a great day.
Ok, I solved it, my icons were 500x500 aprox, on Windows, visual studio or fresh MVVM resize the image to fill the tabbed bars; this does not happen on Mac, so they were showing their actual size, I resized them to 38x38 and now they look like what I was looking for.
The iOS "Human Interface Guidelines" have suggested sizes for the custom icons in the Navigation Bar.
These sizes go from 24px to 28px for the #1x scale factor meaning that for the other scale factors we will have something like:
24px
48px#2x
72px#3x
28px
56px#2x
84px#3x
Of course, you are capable of adjusting these numbers to keep consistency across your application.
More information about this here
Hope this helps.-

Testing swipe on responsive website using Selenium Webdriver C#

I'm trying to test a swipe across an image gallery on a responsive website. On a mobile device it would be a finger swipe, using a desktop browser it functions the same with a mouse click/hold/drag. It's the desktop browser functionality I'm trying to replicate.
The code I have is:
Driver.Navigate().GoToUrl(Properties.Settings.Default.TestPage);
var mainImage = Driver.FindElement(By.CssSelector(".main-image"));
var imageAcross = (mainImage.Size.Width / 4 ) * 3;
var imageDown = mainImage.Size.Height/2;
var builder = new Actions(Driver);
builder.MoveToElement(mainImage, imageAcross, imageDown).ClickAndHold().Build().Perform();
TakeScreenshot(TestContext.CurrentContext.Test.Name);
builder.MoveByOffset(-imageDown, 0).Release().Build().Perform();
TakeScreenshot(TestContext.CurrentContext.Test.Name);
The TakeScreenshot function, as the name suggests, saves a screenshot. I take one before and after the move.
The first builder.MoveToElement places the cursor where I would expect and after the builder.MoveByOffset the cursor has moved as expected. However the swipe didn't change the gallery image. It's as if the ClickAndHold was ignored.
The CSS element .main-image is a div tag that has Javascript attached that changes an image within it on the swipe. The browser I'm using for testing is PhantomJS.
Is there something I am doing wrong? Or any suggestions on how to get the swipe to work?

Blank or Wrong Picture from EMGU capture

I am developing a windows service which processes video input and sends results of interest to a separate platform. I do not need to display the frames in this context. I am having a problem getting the correct camera input.
I want to save a Bitmap resulting retrieved from am EMGU capture object. To make sure that the capture is actually reading the video stream, I save the bitmap to a file, as follows:
Mat frame = mCapture.QueryFrame();
Template = frame.Bitmap;
Template.Save("frozen.jpg");
The capture is initialized as follows:
CvInvoke.UseOpenCL = false;
int index = int.Parse(ConfigurationManager.AppSettings["Index"]);
mCapture = new Capture(index);
One test platform is a Lenovo laptop running 64-bit Windows 10, with a built-in camera and a second camera attached through a USB port. The input of interest is the second camera. However, whatever index I use to open the Capture object, the input comes from the built-in camera.
The other platform is a Meego Pad, running 32-bit Windows 10, with the same camera attached. In this case, I simply get blank frames as video input. For both platforms, running the camera application shows the video input as expected. What is the problem with my initialization of the Capture object?
Further Investigation Shows...
First, I was using the wrong index to create the capture, so that created some of the confusion. But more confusion follows.
When I call the QueryFrame() method in an event delegate, as shown in this simple example I successfully retrieve the frame from the camera. Example code looks like this:
Application.Idle += new EventHandler(delegate(object sender, EventArgs e)
{ //run this until application closed (close button click on image viewer)
viewer.Image = capture.QueryFrame(); //draw the image obtained from camera
});
viewer.ShowDialog(); //show the image viewer
When I call the same method in a different thread (in response to a communication event) I get an empty image. On the gripping hand, when I call the method in a timer callback, I get the correct image.
I won't call this closed, because I would still like to know why QueryFrame() acts correctly in some threads, but not in others. However, I can work with this, so the question is now mostly academic.

Windows 8.1 application and Top vs. Bottom edge gestures

I'm implementing windows 8.1. application and I'd like to show some menus on edge gestures. On top edge gesture Menu A and on bottom gesture Menu B. I found out that it is probably not possible.
In following code
void EdgeGesture_Completed(object sender, EdgeGestureEventArgs e)
{
if (e.Kind == EdgeGestureKind.Touch)
{
Scenario1OutputText.Text = "Invoked with touch.";
}
else if (e.Kind == EdgeGestureKind.Keyboard)
{
Scenario1OutputText.Text = "Invoked with keyboard.";
}
else if (e.Kind == EdgeGestureKind.Mouse)
{
Scenario1OutputText.Text = "Invoked with right-click.";
}
}
we have possible to recognize if top/bottom menu is invoked by Touch, Keyboard or Right click but EdgeGestureEventArgs doesn't contain any other info.
Do you have any idea how to recognize edge gestures? I mean, if it is Top or Bottom edge gesture.
The standard behaviour is to show both the top and the bottom together. If you use the built-in AppBar control then you'll get this automatically.
If you want to separate the top and bottom app bars then it's trickier and you'll need to implement that yourself. There isn't any direct way to tell if edgie was triggered from the top or the bottom, but you can track PointerEvents and if the EdgeGestureKind isTouch then you can guess based on the pointer location.
There is no difference if edgie was triggered by keyboard or mouse since those gestures aren't location dependant.
Also note that the standard appbar and charms behaviour is different in the Windows 10 Technical Preview than on Windows 8.1, so if you implement it yourself your app's behaviour may end up farther from standard than you intend.

Synchronous sound playback from video source in VideoSourcePlayer control

I'm using the Video Source Player control from AForge.Controls to play a few video clips within a winforms application.
The code is something like this.
string fileName = #"C:\path\to\file.example";
videoSourcePlayer.VideoSource = new AForge.Video.AsyncVideoSource(new FileVideoSource(fileName), true);
videoSourcePlayer.Start();
The video file includes both audio and video streams, however as far I'm aware the control only handles video and not audio.
How can I then play the audio stream in a synchronous fashion with the video source player control?
Thank you.
EDIT:
The Video Source Player control has a event named NewFrame, which allows to determine the precise video position which could be useful to keep the audio being played synchronized with the video.
Since you mentioned:
I'm only looking for other alternative in which is possible to
reproduce the audio contained the video file and somehow keep it
synchronized with the video player control...
Maybe you can have a better luck by using a ElementHost and using WPF media control.
If this solution is eligible for you follow this steps:
Create a new WPF UserControl and add to your WindowsForms app.
In this UserControl add a media element and configure the way you want.
Build the solution.
Now in the toolbox must appear YourSolutionName Controls and you controls must be there.
Just drag it to your WindowsForms app and it must create an ElementHost.
I've created the UserControl as follow:
<MediaElement Name="VideoMediaElement"
Source="Media/Wildlife.wmv"
LoadedBehavior="Manual"/>
Just remember in this example this file must be side-by-side with your app in a Media folder. If you miss this step it will give you the strange and not helpful error 0xC00D11B1.
The loaded behavior Manual will give you the chance to control de video more freely.
After that you can do whathever you want in this UserControl like create Play and Pause:
internal void Play()
{
this.VideoMediaElement.Play();
}
And to access them in WindowsForms do this:
private void WindowsFormsButton_Click(object sender, EventArgs e)
{
var videoControl = this.MyElementHost.Child as VideoUserControl;
videoControl.Pause();
}
Hope this helps. WPF MediaElement is much more easy to seach for than other libs.

Categories