Write vertical text using Direct2D's DirectWrite - c#

I want to write vertical text like it is known from a simple chart's y-axis. I found the FlowDirection property which allows me to add the "ToptoBottom" direction but this does not change the text's behaviour.
Is it the only way to rotate the rendertarget by 90 degress, write the text and rotate it back? The problem here is that I also have to recalculate the points for the rotation matrix.
This seems a lot of work just for rotating text? Any better idea?

Im not in front of my computer right now so bear with me. When you are creating the text format you can set the width of the bounding box of the text to the text font size and it should only write one letter per line, giving you vertical text effect that you want!

Related

How to stretch the video completely

I am using axWindowsMediaPlayer and when I make the screen full, video is being shown but the player put 2 black block near side of video. I don't want these blocks.
I tried
axWindowsMediaPlayer1.stretchToFit = true;
but that didn't work. Because my video is 800*600 and my screen 1920*1080, the problem might be. Any way to solve this problem programatically? I don't want to resize video.
Thanks in advance.
AxWMPlayer does not support nonuniform stretching. So, you have to either:
- make the WMPlayer of normal desired size, stretch uniformly (StretchToFit=true) and live with the black margins if they show up
- make the WMPlayer oversized in Height or Width (so that it sticks out of the target space), stretch uniformly (StretchToFit=true). Due to the oversized WMPlayer, some of the video will be trucated (displayed outside of the space) but also the black margins will be truncated
Those two ways will mantain aspect ratio.
If you don't need aspect ratio kept, you may apply some ScalingTransform (WPF) or another similar effect to stretch the view afterwards. You will need to calculate coordinates properly, but the fact that WMP always centers the video and that you can read the video dimensions from IWMPMedia helps much.

DrawString Not Scaling Properly With Transform

I'm essentially re-writing a document viewer with markups to move away from a COTS product and so far everything has been working VERY well. My code is based off of Mark Miller's Extensions to DrawTools (http://www.codeproject.com/Articles/17893/Extensions-to-DrawTools).
The old viewer stores pages and their markups based on x/y coordinates in inches and I have had NO trouble converting this to a pixel-based coordinate system and converting lines, boxes etc to the new viewer. The lines and boxes show up exactly where they are supposed to and have the correct size.
The problem has been displaying text markups, no matter what I do they always end up MUCH smaller than they should be.
I'm doing:
UserControl->OnPaint()
Create a Matrix Transform for:
Scale
Rotate
Translate
Apply Matrix to Graphics Object
Call method that draws the Page Image and then all of the Markups.
I have the X/Y Coords and Font Size of the Text to draw, and the resulting string DOES end up at the correct coordinates but the text is WAY too small. The really bizarre part about this is the original viewer is written in .Net so I know that the Font and Size SHOULD relate especially since everything else scales so well.
Here is an example of what I'm talking about. Please ignore the BackColor and Border of the "This is some Text", I haven't gotten around to getting that transformed yet since I've been so focused on getting the TEXT right.
Original:
My Result:
I ended up having to rework everything to be Inch Unit based. The font simply doesn't have an easy way of scaling between the units and the Inch Unit turned out to be the easiest solution.

XNA Item Tooltip

Im creating a rpg like game, I've made a list of items that contains alot of variables like:
Item type
Name
Weight
ItemID
Dmg
I want so that when you over your mouse over an item, a tooltip will appear telling you all the variables of that item, sorta like WoW and all the other rpg games.
I've been thinking about having a rectangle texture that stays on mouse position and will only be shown when mouse over an item.
Now here comes the part where im having problem. I do not know how to scale the texture depending on the amount of text and variable length of that item, so it doesn't look wired. Also is it possible to use some sort of loop that can loop through all my variables and put them under each other?
Cheers!
/Iskalder
Are you using a Texture (or Textures) for the text or a font to display the text?
For question 1. If you're using a Texture, you can get the height and width pretty easily and adjust the scale of the tooltip accordingly. If you are using a SpriteFont, you can use SpriteFont.MeasureString to get it's dimensions.
For question 2.
As for drawing the items on top of each other, if you are using a SpriteBatch, you can specify how to layer the items in the SpriteBatch.Begin and SpriteBatch.Draw overloads. If you don't mean to layer the variables/items and just want to display them so that they appear "stacked" on top of each other, you can simply specify the origin at which to draw the item in SpriteBatch.Draw and have each subsequent item drawn at a different height (y coordinate).

C# Y coordinate is always offset

I'm a bit stuck with this one.
I'm writing a visual Semaphore flag signalling application, and I'm having a bit of trouble with the positioning of labels for left and right arms.
This is the code before:
private void leftHandDown()
{
display.DrawLine(penLeftArm, centXCoord, centYCoord, LHDownXCoord, LHDownYCoord);
lblLeftHand.Top = LHDownYCoord;
lblLeftHand.Left = LHDownXCoord;
lblLeftHand.Show();
}
And this is what it looks like:
http://i137.photobucket.com/albums/q221/omar319/sema.png (I don't have any rep to post photos on here). I have set the background to blue, as I'm also trying to pin down another problem (labels leave a white box when they change position, not sure why).
I would like the labels to appear at the end of the hands drawn by the pen (end coordinates LHDownXCoord and LHDownYCoord) but the labels are always offset by -80px on the y-axis. The Right Hand label I have added 75px to the Y axis coordinate.
Any idea what is causing the offset?
Cheers,
Omar
I think the labels need to be offset by the top left coordinates of your display control

How to transform an image in a grid both in x-direction and y-direction in c# and wpf?

I am developing a game similar to atomica in C# and WPF. I have a 4*4 grid in which three random images are generated. I must move image from present position to some other position in grid. I have starting position and end position of grid cell number and I have the path through which image or object must move through grid cells.
Here I am not able to animate to move the image first in x-direction for two cells then y-direction for one-cell and then one-cell in x-direction and so-on, so that I am able see the path in which the image is moving.
Please help me guys.
I think this: Improve animation smoothness (moving of controls) is a good solution also with suggetions how to make the animation smooth.

Categories

Resources