?
Solved

C# Picture Switch

Posted on 2009-05-15
4
Medium Priority
?
801 Views
Last Modified: 2013-12-17
Hello All,

Attempting to switchout the picture box on the button click even and then after 5 seconds return to the original image.  Instead i am receiving the following errors...

Error      1      Type or namespace definition, or end-of-file expected      \\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Form1.cs      239      1      Trigger Tracker
Error      2      The name 'imageMain' does not exist in the current context      \\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Form1.cs      35      13      Trigger Tracker
Error      3      The name 'imageTemp' does not exist in the current context      \\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Form1.cs      36      13      Trigger Tracker
Error      4      'Trigger_Tracker.TriggerTrackerPictureBox' does not contain a definition for 'Image'      \\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Form1.cs      38      38      Trigger Tracker
Error      5      The name 'imageMain' does not exist in the current context      \\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Form1.cs      38      46      Trigger Tracker
Error      6      The name 'imageMain' does not exist in the current context      \\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Form1.cs      53      13      Trigger Tracker
Error      7      The name 'imageTemp' does not exist in the current context      \\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Form1.cs      54      13      Trigger Tracker
Error      8      'Trigger_Tracker.TriggerTrackerPictureBox' does not contain a definition for 'Image'      \\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Form1.cs      56      38      Trigger Tracker
Error      9      The name 'imageMain' does not exist in the current context      \\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Form1.cs      56      46      Trigger Tracker
Error      10      No overload for method 'GetListItems' takes '6' arguments      \\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Form1.cs      81      38      Trigger Tracker
Error      11      An object reference is required for the non-static field, method, or property 'System.Windows.Forms.Control.Enabled.get'      \\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Form1.cs      118      13      Trigger Tracker
Error      12      'Trigger_Tracker.TriggerTrackerPictureBox' does not contain a definition for 'Image'      \\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Form1.cs      120      38      Trigger Tracker
Error      13      The name 'imageMain' does not exist in the current context      \\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Form1.cs      120      46      Trigger Tracker

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Xml;
using System.ServiceModel;
using System.Net;
 
namespace Trigger_Tracker
{
    public partial class Form1 : Form
    {//form move on click and drag
        bool FormMoving;
        Point initialPoint;
        TriggerTrackerPictureBox frmPicture;
 
        public Form1()
        {//form move on click and drag
            InitializeComponent();
            comboBox1.SelectedIndex = 0;
            FormMoving = false;
 
            frmPicture = new TriggerTrackerPictureBox();
            frmPicture.localForm = this;
            frmPicture.Owner = this;
            frmPicture.Show();
            frmPicture.Width = 68;
            frmPicture.Height = 65;
            SetPositionOfPictureForm();
            // Load the images into memory
            imageMain = Image.FromFile(@"\\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Resources\AnimatedGecko2.gif");
            imageTemp = Image.FromFile(@"\\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Resources\havalina_animated.gif");
            // Set the picture box main image here
            TriggerTrackerPictureBox.Image = imageMain;
            // Set the timer interval to 5 seconds, each value 1000 = 1 second.
            timer1.Interval = 5000;
 
        }
 
        private void SetPositionOfPictureForm()
        {
            frmPicture.Top = this.Top + 26;
            frmPicture.Left = this.Left + 87;
        }
 
        private void TriggerTrackerLoad(object sender, EventArgs e)
        {
            // Load the images into memory
            imageMain = Image.FromFile(@"\\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Resources\AnimatedGecko2.gif");
            imageTemp = Image.FromFile(@"\\AZ2KNAS01\data\AZ-Service-Projects\Andrew's Programs and Data\Trigger Tracker\Trigger Tracker MOD\Trigger Tracker\Resources\havalina_animated.gif");
            // Set the picture box main image here
            TriggerTrackerPictureBox.Image = imageMain;
            // Set the timer interval to 5 seconds, each value 1000 = 1 second.
            timer1.Interval = 5000;
 
        }
 
        private void PolicyNumberLabel(object sender, EventArgs e)
        {
 
        }
 
        private void TrackerButton(object sender, EventArgs e)
        {
            string listGUID = "3F28BC5A-93DB-4C34-A62D-750F49B758F1";
            string viewGUID = "C1199262-2EEE-4012-A9BB-9AE16926EFA9";
           //string viewGUID2 = "6B2F3EF2-4B0C-41E1-B87E-0C3185B587DD";
 
            int ItemCounter = 1;
            ServiceList.Lists listService = new ServiceList.Lists();
           // RetentionLists.ListsSoapClient listService = new RetentionLists.ListsSoapClient();
 
            //////
           listService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
           //listService.ChannelFactory.Credentials.Windows.ClientCredential   = System.Net.CredentialCache.DefaultNetworkCredentials;
 
            XmlNode activeItemData = listService.GetListItems(listGUID, viewGUID, null, null, "100", null);
            XmlDocument xDoc = new XmlDocument();
            string tmpString = activeItemData.InnerXml.Replace("\r\r", "");
            xDoc.LoadXml(tmpString);
            XmlNamespaceManager nsManager = new XmlNamespaceManager(xDoc.NameTable);
            nsManager.AddNamespace("z", "#RowsetSchema");
            nsManager.AddNamespace("rs", "urn:schemas-microsoft-com:rowset");
 
            XmlNodeList xNode = xDoc.SelectNodes("/rs:data/z:row", nsManager);
 
            foreach (XmlNode tmpNode in xNode)
                ItemCounter++;
 
            StringBuilder strBuilder = new StringBuilder();
            strBuilder.Append("<Method ID='" + ItemCounter + "' Cmd='New'>");
            strBuilder.Append("<Field Name='Attachments'>" + "0" + "</Field>");
            strBuilder.Append("<Field Name='Title'>" + PolicyNumber.Text + "</Field>");
            strBuilder.Append("<Field Name='Reason'>" + comboBox1.Text + "</Field>");
            strBuilder.Append("</Method>");
 
            string strBatch = strBuilder.ToString();
 
            XmlDocument newDoc = new XmlDocument();
            XmlElement newElement = newDoc.CreateElement("Batch");
            newElement.SetAttribute("OnError", "Continue");
            newElement.SetAttribute("ViewName", viewGUID);
            newElement.InnerXml = strBatch;
            
            XmlNode returnNode = listService.UpdateListItems(listGUID, newElement);
 
            this.comboBox1.Text = "Please Select....";
            this.PolicyNumber.Text = "";
            this.PolicyNumber.Mask = "0000000000";
 
            comboBox1.Focus();
            // After the set interval this method is called by the system
            // Disable the timer from triggering again
            TriggerTrackerPictureBox.Enabled = false;
            // Reset the image back to the main image
            TriggerTrackerPictureBox.Image = imageMain;
 
        }
 
        private void PolicyNumberTextBox(object sender, EventArgs e)
        {
 
        }
 
 
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            
        }
 
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {           
            
        }
 
        private void maskedTextBox1_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
        {
 
        }
 
 
        public void Form1_MouseUp(object sender, MouseEventArgs e)
        {//form move on click and drag
            FormMoving = false;
        }
 
        public void Form1_MouseMove(object sender, MouseEventArgs e)
        {//form move on click and drag
            if (FormMoving)
            {
                if ((Left + e.X - initialPoint.X) <= 0)
                    Left = 0;
                else if ((Right + e.X - initialPoint.X) >= Screen.PrimaryScreen.Bounds.Right)
                    Left = Screen.PrimaryScreen.Bounds.Right - Width;
                else
                    Left = Left + e.X - initialPoint.X;
                if ((Top + e.Y - initialPoint.Y) <= 0)
                    Top = 0;
                else if ((Bottom + e.Y - initialPoint.Y) >= Screen.PrimaryScreen.Bounds.Bottom)
                    Top = Screen.PrimaryScreen.Bounds.Bottom - Height;
                else
                    Top = Top + e.Y - initialPoint.Y;
            }
            SetPositionOfPictureForm();
        }
 
        public void Form1_MouseDown(object sender, MouseEventArgs e)
        {//form move on click and drag
            FormMoving = true;
            initialPoint = new Point(e.X, e.Y);
        }
 
        public void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {//form move on click and drag
            FormMoving = true;
            initialPoint = new Point(e.X, e.Y);
        }
 
        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
        }
 
        private void pictureBox1_MouseHover(object sender, EventArgs e)
        {
        }
 
        public void label1_MouseHover(object sender, EventArgs e)
        {
            FormMoving = false;
        }
 
        public void label1_MouseUp(object sender, MouseEventArgs e)
        {
            FormMoving = false;
        }
 
        private void label1_MouseDown(object sender, MouseEventArgs e)
        {
 
        }
 
        private void label1_MouseMove(object sender, MouseEventArgs e)
        {
 
        }
 
        public void Form1_MouseHover(object sender, EventArgs e)
        {
            this.Opacity = 1;
        }
 
        public void Form1_MouseLeave(object sender, EventArgs e)
        {
            if(!PolicyNumber.Focused)
                this.Opacity = .25;
        }
 
        public void pictureBox1_MouseLeave(object sender, EventArgs e)
        {
            this.Opacity = 1;
        }
 
        public void pictureBox1_MouseHover_1(object sender, EventArgs e)
        {
            this.Opacity = 1;
        }
 
        public void Form1_Click(object sender, EventArgs e)
        {
            comboBox1.Focus();
        }
 
        }
    }
}

Open in new window

0
Comment
Question by:Andrew Bass
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 16

Expert Comment

by:CuteBug
ID: 24400826
This is more of a compiler error...

In Lines 35-36 and 53-54 you haven't declared the data type of the variables, imageMain and imageTemp.

Also please look into the code for TriggerTrackerPictureBox, whether the Image property is defined properly or not?
Is it derived from PictureBox?
0
 
LVL 1

Author Comment

by:Andrew Bass
ID: 24400829
Thanks CuteBug let me check into this real quick
0
 
LVL 9

Accepted Solution

by:
tculler earned 2000 total points
ID: 24405317
I'll try to decipher your compiler errors as best I can:
1: You're missing a curly bracket ({ or }); I'm thinking a closing bracket (}). Check your curly-bracket pairs.
2/3/5/6/7/9/13: You haven't declared imageMain and imageTemp. Declare them as you use them (you can put them at the top of your class declaration, if you want)
4/8/13: "TriggerTrackerPictureBox" is a form, not a picture-box. Either access the form's picture box through its name (if it has a picture box), or use the Form's .BackgroundImage property instead.
10: You supplied too few or too many paremeters to the call to method "GetListItems". Check the number of arguments.
11: You must access instance properties through an INSTANCE of the form. In other words, you will never see NameOfFormType.InstanceProperty. You have to declare an instance of that form type, THEN access its properties. So, instead of TriggerTracerPictureBox.Enabled = true;, you'll declare an instance of TriggerTrackerPictureBox, and access that control's Enabled property through its name.

Hope I helped,
Nate
0
 
LVL 1

Author Closing Comment

by:Andrew Bass
ID: 31582150
Thanks Nate that helped a lot!
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question