|
oh,
the signature is cool
You are the best!Me too!
|
|
|
|
|
Thanks!
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
After much hunting yesterday I finally decided to use the following toolbar :
http://www.aisto.com/roeder/dotnet/ (CommandBar for .NET)
It doesnt have all the functionality that I would have liked but I will make do.
This is what the following article is based on :
http://www.codeproject.com/cs/menu/vsnettoolbar.asp
But <sarcasm>unfortunatly Carlos H. Perez has sold out and gone commercial with his code - which is odd considering that is based on somebody elses code and this fact isnt mentioned anywhere on his site, ho humm.
Human Nature + Open Source = error cannot compute
|
|
|
|
|
I intend to tweak Roeders code to meet my needs
When / If I accomplish this I will probably make an article about it
|
|
|
|
|
MrEyes wrote:
which is odd considering that is based on somebody elses code and this fact isnt mentioned anywhere on his site
To my knowledge his toolbar isn't based on anyone else's code, he says that it is based on the Win32 Toolbar control, which is what this except says:Thus, this had to be done using what is already in existence and then modify it to death until it looks like those cool toolbars in Visual Studio .NET. That's what it has been done here: this implementation uses the Windows Common Control: ToolbarWindow32.
[edit]Found it, I didn't think to look through the update history.[/edit]
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
|
Anyone can point to the most recent available library of Carlos Perez? Everyone is talking about it but I cannot find it. I hear it went commercial, but what about latest non commercial version? Where is it?
Thanks,
Roman
|
|
|
|
|
I am having a problem with MeasureString. When I set the format flags to Vertical the sizeF returned has an incorrect height! Does anybody know how to force it to fit the entire string and return the correct height?
Sf.FormatFlags = StringFormatFlags.DirectionVertical Or StringFormatFlags.NoWrap<br />
g.MeasureString(Text, Style.FontFace, New PointF(1, 1), sf)
I read C# but write in VB so C# examples are great
|
|
|
|
|
I think, maybe, the problem is the New PointF(1,1).
Here is an example from a menu item that I had to owner draw.
private void MeasureItemMenuItemCopy(object obj,
MeasureItemEventArgs miea)
{
MenuItem mi = (MenuItem)obj;
Font menuFont = SystemInformation.MenuFont;
StringFormat strfmt = new StringFormat();
SizeF sizef =
miea.Graphics.MeasureString(mi.Text,
menuFont,
1000,
strfmt);
Bitmap bmMenuImage =
new Bitmap(typeof(FormMenuImages),"COPY.BMP");
miea.ItemWidth =
(int)Math.Ceiling(sizef.Width) + bmMenuImage.Width;
miea.ItemHeight =
(int)Math.Ceiling(sizef.Height) + bmMenuImage.Height;
}
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
The mystery deepens
The above techniques do not work either I have figuired out why but have no idea how to solve it. The sizef that is returned is not pixel values. If i multiply the height by 1.6 I get the correct size.
I'm guessing it's to do with the resolution. On .DrawImage we have the GraphicsUnit.Pixel option. but the measurestring doesn't seem to provide an overload that supports it.
I don't just want to multiply by 1.6 because I'm guessing that this will differ depending on the dpi.
Any ideas?
P.S. To explain what i'm up to... I am creating a button based on the size of the text so I need to get the size of the text before I create the target bitmap (which explains why i'm not just drawing straight away )
|
|
|
|
|
I'm creating graphical controls. They use an image as a source and break that image up into top, bottom and the fill area:-
|---|------|---|
| L | F | R |
|___|______|___|
Left is copied to 0,0
Fill is turned into a textureBrush and tiled to fill the text area
Right is copied to the end of the text area.
Hence i need to know the size the text will occupy when rendered. The horizontal works fine. The problem I have is that the vertical (Using Top, Fill, Bottom) is returning a size that is too small so that when the text is drawn it goes outside the fill area.
It seems that .MeasureString is not taking something into account when measuring vertical text. The 1.6 difference becomes 1.4 at a higher resolution so I am assuming i missed a setting somewhere so its returning em's and not pixels.
IT'S DOING MY HEAD IN
|
|
|
|
|
Private Function VerticalGenerate() As Bitmap
Dim TopRect As Rectangle = _Style.Section1
Dim BottomRect As Rectangle = _Style.Section2
Dim TextArea As SizeF
Dim g As Graphics = Graphics.FromImage(Style.SourceImage)
'If Not _Text = "" Then
'calculate text area
Dim tb As New TextBuilder()
TextArea = tb.GetTextArea(g, _Style.txtStyle, _Text, New StringFormat(StringFormatFlags.DirectionVertical))
TextArea.Height = TextArea.Height * 1.4
'End If
'create target bmp
Dim bmp As New Bitmap(TopRect.Width, Convert.ToInt32((_Style.Offset.Top + Style.Offset.Bottom) + (TextArea.Height)))
g = Graphics.FromImage(bmp)
g.DrawImage(Style.SourceImage, TopRect, TopRect, GraphicsUnit.Pixel)
'calculate bottom position
Dim temprect As Rectangle = BottomRect
temprect.Offset(New Point(0, (bmp.Height - BottomRect.Height) - BottomRect.Top))
'draw bottom
g.DrawImage(Style.SourceImage, temprect, BottomRect, GraphicsUnit.Pixel)
'do fill
Dim temprect2 As Rectangle = New Rectangle(0, TopRect.Height, TopRect.Width, _Style.ImageSize.Height - (TopRect.Height + BottomRect.Height))
FillArea(g, Style.SourceImage, temprect2, New Size(TopRect.Width, TextArea.Height), New Point(0, TopRect.Height), WrapMode.Tile)
'bmp.Height - (TopRect.Height + BottomRect.Height)
If Not _Text = "" Then
Dim Sf As New StringFormat()
Sf.FormatFlags = StringFormatFlags.DirectionVertical Or StringFormatFlags.NoWrap
tb.RenderText(g, _Style.txtStyle, _Text, New RectangleF(0, TopRect.Height, TextArea.Width + 1, TextArea.Height), Sf)
' New RectangleF(0, TopRect.Height, TopRect.Width, bmp.Height - (TopRect.Height + BottomRect.Height))
Sf.Dispose()
End If
Return bmp.Clone
g.Dispose()
bmp.Dispose()
End Function
Public Function GetTextArea(ByRef g As Graphics, ByRef Style As TextStyle, ByVal Text As String, ByVal strFormat As StringFormat) As SizeF
Return g.MeasureString(Text, Style.FontFace, New SizeF(1000, 1000), strFormat)
End Function
Public Sub RenderText(ByRef g As Graphics, ByRef Style As TextStyle, ByVal Text As String, ByVal TargetRect As RectangleF, ByRef Format As StringFormat)
If Not Style.Texture Is Nothing Then
g.DrawString(Text, Style.FontFace, Style.Texture, TargetRect, Format)
ElseIf Not Style.Gradient Is Nothing Then
g.DrawString(Text, Style.FontFace, Style.Gradient, TargetRect, Format)
Else
g.DrawString(Text, Style.FontFace, New SolidBrush(Style.ForeColour), TargetRect, Format)
End If
End Sub
|
|
|
|
|
I have a text file with unicode strings (T H I S I S A S T R I N G) and I want to search for those strings and convert them to ascii.
How do I use string.IndexOf for a unicode value? Say I want to search for:
file.IndexOf(Encoding.Unicode.GetBytes("http://"));
which obviously doesn't work since there is no byte[] overload. So how do I convert an ascii string to a unicode string?
All I really need I guess is how to get "http://" converted to "h\0t\0t\0p\0:\0/\0/\0" and back.
|
|
|
|
|
Here's my scenario:
I want a client application to connect to my webservice and request a particular file, which I'll stream down to them.
Client would then save to disk on their side.
Returning a byte[] seems the best option, but I'm not too sure how to get the encoding right so the resultant file is still valid.
The files in question would be binary.
Anyone done this?
Cheers,
Simon
"I ask candidates to create an object model of a chicken.", Bruce Eckel on interviewing programmers.
animation mechanics in SVG (my first abstract photo)
|
|
|
|
|
|
There is a text editor I like to use on Linux called Kate, part of KDE. It has a nice feature where you can have a command prompt in a frame, and the command prompt "follows" the document you are currently editing.
I was thinking it would be nice to have something like this on Windows. But I can't see any way to embed a command prompt in a C# Windows Form.
Does anyone know if this is possible, and if so how to do it? Any ideas?
|
|
|
|
|
imoz wrote:
Does anyone know if this is possible, and if so how to do it? Any ideas?
Yes, see the documentation for the System.Diagnostics.Process; probably there are samples for this on the Internet already.
You'll need to provide alternate input/output StreamWriters on the StandardOutput and StandardInput properties, redirecting it to where you may want.
Kant wrote:
Actually she replied back to me "You shouldn't fix the bug. You should kill it"
|
|
|
|
|
Hi there,
Thanks for the tip. I was able to track down some samples. I am able to start a cmd.exe process w/ no window. However, if I put a textbox on my windows.form, and setup an event handler for the KeyPress event, it hangs when I try to write e.KeyChar to the stream.
Joe Mozelesky
:: powered by imoz ::
"Luck is the result of preparation and opportunity."
|
|
|
|
|
imoz wrote:
Hi there,
Thanks for the tip. I was able to track down some samples. I am able to start a cmd.exe process w/ no window. However, if I put a textbox on my windows.form, and setup an event handler for the KeyPress event, it hangs when I try to write e.KeyChar to the stream.
Maybe the process isn't waiting for a char at the moment you sent the key to its input stream.
One thing I would try would be using a buffered stream or a separate thread that read the chars from a queue.
Kant wrote:
Actually she replied back to me "You shouldn't fix the bug. You should kill it"
|
|
|
|
|
Hi,
I like to create something like the explorer tree. This treeview structure contains more than one node type (drives, systemcontrol, network). Each node type has it's own behaviour, and has to be handled different. Letz say some content are the drives of the local machine, but another node type represents no disk drive (e.g SystemControl) that is handled different as if you click on a drive node.
How to handle stuff like that? The goal should be to reuse my node handler's, so i don't like to implement all the stuff in one special treeview class. I guess i have to write something like NodeHandler's, which only handles the events from the node type it made for.
For my explorer view i would have 3 NodeHandlers, one for drives, one for systemcontrol and one for network, right ?
if you know a good pattern to handle this, please let me know
.:[Greets from Jerry Maguire]:.
|
|
|
|
|
I would like to draw text with a OPAQUE or TRANSPARENT backgound mode.
How to do that with GDI+?
In other terms, under GDI+, how to obtain an effect similar to the SetBkMode and SetBkColor functions of GDI?
|
|
|
|
|
hi there,
Just a quickie:
Are there classes around to directly convert a 4byte big byte array to an Int32, or do I need to go the manual way?
Thanks a lot,
stonee
|
|
|
|
|
byte bt=0;
int i = Convert.ToInt32(bt);
MessageBox.Show(i.ToString());
switch(twinsOnWay)
{
case ("twins on the way"):
MessageBox.Show("for mr and mrs dynamic","twins on the way");
break;
|
|
|
|
|
i am talking about a byte array consisting of 4 bytes!
thanks,
stonee
|
|
|
|
|
have you checked out Convert Class,
it offers great varieties
|
|
|
|
|