Thread: Visual C# Help

Results 1 to 8 of 8
  1. #1
    SeptFicelle's Avatar
    Join Date
    Nov 2010
    Gender
    female
    Location
    In your backyard.
    Posts
    75
    Reputation
    10
    Thanks
    16
    My Mood
    Amused

    Visual C# Help

    I'm creating a DLL that will create 4 objects and place them on a form using custom made methods. The logic I've put into this should work, but it's not. I don't understand why. In a blank DLL I need a method called Create(int x, int y) that will assign the location for all 4 objects. The objects are arranged in a 4 square style pattern so simple location math is required. My problem is creating the objects and placing them on the form in the user's project. My pseudo code is:

    Code:
    // Had to add most of these manually.
    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;
    
    namespace ClassLibraryExample
    {
        public class Class1
        {
            private int x;
            private int y;
    
            public void Create(int x, int y)
            {
                object1.Location = new Point(x, y);
                object2.Location = new Point(x + 10 + object.Width, y);
                object3.Location = new Point(x + 10 + object.Width, y + 10 + object.Height);
                object4.Location = new Point(x, y + 10 + object.Height);
            }
        }
    }
    The idea is to make all 4 objects into a single object. Implementation into a forms application would be like:

    Code:
    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 ClassLibraryExample;
    
    namespace FormExample
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                Class1.Create(50, 50);
            }
        }
    }
    That's pretty much all I have to go on. C# and .NET are easy to convert back and forth (except for a few minor classes and methods). Much thanks to whoever helps.
    You see, maddness, as we know, is like gravity, all it takes is a little push.



    -------------------------------------
    Current Focus: C#
    Languages Known: C++, C#, F#, .NET
    Specialty: Inspection Of Algorithms
    Schooling Focus: Astrobiology
    -------------------------------------

    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/overallsig.png[/IMG]
    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/userbar97571.gif[/IMG]
    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/skypeuser5gu.png[/IMG]
    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/3dsmax9userot0.gif[/IMG]

  2. #2
    pushdis15's Avatar
    Join Date
    Oct 2010
    Gender
    male
    Location
    spokane washington
    Posts
    923
    Reputation
    20
    Thanks
    170
    My Mood
    Twisted
    wrong section

    post here
    C# - MPGH - MultiPlayer Game Hacking
    PlayStation ID:
    Boxing509

    Quote Originally Posted by pushdis15
    Women now have choices. They can be married, not married, have a job, not have a job, be married with children, unmarried with children. Men have the same choice we've always had: work, or prison.

  3. #3
    SeptFicelle's Avatar
    Join Date
    Nov 2010
    Gender
    female
    Location
    In your backyard.
    Posts
    75
    Reputation
    10
    Thanks
    16
    My Mood
    Amused
    Much thanks
    You see, maddness, as we know, is like gravity, all it takes is a little push.



    -------------------------------------
    Current Focus: C#
    Languages Known: C++, C#, F#, .NET
    Specialty: Inspection Of Algorithms
    Schooling Focus: Astrobiology
    -------------------------------------

    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/overallsig.png[/IMG]
    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/userbar97571.gif[/IMG]
    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/skypeuser5gu.png[/IMG]
    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/3dsmax9userot0.gif[/IMG]

  4. #4
    Liz's Avatar
    Join Date
    Feb 2009
    Gender
    female
    Location
    179° 56′ 39.4″, +0° 2′ 46.2″, 7,940 ± 420 parsecs
    Posts
    37,181
    Reputation
    5621
    Thanks
    20,746
    My Mood
    Tired
    Moved to correct forum.

    If anyone claims to be me via any other source outside of MPGH private or visitor messages, IT'S NOT ME!
    They are trying to trick or scam you. Report them immediately and PM me here for verification.
    "Don’t confuse my personality with my attitude. My personality is who I am. My attitude depends on who you are." — Frank Ocean
    Moderator: 5/2009-10/2009 | GMod: 10/2009-10/2010 | Staff Administrator: 10/2010-Present
    I
    do not do requests via PM. Post in the appropriate section.
     
    Stupid/Pointless Private messages = SPAM, SPAM = BAN.

  5. #5
    Imported's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    142
    Reputation
    27
    Thanks
    47
    My Mood
    Relaxed
    How the fuck do you expect that to work. You never instantiated the 4 objects, you never instantiated your Class1 (either than or you should have made the method static).
    TROLOLOLOLO


  6. #6
    SeptFicelle's Avatar
    Join Date
    Nov 2010
    Gender
    female
    Location
    In your backyard.
    Posts
    75
    Reputation
    10
    Thanks
    16
    My Mood
    Amused
    Quote Originally Posted by Imported View Post
    How the fuck do you expect that to work. You never instantiated the 4 objects, you never instantiated your Class1 (either than or you should have made the method static).
    I'm asking for help on that; I've already tried creating new instances of my objects and it didn't work; can you show an example using 4 button controls?
    You see, maddness, as we know, is like gravity, all it takes is a little push.



    -------------------------------------
    Current Focus: C#
    Languages Known: C++, C#, F#, .NET
    Specialty: Inspection Of Algorithms
    Schooling Focus: Astrobiology
    -------------------------------------

    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/overallsig.png[/IMG]
    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/userbar97571.gif[/IMG]
    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/skypeuser5gu.png[/IMG]
    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/3dsmax9userot0.gif[/IMG]

  7. #7
    Imported's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    142
    Reputation
    27
    Thanks
    47
    My Mood
    Relaxed
    [highlight=VB]
    namespace ClassLibraryExample
    {
    public class Class1
    {
    public static void Create(int x, int y)
    {
    Button[] objects = new Button[4];
    object[0].Location = new Point(x, y);
    object[1].Location = new Point(x + 10 + object[0].Width, y);
    object[2].Location = new Point(x + 10 + object[1].Width, y + 10 + object[1].Height);
    object[3].Location = new Point(x, y + 10 + object[2].Height);
    }
    }
    }
    [/highlight]

    Eh.
    TROLOLOLOLO


  8. #8
    SeptFicelle's Avatar
    Join Date
    Nov 2010
    Gender
    female
    Location
    In your backyard.
    Posts
    75
    Reputation
    10
    Thanks
    16
    My Mood
    Amused
    Figured it out, my source was only missing the add method. MUCH THANKS B1ackAnge1!!!!!!!!!

    Code:
    public void Windmill(Form formToAddWindmillTo, int x, int y)
            {
                Button button1 = new System.Windows.Forms.Button();
                Button button2 = new System.Windows.Forms.Button();
                Button button3 = new System.Windows.Forms.Button();
                Button button4 = new System.Windows.Forms.Button();
    
                button1.Location = new System.Drawing.Point(x, y);
                button1.Name = "windmill1";
                button1.Size = new System.Drawing.Size(75, 23);
                button1.TabIndex = 0;
                button1.Text = "Create New";
                button1.UseVisualStyleBackColor = true;
                button1.Click += new System.EventHandler(click1);
    
                button2.Location = new System.Drawing.Point(x + 10 + button2.Width, y);
                button2.Name = "windmill2";
                button2.Size = new System.Drawing.Size(75, 23);
                button2.TabIndex = 0;
                button2.Text = "Create New";
                button2.UseVisualStyleBackColor = true;
                button2.Click += new System.EventHandler(click2);
    
                button3.Location = new System.Drawing.Point(x + 10 + button2.Width, y + 10 + button2.Height);
                button3.Name = "windmill3";
                button3.Size = new System.Drawing.Size(75, 23);
                button3.TabIndex = 0;
                button3.Text = "Create New";
                button3.UseVisualStyleBackColor = true;
                button3.Click += new System.EventHandler(click3);
    
                button4.Location = new System.Drawing.Point(x, y + 10 + button1.Height);
                button4.Name = "windmill4";
                button4.Size = new System.Drawing.Size(75, 23);
                button4.TabIndex = 0;
                button4.Text = "Create New";
                button4.UseVisualStyleBackColor = true;
                button4.Click += new System.EventHandler(click4);
    
                formToAddWindmillTo.Controls.Add(button1);
                formToAddWindmillTo.Controls.Add(button2);
                formToAddWindmillTo.Controls.Add(button3);
                formToAddWindmillTo.Controls.Add(button4);
            }
    Last edited by SeptFicelle; 05-17-2011 at 01:14 PM. Reason: Added thanks to B1ackAnge1.
    You see, maddness, as we know, is like gravity, all it takes is a little push.



    -------------------------------------
    Current Focus: C#
    Languages Known: C++, C#, F#, .NET
    Specialty: Inspection Of Algorithms
    Schooling Focus: Astrobiology
    -------------------------------------

    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/overallsig.png[/IMG]
    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/userbar97571.gif[/IMG]
    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/skypeuser5gu.png[/IMG]
    [IMG]https://i276.photobucke*****m/albums/kk13/Teddynezz/3dsmax9userot0.gif[/IMG]