|
From an ASP page? Is this a server running a an FTP or web site?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You might be able to get away with it, but by the time the machine calls back and gets connected to the net your ASP.NET page and/or browser will have long since timed out.
If your are remotely waking a machine up and having connect to the Internet, is it using a standard ISP service? If so, then the machine will receive a different IP address every time and will be incredibly slow for a server, so what good is the remote machine??
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am wanting to add functionality which allows the user to insert text wherever his/her insertion point is located. For instance, if I had the following text in the RichTextBox:
"Hello World!"
And my insertion point was between the 'd' and the '!', how would I insert the string " today" at the insertion point's location so that the outcome would be:
"Hello World today!"
Thanks in advance.
Happy Programming and God Bless!
WWW::CodeProject::BNEACETP
|
|
|
|
|
That functionality is already there. Click at the point you want and start typing, so long as the RTB control's ReadOnly property isn't set to True. Even Copy/Paste works...
If you are trying to insert via code, then all you do is set the SelectionStart property to the position you want, set SelectionLength=0, then set SelectionText equal to whatever you want to insert at that point.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the help!
Happy Programming and God Bless!
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
I'm working on a business object that stores a DateTime as a property. In the context within which this object will be used, this DateTime property is most frequently referred-to property, so I would like to be able to write my code such that I can read and assign this date value directly, ie:
<br />
DateTime collectedDate = new DateTime(5, 28, 2004);<br />
string requiredString = "Additional info I need";<br />
bool[] requiredBoolArray = new bool[4]{true, true, false, true};<br />
myDateObject = new CustomDateObject(collectedDate, requiredString , requiredBoolArray);<br />
if (myDateObject <= System.DateTime.Now)<br />
{<br />
}<br />
else<br />
{<br />
myDateObject = System.DateTime.Now;<br />
}<br />
I've got the binary operators to evaluate my object as a DateTime value working just fine. My assignment operators are another story entirely - how do I create an assignment operator without having the other data in my object get reset to their default values (as happens below)?
<br />
public static implicit operator CustomDateObject(DateTime date)<br />
{<br />
CustomDateObject cdo = new CustomDateObject();<br />
cdo.Date = date;<br />
return cdo;<br />
}<br />
TIA...
-- Carter
Seattle, WA
"In illusion comfort lies" - SoM
|
|
|
|
|
Thats the first thing you should learn, never try and be fancy with operators and casts.
wickerman.26 wrote:
CustomDateObject cdo = new CustomDateObject();
cdo.Date = date;
return cdo;
I mean there is no logic! how on earth can the previous values magically appear if u are creating a new object?
top secret xacc-ide 0.0.1
|
|
|
|
|
I'd always thought that the first thing one should learn was to never use absolutes... At any rate, under the heading of sublimely unhelpful, we have:
leppie wrote:
I mean there is no logic! how on earth can the previous values magically appear if u are creating a new object?
Um, there was logic behind that question had you read it in it's entirety. The only way I could see how to cast a date struct into my date object was by returning a new instance of my date object; I was trying to find out if I was missing something. Evidently I wasn't.
See? No magic.
-- Carter
Seattle, WA
"In illusion comfort lies" - SoM
|
|
|
|
|
wickerman.26 wrote:
I've got the binary operators to evaluate my object as a DateTime value working just fine. My assignment operators are another story entirely - how do I create an assignment operator without having the other data in my object get reset to their default values (as happens below)?
You can't. It is like if you cast between an int and a byte. A byte can hold values 0 to 255, an int can hold values -2billion to +2billion (approx.)
byte myByte = 100;<br />
int myInt = (int)myByte;<br />
But if you do this:
int myInt = 1000;<br />
byte myByte = (byte)myInt;<br />
Actually the result is 232, which is the same as (myInt%256) . This is because to fit into an int the data had to be truncated, and if we try and reassign the byte back to the int, we will only ever see as much as was truncated.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Thanks, that's what I thought.
-- Carter
Seattle, WA
"In illusion comfort lies" - SoM
|
|
|
|
|
Can anyone point me to an example that seperates your Windows Form and it's events away from the class that actually carries out your Application logic?
|
|
|
|
|
CN78 wrote:
Can anyone point me to an example that seperates your Windows Form and it's events away from the class that actually carries out your Application logic?
Yes, create a new C# file, without any controls in it
top secret xacc-ide 0.0.1
|
|
|
|
|
Model-View-Controller Pattern[^]
This article describes the MVC pattern in relation to web pages, but many of the ideas also apply to Windows Forms.
From the above link:
The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes [Burbeck92]:
Model. The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).
View. The view manages the display of information.
Controller. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
I'm looking to read a text file that has properties coded on it ex : name=Joe
and can set a control with those properties at run time. Here is an example of what i've coded for this already :
private void ReadFile()
{
StreamReader sr;
string ;s
sr = File.OpenText("c:\\Test.txt");
s = sr.ReadLine();
sr.Close();
tabPage1.Text = s;
}
I need to start setting the numberOfTabs I want, the Alignment of the tabs.
|
|
|
|
|
Anonymous wrote:
private void ReadFile()
{
StreamReader sr;
string ;s
sr = File.OpenText("c:\\Test.txt");
s = sr.ReadLine();
sr.Close();
tabPage1.Text = s;
}
private Hashtable ReadFile(string filename)
{
string s;
Regex re = new Regex(@"^\s*(?<name>\w+)\s*=\s*(?<value>.+?)\s*$",
RegexOptions.ExplicitCapture);
Hashtable nv = new Hashtable();
StreamReader sr = File.OpenText(filename);
while ((s = sr.ReadLine()) != null)
{
Match m = re.Match(s);
if (m.Success)
{
nv.Add(m.Groups["name"].Value, m.Groups["value"].Value);
}
}
sr.Close();
return nv;
}
top secret xacc-ide 0.0.1
|
|
|
|
|
Sounds like what I use .ini files for.
I think there's a C# article on Code
Project that encapsulates WritePrivateProfileString
and ReadPrivateProfileString. Or you could
DLLImport them and roll your own.
Delphi has a pretty nice TIniFile class so
what I did was write a dual-interface COM
wrapper for it so I could use it with anything
that can use COM. I haven't tried it with
C# yet though. It worked fine with VB 6 and
VC++ 6.
|
|
|
|
|
Thanks for the replies, any other ways of doing this ?
|
|
|
|
|
It is kind of like any INI file, but you instead of initializing the component on startup, you are just setting its propeties. I realize this is not the best way to do this, however this is an exercise I must complete. Thanks for the replies, any other ways of doing this ?
|
|
|
|
|
|
No, there is no premade assembly that wraps GhostScript. Various people have built their own by P/Invoking the hell out of the GhostScript .DLL's, but I haven't seen any wrapper publicly available.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a dll with about 10 embedded images in it. I would like to pull these out and load them when an event is fired(not all at once )but which ever one is needed depending on the user selection.
My problem is I have absoulutly no clue how to go about this even after making the reference.
Also I don't know that the dll was built properly. I created a resource file and added all the pics to it ( paths) and opened a blank project and added the resource file and built the proj as a class lib.
Also I created an empty proj and added all images, changed their propertys to embeded types , and built the proj as a class lib.
Both files are the same size 236kb. Still I can not "Get" the images out of the darn dll.
Any help , links , answers would MORE than apprieciated !!!
Thanks in advance,
Billy
I wish I could help instead of asking for it !
Can I open that beer for you ?
|
|
|
|
|
You need to create a ResourceManager object and use it to pull the images from your assembly.
See this[^], this[^], and this[^] on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Our scenario is:
Various business objects on server using interfaced-based remoting being called by a thick Windows client.
In some situations, instead of receiving a "normal" exception or one of our custom exceptions we receive the following:
"See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.IO.FileNotFoundException: File or assembly name Product, or one of its dependencies, was not found.
File name: "Product"
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Reflection.MemberInfoSerializationHolder..ctor(SerializationInfo info, StreamingContext context)
at System.Exception.GetExceptionMethodFromString()
at System.Exception.GetTargetSiteInternal()
at System.Exception.get_TargetSite()
at IDTEC.Components.Exceptions.IDTException.ToString()
at IDTec.UI.IDTecControls.IDTDialogBox.ShowErrorDialog(String showOnlyMessage, Exception e, String pluginName, String pluginVersion, String methodName)
at Rectron.Plugins.Side.btnNew_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)"
I'm 100% percent sure that is not a missing dependancy - else nothing would ever work.
We have also been seeing this type of error from other assemblies.
Has anyone come across a situation where the DLL throws this error instead of a standard .NET exception?
EDIT:
I get a proper error while running in debug inside VS, but get the above error while running on our test machine.
Same build and same user, but different error...
Cheers,
Simon
sig :: "Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards "It'll be a cold day in Hell when I do VB.NET...", Chris Maunder
|
|
|
|
|
Hello,
I've coded my own NumericTextBox. But there's a little feature I want to add: If you try to enter a character in the TextBox, this very typical sound should be played. But I don't know how I can do this.
|
|
|
|
|
If you've done this correctly and your already filtering out the incorrect key presses, you could just P/Invoke Beep in the Win32 API.
[DllImport("kernel32.dll", SetLastError=true)]
static extern bool Beep(uint dwFreq, uint dwDuration);
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|