S J

S J

  • NA
  • 171
  • 25.7k

Add multiple rectangles to maximum size and location of panel in

Oct 30 2020 7:02 AM
hello I need to draw rectangle within panel and panel size(890,850),location(274,12) in this area only i need to draw rectangle inside this area,if overlaps one another that also okay keep that old rectangles untill i click reset button. if the user given data exceed panel size and location show message box in c# windows application....

Answers (3)

0
Syed Shanu

Syed Shanu

  • 0
  • 33.4k
  • 7.7m
Apr 13 2015 12:17 AM
Check this Hope this will help you

 static  int iCountval = 0;
        static void Main(string[] args)
        {
            const int MAX_NUM_PRODUCTS = 100;
            double[] retailPrices = new double[MAX_NUM_PRODUCTS];
            string[] productNames = new string[MAX_NUM_PRODUCTS];
            int numberOfProduct = 0;
            int choice = 0;

            productNames[0] = "Golden Apple Watch";
            retailPrices[0] = 100;
            productNames[1] = "Swiss cuckoo clock";
            retailPrices[1] = 500;
            productNames[2] = "ACME watch";
            retailPrices[2] = 600;
            iCountval = 3;
            while (choice == 0)
            {
                Console.WriteLine("1. Add new product and price");
                Console.WriteLine("2. Update existing product price");
                Console.WriteLine("3. Calculate profits");
                Console.WriteLine("4. Calculate totals");
                Console.WriteLine("5. All product Details");
                Console.WriteLine("6. Exit");

                Console.WriteLine("Enter your option: ");
                int option = int.Parse(Console.ReadLine());

                switch (option)
                {
                    case 1:
                        Console.WriteLine("Enter the name of a new product in your catalogue");
                    
                            productNames[iCountval] = Console.ReadLine();
                       
                        Console.WriteLine("Enter the price for it");

                     
                            retailPrices[iCountval] = int.Parse(Console.ReadLine());
                            iCountval = iCountval + 1;
                        break;
                        numberOfProduct++;
                    case 2:
                        Console.WriteLine("Enter product Name to Update : ");
                     int index1 = Array.IndexOf(productNames, Console.ReadLine());
                         Console.WriteLine("Enter the price  to Update : ");

                         retailPrices[iCountval] = int.Parse(Console.ReadLine());
                        

                        break;                       
                    case 3:
                        Console.WriteLine("Enter the profit Percentage:");
                        int profitInPercent = int.Parse(Console.ReadLine());

                        for (int i = 0; i < iCountval; i++)
                        {

                            double salesProfits = (profitInPercent * retailPrices[i]) / 100;

                            Console.WriteLine(productNames[i] + " is : percentage :\t{0,8:c} ", salesProfits);

                        }

                        Console.WriteLine("Products:");
                        break;
                    case 4:
                        Console.WriteLine("4. Calculate totals");
                        double calculatevalues = 0;
                        for (int j = 0; j < iCountval; j++)
                        {
                            calculatevalues = calculatevalues+retailPrices[j];                           
                        }
                        Console.Write("This is the tottal : ");
                        Console.WriteLine(calculatevalues);
                        break;
                    case 5:
                        Console.WriteLine("5. Details");
                        for (int j = 0; j < iCountval; j++)
                        {
                            Console.WriteLine("No." + j + "Product Name : " + productNames[j] + " Prize :" + retailPrices[j]);
                        }
                    
                        break;
                    case 6:
                        Console.WriteLine("6. Exit");
                        System.Environment.Exit(-1);     //to terminate the program
                        break;
                    default:
                        Console.WriteLine("Invalid input!!");
                        break;
                }
            }
        }




        public static string salesProfit { get; set; }