best way to create a fancy log - c#

I have a 'log' in my application. Currently I'm using richtextbox control to display colored text. The problem I want to have a simple animation from background images in the background. According to this answer: Can a background image be set on a Winforms TextBox? it's not recommended. I could use datagridview for log, but it flickers when new items are added and it makes it look unstable and ugly. What would be a good way on winforms to display colored text in log and have a background image? Thanks!

If you want something that is easy and looks at least decent your best bet is probably to use WPF Interop (ElementHost) and build the control in WPF. Winforms constrols are a real headache for this type of application.
The WPF TextBox already supports a background image and renders it well.
In your WinForms Project : Right-click, "Add" --> "New Item..."
Select "WPF" --> "UserControl".
Drag a WPF TextBox onto the control, set up background image as you like, etc.
In your Winforms form --> "WPF Interoperability" (in Tools pane) --> drag "ElementHost" to your form.
Set the "Selected Host Content" to your new WPF user control.
Job done.

Related

Error When using Microsoft.DwayneNeed to solve WPF airspace isssue

I have a wpf app,which used winform control on the mainwindow.Of course ,this winform control stays ontop when a show a modal border. After that,I found Microsoft.DwayneNeed way to solve this problem.It works. But there's a new problem shows up. Let me describle my situation:
In the MainWindow,I have a Grid,which has three columns.The control in first column is a normal wpf control.The second column contains a Gridsplitter.And the third columns is where the winform control lays in.
Before I use AirspaceDecorator(From Microsoft.DwayneNeed) as container of winform control,except the winform control always stays on topmost,every thing is ok, and GridSplitter works well.
After I use AirspaceDecorator as winform control's container, winform control doesn't stay topmost.It's good,it's what I want. But surprisingly, GridSplitter doesn't work any more:
1.Generayly,I can't drag GridSplitter --- it should be drag horizontally as designed.
2.On occassionly,GridSplitter will be dragged to the end of the left or the right edge of window .At this curcirmstance,the winform control occpies all the window,or zero.
I tried some ways,such as AirspaceFixer,using WinformHost to host dialoge border,etc. But none of these methods works.
Thanks !
After some testing,I resolved this problem.The answer is to use AirspaceFixer correctly.
Before you call something show on winform control that wrapped by AirspaceFixer,you should set FixAirspace to true,and after you hide upper wpf control,you should set FixAreaSpace property to false. Just like it's demos shows up.

(WPF) Popup with a TabItem Layout

I currently have an application that uses a ToggleButton/Popup feature and it all works as expected, but I wanted to see if there's a way (either through control templates or custom controls) that allows the toggle button to be included as part of the popup window.
The effect I'm going for is similar to the standard TabControl/TabItem layout but instead the ToggleButton would replace the header of the TabItem and the Popup would serve as it's content.
In the end, I want to have the Popup window display to the immediate right side of the ToggleButton and have one continuous border that wraps around the outside edges of the ToggleButton and the outside edges of the Popup window with no border inbetween. The final appearance would show no separation between the two controls, and the user would perceive the ToggleButton and the Popup as a single control object.
I was thinking it might be possible to edit a template of a standard TabItem and have it's content property display as a popup, but haven't tried it yet.
Let me know if you think this is the way to go or if there's any other potential solutions. Thanks.
Almost everything in WPF can be done in multiple ways. The same is true with your goal.
If you plan on reusing this control in multiple places, I would suggest building it as a custom control. I build custom controls and UI libraries for a living, so I am a bit biased.
I would build a custom control that inherits from HeaderedContentControl. The Header property is the content of your ToggleButton, and the Content property would be the content of your Popup. Since you own the ControlTemplate and code, you can make it look and function exactly how you need it to with no compromises.

tooltip text property on user controls of system windows forms missing

After using C# a while, I recognized that the user controls of system windows forms don't provide a tooltiptext property like I am knowing it from Visual Basic 6.
I saw that the Form, TextBox, Label, ComboBox and PictureBox don't have such property.
Now I have the curious question:
How would I display a tooltip to the user on mousehover over a control like the above mentioned?
And Yes, I saw the "tooltip" control in the toolbox. It provides a baloon and I do not need a baloon.
It shows the tooltip for one item only once per user session and then never (known problem of the component) and why I would need an extra component, if this should be just a property of the corresponding control, for which I would like to provide a tooltip like TextBoxes, Labels etc.
And Yes, I saw the "Help Provider". I have usually never a help file assigned with my projects,
so I do not use the Help System. What I need is a simple Tooltiptext, not a "F1 component".
Now I am curious, how I would implement a Tooltiptext if the controls don't provide a option for it.
Can it be, that C# has no control tooltips? Even Delphi has! Or have I missed something somewhere?
The solution:
Delete all notifyicon controls from your project to ensure no unwanted info bubbles appearing
in the system tray.
Drag and Drop the Tooltip Component in Toolbox on your form, but ignore all the baloon properties and the baloon timeout properties and baloon timer properties, just Drag and Drop
the component without further action.
A weird new property field "tooltip on tooltip1" shows now up in all TextBoxes and Labels etc. on the form.
Just handle this field as it would be your Tooltip property and don't setup anything else in code
or on the designer. Build and compile. The tooltiptext will now show up as normal tooltip without
baloon functionality.
It sounds like you are using the ToolTip control incorrectly.
1- Drag it from the toolbox to your form.
At this point, each control on the form now gets a property "Tooltip" to set the appropriate text.
2- Set each control's new "ToolTip" property in the way you find most intuitive.

WP7 - Progress Bar

What is the best way to structure a ProgressBar using Blend?
Right now I have
LayoutRoot > Panorama > PanoramaItem > ListBox
I want to have a progress bar 'behind' the ListBox, and hide it when my web request finishes. So, should I put the ListBox & ProgressBar into a StackPanel? Or should I just programatically add or remove the ListBox / ProgressBar?
I just want to do this the best way possible. Most of the tutorials I find are for progress bars that are just underneath an area of fixed height, and hid when loading completes.
With Windows Phone 7.5 you should use the SystemTray-class with the new ProgressIndicator property. It enables you to provide a progress indicator quick and easy and with a consistent look'n'feel for the user at the top of your screen. This would be the best user-experience possible (see image below) :-)
If you want to show the progressbar nevertheless in the middle of the empty ListBox you can arrange both controls for example with a Grid and toggle the visibility as you need it. Removing and re-creating those controls isn't recommened because it would use a much larger overhead in the background and may be not very performant. But as mentioned above it would be best-practice to use the system tray for status information, including the ProgressBar.
But wether you use the SystemTray-Class or using a ProgressBar control, you shouldn't only toggle the visibility, but also toggle the IsIndeterminate property - it's using resources when "true", even if the ProgessIndicator isn't visible!

Winforms Creating Dropdown style panel

I am attempting to create my own custom Autocomplete style dropdown control in c# .net2.0. For speed of development I have built my control as a UserControl but have hit on an issue of doing it this way.
When the custom drawn dropdown gets drawn I have to resize the UserControl area to be able to display the list of options.
Ideally I want to be able to mimic the drodpown list behaviour in that the list of options is drawn 'floating' and is not constrained by the UserControls height and width (nor even the parent forms boundaries). A tooltip is another example of the unconstrained 'floating' that I desire.
The only way I can think of achieving this is to create on the fly a new form with no border or title bar and display this when the popup is required.
Is there a better (but also quick) way of doing this?
TIA
You would need to use a Form or NativeWindow to allow the control to float correctly. To make a form follow the control is easy enough but it is more difficult to implement and handle all of the focusing/hiding issues especially if you need seamless tabbing/key navigation.
You can try creating a control that is based off the ToolStrip Drop Down Button control. I believe that this control has the functionality that you are looking for. I found this reference for creating controls based off the ToolStrip, you might try starting with this.
http://blogs.msdn.com/jfoscoding/attachment/1335869.ashx

Categories

Resources