So, long story short: I'm writing a POS program, and I have a receipt printer connected and the Windows Forms printing API works great with it, much easier than I expected.
However, searching through the API, it seems that the easiest (or perhaps only) way to programmatically print something is to use the Graphics object inside the PrintPageEventArgs object in the printer's event handling method.
Every overloaded parameter list for the Graphics.DrawXXX() method requires some kind of coordinate pair to use as a reference point for where to start drawing the object passed to it.
So my question is, let's say I want to print some string value, and then an Image. Doing it the other way around (first the Image, then the string) would be easy because the reference point to start drawing the string would be (0, Image.Size.Height). However, since a string does not have a "size" associated with it, what is the best way to go about telling the printer where to start drawing an image after a string has been printed?
Let me know if this is confusing or needs additional clarification.
Related
My question is pretty similar to this one and I'm afraid the answer is the same... I want to save all the shapes/images on a slide as a single png (or jpeg). Programmatically, I get as far as
slide.Shapes.SelectAll();
but don't see a way to save as image. Is this possible? If not, any other suggestions, hopfully w/ examples? (not VBA - I need to automate the whole conversion)
There was a reference to OpenXML in the other post, but I'm not even sure how to pull that in.
I don't know how you'd do this in C# but I'd guess that you'd make use of the same methods as you would with VBA, where you can do:
Activewindow.Selection.ShapeRange.Export( "c:\temp\delete-me.jpg",ppShapeFormatJPG)
ppShapeFormatJPG is a PowerPoint constant, a VBA Long = 1; IIRC that'd be an Integer in C#.
The method also can take two more optional parameters, scalewidth and scaleheight, which govern the width and height of the exported image in undocumented ways. By default, no parms supplied, I get exports at 72 dpi. Larger numbers result in higher pixel count exports but distorted proportions. I'm sure there's some strange logic to it, but it escapes me; all hints welcome!
There's a third optional parm, ExportMode. In my tests, it makes no difference whether you supply it or not, and if you do, which of the available values you choose.
How do you call this method on Nvidia GPU:
NVAPI_INTERFACE NvAPI_GPU_SetEDID (
NvPhysicalGpuHandle hPhysicalGpu,
NvU32 displayOutputId,
NV_EDID * pEDID
)
Src: http://docs.nvidia.com/gameworks/content/gameworkslibrary/coresdk/nvapi/group__gpu.html#ga6a41b31dd9743120213435d985f8fbcf
I need to execute the above command to remove all EDID set on all DisplayOutputs on our new Quadro Graphics Cards. Based on the API documentation, I tried searching for NvPhysicalGpuHandle and came across this project/library:
https://github.com/openhardwaremonitor/openhardwaremonitor/blob/master/Hardware/Nvidia/NVAPI.cs
This does not have the method I need NvAPI_GPU_SetEDID
I am not hardware programmer, I just need to be able to call this one command. any ideas? Can this be achieved using nvapi.dll/nvapi64.dll via pinvoke or something?
I personally didn't test this, but you can try the library and see if it can set EDID information without any problem, if it fails, please open an issue.
https://github.com/falahati/NvAPIWrapper
Here is how you should do it,
First, you need to find the right DisplayDevice or GPUOutput that you want to write EDID information to. There are multiple ways to do so.
Get a list of all PhysicalGPUs in the system using the NvAPIWrapper.GPU.PhysicalGPU.GetPhysicalGPUs() static method, then select the PhysicalGPU you desire based on your logic. After finding the right PhysicalGPU, use the NvAPIWrapper.GPU.PhysicalGPU.GetDisplayDevices() method to get a list of all connected DisplayDevices to that GPU and store the right one in a variable.
Instead of searching for connected DisplayDevices, you can also go for the GPUOutputs. Just like before, you first need to find the right PhysicalGPU and then you can get a list of all GPUOutputs using the NvAPIWrapper.GPU.PhysicalGPU.ActiveOutputs property and store the right GPUOutput in a variable.
Another way to find the right DisplayDevice is to go for a list of all Displays. To do so, you need to use the NvAPIWrapper.Display.Display.GetDisplays() static method. This returns an array of Displays. Then using the NvAPIWrapper.Display.Display.DisplayDevice property, you can get the corresponding DisplayDevice of a Display.
After finding the right DisplayDevice or GPUOutput, you should use the NvAPIWrapper.GPU.PhysicalGPU.WriteEDIDData() method. This method allows you to write EDID data stored in a byte array to the DisplayDevice or the GPUOutput you selected before.
Note: Make sure to capture NVIDIAApiException and check for the NVIDIAApiException.Status property in case something went wrong.
I am writing app (Windows Phone 8.1 Store App) that allows user to connect to IP Camera. I am using FFmpeg Interop library for ffmpeg which allows me to play eg. rtsp streams in media element. I need now a way to somehow extract a single frame from stream or from media element.
I have tested other application wchih allows connecting to IP cameras - IP Centcom, and they have working snapshots only for mjpeg streams as far as I now (they were not working for rtsp). Becouse of that I belive that it is impossible or at very least very hard to export frame from media element.
I have different question - if anyone has ever used FFmpeg Interop and would like to help/explain me how could I modify/extend FFmpegInteropMSS to add method called 'GetThumbnailForStream' that would work similary to 'GetMediaStreamSource' but would return single frame (bitmap or jpg) instead of MediaStreamSource?
Every help would be appreciated
EDIT:
I have found something;
in MediaSampleProvider in method WriteAVPacketToStream (line ~123) there is line
auto aBuffer = ref new Platform::Array<uint8_t>(avPacket->data, avPacket->size);
and I belive that this is the place that stores single frame data that is needed to convert into bitmap - now since I do not know c++ too much I have a question : how can I convert it into a form that I could return via public method ?
When returning:
Platform::Array<uint8_t>^
I get
'FFmpegInterop::MediaSampleProvider' : a non-value type cannot have any public data members
EDIT2:
Ok I am doing approprate projection to byte according to this microsoft information, now I need to check if this is correct data.
I am wanting to know if there is a methodology to feed calculated values to a built-in Revit command from inside a C# program, and then possibly (based on results, such as whether this makes an element too short or too long for a known "maximum span" of a particular beam) continue with my C# program and change the beam size). I am told you can invoke the Revit built-in command after execution of your c# external command, but you cannot then return to the c# program
As another example, I want to select an element to trim/extend to, and have the code figure out which "Joist" beams to extend to this element. My program would do extended filtering (such as "Reference Level", or "Workset", or "Comments", or "Mark" parameters (etc.)) and then run the built in function, providing the element to extend to and then each of my beams.
I've tried internet searches, as well as the Revit SDK samples, and nothing obviously used this (but there are a lot of csproj's to look through).
Can anyone verify that you cannot go back and forth between the C# program and the Revit built-in command?
You can programmatically invoke a built in Revit command with the UIApplication.PostCommand() method. Refer to documentation and building coder for more information. It will not execute until after the API context is over, however.
I don't think you'll be able to feed arguments into the command however, short of some kind of Win32 hack. Perhaps you will need to recreate the functionality of the built in command within the Revit API.
Unfortunately, I don't think we can do (command "_line" pnt1 pnt2) type of thing here.
Perhaps start with the SDK sample "MoveLinear". It shows how to modify end points of linear elements (which includes beams).
The main part of the sample's code is
Autodesk.Revit.DB.Line line;
//get start point via "get_EndPoint(0)"
Autodesk.Revit.DB.XYZ newStart = new XYZ(
lineLoc.Curve.GetEndPoint(0).X + 100,
lineLoc.Curve.GetEndPoint(0).Y,
lineLoc.Curve.GetEndPoint(0).Z);
//get end point via "get_EndPoint(1)"
Autodesk.Revit.DB.XYZ newEnd = new XYZ(
lineLoc.Curve.GetEndPoint(1).X,
lineLoc.Curve.GetEndPoint(1).Y + 100,
lineLoc.Curve.GetEndPoint(1).Z);
//get a new line and use it to move current element
//with property "Autodesk.Revit.DB.LocationCurve.Curve"
line = Line.CreateBound(newStart, newEnd);
lineLoc.Curve = line;
Which moves the X of the first point and the Y of the second point 100 feet.
you can try:
RevitCommandId commandId = RevitCommandId.LookupPostableCommandId(PostableCommand.PlaceAComponent);
commandData.Application.PostCommand(commandId);
I'm looking at libvlcnet 0.4.0.0 "SimplePlayer" example from http://sourceforge.net/p/libvlcnet/wiki/Home/ and I want to ask if is it possible to to open new file and play it from predefined position without needing to play the start of the movie? I use something like this:
LibVlcInterop.libvlc_media_player_play(descriptor);
LibVlcInterop.libvlc_media_player_pause(descriptor);
LibVlcInterop.libvlc_media_player_set_position(descriptor, (float)0.8);
int res = LibVlcInterop.libvlc_media_player_play(descriptor);
When trying to play new file user can notice small fraction of the beginning of the movie.
How can I position player to particular area after I load new file without showing small portion of the beginning of movie?
I don't know about that particular library, but you can do this generally by passing "media options" before you play the media. To do this use the LibVLC API function libvlc_media_add_option.
If you can do this in that library, then you can specify a start time and/or an end time - but it has to be specified as seconds rather than as a percentage position.
The options you would pass to the API function would be:
:start-time=30
:stop-time=60.5
You can actually pass fractional seconds as shown in the stop-time example.
When I do this, I do not notice any flash of content showing the beginning of the movie but I suppose that still might happen on some platforms or with some types of media.