|
Are you using a custom graph library, or is it one you've created yourself?
|
|
|
|
|
I'm using the chart library that comes with .Net Framework 4.0 in the
'System.Windows.Forms.DataVisualization.Charting' namespace.
|
|
|
|
|
This[^] might help you out then.
|
|
|
|
|
Hi everyone! I'm creating a line chart using .net framework 4. I'm a able to add points to the series which are used on the vertical axis. However, numbers are automatically assigned to the x-axis for each marker.
How do I change the numbering into my own values? The labels for the x-axis are string values and not numbers. Thanks.
modified 3-Jul-12 10:28am.
|
|
|
|
|
Hi All (especially Pete O'Hanlon),
I have now found the driver I think I am looking for the " KernelDriver,FTDIBUS,USB Serial Converter Driver" I can now check for this driver find it using the code:
ServiceController[] scDevices = ServiceController.GetDevices();
MessageBox.Show("Device driver services on the local computer");
foreach (ServiceController scTemp in scDevices)
{
lstDrivers.Items.Add(scTemp.ServiceType + "," + scTemp.ServiceName +
"," + scTemp.DisplayName);
}
I think if I can check the value of this it will do.
Pete O'Hanlon gave me some code in a question called "Correct way of doing installers"
using a Dictionary command, in copying this and trying to use it, I have obviously lost something / not understood something as the red wiggly line for syntax errors appear in System.Management. commands, I am using VS 2008 (.NET 3.5) and using System.Management only give one . option Instrumentation(?). Should I be using a Build option I have not seen before. So really the question is if I can't do it from here how can I get Petes example to work in VS 2008?
Glenn
modified 3-Jul-12 7:51am.
|
|
|
|
|
ServiceController exists in System.ServiceProcess. You need to add a reference to that.
[Edit]It's worth noting that your code is different to the example I gave, so your question doesn't make much sense if someone just reads what you've put (as I just did). This[^] is the original thread.
|
|
|
|
|
I do have that full list below (I am using 2008, .NET3.5) also
System.Management.SelectQuery query = new System.Management.SelectQuery("Win32_SystemDriver");
should get around that
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Management;
using System.ServiceProcess;
I take it the method I created will only get the name rather than anything useful. The dictionary method, I have not used much (you are only using a get method no set!) could you point me in the direction of a reasonable tutorial. A few minute job is taking so long!
Glenn
|
|
|
|
|
Have you added a reference to System.Management? It sounds like you accidentally added a reference to System.Management.Instrumentation instead.
|
|
|
|
|
Yup!
is only there as I was looking for what else was there (being nosey!) I do have
using System.Management; and
using System.ServiceProcess; any ideas.....
|
|
|
|
|
That's not what I meant by adding a reference. Right click on your project and choose Add Reference... . Scroll through the list of available .NET references and add System.Management (and System.ServiceProcess if you need it).
|
|
|
|
|
Ahh, right okay, sorry about that (too many other things, phone calls etc. got distracted from what I was (trying) to do!) the red wiggly lines have gone, been replaced by blue
on the
System.Management.ManagementObject manageObject = searcher.Get();
and the additions to the list box "driver"
driver.Add("PathName", manageObject["PathName"]);
Sorry, again I have missed something!
Glenn
|
|
|
|
|
Change the method to this:
public static Dictionary<string, string> GetDriverInfo(string driverName)
{
Dictionary<string, string> driver = new Dictionary<string, string>();
System.Management.SelectQuery query = new System.Management.SelectQuery("Win32_SystemDriver");
query.Condition = string.Format("Name='{0}'", driverName);
System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher(query);
foreach (System.Management.ManagementObject manageObject in searcher.Get())
{
driver.Add("PathName", manageObject["PathName"].ToString());
driver.Add("Description", manageObject["Description"].ToString());
driver.Add("State", manageObject["State"].ToString());
driver.Add("StartMode", manageObject["StartMode"].ToString());
}
return driver;
} That should do it.
|
|
|
|
|
Yayy!! the wiggly lines have gone, cue the happy dance!
(seriously) Thanks Alot!
Glenn
|
|
|
|
|
You're welcome. This is what I get when I just type code samples into the CP Message box with the famous battle cry of "this should work".
|
|
|
|
|
I now need to use the Dictionary created how can I upload the list and then search it,
if follow the reckoning I have used before would give:
driver.Add(manageObject["PathName"].ToString(),"Description",manageObject["Description"].ToString(),"State", manageObject["State"].ToString()+"StartMode",ManageObject["StartMode"].ToString());
As I in the past have done with a Dictionary
Dictionary.Add("01010", "Glenn"); and this is read out using
Console.WriteLine("myDictionary[\"01010\"]:{0}",Dictonary["01010"]);
only done it at the console!
Glenn (sorry)
modified 3-Jul-12 11:40am.
|
|
|
|
|
Right - now I'm assuming that you are using the Visual Studio installer in this example. What you do is create a custom installer step (like this[^]) and add your logic in there. Have a look here[^] for further details.
|
|
|
|
|
|
Umm, it will be caught up in an installer once it's all working, however now I would like a method of finding out about the drivers with out having to run an installer (I can see a use for it not connected to this project!)
Glenn
|
|
|
|
|
Thanks for that still learning the correct (CP) way of doing things.
Glenn
|
|
|
|
|
Hi All
I've got some problems with converting readed text from *.doc file. I'm using this code:
FileStream fs = null;
fs = new FileStream(plik.ToString(), FileMode.Open);
byte[] example = new byte[fs.Length];
fs.Read(example, 0, example.Length);
string outtext = "";
int count = 0;
for (int i = 2560; i < example.Length; i++)
{
if (example[i] == 0)
{
break;
}
count++;
}
BinaryReader br = new BinaryReader(fs, Encoding.GetEncoding(1250));
br.BaseStream.Position = 2560;
byte[] newarr = br.ReadBytes(count);
outtext = System.Text.UTF8Encoding.UTF8.GetString(newarr);
string str = "";
for (int i = 0; i < outtext.Length; i++)
{
if ((outtext[i] >= '!' && outtext[i] <= '~') || (outtext[i] == ' ') || (outtext[i] == '\r'))
{
str += outtext[i];
}
}
fs.Close();
tekst = str;
It works great till I try to read file with polish symbols (ISO-8859-2). I try'ed to convert it to ISO-8859-2 but it is not working propertly.
Could anybody help me with this problem?
|
|
|
|
|
"Windows-1250 is similar to ISO-8859-2 and has all the printable characters it has and more. However a few of them are rearranged (unlike Windows-1252, which keeps all printable characters from ISO-8859-1 in the same place). Most of the rearrangements seem to have been done to keep characters shared with Windows-1252 in the same place as in Windows-1252 but three of the characters moved (Ą,Ľ,ź) cannot be explained this way."
I'd suggest you use "ISO-8859-2" as your encoding to read the file, not Windows-1250.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
|
Satay84 wrote: I'm using ISO-8859-2 encription:
Not in the code you posted;
BinaryReader br = new BinaryReader(fs, Encoding.GetEncoding(1250));
If you read them in the correct format and save them as UTF8, you should not see a loss of information.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
As You told me I convert sorce data to iso-8859-2 and then to UTF-8, but the result was the same. If I convert english docs it works perfect, but when I use polish docs i get this result string: "."
There's solution that I create for this:
FileStream fs = null;
try
{
fs = new FileStream(plik.ToString(), FileMode.Open);
byte[] example = new byte[fs.Length];
fs.Read(example, 0, example.Length);
string outtext = "";
int count = 0;
for (int i = 2560; i < example.Length; i++)
{
if (example[i] == 0)
{
break;
}
count++;
}
BinaryReader br = new BinaryReader(fs, Encoding.GetEncoding("iso-8859-2"));
br.BaseStream.Position = 2560;
byte[] newarr = br.ReadBytes(count);
outtext = System.Text.UTF8Encoding.UTF8.GetString(newarr);
string str = "";
for (int i = 0; i < outtext.Length; i++)
{
if ((outtext[i] >= '!' && outtext[i] <= '~') || (outtext[i] == ' ') || (outtext[i] == '\r'))
{
str += outtext[i];
}
}
fs.Close();
tekst = str;
}
catch (Exception exc)
{
Console.WriteLine(exc.ToString());
return;
}
So could anybody give me any other advice?
|
|
|
|
|
Aight, let's take a look at this piece of the code;
BinaryReader br = new BinaryReader(fs, Encoding.GetEncoding("iso-8859-2"));
br.BaseStream.Position = 2560;
byte[] newarr = br.ReadBytes(count);
outtext = System.Text.UTF8Encoding.UTF8.GetString(newarr);
You are reading the file as an array of bytes - those values won't change based on the encoding. Once you convert it to a string, it'll have to know what encoding to use to convert those bytes into the correct character. That's what your last line is doing, but it is using the UTF8-encoding - not your iso-8859-2. Hence, the system will interpret those bytes that you just read as UTF8.
Read them as the iso-format, and all should work.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|