Click here to Skip to main content
15,903,362 members
Home / Discussions / C#
   

C#

 
AnswerRe: please help me!, delete error of the image files(attached source code) Pin
Yusuf18-May-10 15:33
Yusuf18-May-10 15:33 
AnswerRe: please help me!, delete error of the image files(attached source code) Pin
Luc Pattyn18-May-10 15:33
sitebuilderLuc Pattyn18-May-10 15:33 
AnswerRe: please help me!, delete error of the image files(attached source code) [modified] Pin
Dr.Walt Fair, PE18-May-10 15:46
professionalDr.Walt Fair, PE18-May-10 15:46 
GeneralRe: please help me!, delete error of the image files(attached source code) Pin
Luc Pattyn18-May-10 16:16
sitebuilderLuc Pattyn18-May-10 16:16 
GeneralRe: please help me!, delete error of the image files(attached source code) Pin
Dr.Walt Fair, PE18-May-10 16:30
professionalDr.Walt Fair, PE18-May-10 16:30 
GeneralRe: please help me!, delete error of the image files(attached source code) Pin
Luc Pattyn18-May-10 16:31
sitebuilderLuc Pattyn18-May-10 16:31 
GeneralRe: please help me!, delete error of the image files(attached source code) Pin
Dr.Walt Fair, PE18-May-10 18:12
professionalDr.Walt Fair, PE18-May-10 18:12 
QuestionMy LCD doesnt show anything? [modified] Pin
THeKiNG2018-May-10 14:54
THeKiNG2018-May-10 14:54 
My Project:

http://rapidshare.com/files/388966495/bandwidth_meter.rar.html[^]

This program is working but my LCD doesnt show anything. By the way LCD is working a normal condition. I am waiting for your advice. Thank you...

public partial class MainForm : Form
   {
       /// <summary>
       /// Timer Update (every 1 sec)
       /// </summary>
       private const double timerUpdate = 1000;

       /// <summary>
       /// Interface Storage
       /// </summary>
       private NetworkInterface[] nicArr;

       /// <summary>
       /// Main Timer Object
       /// (we could use something more efficient such
       /// as interop calls to HighPerformanceTimers)
       /// </summary>
       private System.Windows.Forms.Timer timer;

       /// <summary>
       /// Constructor
       /// </summary>

       public MainForm()
       {
           InitializeComponent();
           InitializeNetworkInterface();
           InitializeTimer();
       }

       public int data = 888;
       public int control = 890;

       /// <summary>
       /// Initialize all network interfaces on this computer
       /// </summary>
       private void InitializeNetworkInterface()
       {
           // Grab all local interfaces to this computer
           nicArr = NetworkInterface.GetAllNetworkInterfaces();

           // Add each interface name to the combo box
           for (int i = 0; i < nicArr.Length; i++)
               cmbInterface.Items.Add(nicArr[i].Name);

           // Change the initial selection to the first interface
           cmbInterface.SelectedIndex = 0;
       }

       /// <summary>
       /// Initialize the Timer
       /// </summary>
       private void InitializeTimer()
       {
           timer = new System.Windows.Forms.Timer();
           timer.Interval = (int)timerUpdate;
           timer.Tick += new EventHandler(timer_Tick);
           timer.Start();
       }

       /// <summary>
       /// Update GUI components for the network interfaces
       /// </summary>


private void UpdateNetworkInterface()
        {
            string title, duration;

            // Grab NetworkInterface object that describes the current interface
            NetworkInterface nic = nicArr[cmbInterface.SelectedIndex];

            // Grab the stats for that interface
            IPv4InterfaceStatistics interfaceStats = nic.GetIPv4Statistics();

           
            int bytesSentSpeed = (int)(interfaceStats.BytesSent - double.Parse(lblBytesSent.Text)) / 1024;
            int bytesReceivedSpeed = (int)(interfaceStats.BytesReceived - double.Parse(lblBytesReceived.Text)) / 1024;

            // Update the labels
            lblSpeed.Text = nic.Speed.ToString();
            lblInterfaceType.Text = nic.NetworkInterfaceType.ToString();
            lblSpeed.Text = nic.Speed.ToString();
            lblBytesReceived.Text = interfaceStats.BytesReceived.ToString();
            lblBytesSent.Text = interfaceStats.BytesSent.ToString();
            lblUpload.Text = bytesSentSpeed.ToString() + " KB/s";
            lblDownload.Text = bytesReceivedSpeed.ToString() + " KB/s";

            title = lblDownload.Text;
            duration = lblUpload.Text;

            writetoLCD(title, duration);

            

        }

        /// <summary>
        /// The Timer event for each Tick (second) to update the UI
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void timer_Tick(object sender, EventArgs e)
        {
            UpdateNetworkInterface();
        }

private void writetoLCD(string title, string duration)
        {
            PortAccess.Output(data, 1);
            PortAccess.Output(control, 8); Thread.Sleep(1);
            PortAccess.Output(control, 9); Thread.Sleep(1);


            int a;
            char[] line1_ch_buffer, line2_ch_buffer;
            string line1_st_buffer, line2_st_buffer;

            line1_st_buffer = title;
            line1_ch_buffer = line1_st_buffer.ToCharArray();
            line2_st_buffer = duration;
            line2_ch_buffer = line2_st_buffer.ToCharArray();

            HangiSatir(1, 1);
            for (a = 0; a < line1_ch_buffer.Length; a++)
            {
               
                PortAccess.Output(control, 4); Thread.Sleep(1);
                PortAccess.Output(data, (int)line1_ch_buffer[a]);
                
                PortAccess.Output(control, 5); Thread.Sleep(1);
            }

            HangiSatir(2, line1_ch_buffer.Length);
            for (a = 0; a < line2_ch_buffer.Length; a++)
            {
                
                PortAccess.Output(control, 5); Thread.Sleep(1);
                PortAccess.Output(control, 4); Thread.Sleep(1);
                PortAccess.Output(data, (int)line2_ch_buffer[a]);
                
                PortAccess.Output(control, 5); Thread.Sleep(1);
            }
        }

        private void HangiSatir(int line, int column)
        {
            PortAccess.Output(control, 8);

            if (line == 1)
                PortAccess.Output(data, 127 + column);

            if (line == 2)
            {
                int sayi = 39 - column;
                for (int i = 0; i <= sayi; i++)
                {
                    PortAccess.Output(control, 4); Thread.Sleep(1);
                    PortAccess.Output(data, 16);
                    PortAccess.Output(control, 5); Thread.Sleep(1);
                }
            }
        }

public class PortAccess
{

    [DllImport("inpout32.dll", EntryPoint = "Out32")]
    public static extern void Output(int adress, int value);
    
    [DllImport("inpout32.dll", EntryPoint = "Inp32")]
    public static extern int Input(int adress);



Please help me. Thank you for your answers

modified on Tuesday, May 18, 2010 9:48 PM

AnswerRe: My LCD doesnt show anything? Pin
Yusuf18-May-10 15:34
Yusuf18-May-10 15:34 
GeneralRe: My LCD doesnt show anything? Pin
THeKiNG2018-May-10 15:39
THeKiNG2018-May-10 15:39 
AnswerRe: My LCD doesnt show anything? Pin
Luc Pattyn18-May-10 15:37
sitebuilderLuc Pattyn18-May-10 15:37 
GeneralRe: My LCD doesnt show anything? Pin
THeKiNG2018-May-10 15:40
THeKiNG2018-May-10 15:40 
AnswerRe: My LCD doesnt show anything? Pin
THeKiNG2019-May-10 9:36
THeKiNG2019-May-10 9:36 
QuestionQuery users in Security Tab from an AD member Pin
Scolo18-May-10 11:10
Scolo18-May-10 11:10 
QuestionOpening IE7 without menus or an address bar Pin
Melanie Peterson18-May-10 11:04
Melanie Peterson18-May-10 11:04 
AnswerRe: Opening IE7 without menus or an address bar Pin
Not Active18-May-10 11:19
mentorNot Active18-May-10 11:19 
GeneralRe: Opening IE7 without menus or an address bar Pin
Melanie Peterson18-May-10 11:25
Melanie Peterson18-May-10 11:25 
GeneralRe: Opening IE7 without menus or an address bar Pin
Not Active18-May-10 11:30
mentorNot Active18-May-10 11:30 
QuestionDataGridView DataSource: bindingSource or dataSet? Pin
mprice21418-May-10 10:49
mprice21418-May-10 10:49 
AnswerRe: DataGridView DataSource: bindingSource or dataSet? Pin
Henry Minute18-May-10 12:42
Henry Minute18-May-10 12:42 
QuestionMessage Closed Pin
18-May-10 10:24
Member 333565318-May-10 10:24 
Questiondisable sound Pin
behzadcp18-May-10 9:14
professionalbehzadcp18-May-10 9:14 
AnswerRe: disable sound Pin
Not Active18-May-10 10:03
mentorNot Active18-May-10 10:03 
AnswerRe: disable sound Pin
Henry Minute18-May-10 10:12
Henry Minute18-May-10 10:12 
GeneralRe: disable sound Pin
harold aptroot18-May-10 13:02
harold aptroot18-May-10 13:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.