예제 #1
0
        public void PnlMouseUp(object sender, EventArgs e)
        {
            Panel pan = sender as Panel;

            Console.WriteLine("Re-Dibujado1");
            if (!this.pnlMvd)
            {
                Console.WriteLine("Re-Dibujado2");
                foreach (Figura_Relacion rel in Formas.Formas.OfType <Figura_Relacion>())
                {
                    if (rel.isFull)
                    {
                        if (rel.RelIni.Name == pan.Name)
                        {
                            rel.RelIni       = pan;
                            rel.RelPuntos[0] = new Point(rel.RelIni.Location.X + rel.RelIni.Size.Width / 2, rel.RelIni.Location.Y + rel.RelIni.Size.Height / 2);
                        }
                        else if (rel.RelFin.Name == pan.Name)
                        {
                            rel.RelFin       = pan;
                            rel.RelPuntos[1] = new Point(rel.RelFin.Location.X + rel.RelFin.Size.Width / 2, rel.RelFin.Location.Y + rel.RelFin.Size.Height / 2);
                        }
                        Formas.Dibujar();
                        masterPanel.BackgroundImage = Image.FromFile(Formas.GetNewBackground());
                    }
                }

                Console.WriteLine("Re-Dibujado2");
            }
        }
예제 #2
0
        public void PointForRelation(object sender, EventArgs e)//cuando drawing esta activado carga las posiciones de los paneles al una lista
        {
            Panel           pan   = sender as Panel;
            Graphics        g     = this.CreateGraphics();
            Pen             lapiz = new Pen(Color.Black, 3);
            Figura_Relacion rel;

            if (drawing)
            {
                rel = relaciones.Last();
                if (!rel.isFull)
                {
                    if (rel.RelIni == null)
                    {
                        rel.RelIni = pan;
                    }
                    else if (rel.RelIni != null && rel.RelFin == null)
                    {
                        rel.RelFin = pan;
                        rel.isFull = true;
                        rel.RelPuntos.Add(new Point(rel.RelIni.Location.X + rel.RelIni.Size.Width / 2, rel.RelIni.Location.Y + rel.RelIni.Size.Height / 2));
                        rel.RelPuntos.Add(new Point(rel.RelFin.Location.X + rel.RelFin.Size.Width / 2, rel.RelFin.Location.Y + rel.RelFin.Size.Height / 2));
                    }
                }

                if (rel.isFull)
                {
                    Formas.Formas.Add(rel);
                    Formas.CanvasSize = masterPanel.Size;
                    Formas.Dibujar();
                    try
                    {
                        //masterPanel.BackgroundImage = Image.FromFile(@"C:\Users\Andres\Dropbox\6toSemestre\AppAmbProp\Examples\PropietariosMov\PropietariosMovDib4\ProyectoPropietarios\ProyectoPropietarios\Reltst1.bmp");
                        masterPanel.BackgroundImage = Image.FromFile(Formas.GetNewBackground());
                    }
                    catch { }
                    drawing = false;
                }
            }
        }
예제 #3
0
        public void CrearPanel(ref Panel panel)                                                //permite crear un panel con una clase
        {
            MenuItem[] menuItems = new MenuItem[] { new MenuItem("Modificar", MenuItem_Click), //hacemos esto para definir como se comportaran luego
                                                    new MenuItem("Reiniciar", MenuItem_Click), new MenuItem("Exit", MenuItem_Click) };
            ContextMenu buttonMenu = new ContextMenu(menuItems);

            panel.Location = new System.Drawing.Point(570, 370);
            panel.Name     = "Panel " + paneles.Count;//se poodria cambiar por parametro aunque no me parecee necesario
            panel.Size     = new System.Drawing.Size(228, 201);
            Figura_Clase fig = new Figura_Clase(panel.Size);

            Formas.Formas.Add(fig);
            panel.BackgroundImage = Image.FromFile(Formas.GetNewBackground());
            panel.BackColor       = Color.LightBlue;
            panel.ContextMenu     = buttonMenu;
            panel.Click          += PointForRelation;//Se guarda en los puntos para utilizarlos en relaciones
            panel.MouseClick     += PnlMouseDown;
            panel.MouseMove      += PnlMouseMove;
            panel.MouseUp        += PnlMouseUp;
            ControlExtension.Draggable(panel, true);
            fig.Contenedor = panel;
            //Controls.Add(panel);
            masterPanel.Controls.Add(panel);
        }