Been a while since I had a problem; so I guess it's about time. I've written a .dll that has a few methods, and a few variables. It has a method called Create(int x, int y) that will place a new 4 square formation onto the form in the project that is using the dll. Now when I test it in my forms application it doesn't create the 4 square. Any help is appreciated.

please can you show your code ?

This is the dll that I'm programming.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic.PowerPacks;
using System.Drawing;

namespace agWindmillSharp
{
    public class agWindmill
    {
        // Design Required
        private System.ComponentModel.IContainer components = null;

        // Declarations
        public int RotationSpeed = 100;
        private int x;
        private int y;

        private RectangleShape rs1;
        private RectangleShape rs2;
        private RectangleShape rs3;
        private RectangleShape rs4;
        private Timer windmillTimer;
        private ShapeContainer sc1;

        // Event Creations
        public void InitializeComponent()
        {
            components = new System.ComponentModel.Container();
            windmillTimer = new Timer(components);
            sc1 = new ShapeContainer();
            rs1 = new RectangleShape();
            rs2 = new RectangleShape();
            rs3 = new RectangleShape();
            rs4 = new RectangleShape();

            windmillTimer.Tick += new EventHandler(Rotate);

            sc1.Location = new System.Drawing.Point(0, 0);
            sc1.Margin = new System.Windows.Forms.Padding(0);
            sc1.Name = "shapeContainer1";
            sc1.Shapes.AddRange(new Shape[] {
            rs1,
            rs2,
            rs3,
            rs4});
            sc1.Size = new System.Drawing.Size(599, 359);
            sc1.TabIndex = 0;
            sc1.TabStop = false;

            windmillTimer.Interval = RotationSpeed;
            // Upper Left Square
            rs1.BorderColor = Color.Lime;
            rs1.FillColor = Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
            rs1.FillGradientColor = Color.Green;
            rs1.FillGradientStyle = FillGradientStyle.Vertical;
            rs1.FillStyle = FillStyle.Solid;
            rs1.Name = "rs1";
            rs1.Size = new Size(50, 50);

            // Upper Right Square
            rs2.BorderColor = Color.Lime;
            rs2.FillColor = Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
            rs2.FillGradientColor = Color.Green;
            rs2.FillGradientStyle = FillGradientStyle.Vertical;
            rs2.FillStyle = FillStyle.Solid;
            rs2.Name = "rs1";
            rs2.Size = new Size(50, 50);

            // Lower Right Square
            rs3.BorderColor = Color.Lime;
            rs3.FillColor = Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
            rs3.FillGradientColor = Color.Green;
            rs3.FillGradientStyle = FillGradientStyle.Vertical;
            rs3.FillStyle = FillStyle.Solid;
            rs3.Name = "rs1";
            rs3.Size = new Size(50, 50);

            // Lower Left Square
            rs3.BorderColor = Color.Lime;
            rs3.FillColor = Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
            rs3.FillGradientColor = Color.Green;
            rs3.FillGradientStyle = FillGradientStyle.Vertical;
            rs3.FillStyle = FillStyle.Solid;
            rs3.Name = "rs1";
            rs3.Size = new Size(50, 50);

            Create(x, y);
            windmillTimer.Start();
        }

        // Create Windmill
        public void Create(int x, int y)
        {
            rs1.Location = new Point(x, y);
            rs2.Location = new Point(x + 54, y);
            rs3.Location = new Point(x + 54, y + 54);
            rs3.Location = new Point(x, y + 54);
        }

        // Windmill Rotation
        public void Rotate(Object sender, EventArgs e)
        {
            if (rs1.BorderColor == Color.Lime)
            {
                rs1.BorderColor = Color.FromArgb(0, 192, 0);
                rs1.FillColor = Color.FromArgb(0, 64, 0);
                rs1.FillColor = Color.FromArgb(0, 30, 0);

                rs2.BorderColor = Color.Lime;
                rs2.FillColor = Color.ForestGreen;
                rs2.FillColor = Color.FromArgb(0, 64, 0);
            }

            else if (rs2.BorderColor == Color.Lime)
            {
                rs2.BorderColor = Color.FromArgb(0, 192, 0);
                rs2.FillColor = Color.FromArgb(0, 64, 0);
                rs2.FillColor = Color.FromArgb(0, 30, 0);

                rs3.BorderColor = Color.Lime;
                rs3.FillColor = Color.ForestGreen;
                rs3.FillColor = Color.FromArgb(0, 64, 0);
            }

            else if (rs3.BorderColor == Color.Lime)
            {
                rs3.BorderColor = Color.FromArgb(0, 192, 0);
                rs3.FillColor = Color.FromArgb(0, 64, 0);
                rs3.FillColor = Color.FromArgb(0, 30, 0);

                rs4.BorderColor = Color.Lime;
                rs4.FillColor = Color.ForestGreen;
                rs4.FillColor = Color.FromArgb(0, 64, 0);
            }

            else if (rs4.BorderColor == Color.Lime)
            {
                rs4.BorderColor = Color.FromArgb(0, 192, 0);
                rs4.FillColor = Color.FromArgb(0, 64, 0);
                rs4.FillColor = Color.FromArgb(0, 30, 0);

                rs1.BorderColor = Color.Lime;
                rs1.FillColor = Color.ForestGreen;
                rs1.FillColor = Color.FromArgb(0, 64, 0);
            }
        }
    }
}

Then using a test forms application I'm trying to use the agWindmill.Create(int x, int y) method I created to generate a new windmill. I'm trying to learn exactly how to create custom methods that will generate graphic content. This is the test form source.

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 agWindmillSharp;

namespace test
{
    public partial class Form1 : Form
    {
        agWindmill myWindmill;

        public Form1()
        {
            InitializeComponent();
            myWindmill = new agWindmill();
            myWindmill.InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            myWindmill.Create(8, 8);
            myWindmill.RotationSpeed = 500;
            myWindmill.Rotate(sender, e);
        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.