Scenario- I have a website that tracks/manages data stored in a DB(I know this covers 90% of websites :)). I have users that need to print specialized labels and barcodes. The app will need to print to a specialized Zebra RFID printer as well as a specific printer for bar codes. All users must use IE 7. Only 3-4 users will print these items. I want to give the user a button they press and then the barcodes/reports are just printed.
Question-
I can create all the files that need to be printed on the server but can I use an XBAP to automate the specialized printing? If not is there any other way?
Access to special hardware from within Internet Explorer is not always easy - even for something as basic as a printer. You can try using the built-in printing facilities of IE7 - but you are likely to run into formatting and layout problems when printing something like barcodes.
XBAPs run an a sandbox and have limited access to hardware as well - but you may be able to print from one - it all depends on whether you need access to any Win32 print or device APIs.
A gauranteed way to implement something like this is using an ActiveX control - but that a much more complicated thing to implement - and it will only work on Internet Explorer - and on a machine that is configured to allow ActiveX controls to run.
Related
ASP.NET 4.5, c#, VS2013
I have a windows form application in c#. The application creates a pdf and I wanted to print it to a specific printer.
I could do:
axAcroPDF1.printWithDialog()
and user selects a printer from the list.
But my users do not like this at all. The preferred printer in this case is way back in the list and they want this to be the default printer for this program only.
I am not able to see a default printer like property in axAcroPDF and I do not know how to set the default printer for this windows application only.
Please advise an optimum solution. I did not expect this to get so complicated.
Thanks,
I don't think you can set the default printer per application, only per user. (I'm all ears if this is not the case!)
You could try programmatically getting the default printer, setting it to what you require, and then setting it back to its original value once you're done with your PDF. You can accomplish this with the Windows API using SetDefaultPrinter and GetDefaultPrinter.
You'll need to know how to make Windows API calls from C#. Have a look at pinvoke if you're not sure where to start.
I'm attempting to put together a telnet client for wp7 mango, so I can play some muds on my dev phone. I am having difficulty finding a decent open source terminal emulation library that will work for Silverlight (mango is roughly equivalent to the sl 4 stack). I see amuse, but that was written for wpf and sl doesn't seem to have that flow layout control it uses to display the telnet console. Any suggestions? I am already able to connect to a telnet server and get a two way stream, but of course i get mostly garbage without term emulation.
Edit: I ended up implementing my own ascii escape code (a sub-set of VT100 essentially, with unsupported options parsed but ignored) and telnet server command parsing engine (it wasn't as difficult as I thought it would be), and also my own rendering code using the RichTextBox control, which was necessary due to limitations of silverlight on the phone which aren't there in either silverlight for the browser or WPF in windows.
You could try to contact Stefan Olson, who implemented a FlowDocument Viewer for Silverlight (unfortunately he didn't have time yet to clean it up and release the code):
http://www.olsonsoft.com/blogs/stefanolson/post/Introduction-to-FlowDocument-for-Silverlight.aspx
Are you asking for a technical layout, or a complete component? In regards to the flow layout, all you need is to represent text, so a StackPanel with TextBlock's in should work just fine.
A TextBlock can support multiple Run elements, which pratically gives you a flow-layout.
Either way, for a phone you should look into customizing the UI to suit your needs, rather than expecting a component to do it for you. If there was a component for it, there most likely would be a app for it, and then there wouldn't be a reason to write another app for it, would there now?-)
I ended up implementing my own terminal emulation/telnet negotiation code from scratch.
I would like to know if it is possible to mute only a specific window. For example I have got Firefox open and two more windows. I want to mute everything related to Firefox but not the whole sound of my computer.
Is this possible? If so, how can it be done?
look, basically, there isn't any relation between the window handle and the sound which something in its code is playing.. the audio card can't tell who wants it to play.
theoretically, there is an option to do what you want on web browsers, but it's not easy, and not 100%. it goes like this:
most of the audio that is playing from browsers are from known objects like wmp/quick time/vlc/flash/etc..
when the user will choose to mute all audio from firefox, your application will search those known objects in the firefox tabs, and mute/unmute them using their api.
in order to do that, you will need to write an extension to firefox, so you could have an access to the tabs memory from your application.
btw, what os?
and check this out: http://www.indev.no/?p=projects#flashmute (flashmute) i believe it does what is said - only for flash.
On Vista/Windows 7:
I expect there to be some API which can change the volume on a per process basis which the audiomanager uses. Should be relatively straight forward to use.
On XP
I don't think there is any built in functionality for what you want to do. I recommend just not offering that feature on XP. But if you really want to, there are some hackish solutions:
Usermode API hooking. Intercept the calls to audioapis with your own functions. These change the volume or manipulate the audiosignal so you get what you want. You need to do this differently for any of the several available audio-apis. I guess DirectSound and DirectShow are particularly annoying. And this requires injection of a dll into any process you want to manipulate. And this dll better not require the .net runtime. Search for IAT(import address table) or EAT(export address table) hooking.
Kernel mode audio hooking. Write a driver which intercepts the audio in the kernel and changes it on a per process basis. No clue how to do that.
But as you can see both solutions aren't good.
If I understand it right, a printer is also a file from the operating system's view. Can I get a .NET C# FileStream type for a printer? It seems wild to do this.
Thanks in advance.
A printer is modeled in Win32 as a set of bitmaps. This is wrapped by the PrintDocument, which basically sets up a callback that lets you draw each page individually and sends them one by one to the printing spooler which then sends the data (in .ps format usually) to the printer.
This is how modern printers operate, they draw pages, not text. Only the old school matrix printers drew text character by character, in a stream-like fashion. They used to use the "PRN:" special file. This has lost all meaning in a modern environment however.
The good news is, it's really easy to work with the PrintDocument class, you get a Graphics object for each page that you can use to print text anywhere on the page, as well as draw graphics.
You can simulate a stream-like printer if you so wish by caching all the data then just calling DrawText for every page.
Building a Windows Forms application, you can think of a printer as a Graphics Device.
The System.Drawing.Printing namespace provides print-related services for Windows Forms applications.
If you want to print from a Windows Presentation Foundation (WPF) application, see the System.Printing namespace. It provides classes that enable you to automate the management of print servers, print queues, and print jobs.
Assuming that you want to send the raw data to printer, please see How to send raw data to a printer by using Visual C# .NET
Since .Net 3.0 you can, by using the
PrintSystemJobInfo.JobStream
When you create a printjob in the spooler, e.g.
var job = LocalPrinter.GetDefaultQueue().AddJob();
You can write to the
job.JobStream
Closing that stream queues it for printing.
Interestingly, you can use that stream to write control codes and text to a generic/text-only printer (e.g. LPT1 parallel port impact printer)
Using ExternalInterface in AS3 is it possible to call OS (C#?) functions within XP?
Example: Set the desktop background to a image supplied by a flash app?
If it is possible would it be different calls when applied to different OS. And what about cross over the Mac?
Any information would be great
Thanks
If you're launching the swf from within a C# app, external interface will do just fine. Nothing will change on the flash side, but you'll need to go through a couple hoops to get it to work in C#. It's not as simple as AMF or External Interface to JS.
All the communications to C# get converted to XML describing the data, and you've gotta write XML to send back to flash. Other than that though, its relativly simple.
Here's some info on how to do it. The AS portion is Flash 8/AS2, but the C# portion should say the same.
When working with Flash from a webpage or as a desktop app, you are limited to a small security sandbox and you will not be able to make any relevant OS call. I thought that switching to AIR would give the developper more flexibility but it doesn't seem correct either. From "The Pros and Cons of Adobe Air":
AIR apps have
file access, clipboard access, support
multiple windows, support drag and
drop, and can trigger notifications
(toast in Windows). If you app needs
to interact with the desktop in other
ways, the chances are that AIR is not
suitable. For example, there is no
access to COM automation, and no way
to execute external applications. The
reason is to maintain cross-platform
compatibility. That's a worthy goal,
but it would be good to have a way out
of the sandbox. Unlike Java or .NET,
you cannot extend AIR with custom
native code libraries. Nor can you
call operating system APIs.
As Alex Jillard commented, if your swf is called inside a C# desktop application, you should be able to access more OS funcionalities although I'm not sure how.
You could use as already mentioned AIR. Another idea would be to use HippoHX (I haven't written this, the similarity with my username is just coincidence). It runs on top of the NekoVM and gives you unrestricted (so no limitations like in AIR ) access to the system.