Treceți la conținutul principal

piese control cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Data;
using System.Windows.Forms;


namespace Piesa
{
    public class Cadru : Control
    {
        private int x = 0;
        private int y = 0;
        private int startDrag = 0;
        TextBox TextValue = new TextBox();
        PictureBox ImaginePiesa = new PictureBox();
        private int TipPiesa = 0;
        
        private string TextValueN = "0";


        public void SetTipPiesa(int _TipPiesa){
        this.TipPiesa=_TipPiesa;
        }
        public int GetTipPiesa() {
            return TipPiesa;
        }

        public void SetTextValuePosition(int lx,int ty) {
            this.TextValue.Top = ty;
            this.TextValue.Left = lx;

        }

        public void SetTextValueWidthHeight(int w, int h)
        {
            this.TextValue.Width =w;
            this.TextValue.Height = h;

        }

        public void SetImaginePiesaPosition(int lx, int ty)
        {
             this.ImaginePiesa.Top = ty;
             this.ImaginePiesa.Left = lx;

        }

        public void SetImaginePiesaWidthHeight(int w, int h)
        {
            this.ImaginePiesa.Width = w;
            this.ImaginePiesa.Height = h;

        }

        public void SetTextValueN(string Str){
            this.TextValueN = Str;
            this.TextValue.Text = this.TextValueN;
        }
        
        public void CadruPaint()
        {
          

           
        }

        protected override void OnMouseDoubleClick(MouseEventArgs e)
        {
            base.OnMouseDoubleClick(e);
            this.TextValueN = this.TextValue.Text;
            MessageBox.Show(this.TextValue.Text);
        }
        protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
            
        Pen p = new Pen(Color.Red, 2);
        Graphics g = this.CreateGraphics();
        Rectangle rec = new Rectangle(1, 1, 70, 70);
        Brush b1 = new SolidBrush(Color.Red);
        Brush b2 = new SolidBrush(Color.Black);
        Brush b3 = new SolidBrush(Color.Blue);
        Brush b4 = new SolidBrush(Color.Yellow);
             
        Controls.Add(TextValue);
        switch (TipPiesa){
            case 0:
                ImaginePiesa.Load("C:\\Ground.png");
                break;
            case 1:
                ImaginePiesa.Load("C:\\LDR.png");
                break;
            case 2:
                ImaginePiesa.Load("C:\\Capacitor.png");
                break;
            case 3:
                ImaginePiesa.Load("C:\\Wire.png");
                break;
            default:
                ImaginePiesa.Load("C:\\Resistor.png");
                break;

        }
        ImaginePiesa.InitialImage = ImaginePiesa.Image;
        Controls.Add(ImaginePiesa);
        
        TextValue.Text = TextValueN;


       this.SetTextValuePosition(0, 0);
       this.SetTextValueWidthHeight(20, 20);
       this.SetImaginePiesaPosition(0, 20);
       this.SetImaginePiesaWidthHeight(45, 45);
        
    }
        
       
        protected override void OnMouseDown(MouseEventArgs e)
        {

            this.x = e.X;
            this.y = e.Y;
            this.startDrag = 1;
        }
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            this.startDrag = 0;
        }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (startDrag == 1)
            {
                base.OnMouseMove(e);
                this.Left = (this.Left + e.X) - x;
                this.Top = (this.Top + e.Y) - y;
            }
        }

        

        public Cadru(int CodPiesa)
     {
            this.SetTipPiesa(CodPiesa);
            Pen p = new Pen(Color.Red, 2);
            Graphics g = this.CreateGraphics();
            Rectangle rec = new Rectangle(1, 1, 70, 70);
            Brush b1 = new SolidBrush(Color.Red);
            Brush b2 = new SolidBrush(Color.Black);
            Brush b3 = new SolidBrush(Color.Blue);
            Brush b4 = new SolidBrush(Color.Yellow);
            switch (TipPiesa)
            {
                case 0:
                    ImaginePiesa.Load("C:\\Ground.png");
                    break;
                case 1:
                    ImaginePiesa.Load("C:\\LDR.png");
                    break;
                case 2:
                    ImaginePiesa.Load("C:\\Capacitor.png");
                    break;
                case 3:
                    ImaginePiesa.Load("C:\\Wire.png");
                    break;
                default:
                    ImaginePiesa.Load("C:\\Resistor.png");
                    break;

            }
            ImaginePiesa.InitialImage = ImaginePiesa.Image;
            Controls.Add(TextValue);
            Controls.Add(ImaginePiesa);
            
            TextValue.Text = TextValueN;
     }


   
     
    }
}

Comentarii

Postări populare de pe acest blog

program principal cpp

#include "clasa.h" #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> #define DELAY 9000000 void delay() { for(long i=0;i<DELAY;i++); } //constructor cu initializare de la tastatura BigInt::BigInt() {char x; signed char t[400]; int i; printf("\nNumarul cu semn "); do s=getche(); while((s!='+')&&(s!='-')); n=0; do {x=getche(); t[n]=x-'0'; n++; } while((x>='0')&&(x<='9')); n--; for(i=0;i<n;i++) nr[i]=t[n-i-1]; } //constructor cu initializare prin parametri BigInt::BigInt(char semn,signed char numar[],int dim) {int i; s=semn; n=dim; for(i=0;i<n;i++) nr[i]=numar[n-i-1]; } //transform un int negativ in pozitiv int BigInt::Pozitiv(int x) {int a,vb; a=0; vb=0; while(vb==0) if((x+a)==0) vb=1; else a=a+1; x=a; return x; } //constructor dintr-un nr int obisnuit BigInt::BigInt(int x) {int i; if(x>=0) s='+'…

NUMERE PRIME ALGORITM C++

// NUMERE PRIME ALGORITM C++//  reediting from scratch //on this page is just the study for a next algoritm for generating the parime nr series like Fibonnaci or ....if possibile

74111121313417374414124343447 if u know the red part you can generate the orange part
1 0 1 111112222 1 1 23

o aplicatie php localitati romania

//APLICATIA SE REFERA LA BAZA DE DATE SIRUTA

//dragtable.js


/* dragtable v1.0 June 26, 2008 Dan Vanderkam, http://danvk.org/dragtable/ http://code.google.com/p/dragtable/ \Bsortabledraggable\B Instructions: - Download this file - Add <script src="dragtable.js"></script> to your HTML. - Add class="draggable" to any table you might like to reorder. - Drag the headers around to reorder them. This is code was based on: - Stuart Langridge's SortTable (kryogenix.org/code/browser/sorttable) - Mike Hall's draggable class (http://www.brainjar.com/dhtml/drag/) - A discussion of permuting table columns on comp.lang.javascript Licensed under the MIT license. */ // Here's the notice from Mike Hall's draggable script: //***************************************************************************** // Do not remove this notice. // // Copyright 2001 by Mike Hall. // See http…