WPF Documentviewerbase.Print. Remove dialog box - wpf

I am using WPF and the DocumentViewer to display a document. However, when I use DocumentViewerBase.Print, it gives the "standard" Windows dialog box asking me to choose a printer with the default already selected. How can I get rid of this? I just want to use a Print method that will automatically start printing with no other prompt in between.

I believe in order to do this you would need to write your own printing routine e.g. by overriding OnPrintCommand method of the DocumentViewer. The reason is that default implementation is using PrintQueue.CreateXpsDocumentWriter method to create XpsDocumentWriter object and shows a PrintDialog in order to define its properties. For more details check the DocumentViewerBase.OnPrintCommand with reflector

Related

Maya drop down menu

I've got a pretty complex question for any Maya coders...
I want to utilize a drop down menu similar to that of the cmdScrollFieldExecuter's [script editor's] "Show Tooltip Help". It looks like a window that has been appended to the bottom of the inputted text with a feedback of all relative commands or strings.
Does anyone have experience with appending a similar textbox/ window/ menu to typed input, and if so, can you toss me in the right direction?
Note: I am not talking about "optionMenu".
Alternatively, is there a way to get cmdScrollFieldExecuter to reference a different array or set of strings?
A complete port of that won't be possible in vanilla Maya - You'd need to use python and QT because the built-in GUI objects (such as TextField) don't fire any events on keypresses so you won't be able to live-update as the user types.
You can almost fake the visual appearance with a window whose title bar is set to off. Use a formLayout to dock a TextScrollField inside it. You'll need to hack up some way of dismissing it since it won't have a close box -- you could put it on a timer or add an invisible button covering the whole thing which closed the window when clicked

GtkColorChooser vs GtkColorSelection

(Jacked straight from my last thread:) Reading through the GTK Book, there are lots of things to clean up when making sure to learn GTK3-focused skills. One is color selection widgets.
First, I'm wondering how GtkColorChooser is supposed to permit alpha choosing. The book just has you gtk_color_selection_set_has_opacity_control (GTK_COLOR_SELECTION (colorsel), TRUE);. There's a similar function for GtkColorChooser, but it doesn't seem to create anything. There's also the show-editor attribute that I flipped to TRUE without seeming to do anything.
Second, is there an equivalent notion to GtkColorSelectionDialog->colorsel for GtkColorChooserDialog? As in, can you access the GtkColorChooser widget from the parent dialog?
EDIT:
This is the source for the dialog creation where I'm missing something. I'm expecting this to show me an alpha-enabled color chooser widget, but it only gives me the regular swatches.
dialog = gtk_color_chooser_dialog_new(title, window);
gtk_color_chooser_dialog_set_use_alpha(GTK_COLOR_CHOOSER(dialog), TRUE);
My only guess is that I'm trying to access the color chooser incorrectly, but I haven't been able to find sufficiently detailed instructions about how to get to the chooser from the dialog.
the GtkColorChooser interface allows choosing the alpha channel by setting the :use-alpha property:
https://developer.gnome.org/gtk3/stable/GtkColorChooser.html#gtk-color-chooser-set-use-alpha
when the :use-alpha property is set, you can select the alpha when creating a new custom color in the editor; a new scale widget will appear at the bottom of the color editor and will let you select the alpha level:
the GtkColorChooserDialog is a GtkDialog with a GtkColorChooserWidget inside the dialog's content area, so you can use gtk_dialog_get_content_area() and then get the first child of the returned GtkBox. this is arguably a layering violation, and should not be needed: GtkColorChooserDialog proxies all the GtkColorChooser methods to its GtkColorChooserWidget, and you should never need to access the widget directly. if you want to keep control of the GtkColorChooserWidget, you should create your own GtkDialog and pack a GtkColorChooserWidget into it yourself. again, I would not recommend doing that unless you want to create your own custom dialog.

Change WPF DocumentViewer viewing mode

Hello I've got the problem that when I just add a <DocumentViewer x:Name="docViewer" /> I get a toolbar what allow me to change the viewing mode of the XPS document like here:
But how can I do this programmatically?
I cant find any property that do this and the MSDN and Google say nothing about this feature.
Then I found the FlowDocumentReader control what have a ViewingMode property, however it can't display a XPS document. I can't believe that it is not possible to do this, I mean that function is available by default, I just want to change it programmatically...
DocuementViewer didn't exposed any property to change the ViewMode. But in case you want to change the ViewMode programmatically, you can execute the commands exposed by DocumentViewer which are as -
DocumentViewer.FitToWidthCommand
DocumentViewer.FitToHeightCommand
DocumentViewer.FitToMaxPagesAcrossCommand
You can bind these commands to your custom button or programmatically you can change the ViewMode. Suppose you have a DocuementViewer named documentViewer, you can call these methods on this instance like this -
documentViewer.FitToWidth()
documentViewer.FitToHeight()
documentViewer.FitToMaxPagesAcross()

Tool to know Windows Form Application's Form fields

I am working on a WinForm Application.
The Form has many fields/components but is poorly built.
for example a field is used as user name on one case and used as folder path on the other case. Code is quite poorly maintaned.
Is is possible that when i run the application and GUI appears, i can use a tool like 'spy++' which can show me 'names' of the components (not ids). For instance the name of a button or name of a label.
Or if i can use SPY++ for 'names' please tell me?
I would solve the problem by adding a ToolTip control to your form and iterating over each control and adding a Tool Tip message to each control that is the name of the control.
First, add a ToolTip object to your form (from the Tools section of the designer.) You can rename it, but for the sake of my demo, I left it as the default name toolTip1.
Next, add a method similar to the one I'm posting below to the code page of your form. (I'm assuming this is for C# but the code is simple and can easily be modified for VB or C++).
public void AddNameToToolTip(Control c)
{
toolTip1.SetToolTip(c, c.Name);
foreach (Control child in c.Controls) AddNameToToolTip(child);
}
Finally, from within the Form constructor, add the following line of code after the call to InitializeComponent().
AddNameToToolTip(this);
This will add a ToolTip message to each control in your form. All you should have to do is hover your mouse over each control and the ToolTip will pop up a message after a second or two displaying the name of the underlying control.
Alternatively, you can recursively adding a MouseHover event to each control and when the event is fired, write the name of the control to the debugger. This would also work if you are already using a ToolTip control within your form.

Printing Multiple pages in wpf

I have a Scroll Viewer and inside that a text block with multiple pages contents.
How can I print everything within the Scroll Viewer.I'm Using WPF MVVM pattern.
Is text block is the right control for this?Or shall I go for any other WPF controls.?
Thanks in advance..
DocumentViewer ir a better control for paginated printing
I don't know what is exactly the problem,But something related to Printer.
From Control Panel->Printers & Fax
1.Right Click the Printer and take Printer preferences
2.Change the Source property to 'Manual Feed'& Apply.(Initially it was'AutoSelect')
3.Still got some error.
4.Again me changed the Source property back to 'Auto Select'& Apply.
5.Changed the Quick set Property to 'Defaults'& Apply
5.Now its Working Fine

Resources