|
Where did you put the library?
it should be in a folder that is listed in the PATH environment variable.
As it probably is a 32-bit dll, it should NOT be put in C:\Windows\System32 (which is used only by 64-bit apps), Windows is confusing here, C:\Windows\SysWOW64 (which is used only by 32-bit apps) would be good though. Same applies to all dependencies of your dll file, if any.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
First I put it in folder when is file .exe. Now I put it to C:\Windows\SysWOW64, but application have error, that not found this library.
|
|
|
|
|
hi everyone,
this is my first post here.
i need a help please...
(i'm a beginner in c#)
i have to make two analog clocks with visual studio in c#,wich they must be in a different time zone beside each other,one with our time and the second could be any place in the world.
i made the first analog clock and than i copied it and i made a new class for it,but when i start debugging the second clock comes under the first one and attached to it,how can i move the second clock parallel to the right side of the first clock??
this is the main code wich contain the ode of the first clock:
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Drawing.Drawing2D;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace analoge_uhr<br />
{<br />
public partial class Form1 : Form<br />
{<br />
private Clock uhr1;<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);<br />
this.SetStyle(ControlStyles.UserPaint, true);<br />
this.SetStyle(ControlStyles.DoubleBuffer, true);<br />
uhr1 = new Clock();<br />
}<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
base.OnPaint(e);<br />
System.Drawing.Graphics gr = e.Graphics;<br />
<br />
Rectangle rec = new Rectangle(20, 20, 250, 250);<br />
LinearGradientBrush linearbrush = new LinearGradientBrush(rec, Color.Yellow, Color.Green, 225);<br />
gr.FillEllipse(linearbrush, 20, 20, 200, 200);<br />
linearbrush.LinearColors = new Color[] { Color.Silver, Color.Silver, };<br />
gr.FillEllipse(linearbrush, 30, 30, 180, 180);<br />
linearbrush.LinearColors = new Color[] { Color.Black, Color.Black };<br />
gr.FillEllipse(linearbrush, 33, 33, 174, 174);<br />
SolidBrush solidbrush = new SolidBrush(Color.White);<br />
Font textFont = new Font("Arial Bold", 12F);<br />
gr.DrawString("12", textFont, solidbrush, 109, 40);<br />
gr.DrawString("11", textFont, solidbrush, 75, 50);<br />
gr.DrawString("10", textFont, solidbrush, 47, 75);<br />
gr.DrawString("9", textFont, solidbrush, 43, 110);<br />
gr.DrawString("8", textFont, solidbrush, 52, 145);<br />
gr.DrawString("7", textFont, solidbrush, 75, 170);<br />
gr.DrawString("6", textFont, solidbrush, 113, 180);<br />
gr.DrawString("5", textFont, solidbrush, 150, 170);<br />
gr.DrawString("4", textFont, solidbrush, 173, 145);<br />
gr.DrawString("3", textFont, solidbrush, 182, 110);<br />
gr.DrawString("2", textFont, solidbrush, 173, 75);<br />
gr.DrawString("1", textFont, solidbrush, 150, 50);<br />
gr.TranslateTransform(120, 120, MatrixOrder.Append);<br />
int hour = DateTime.Now.Hour;<br />
int min = DateTime.Now.Minute;<br />
int sec = DateTime.Now.Second;<br />
Pen hourPen = new Pen(Color.White, 2);<br />
Pen minutePen = new Pen(Color.LightGray, 2);<br />
Pen secondPen = new Pen(Color.Red, 1);<br />
double secondAngle = 2.0 * Math.PI * sec / 60.0;<br />
double minuteAngle = 2.0 * Math.PI * (min + sec / 60.0) / 60.0;<br />
double hourAngle = 2.0 * Math.PI * (hour + min / 60.0) / 12.0;<br />
Point centre = new Point(0, 0);<br />
Point hourHand = new Point((int)(40 * Math.Sin(hourAngle)),<br />
(int)(-40 * Math.Cos(hourAngle)));<br />
gr.DrawLine(hourPen, centre, hourHand);<br />
Point minHand = new Point((int)(70 * Math.Sin(minuteAngle)),<br />
(int)(-70 * Math.Cos(minuteAngle)));<br />
gr.DrawLine(minutePen, centre, minHand);<br />
Point secHand = new Point((int)(70 * Math.Sin(secondAngle)),<br />
(int)(-70 * Math.Cos(secondAngle)));<br />
gr.DrawLine(secondPen, centre, secHand);<br />
<br />
uhr1.daw(e.Graphics);<br />
<br />
Invalidate();<br />
}<br />
<br />
} <br />
}<br />
and here is the code for the second clock,wich i opened for it a new class:
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Drawing;<br />
using System.Drawing.Drawing2D;<br />
<br />
namespace analoge_uhr<br />
{<br />
class Clock<br />
{<br />
<br />
public void daw(System.Drawing.Graphics g){<br />
<br />
Rectangle rec = new Rectangle(20, 20, 250, 250);<br />
LinearGradientBrush linearbrush = new LinearGradientBrush(rec, Color.Blue, Color.BlueViolet, 225);<br />
g.FillEllipse(linearbrush, 20, 20, 200, 200);<br />
linearbrush.LinearColors = new Color[] { Color.Silver, Color.Silver, };<br />
g.FillEllipse(linearbrush, 30, 30, 180, 180);<br />
linearbrush.LinearColors = new Color[] { Color.Black, Color.Black };<br />
g.FillEllipse(linearbrush, 33, 33, 174, 174);<br />
SolidBrush solidbrush = new SolidBrush(Color.White);<br />
Font textFont = new Font("Arial Bold", 12F);<br />
g.DrawString("12", textFont, solidbrush, 109, 40);<br />
g.DrawString("11", textFont, solidbrush, 75, 50);<br />
g.DrawString("10", textFont, solidbrush, 47, 75);<br />
g.DrawString("9", textFont, solidbrush, 43, 110);<br />
g.DrawString("8", textFont, solidbrush, 52, 145);<br />
g.DrawString("7", textFont, solidbrush, 75, 170);<br />
g.DrawString("6", textFont, solidbrush, 113, 180);<br />
g.DrawString("5", textFont, solidbrush, 150, 170);<br />
g.DrawString("4", textFont, solidbrush, 173, 145);<br />
g.DrawString("3", textFont, solidbrush, 182, 110);<br />
g.DrawString("2", textFont, solidbrush, 173, 75);<br />
g.DrawString("1", textFont, solidbrush, 150, 50);<br />
g.TranslateTransform(120, 120, MatrixOrder.Append);<br />
int hour = DateTime.Now.Hour;<br />
int min = DateTime.Now.Minute;<br />
int sec = DateTime.Now.Second;<br />
Pen hourPen = new Pen(Color.White, 2);<br />
Pen minutePen = new Pen(Color.LightGray, 2);<br />
Pen secondPen = new Pen(Color.Red, 1);<br />
double secondAngle = 2.0 * Math.PI * sec / 60.0;<br />
double minuteAngle = 2.0 * Math.PI * (min + sec / 60.0) / 60.0;<br />
double hourAngle = 2.0 * Math.PI * (hour + min / 60.0) / 12.0;<br />
Point centre = new Point(0, 0);<br />
Point hourHand = new Point((int)(40 * Math.Sin(hourAngle)),<br />
(int)(-40 * Math.Cos(hourAngle)));<br />
g.DrawLine(hourPen, centre, hourHand);<br />
Point minHand = new Point((int)(70 * Math.Sin(minuteAngle)),<br />
(int)(-70 * Math.Cos(minuteAngle)));<br />
g.DrawLine(minutePen, centre, minHand);<br />
Point secHand = new Point((int)(70 * Math.Sin(secondAngle)),<br />
(int)(-70 * Math.Cos(secondAngle)));<br />
g.DrawLine(secondPen, centre, secHand);<br />
<br />
}<br />
}<br />
<br />
}<br />
<br />
and thanky you...
modified on Saturday, April 30, 2011 4:31 PM
|
|
|
|
|
Hi,
welcome to CodeProject.
A few suggestions for starters: there is a nice message "How to get an answer..." somewhere high up on this page; I suggest you read it carefully. It will tell you to provide a better subject line, to format your code (by using PRE tags), and many other things all helping you to get more answers, resulting in better and earlier feedback.
I did not study all that code (as it isn't in PRE tags, you can still edit the existing message!) however I can tell you this:
1.
it isn't object oriented. You should never copy-paste a bunch of code just because you want two identical or almost identical things somewhere. That most likely gets handled by creating a class (=a set of code and data pertaining to a real-world object (or maybe something more abstract).
2.
Furthermore, an AnalogClock should be a class that inherits from UserControl, so you can turn it into a separate DLL file, making it available to all kinds of WinForms applications, just like the standard Buttons, Labels and all known Controls. I suggest you read up on UserControl, and maybe search for some CodeProject articles on analog clocks while you're at it.
3.
Controls (and other classes) can have Properties, that is how you would specify e.g. their location on a Form. Or their offset from GMT (their time zone).
4.
there are more elegant ways to draw the digits, a for loop driven by a coordinates array comes to mind. Anything would be better than a sequence of
gr.DrawString("12", textFont, solidbrush, 109, 40);
gr.DrawString("11", textFont, solidbrush, 75, 50);
gr.DrawString("10", textFont, solidbrush, 47, 75);
...
5.
When you create drawing objects such as Fonts, Pens, Graphics, etc, you should clean up after yourself (yes, the GC does that also, however it does it late, and graphics objects can be expensive). So check if the class has a Dispose() method, and if it does, use it.
There are two alternatives:
- create those objects once, and keep them around as class members inside your AnalogClock class;
- or use a using statement (read up on it, it is perfect for these kinds of things).
There may be more, however that should get you started in the right direction.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
thanks 4 ur reply,i would notice that...
|
|
|
|
|
I want to make a wysiwyg program in c#, that is composed from a webbrowser control and a form1.
Inside form1 I want to make some search through files(mostly simple txt files) and if needed some extraction from zipped files. That is the main purpose of that form1 made in c#. In the webbrowser control I want to load txt files,generate menus with those txt files, html pages(local or online). All of these I will edit INSIDE that webcontrol through javascript-html-css on the fly(or edit the source file itself).
Why? because is so easy to make allmost anything in a html format-its more intuitive.
Most of the things that this program should do is for local files management => meaning tutorials, hints,tips, snippets,codes,thoughts,comments,pictures,etc.
That is what I want to do.
Now, my question is like this:
How do I take the content from a javascript variable, and paste it into a c# variable?
(The revers situation when i must copy content from a c# variable, I usually save that content in a txt file,then read that file in a javascript variable.)
thank you.
|
|
|
|
|
You don't. Javascript doesn't know anything about C# nor does it even know that it's running inside of a webbrowser control inside your Windows Forms app.
|
|
|
|
|
merlinq12 wrote: How do I take the content from a javascript variable, and paste it into a c# variable?
Call a webservice
I are Troll
|
|
|
|
|
I am totally new on webservice callings.
Can you give me an explicit example? please.
thank you.
|
|
|
|
|
merlinq12 wrote: I am totally new on webservice callings.
Can you give me an explicit example? please.
It's not something you do within a few lines of code.
The w3schools website has a nice explanation on Ajax[^], that should show you how to call a webservice with a variable. You'd also need a webserver to host that webservice - that's where the C# code would run.
I are Troll
|
|
|
|
|
Hello!
I'm using this code to detect the cpu temperature.
But I get the error: "The type or namespace name 'ManagementClass' could not be found (are you missing a using directive or an assembly reference?)", But I think I use all usings I need.
I'm using visual C# 2010
This is my code:
using System;
using System.Windows.Forms;
using System.Management;
namespace Heater
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ManagementClass processClass = new ManagementClass(@"root\WMI:MSAcpi_ThermalZoneTemperature");
foreach (ManagementObject service in processClass.GetInstances())
{
MessageBox.Show("CPU Temperature: " + service.GetPropertyValue("CurrentTemperature"));
}
}
static decimal ConvertToCelsius(string reading)
{
return (decimal.Parse(reading) / 10 - 273.15m);
}
}
}
I want the output to label1, but that's not important now, because the script isn't working.
If I remove all unused usings, system.management is gone too!
Thanks in advance!
PS: sorry for my worse English :/
|
|
|
|
|
I guess you are compiling for "Client profile" and need to compile for the "Full framework".
Philippe Mori
|
|
|
|
|
Ok, but how to that in MS Visual C# 2010?!?
|
|
|
|
|
- Display project properties (from contextual menu)
- Application tab
- Target framework
- Select appropriate target framework.
Client profile is a subset of the full framework that essentially contains classes that are mostly used by regular applications.
Philippe Mori
|
|
|
|
|
|
as the error suggests, you need two things: a using directive (or a heavy duty keyboard and a lot of time) and a reference.
I think you did the using directive yourself, without having the required reference. My advice is:
1.
Take care of the reference first, use Solution Pane, Add Reference; the MSDN doc on the class of interest tells you which one you need.
2.
Once the ref is in place, Intellisense will guide you trough the using directive.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I only can find this, but what do you mean? Do I miss a piece of code?
|
|
|
|
|
and that page says:
Assembly: System.Management (in System.Management.dll)
So add the reference to your project as I told you.
rms123 wrote: Do I miss a piece of code?
No.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Okey! thanks, it's working!
|
|
|
|
|
Luc Pattyn wrote: you need two things: a using statement
No you frackin' don't!
|
|
|
|
|
Right. Fixed it.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Better... but it's a directive, not a statement.
|
|
|
|
|
fixed that too. Thanks.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi all
i created a database and table for language and translations
the fileds are like this
<br />
language-><br />
languagename,languagecode<br />
English 101<br />
Hindi 102<br />
<br />
translation-><br />
textinenglish,languagecode,translated<br />
Hellow 101 Hellow<br />
Hellow 102 hindihellow
Now I Have A Combo box in my form and 1 label
I Need To Change label text to the selected language in combobox
so i writed code like this but i dont know how to get the value from database Please Help me
SqlConnection con = new SqlConnection("server=ARUN-09BF105DE8\\AR; initial catalog=prod; integrated security=true");
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
object scode;
scode = comboBox1.SelectedValue;
changelanguage(scode);
}
public void changelanguage(object code) {
con.Open();
SqlCommand com = new SqlCommand();
SqlDataReader dr;
com.Parameters.AddWithValue("language", code);
com.CommandText = "SELECT translated FROM translation WHERE languagecode=@language";
dr=com.ExecuteReader();
}
Trust one who has tried
|
|
|
|
|
If you look here: http://stackoverflow.com/questions/119568/best-practice-to-make-a-multi-language-application-in-c-winforms[^] there is a discussion of the various ways to achieve this. The way you have selected is not necessarily the best: it requires a version of SQLServer to be available to each PC on which your app will run, which may not be possible or desirable.
However:
public void changelanguage(object code) {
con.Open();
SqlCommand com = new SqlCommand();
SqlDataReader dr;
com.Parameters.AddWithValue("language", code);
com.CommandText = "SELECT translated FROM translation WHERE languagecode=@language";
dr=com.ExecuteReader();
while (dr.Read()) {
if ((string) dr["textinenglish"] == theWordIWantToTranslate) {
...
}
}
}
BTW: Please remember that you are responsible for Close-ing and Dispose-ing all of the SQLCommand and SQLConnection objects you create!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|