|
What's an IP device and what part of the GUI are you struggling with, creating a menu bar?
|
|
|
|
|
For example an IP relay. on its web page i can set the 4 relays on/off and i have config menu. in my gui i just want to play with 2 relays only. basicly it will be a button but how to connect this button click with relay?
|
|
|
|
|
Well the first thing to understand is the protocols used by the IP Relay to control it.
Then you would have to write a suitable communications class to do the interfacing, and on top of that the gui to do the user interaction.
Without more knowledge of the type/make/model of the IP Relay then nothing more can be added. In situations like this, Google and some of the Hardware sites can help. The OEMs usually have samples available on their websites.
|
|
|
|
|
Could you clarify:
1. you are asking for help only in how to make a GUI in a WinForms C# application using some form of menu ?
2. you have already solved all issues relating to how your C# application communicates with your IP device ? So the information you need to display in the C# application is available, and the means to take action ... sending whatever to the IP Device ... depending on the user's choices in the application ... is already worked out ?
3. By 'menu' do you mean the typical drop-down Menu Control ? ... or ... ?
best, Bill
"Beauty is in the eye of the beholder, and it may be necessary from time to time to give a stupid or misinformed beholder a black eye." Miss Piggy"
|
|
|
|
|
That means that you have to analyze the source code of the html pages shown in your web browser.
Find out which actions are invoked on the web server of your device, when a button on the form is clicked (the protocol GET or POST, the address the browser sends the data to, the data which are sent), and then send the equivalent http requests from your application.
|
|
|
|
|
Ex:
If I send user the download url like http://www.mysite.com/downloads/file1.pdf
but there are file2.pdf,file3.pdf in the same folder and user can simple rename the file1.pdf to file2.pdf in the url and he can download file2.pdf.
How can we restrict users from doing this.
I really appreciate for you help....
Thanks
Nani
|
|
|
|
|
How about using randomly generated file names so that the user has no way of replacing the file name?
0100000101101110011001000111001011101001
|
|
|
|
|
You would have to keep the files in a different location and then use a Web Handler file (ASHX) to read the file bytes and Write them to the Response.
|
|
|
|
|
Nani - you actually need to invert your thinking on this. Should you be restricting the user from doing this? If the user has the permissions to download the file then why should you restrict it? If, however, you change the problem around to "should I allow a user to be able to download a file that they don't have permissions to?" then you get a totally different question, but a one that makes a lot of sense.
You can use the security aspects of ASP.NET - and combine this with ashx handlers to parse the request that's coming in - and control the users access to the files. BTW - this should have been asked in the ASP.NET forum, not this one.
|
|
|
|
|
You accomplish this by keeping your assets in a non-accessible location (eg, somewhere in App_Data ) and using an HttpHandler to serve the files out after verifying permissions.
|
|
|
|
|
public void RenameSetting(string xPath, string newNode, string oldNode, string bladeName)
{
XmlDocument xmlDocument = new XmlDocument();
string documentPath = Application.StartupPath + "\\groupSettings.xml";
xmlDocument.Load(documentPath);
XmlNode xmlNode = xmlDocument.SelectSingleNode("settings/" + xPath);
XmlNode oldChild = xmlDocument.SelectSingleNode("settings/Groups/" + xmlNode.Name + "/" + oldNode);
XmlNode newChild = xmlDocument.SelectSingleNode("settings/Groups/" + xmlNode.Name + "/" + newNode);
PutSetting("Groups/" + xmlNode.Name + "/" + newNode + "/Name", bladeName);
PutSetting("Groups/" + xmlNode.Name + "/" + newNode + "/User", GetSetting(xPath + "/" + oldNode + "/User", ""));
PutSetting("Groups/" + xmlNode.Name + "/" + newNode + "/Host", GetSetting(xPath + "/" + oldNode + "/Host", ""));
xmlNode.RemoveChild(oldChild);
xmlDocument.Save(documentPath);
}
public void PutSetting(string xPath, string value)
{
XmlNode xmlNode = xmlDocument.SelectSingleNode("settings/" + xPath);
if (xmlNode == null) { xmlNode = createMissingNode("settings/" + xPath); }
xmlNode.InnerText = value;
xmlDocument.Save(documentPath);
}
I call RenameSettings like this:
RenameSetting("Groups/Group2", "Blade5", "Blade4", "Blade 5");
Here is my xmlDocument:
<settings>
<Groups>
<Group2>
<Blade4>
<Name>Blade 4</Name>
<User>k</User>
<Host>7</Host>
</Blade4>
</Group2>
</Groups>
</settings>
In short, I am trying to create a method that can rename my "settings/Groups/Group2/Blade4" to "settings/Groups/Group2/Blade5", my current method should copy everything from Blade4 to Blade5, then delete Blade4, but it throws the error:
the node to be removed is not a child of this node on
xmlNode.RemoveChild(oldChild); and as you can clearly see in the XML, Blade4 (which is oldChild) is most definitely a child of Group2. I assume I am defining oldChild wrong, but how else do you define it so it properly sees oldChild as a child of xmlNode?
modified 22-Sep-11 17:11pm.
|
|
|
|
|
I think your RenameSetting call should be:
RenameSetting("Group2", "Blade5", "Blade4", "Blade 5");
0100000101101110011001000111001011101001
modified 22-Sep-11 17:11pm.
|
|
|
|
|
Actually, wouldn't it be:
RenameSetting("Groups/Group2", "Blade5", "Blade4", "Blade 5");
?
That was just a slight error in my post of so....if you look at my XML though, the full path to Blade4 is: "settings/Groups/Group2/Blade4", if I call RenameSetting like you say I should, then wouldn't every instance of ("settings/" + xPath) resolve to "settings/Group2" which currently doesn't exist in my XML?
|
|
|
|
|
You are right of course.
Did you try debugging the code to see what the value of xmlNode.Name is?
You could also try replacing
XmlNode oldChild = xmlDocument.SelectSingleNode("settings/Groups/" + xmlNode.Name + "/" + oldNode);
with
XmlNode oldChild = xmlDocument.SelectSingleNode("settings/" + xPath + "/" + oldNode);
and see what happens.
0100000101101110011001000111001011101001
|
|
|
|
|
Yes, xmlNode.Name = Group2, exactly what you would expect it to be.
I tried replacing that line with your suggestion, but it didn't change anything....
An interesting thing through, if I break at the "XmlNode newChild" line, and examine "oldChild", it shows the ParentNode as "{Element, Name="Group2"}", which is exactly what you would expect, but then if I break again at "xmlNode.RemoveChild(oldChild);", "oldChild" shows a ParentNode of "null".....so somewhere between line 7 (initialize/define oldChild) and 12 (remove oldChild), oldChild loses its ParentNode attribute......which causes xmlNode to not see oldChild as a child node.
edit: oddly enough, if I examine xmlNode however, oldNode (which is equivilent to "Blade4") IS shown as a child node of xmlNode....yet if I define an XmlNode using my oldNode variable as part of the SelectSingleNode string, xmlNode does NOT see "Blade4" as a valid child node.
|
|
|
|
|
Seems like your PutSetting calls might be causing a problem.
If you comment out the RemoveChild statement, how does the xml file look?
0100000101101110011001000111001011101001
|
|
|
|
|
<settings>
<Groups>
<Group2>
<Blade4>
<Name>Blade 4</Name>
<User>k</User>
<Host>7</Host>
</Blade4>
<Blade5>
<Name>Blade 5</Name>
<User>k</User>
<Host>7</Host>
</Blade5>
</Group2>
</Groups>
</settings>
Exactly how you would expect it to look, Blade5 is added as an exact duplicate of Blade4, with the exception of the Name innertext changed to match the name change.
|
|
|
|
|
One more thing I can think of is to try is to get the setting of the old node and store them in variables and then first remove the old node and before finally creating the new node.
See what happens when you try it that way?
Also did you step through the code to find out at which point the oldChild node losses its parent?
0100000101101110011001000111001011101001
|
|
|
|
|
oldChild loses its parent as soon as I make the first call to PutSetting. I added a breakpoint to "XmlNode newChild", and all three PutSetting lines, the first breakpoint of PutSettings (breaks after XmlNode newChild is defined), oldChild still has its parent value, the second breakpoint of PutSettings (breaks after the first PutSettings line is called), and oldChild loses its parent.
So something with this line:
PutSetting("Groups/" + xmlNode.Name + "/" + newNode + "/Name", bladeName);
causes oldChild to lose its parent.
After trying your suggestion of assigning variables of the values in oldChild first, then deleting it before assigning the new node, and it seems to work fine, my XML after running it is:
<settings>
<Groups>
<Group2>
<Blade5>
<Name>Blade 5</Name>
<User>k</User>
<Host>7</Host>
</Blade5>
</Group2>
</Groups>
</settings>
Which is what I expected from the beginning. Still not sure why the PutSettings function causes a node that isn't even touched (oldChild) to lose its parent. Maybe its because it adds another child node to Group2, or more likely because it calls xmlDocument.save, which somehow causes oldChild to lose its parent (because now xmlNode and/or oldChild are no longer the latest value contained in xmlDocument?).
Meh, oh well......I don't like adding variables where I don't really need them, but it works fine for what I'm doing and they're only temporary anyway.
|
|
|
|
|
I am trying to add text to an existing pdf. I know that I can use a paragraph, phrase, or chunk, but I want to be able to specify a location on the pdf. I haven't been able to find any examples on how to do this. I'm trying to add a timestamp to the bottom of the first page when the new pdf is created.
|
|
|
|
|
|
|
On C#.net 2010 new in asp.net and desktop applications, I am suppose to have a 'type ahead' feature. Basically a user 'starts' to type a 'company name' in a text box, and then the application comes up with options on what the user is trying to enter. This way the user does not have to enter the entire company.
I do not know what this option occurs in C#.net 2010. Can you explain this to me and/or point me to a url that would explain this option to me?
|
|
|
|
|
googling Autocomplete textbox would yield a lot, including this[^]. HTH.
|
|
|
|
|
In a desktop application you can just set the AutoCompleteMode of the TextBox and then set the AutoCompleteSource to Custom and then set up the AutoCompleteCustom collection.
There is an ASP.Net AJAX control that will allow you to do this in ASP.Net: click[^]
|
|
|
|