|
NewJavaBean wrote: You see where my prob is?
Not really. How do you draw a vertical line? how do you draw a rectangle? the only thing a PictureBox helps you to achieve is showing a single, full-sized image. Everything else needs code in the Paint handler, so why not do it all yourself, in the Paint handler of the Control you choose (I choose Panel instead of PictureBox).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Ok i see
Lets rephrase myself. I'm not sure how to interact with the user.
It should be this way:
User activates the button to draw some text.
User clicks onto the PictureBox and a cursor displays at this point.
User writes a line.
After this point i sould handle it, but how to get there?
Do i actually need a textbox or should i try it another way?
|
|
|
|
|
That is entirely up to you. Here are some possibilities; they all share a "trigger", i.e. something telling your app that text is going to be added (could be a button, menu item, whatever):
1. have the user click on the PB, then hit the trigger; now create a dynamic textbox and add it to PictureBox.Controls giving it the clicked location. Enter the text, upon ENTER read the text, remove the TB from the Controls, add the text to the drawing.
2. without a TB: have the user click on the PB, then hit the trigger; now, let him type text and add it immediately to the drawing until he terminates with ENTER. Here you don't have a cursor, no copy/paste, and you need to support backspace/delete for editing. Is probably more visually pleasing though, as you see the results immediately.
3. with a static TB outside the PB.
4. with a text entry dialog.
1. uses the trigger event, and the TB.KeyDown event to check for ENTER.
2. uses the trigger event, and the PB.KeyPress event (for text) and PB.KeyDown event (for ENTER).
BTW: Once more, I would use a Panel, not a PB.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks Luk thats what i wanted to know.
So i have to create the TexBox by my own, what usually the Designer does for me, and destroy it afterwards.
And i've heard you with the panel
But this is a group project and we've got more than one PB in the program.
The other students would probably kill me if i change such major things in this state of the project.
So now im gonna sleep, its late.
Good night... or day, according to your local timezone
Thanks again!
|
|
|
|
|
NewJavaBean wrote: i try to build a user interface like Paint, or a primitive kind of it.
I did not read all this thread, but at the core, a picturebox is an absolute waste of time here, and can make things harder. Handle your own paint event and go from there.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Given a shape that has the form of an "L", does anyone know how to render a gradient border that follows the shape of the "L"?
|
|
|
|
|
You would do two gradients, or do one that radiates from the bottom right, so that it follows both lines in the L. A more complex letter would be a lot harder, obviously.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi,
my experience with PathGradientBrush is limited to a simple case[^], however I would say you should provide intermediate points and colors in any way that suits you.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
You might want to take a look at Rich Design Time Editing with UITypeEditors (VB.NET)[^], as you can see from the title its primary target is TypeEditors, but it demonstrates this by using various fills and paths. It is in VB.Net, hope that is not a problem.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
i want to fetch the characters from file for example :
1st example:
// mehmood// hello ,how r u?
just within comments and replace it to all caps
2nd example:
/* hi
mehmood
ahmed */
i want to fetch the characters within sigle line comment and multi line comments .
just within comments not outside the comment.
--------------------------------------------------------------------------------
i am trying this code, kindly correct my code:
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
StreamReader sr = new StreamReader(fs);
int countComment=0;
while(sr.Peek() >= 0 )
{
str =sr.ReadLine();
strTemp = new char[str.Length];
#region From String method
int count=0;
for (int i = 0; i < str.Length; i++)
{
if (str[i] == '/')
{
++countComment;
count=i;
}
if (char.IsLetterOrDigit(str,count+1) && countComment==2)
{
strTemp2 += str.Substring(count+1).ToUpper();
}
}
#endregion
countComment = 0;
this.textBox2.Text += strTemp2 + Environment.NewLine; ;
this.textBox1.Text += str + Environment.NewLine;
}
sr.Close();
fs.Close();
it generates an exception :
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
Maifs
modified on Monday, July 13, 2009 5:08 PM
|
|
|
|
|
Hi,
you need to debug your code, and you should do that yourself.
Here are some hints:
- an exception contains a message and a stack traceback indicating class and method names, file names, and line numbers (when available; use debug mode!)
- when you try-catch an exception, make sure to show the ENTIRE exception, use Exception.ToString()
- teach your IDE to always show line numbers in editor windows; for Visual Studio, look under menu Tools/Options/TextEditor/AllLanguages
and if you must show us some code please use PRE tags (that's under the "code block" widget above the text edit box)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Issues
1 - the code is a mess
2 - it won't work
3 - it's hard to read
Do you not know how to use the debugger ? The error message is telling you what is wrong, what is the issue ?
maifs wrote: if (char.IsLetterOrDigit(str,count+1) && countComment==2)
{
strTemp2 += str.Substring(count+1).ToUpper();
}
Why do you use -1 AND +1 ? What if +1 is out of range ( wait, isn't that what the error message says ? )
This needs a lot of work. I'd read a C# book to learn some basics, then rewrite it using regex and the split method of the string class.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello.
I'm using
Graphics gr = Graphics.FromHwnd(IntPtr.Zero);
(int)gr.MeasureString(xrt.Rows[x].Cells[y].Text, xrt.Rows[x].Cells[y].Font).Width;
But as you can see http://img156.yfrog.com/img156/3585/measurestring.jpg it doesn't work as i would like.
Can you please advice me so i can increase its accuracy?
Thank you in advance!
|
|
|
|
|
What's wrong with it ? Also, you can't make it more accurate than it is. I am sure it is accurate, it always has been for me.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello and thanks for replying.
Well "personal information" is not in the same line.Moreover "Orders table" "for each order" etc.
I would like them to be in the same line and not wordwraped.
|
|
|
|
|
Every time it wraps, it's because there's not enough room to fit them. If the column has been sized to the biggest string ( you don't actually tell us what you do with it ), then perhaps you just need to add a few pixels ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks for the replies.Well i just want to fit the text exactly inside the cells(table cells).I create a table(control provided) and set text inside its cells.Then i process all the cells and try to set the correct width(using measurestring).
How will i know that more pixels are needed to be added?
I will try the links provided but i don't know if they fit in my occasion.
Thanks again people.
|
|
|
|
|
Hi,
I've read before there are some slight inaccuracies, so I tend to add some 10 pixels to make strings fit.
This article will tell you more: Bypass Graphics.MeasureString limitations[^]
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi, i have a windows service that needs to read files from mapped drive. The drive is located at \\networkshare\mynetwork. This path has a a folder named ConfirmedOrders. so i am trying to read as:
"file.readalllines(\\networkshare\mynetwork\confirmedorders\myfile.txt)" in windows service and i get an exception UnauthorizedAccess with msg "Access to path ... was denied".
I have another asp.net page which connects to same location and is able to read the file.
I have no idea why my service is not reading the file. The account that i am using for service is LocalSystem and yeah, the mapped drive has permissions for all users.
I tried switching the service to user account but that requires username and password and am not sure on wat the username and password should be. Tried assingning a username and password and i get a msg that "no mapping between account names and security Ids was done".
Any help would be greatly appreciated.
Thanx
|
|
|
|
|
I recently created a simple service that moves files, but it may be similar enough to be useful. It uses a P/Invoke of mpr.dll to create a share without a drive letter; I did this because I ran into the same access denied errors that you mention above.
Don't know if this will help or not, but it worked for what I was doing. Good luck!
private const int RESOURCETYPE_DISK = 0x1;
[DllImport("mpr.dll")]
private static extern int WNetAddConnection2A(ref structNetResource pstNetRes, string psPassword, string psUsername, int piFlags);
[StructLayout(LayoutKind.Sequential)]
private struct structNetResource
{
public int Scope;
public int Type;
public int DisplayType;
public int Usage;
public string LocalName;
public string RemoteName;
public string Comment;
public string Provider;
}
private void fileTransfer(string AbsoluteFilename, string FileName)
{
try
{
structNetResource stNetRes = new structNetResource();
stNetRes.Scope = 2;
stNetRes.Type = RESOURCETYPE_DISK;
stNetRes.DisplayType = 3;
stNetRes.Usage = 1;
stNetRes.RemoteName = destinationFolder;
stNetRes.LocalName = string.Empty;
int i = WNetAddConnection2A(ref stNetRes, destinationPass, destinationUser, 0);
if (i > 0) { throw new System.ComponentModel.Win32Exception(i); }
if (File.Exists(AbsoluteFilename)) File.Move(AbsoluteFilename, destinationFolder + "\\" + FileName);
}
catch (Exception ex)
{
throw new System.Exception(ex.Message);
}
}
modified on Monday, July 13, 2009 4:37 PM
|
|
|
|
|
Hi, Thankyou and wow!!!
First look through your code was confusing but ful of hope. I might need help though. Do i have to download mpr.dll? and also RESOURCETYPE_DISK (0X1)? also wat will be destinationPass,destinationUser.
I thought UNC makes things easy and though my drive letter was Y: , i was using \\xyx\\abc.
Thankyou again
|
|
|
|
|
Also, note that you may need to involve these namespaces:
using System.IO;
using Shell32;
using System.Runtime.InteropServices;
mpr.dll should be located in your Windows directory at the following location: C:\WINDOWS\system32. It's part of the OS. (I don't think that they changed it in Vista; I use XP.)
RESOURCETYPE_DISK is a constant hex value; you can use that line as-is.
destinationUser = "Domain\Username", e.g. @"MSHOME\Jane.Doe" or "MSHOME\\Jane.Doe"
destinationPass = The password for the user above.
destinationFolder = The path to the remote folder the user account has rights to. e.g., @"\\SERVER\ShareFolder" or "\\\\SERVER\\ShareFolder"
Note that the purpose of the code snippet given was to move a file from the local machine to a remote share. You would need to modify it slightly to open files instead. (Change the last line, right before the Catch block.) You don't need to provide a drive letter to use this code; I leave mine as string.Empty.
modified on Wednesday, July 15, 2009 12:16 PM
|
|
|
|
|
Could it be the user that is being set to run the service has no access to that folder?
|
|
|
|
|
Yeah, it was because of the user. I figured it out though. Thanx for replying.
|
|
|
|
|
Hi.
I've heard somewhere that openCV doesn't develop by Intel anymore ?
Is that true?
Thanks.
|
|
|
|