castajiz_2 35 Posting Whiz

Well suppose that you ve added images to the Resources and you have them already in your Listbox. You can do this by writting the folowing code:

List<Image> list;
        public Form1()
        {
            InitializeComponent();
            list = new List<Image>();
            list.Add(Properties.Resources.image1name);
            list.Add(Properties.Resources.image2name);
            list.Add(Properties.Resources.image3name);
            //and so on...


        }

        private void Form1_Load(object sender, EventArgs e)
        {

            listBox1.DataSource = list;

        }

Now that you have your Image objects in your listbox by clicking on one of them you should be able to display your image to the PictureBox by using this code.

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

                pictureBox1.Image = (Image)listBox1.SelectedItem;

        }

So you just generate the event and put the folowing code inside, You have to cast the items in the listbox otherwise you ll get an error.

ddanbe commented: good +15
castajiz_2 35 Posting Whiz

The title says it all. What do you suggest?

castajiz_2 35 Posting Whiz

There are really numerous way on how you can do this. But there is a good article on CodeProject and it helped me a lot.
Click Here

castajiz_2 35 Posting Whiz

Posting again here i m done with this so i will mark this trhead as solved.
I created a class for my object wich pick s up letters and i ve created a class for my letters and the thing that solved the main problem were the properties where i checked if there is a collision. I hate object oriented programming at first but now i love it and i can see how powerfull it actually is.
I m posting just a few lines of code.

for (int i = 0; i < lt.Y1.Length; i++) 
            {
                lt.Y1[i]++;
            }
             for (int i = 0; i < lt.X1.Length; i++)
             {
                 if ((lt.Y1[i] == cl.Y2) && ((lt.X1[i] >= cl.X2) && lt.X1[i] <= (cl.X2 + cl.Widht)))// for x coordinates if letter is between the the borders of the image then...
                 {
                     label6.Text = label6.Text + lt.Word[i];
                     lt.Y1[i] = // random coordinates;
                 }
             }        
             this.Invalidate();
castajiz_2 35 Posting Whiz

I would like to know if there is a class wich generates RANDOM words which have sense(are in use in the daily language in englis). I am making a project where uppon a given random generated word i would like to collect letters for that given word so once i collect the letters it should match the generated word. Or if there isn t please give me a suggestion how to do this.

castajiz_2 35 Posting Whiz

I forgot to call the base class FORMS,now i m able to see that method.-.-

castajiz_2 35 Posting Whiz

I have a method which does something. However to do the desired thing i must call the CreateGraphics method. I Created a new class (added a new class) and now inside my method i can t call this method. What am i missing? I can call the CreateGraphics method inside my main class.

castajiz_2 35 Posting Whiz
castajiz_2 35 Posting Whiz

Tnx Guys!

castajiz_2 35 Posting Whiz
for (;n!=0;n/=10)
{
  do something till n==0;
}

Is this something like a while loop or do while loop or some kind of imitation?

Dawood Ahmad commented: for loop +0
castajiz_2 35 Posting Whiz

Hi guys. for several weeks i can t make my mind whether to go and learn php or should i stick with my C# knowledge and learn ASP.net. I ve started to programming in C# 2 years ago, learned sql and databases and learned html css when i was still a kid. I love C# (started with Visual basic but didn t like the syntax so i switched to c#). The thing that s bothering me that i ve always "hated" microsoft and the proffesors and high school encouragde me to move to open source but still microsoft offers everything and it is much more easier to start with their products and the society also usses them on daily bases. I know that if i choose ASP that it will be much easier to grasp it rather then trying to learn PHP but somehow i think that microsoft techologies won t be here anymore within 5 years and that PHP will takve over. I know that this sounds crazy but i just cant make up my mind. Also if i m going to start on either one of them i will commit myself to only one language and master it I don t want to skip sometime in my life to another server side language.

castajiz_2 35 Posting Whiz

If you could put you option array declaration and curly brackets of the for loop to know where it ends and the User_Answer and Correct_Answer arrays and it would be good to put the code for the last if statement, if checked then what.

castajiz_2 35 Posting Whiz

did you call your method properly?

castajiz_2 35 Posting Whiz

The thing that i don t understand here is how can you put a FUNCTION that hasn t yet evaluated into a integer(will evaluate later but at the moment of the recursion it hasn t) into a int variable? Once n equals 0 the int smallResult will get populated but what happens in the memory and how can an int hold a FUNCTION for example for the first recurssive call that would be smallResult=sum(arr,n-1); the function sum(arr,n-1) did not evaluate yet (will afterwards).

int sum( int arr[], int n )
{
  if ( n == 0 )
    return 0;
  else 
    {
       int smallResult = sum( arr, n - 1 );  // A
       return smallResult + arr[ n - 1 ];
    }
}

this is what i understand and how i would do it everytime (it gives the same result)

  int sum( int arr[], int n )
    {
      if ( n == 0 )
        return 0;
      else 
        {
           return sum( arr, n - 1 )+ arr[ n - 1 ];
        }
    }
castajiz_2 35 Posting Whiz

A pixel is the smallest thing that a image contains it can be a dot, square, line ect... If you want to read pixels from a image you ve got several methods in the bitmap class. I suggest you to use 2 for loops and go through each pixel (image cell) and do whatever you want to do. A image is actually a matrix with columns and rows (height,width) for example if you ve got 64 "rows" and 64 "columns" you would have 64^2 pixels in your image. Just don t think about the pixels as something physical, it doesn t have a native size. You can use the Color struct as an object to put data inside of it. The data would be then Argb data. The Argb value will depend upon the image pixels colors.

castajiz_2 35 Posting Whiz

Try this:

 private void button1_Click(object sender, EventArgs e)
        {

            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {

            Process[] processPads = Process.GetProcessesByName("notepad");
            foreach (Process processes in processPads)
            {

                if (!(processes.MainWindowTitle.Contains("Untitled") || processes.MainWindowTitle==""))
                {
                    processes.Kill();
                    Process.Start("notepad");
                }
            }
        }
castajiz_2 35 Posting Whiz

The thing is that when you click on any menu the property: MainWindowTitle goes into a empty string.Thats why the "Untitled" is being rejected and the code goes into the if and by that kills the proccess and starts over.

castajiz_2 35 Posting Whiz

I m really curious about this one. I ve tested your code but declared processPads outside the the timer method. By doing that you don t get the problem and you can work with your notepads but you get another error wich is unusual.

castajiz_2 35 Posting Whiz

I suggest you to try with this Click Here
and this Click Here
Ofcourse you ll always run into some kind of trouble which you will have to google to find the solution to it and you ll have to combine your knowledge with the thing you found on the web. Good luck!

castajiz_2 35 Posting Whiz

I was a little bit curious and i really wanted to do this since i haven t been using the streamreader and streamwritter classes for quite a time. Here is the code that solves your problem but only for 3 characters numbers if for example you had more you would have to make a method for more.

 static void Main(string[] args)
        {
            # region variables

            int counter=0;
            string replace= "";
            int counter2 = 0;
            string concatenate = "";
            int j=0;
            double[] array = new double[18]; // storing numbers; 
            char [] buffer=new char[10];
            string[] alphabet = new string[6] { "A", "B", "C", "D", "E", "F" };
            int interval = alphabet.Length;
            int num = 0;
            List<string> readnumber = new List<string>();

            #endregion

            List<char> items = new List<char>();
            // getting array results;
            try
            {
                using (StreamReader str = new StreamReader(@"....txt"))// file path
                {
                    while (!str.EndOfStream)
                    {
                        counter++;

                        if (counter%7==1) // for a longer data sheet
                        {
                           readnumber.Add(str.ReadLine());
                        }

                        else
                        {
                            str.Read(buffer, 0, buffer.Length); 
                            str.ReadLine();
                            for (int i = 0; i < buffer.Length; i++)
                            {
                                if (i > 5 && i < 9) // since there are only 3 characters (decimal, or int ) if there are more, code will not work
                                {
                                    counter2++;
                                    items.Add(buffer[i]);
                                    if (counter2 == 3)
                                    {
                                        foreach (char k in items)
                                        {
                                            concatenate = concatenate + k.ToString();
                                        }

                                        replace = concatenate.Replace('.', ',');
                                        array[j] = double.Parse(replace);
                                        j++;

                                        items.Clear();
                                        replace = "";
                                        concatenate = "";
                                        counter2 = 0;

                                    }
                                }
                            }
                        }
                    }
                }
            }

            // array filled whith result values; …
castajiz_2 35 Posting Whiz

Yeah i tought of that. I think i ll make a class with some properties(coordinates) and the drawstring method that you mentioned. I know that you can not cast methods to objects but still i was thinking if there is another way to do that i was thinking all night about that but couldn t get any idea. When i solve My problem i ll post the code here and mark this thread as solved! TNX!

castajiz_2 35 Posting Whiz
  private void Form1_Paint(object sender, PaintEventArgs e)
        {



                RotateImage( "A", MainArray[0],ycoordinates[0]);
                RotateImage( "B", MainArray[1],ycoordinates[1]);

                // intersecting (strings  with another object)

               }



        public void RotateImage(string theString, int x, int y)  // method 0, main method
        {


            Graphics paper = CreateGraphics();

            paper.TranslateTransform(x, y);
            sz = paper.MeasureString(theString, stringFont);
            paper.RotateTransform(rtangle);
            rtangle += 10;
           paper.DrawString(theString, stringFont, new SolidBrush(Color.Blue), -(float)sz.Width / 2, -(float)sz.Height / 2);


        }

so i want my strings to intersect with this object once they reach a certain point when falling down

castajiz_2 35 Posting Whiz

I was wondering is there any way to put my e.Graphics.DrawString() method into a variable(object) so that i can do some actions aftewards. The thing is that I ve got my words falling and rotating on the form. I ve also got a object wich is a Image which moves right or left. The problem is that i have to collect this words (falling and rotating) with my image object which i m able to move. I Know that the problem would have been much easier if i decided to populate images of string let s say into an array because i would have actual objects, but is there anyway to do that with the drawstring() already? I hope that i was clear enough.

castajiz_2 35 Posting Whiz

I was just wondering not just concerning this piece of code but in some other code as well how can i avoid --> if (j!=array.Length-1) and put something else maybe
something in the for loop? LINE6

for (int i = 0; i < array.Length; i++)
            {

               for (j=counter; j < array.Length; j++)
                {
                    if (j!=array.Length-1)
                    {
                        if (array[i] == array[j+1] ) 
                         {
                             array[i] = 0;

                         }
                     }

                }
                if (array[i] != 0)
                {
                    items.Add(array[i]); // storing none duplicates random number.
                }
                counter++;
               }
castajiz_2 35 Posting Whiz
public void RotateImage( string theString, int x, int y)  // napokon radi!
        {
            Graphics paper = CreateGraphics();
            paper.TranslateTransform(x, y);
            sz = paper.MeasureString(theString, stringFont);
            paper.RotateTransform(rtangle);
            rtangle += 10;
            paper.DrawString(theString, stringFont, new SolidBrush(Color.Blue), -(float)sz.Width / 2, -(float)sz.Height / 2);


        }

this solves my problem, removed the parameter e.graphics and always assign new graphics by creating it inside the method.

castajiz_2 35 Posting Whiz

i ve been struggling with the graphics class and yes removing the Dispose() does solve my problem but when the second method is called again somehow the other string that needs to be drawn loosses the rotation point , it does not rotate as it should , better said i does not rotate as the first string rotates.

castajiz_2 35 Posting Whiz
 public void RotateImage(Graphics paper,string theString)
        {
            try
            {
                using (paper)
                {

                    paper.RotateTransform(angle);
                    angle++;

                    sz = paper.MeasureString(theString, this.Font);


                    paper.DrawString(theString, new Font("Arial", 24), Brushes.Black, -(sz.Width / 2), -(sz.Height / 2));
                    paper.Dispose();
                }
            }
            catch (Exception e) { MessageBox.Show(e.ToString()); }

i get an error saying parameter is not valid, but only if i call my method for the second time in the paint method

private void Form1_Paint(object sender, PaintEventArgs e)
        {
            RotateImage(e.Graphics, "A");
            RotateImage(e.Graphics, "B");

        }

if i call it once , the error will not happen.

 private void Form1_Paint(object sender, PaintEventArgs e)
            {
                RotateImage(e.Graphics, "A");

            }
castajiz_2 35 Posting Whiz

hah, youre unbeliveable , cheers.

castajiz_2 35 Posting Whiz

Thank Sir i should have read about Translatetransform i wasn t aware that this method set s it up from zero. I more thing . How come

-(sz.Width/2),-(sz.Height/2)

results in a positive value not negative as it shoudl be? Otherwise you ve solved my problem

castajiz_2 35 Posting Whiz
private void Form1_Paint(object sender, PaintEventArgs e)
        {

            String theString = "A";
            SizeF sz = e.Graphics.VisibleClipBounds.Size;

            e.Graphics.TranslateTransform(sz.Width / 2 ,sz.Height / 2);

            e.Graphics.RotateTransform(angle);
            angle++;
            sz = e.Graphics.MeasureString(theString, this.Font);


            e.Graphics.DrawString(theString, this.Font, Brushes.Black,-(sz.Width/2),-(sz.Height/2));

        }

I dont understand the last part with the DrawString(). The 2 last arguments of the method specify the location where the string HAS TO BE drawn and when i debug i get this 2 values: {Width = 11.2202139 Height = 13.8251934}. But the string is drawn in the center because of the translatetransform() method listed above. So basically i do not understand the last two arguments whatsoever. Please clear that for me.
BTW. Everything works fine the string rotates as it should be but i simply do not understand i do not want to go further without understanding it.

castajiz_2 35 Posting Whiz

Well I have used this as well but i quit it in the early stage. I don t have a particular reason for quitting but i just did. If you could specify a little bit more the problem maybe i could help you.

castajiz_2 35 Posting Whiz

i feel a little bit stupid now, but yes ctrl V does solve my problem. I m sorry about that but it s just that i never use the keyboard for such action I always go with my mouse.

castajiz_2 35 Posting Whiz

b5a4c6111b81b950d59e4b84a1a7ab35

This post has no text-based content.
castajiz_2 35 Posting Whiz

For example, here where I m writting now i can not paste any text no matter where i copy it from earlier. Also if I go to the code section to insert code I can not paste as well, neither can I copy from this area where I m writting. I ve enabled a few things in the browser (the clipboard) but still can not copy or paste.

castajiz_2 35 Posting Whiz

Bassically I want my letter to rotate clockwise but not all over the form, I want it to rotate in one place.

 private void Form1_Paint(object sender, PaintEventArgs e)
        {
            RotateImage(e.Graphics);
.
        }
        string a = "A";
        float d= 15f;
        Font stringFont = new Font("Arial", 16);

        private SizeF stringSize(Graphics paper1) 
        {
            SizeF stringSizee = new SizeF();
            stringSizee = paper1.MeasureString(a, stringFont);
            return stringSizee;

        }

        public void RotateImage(Graphics paper)
        {

            SizeF far = stringSize(paper);
            paper.TranslateTransform((float)far.Width/2,(float)far.Height/2);
            paper.RotateTransform(d);
            d+=2f;
            paper.TranslateTransform(- (float)far.Width / 2, -(float)far.Height / 2);
            paper.DrawString(a, stringFont, Brushes.Black,new PointF(100,100));

        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Invalidate();
        }
castajiz_2 35 Posting Whiz

The title says it all. I switched to Opera for some reason but i m trying to paste some code from vs2012 to this area overhere and I m unable to do that. Any ideas? Should I enable something in my settings? I m having the latest version.
I assume this post should be somewhere else but i couldnt find a better thread to post it.

castajiz_2 35 Posting Whiz

ddanbe said everything, just put your messagebox at line 39 to line 38 so it doesnt show two times when the letter is guessed. Just an advice if you want to put on line 29 instead of

if(char.IsWhiteSpace(myguess)) 

to

if (txtMessage.Text==" " || String.IsNullOrEmpty(txtMessage.Text))

and replace line 22 to line 28.

castajiz_2 35 Posting Whiz
1.code
   static void Main(string[] args)
            {
                SqlConnection sc = new SqlConnection("Data Source=pc3490ierf43;Initial Catalog=Persons;Integrated Security=True");

                    sc.Open();
                   SqlCommand command=new SqlCommand("Select Name from Persontable",sc);
                     SqlDataReader reader= command.ExecuteReader();

                        while (reader.Read())
                        {
                            Console.WriteLine("{0}", reader.GetString(0));

                        }




                Console.ReadLine();
            }

---------------------------------------------------------------------------------------------------------------------
** 2.code**

static void Main(string[] args)
        {
            using (SqlConnection sc = new SqlConnection("Data Source=pc3490ierf43;Initial Catalog=Persons;Integrated Security=True"))
            {

                sc.Open();
                using (SqlCommand command = new SqlCommand("Select Name from Persontable", sc))
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Console.WriteLine("{0}", reader.GetString(0));

                    }

                }

            }
            Console.ReadLine();
        }

----------------------------------------------------------------------------------------------------------------------------
First of all, I get the same output for both code blocks.
My question is how does the first example work since i haven't used the .Dispose() method and what dou you suggest should i stick with the using's or should i manage my connections manually?. I ve read that the using 's have the dispose integrated inside of them. I m just unsure sometimes when to use using when not. For instance in this code i would just use it for making a connection and the other constructros such as SqlCommand and SqlDataReader i wouldn't.

castajiz_2 35 Posting Whiz

Is it posible to install and deploy my c# apllication on my phone (name in the title)?

castajiz_2 35 Posting Whiz

hmm , i think i should find a new hoster, btw. i solved the problem it was the z-index that did it. Anyway thanks for the always quick replys.

castajiz_2 35 Posting Whiz
castajiz_2 35 Posting Whiz

Hi there. I ve got a problem with my drop down menu, i ve centered a border on my page and when i hover over the <li> of my <ul> a drop down menu appears but it appears behind the border that i ve inserted. My question is do i have to use the css position property or something else. i hope that i was clear enough.

castajiz_2 35 Posting Whiz

I was wondering if I could develop a comment section where people would post comments without using php or asp. The only thing that i would like to use ih javascript, html, css, ajax and things like that. Is this achievable without the usage of php or asp?

castajiz_2 35 Posting Whiz

wow, i ve never heard anyone doing programming on a phone or wanting to do it no matter how big or how good it is for typing. deceptikon answered your question.

castajiz_2 35 Posting Whiz

o thanks, i dont know why w3c schools did not mention this kind of thing and by the way how is this syntax called?

castajiz_2 35 Posting Whiz

Hi there new to css and there is something I don t understand for example

div.img img
  {
  display:inline;
  margin:3px;
  border:1px solid #ffffff;
  }

what does the other img represent, what is this? I understand that the class called img is going to be applyed on the div tag in the html body but what is the other img?? is this like a recursion in programming something inside something?

castajiz_2 35 Posting Whiz

I m not sure what you want exactly but if you want your image to fill the screen then try this on LINE 11

 background-size:stretch;
castajiz_2 35 Posting Whiz

Hm it seems that youve got me wrong or maybe i don t understand you, but i think that i understood you quite well. To make it simple,in Xamarin you write you C# code and you apply it as it is a android code to your phone. So yes, xamarin is for writting android apps but in C#.

castajiz_2 35 Posting Whiz

Xamarin, i ve used this, not using it anymore so i don t know what s going on really, neverthless i think that this is what you re looking for.

castajiz_2 35 Posting Whiz

well since i m a student i could give you my account where i can download all microsoft products apart from ms office. The thing is that that i ve already downloaded VS 2012 ultimate and it can not be downloaded twice.I ve seen that VS 2013 has come out but it s just some preview version.