|
hey,
I want to use MouseWheel for my drawing application...Idea is to expand and contract a circle depending upon the direction of wheel motion...which function/property to use..?
thanks
|
|
|
|
|
It will take more than a function or property to do that. You can use Mouse Move for sure but will have to add drawing and all those things. Try to do a research on System.Drawing.
|
|
|
|
|
Hi,
there are at least two approaches to do such things.
1.
Every shape (line, rectangle, circle, ...) could be a (user-defined) Control;
in that case you create and select a shape, then it gets its events fired
such as MouseWheel.
2.
In a lightweight approach (which I prefer) only one Control is involved (say a Panel)
on which you create your drawing. Now it is the Panel itself that gets the events,
such as MouseWheel.
In both cases, the MouseEventArgs.Delta property will tell you how much the wheel
has moved (and the sign of that will tell the direction). You should follow UI design rules
as explained in MSDN, concerning SystemInformation.MouseWheelScrollLines
|
|
|
|
|
hi i am currently trying to make an console application with c# which telnet and use the command line : "show cdp neighbour" is that possible? if it is pleaswe show me the way please i feel its a veri useful skill
|
|
|
|
|
Hi,
I need to do the following:
DataRow[] dr = this.myDataSet.Tables[tr[0]].Select("c-ip" = '12.12.12.12');
How can I escape the " so that the select statement reads correctly.
I would have thought (""c-ip""" = '12.12.12.12') would work but it doesn't. Keep getting compiler warnings regarding newlines, ; or ) expected. Neither does \" .
I need to pass the " as the column name is c-ip (as in a w3c log).
Thanks,
Glen Harvy
|
|
|
|
|
\" will translate to " in C#, unless you put an @ in front of the string. Then, nothing is escaped, and quotes are "".
DataRow[] dr = this.myDataSet.Tables[tr[0]].Select(@"""c-ip"" = '12.12.12.12'");
If what you've got now, is meant to be what's ultimately passed in. Not sure why c-ip is in quotes, tho, if it's a column name, I'd expect ("c-ip = '12.12.12.12'") to be what you wanted.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: \" will translate to " in C#, unless you put an @ in front of the string. Then, nothing is escaped, and quotes are "".
DataRow[] dr = this.myDataSet.Tables[tr[0]].Select(@"""c-ip"" = '12.12.12.12'");
Thanks for your suggestion.
That was my understanding as well BUT this is the result:
DataRow[] dr = this.myWebLoggerDataSet.Tables[tr[0]].Select(@"""c-ip"" = '70.87.3.226'");
Cannot interpret token "" at position 6
I have tried combination after combination without success.
Christian Graus wrote: Not sure why c-ip is in quotes,
the ' - ' is not permitted in column names (at least in SQL CE) so I need to put the column name into double quotes. Naturally I could change the column name but that is going to be a big task when the w3c log format includes the dash.
Glen Harvy
|
|
|
|
|
No, you put the column name in [] in order to override a name that's not standard.
DataRow[] dr = this.myWebLoggerDataSet.Tables[tr[0]].Select(@"[c-ip] = '70.87.3.226'");
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
I have defined an interface called ICustomControl that all of my controls implement. One property in the interface is...
bool LockControl { get; set; }
This property exists so that I can iterate through a collection of ICustomControls and lock them or unlock them. The definition of "locking" a control is control specific.
For a textbox the property looks like this...
public bool LockControl { get { return ReadOnly; } set { ReadOnly = value; } }
For most controls the property looks like this...
public bool LockControl { get { return !Enabled; } set {Enabled = !value; } }
When in the designer I am able to change the LockControl property of a textbox and the ReadOnly property changes along with it. This does not work for controls whose LockControl property tries to change the Enabled property. In fact, the designer does not even allow me to change the value of LockControl.
Is there an attribute I have to put on the property to get this to work correctly in the designer?
|
|
|
|
|
Hi,
I have no experience with this whatsoever, but I would suggest you try
... set { if (!DesignMode) Enabled=!value; }
rationale: the code gets executed by the Designer, so you are actually asking to use
the Control to enable/disable itself. My small addition leaves the Enabled property unchanged
while inside Designer.
|
|
|
|
|
Hello Coders!
This is quite a general question, I’m just looking for a point in the right direction
Is there any way you can “view” an xml document on a C# Form? By this I mean each element shown on various controls and then a next and previous button to cycle through the XML Nodes?
i have tried various things with XMLDocument, XMLNode and XMLElement but have had no avail, and i was just wondering if there was a set way to do it. The XML file contains Portfolio items that have a name, description and an image link.
Thanks for any help
Kris
|
|
|
|
|
I don't know a lot about XML in C#, but since the XML file is encoded using ASCII you should be able to store the xml file in a string then filter it out. That probably doesn't help, but it might work.
-----
*** Never give me an answer having anything to do with Visual Studio. I don't have this because I have two computers, one being my dad's mac, which is connected to the internet, the other being my pc, which is, sadly, not connected to the internet. The setup for the Visual C# program I think is called a "bootstrap" program, and it needs to connect to the internet to install the program. THEREFORE I cannot install this program onto my pc.***
|
|
|
|
|
I am not very clear with your question. But it seems like you want to populate node values in controls. If i am correct then, you can use Xpath and it is pretty straightforward.
In case you need any source code please let me know...
Thanks
Amit
|
|
|
|
|
One option is to host IE as a control, it displays XML with +/- buttons for the parent nodes.
Otherwise, you need to write your own control, or search the web. The classes you mention are for iterating over XML, and they work just fine, they have nothing to do with displaying it, however.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Cheers for the replies guys!
Sorry, I think i was being a bit vague before. What I’m attempting to do is take an XML file that is structured like so:-
<portfolio>
<Item>
<Title>Title</Title>
<Description>Description</summaryDescription>
<Image>imageURL</Image>
</Item>
<Item>
<Title>Title</Title>
<Description>Description</summaryDescription>
<Image>imageURL</Image>
</Item>
...etc
</portfolio>
and displaying the info in separate controls...to the Title in a Textbox and the Image in an Image etc. Then, using 2 buttons, cycle through (left and right) through the items.
its getting the XML into the program I’m having difficulty with, what I want to do is load each Item into an object instance, then put those instances into an ArrayList or something. I’m very new to the .net framework and have tried different things but getting nowhere.
any further help would be fantasic
Thanks again
Kris
|
|
|
|
|
Okay, now that I am learned in the art of XML in C# , here's some code:
using System;<br />
using System.IO;<br />
using System.Xml;<br />
using System.Collections;<br />
<br />
class Run {<br />
static void Main() {<br />
XmlTextReader reader = new XmlTextReader("file.xml");<br />
<br />
ArrayList titles = new ArrayList();<br />
ArrayList descriptions = new ArrayList();<br />
ArrayList images = new ArrayList();<br />
<br />
reader.MoveToContent();<br />
while (reader.Read()) {<br />
if (reader.NodeType == XmlNodeType.Element) {<br />
switch (reader.Name) {<br />
case "Title":<br />
titles.Add(reader.ReadString());<br />
break;<br />
case "Description":<br />
descriptions.Add(reader.ReadString());<br />
break;<br />
case "Image":<br />
images.Add(reader.ReadString());<br />
break;<br />
}<br />
}<br />
}<br />
<br />
for (int a = 0; a < titles.Count; a++) {<br />
Console.WriteLine("-----" + titles[a] + "-----");<br />
Console.WriteLine(descriptions[a]);<br />
Console.WriteLine("Image: " + images[a]);<br />
Console.WriteLine();<br />
}<br />
}<br />
}
There 'ya go! This code gathers all the data and seperates it into ArrayList s, then writes them to the console. To do what you are speaking of, all you have to do is...
- Create your two textboxes, an imagebox (I think that's what it's called) and two buttons
- Create an index integer (e.g.
int index = 0; )
- For the
Click event of the next button, increase the index field by one and set the properties of the textboxes and imagebox to the data in the ArrayLists. (e.g. titleBox.Text = titles[index]; descriptionBox.Text = descriptions[index]; etc.)
- For the
Click event of the back button, do the same thing, except decrease the index field
- Don't forget - if index is greater than titles.Count, set index to zero, and if index < 0, set index to titles.Count
That should do it.
-----
*** Never give me an answer having anything to do with Visual Studio. I don't have this because I have two computers, one being my dad's mac, which is connected to the internet, the other being my pc, which is, sadly, not connected to the internet. The setup for the Visual C# program I think is called a "bootstrap" program, and it needs to connect to the internet to install the program. THEREFORE I cannot install this program onto my pc.***
|
|
|
|
|
Okay, here's the finished code:
using System;<br />
using System.Windows.Forms;<br />
using System.Drawing;<br />
using System.Xml;<br />
using System.Collections;<br />
<br />
class Run : Form {<br />
ArrayList titles;<br />
ArrayList descriptions;<br />
ArrayList images;<br />
int index;<br />
<br />
TextBox titleBox;<br />
TextBox descriptionBox;<br />
PictureBox imageBox;<br />
Button nextButton;<br />
Button prevButton;<br />
<br />
public Run() {<br />
XmlTextReader reader = new XmlTextReader("file.xml");<br />
<br />
index = 0;<br />
titles = new ArrayList();<br />
descriptions = new ArrayList();<br />
images = new ArrayList();<br />
<br />
reader.MoveToContent();<br />
while (reader.Read()) {<br />
if (reader.NodeType == XmlNodeType.Element) {<br />
switch (reader.Name) {<br />
case "Title":<br />
titles.Add(reader.ReadString());<br />
break;<br />
case "Description":<br />
descriptions.Add(reader.ReadString());<br />
break;<br />
case "Image":<br />
images.Add(reader.ReadString());<br />
break;<br />
}<br />
}<br />
}<br />
<br />
reader.Close();<br />
<br />
this.Size = new Size(520, 430);<br />
<br />
titleBox = new TextBox();<br />
titleBox.Text = (string)titles[index];<br />
titleBox.Location = new Point(5, 5);<br />
titleBox.Size = new Size(300, 25);<br />
this.Controls.Add(titleBox);<br />
<br />
descriptionBox = new TextBox();<br />
descriptionBox.Text = (string)descriptions[index];<br />
descriptionBox.Multiline = true;<br />
descriptionBox.Location = new Point(5, 50);<br />
descriptionBox.Size = new Size(300, 300);<br />
this.Controls.Add(descriptionBox);<br />
<br />
imageBox = new PictureBox();<br />
imageBox.Image = Image.FromFile((string)images[index]);<br />
imageBox.Location = new Point(310, 50);<br />
imageBox.Size = new Size(100, 100);<br />
this.Controls.Add(imageBox);<br />
<br />
prevButton = new Button();<br />
prevButton.Text = "<--";<br />
prevButton.Location = new Point(5, 350);<br />
prevButton.Click += new EventHandler(UpdateInfo);<br />
this.Controls.Add(prevButton);<br />
<br />
nextButton = new Button();<br />
nextButton.Text = "-->";<br />
nextButton.Location = new Point(90, 350);<br />
nextButton.Click += new EventHandler(UpdateInfo);<br />
this.Controls.Add(nextButton);<br />
}<br />
<br />
public void UpdateInfo(object sender, EventArgs e) {<br />
if (((Button)sender).Text == "-->") {<br />
index++;<br />
if (index >= titles.Count)<br />
index = 0;<br />
} else {<br />
index--;<br />
if (index < 0)<br />
index = titles.Count-1;<br />
}<br />
<br />
titleBox.Text = (string)titles[index];<br />
descriptionBox.Text = (string)descriptions[index];<br />
imageBox.Image = Image.FromFile((string)images[index]);<br />
}<br />
<br />
static void Main() {<br />
Application.EnableVisualStyles();<br />
Application.Run(new Run());<br />
}<br />
}
I tested it, and it works. Just change the name of the xml file to "file.xml".
-----
*** Never give me an answer having anything to do with Visual Studio. I don't have this because I have two computers, one being my dad's mac, which is connected to the internet, the other being my pc, which is, sadly, not connected to the internet. The setup for the Visual C# program I think is called a "bootstrap" program, and it needs to connect to the internet to install the program. THEREFORE I cannot install this program onto my pc.***
|
|
|
|
|
When you right click on an .exe and go to the Version tab (I think that's what it's called), There are several properties of the application that are visible; they are:
- File Version
- Description
- Copyright
- Assembly Version
- Internal Name
- Language
- Original File Name
- Product Version
Are there options in csc.exe that let you alter these? I couldn't find any when I did csc -? .
Oh yeah, one more thing; When I want to open a file with a program I just created, I right-click the file and press "Open With...". My program is shown in the dialog box that pops up, but all you see is its icon (the default icon) with no text to the right. How do I set the text that is supposed to be there?
-----
*** Never give me an answer having anything to do with Visual Studio. I don't have this because I have two computers, one being my dad's mac, which is connected to the internet, the other being my pc, which is, sadly, not connected to the internet. The setup for the Visual C# program I think is called a "bootstrap" program, and it needs to connect to the internet to install the program. THEREFORE I cannot install this program onto my pc.***
|
|
|
|
|
max29297 wrote: When you right click on an .exe and go to the Version tab (I think that's what it's called), There are several properties of the application that are visible; they are:
* File Version
* Description
* Copyright
* Assembly Version
* Internal Name
* Language
* Original File Name
* Product Version
You can change those values in your AssemblyInfo.cs (or .vb) file. If you look in your solution explorer, expand the "Properties" folder, you should find it there.
|
|
|
|
|
I don't think you read my sig Thanks though, I have some other people's AssemblyInfo.cs files from downloading projects from articles. I can figure it out from there
-----
*** Never give me an answer having anything to do with Visual Studio. I don't have this because I have two computers, one being my dad's mac, which is connected to the internet, the other being my pc, which is, sadly, not connected to the internet. The setup for the Visual C# program I think is called a "bootstrap" program, and it needs to connect to the internet to install the program. THEREFORE I cannot install this program onto my pc.***
|
|
|
|
|
Hi Max,
the AssemblyInfo.cs file gets generated automatically by Visual Studio, but
you can create your own, give it a different name, and/or merge it with other files.
Here is a typical example:
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("TrayIconBuster")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TrayIconBuster")]
[assembly: AssemblyCopyright("Copyright © 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("fbd90b31-54df-4581-b476-c5fd53c9d279")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
|
|
|
Hi Max,
to add a file type with description, use Windows Explorer, Tools, Folder Options,
File Types, New, Advanced, and enter the required information.
BTW: you can add/remove/changeorder the fields shown in Windows Explorer through
View, Choose Details. Some of that info is fetched from the file itself, such as
"program version number" for an .EXE, or "date photo taken" for a .JPEG file (from
a camera that provides such info).
|
|
|
|
|
Hi
I have a problem. How can I get detailed info about sound from the microphone - the info like the 'jumping bars' in winamp, amplitude, etc. I want to make a voice recognition program using a neural net, but need info about the sound.
Thanks for help
|
|
|
|
|