示例#1
0
 public override void Regen(Vista v, bool addToDisplayList = true)
 {
     ps = v.Scala(p);
     if (addToDisplayList)
     {
         v.AddDL(this, Def.Shape.Nodo, ps.X, ps.Y);
     }
 }
示例#2
0
 /// <summary>
 /// Allinea tutti i nodi alla griglia della vista
 /// </summary>
 /// <param name="v">Vista con la griglia</param>
 public void AllineaAllaGriglia(Vista v)
 {
     foreach (Elemento el in Dati.Elementi())
     {
         if (el is Nodo)
         {
             Point2D rp = ((Nodo)el).P / v.GridStep;                         // Rapporti
             rp.X           = Math.Round(rp.X, 0) * v.GridStep;
             rp.Y           = Math.Round(rp.Y, 0) * v.GridStep;
             ((Nodo)el).P.X = rp.X;
             ((Nodo)el).P.Y = rp.Y;
         }
     }
     _isModified = true;
 }
示例#3
0
 public void Draw(Graphics g, Vista v, Pen pn)
 {
     if (active && visible)
     {
         int i, j;
         for (i = imin; i < imax; i++)
         {
             for (j = jmin; j < jmax; j++)
             {
                 Point p = v.Scala(new Point2D(i * step * Math.Sign(v.Verso.X), j * step * Math.Sign(v.Verso.Y)));
                 g.DrawLine(pn, p.X - 2, p.Y - 2, p.X + 2, p.Y + 2);
                 g.DrawLine(pn, p.X - 2, p.Y + 2, p.X + 2, p.Y - 2);
             }
         }
     }
 }
示例#4
0
        /// <summary>
        /// Seleziona l'ultimo elemento evidenziato
        /// </summary>
        public void SelectLastElement(Vista v)
        {
            Elemento el = v.GetLastHighLighted();

            if (el != null)
            {
                el.Selected = !el.Selected;
                if (el.Selected)
                {
                    selezionati.Add(el);
                }
                else
                {
                    selezionati.Remove(el);
                }
            }
        }
示例#5
0
        public readonly List <int> indxList;        // Lista indici evidenziati nell'ultimo Play()

        /// <summary>
        /// Costruttore
        /// </summary>
        public DisplayList(Vista v)
        {
            vista    = v;
            indxList = new List <int>();                    // Crea la lista degli indici

            /*
             * brush = new Brush[]
             *      {
             *      new SolidBrush(Def.ColourSelected),			// Selected
             *      new SolidBrush(Def.ColourHighlighed),		// Highlighted
             *      new SolidBrush(Def.ColourNodo),				// Nodi
             *      new SolidBrush(Def.ColourRamo),				// Rami
             *      new SolidBrush(Color.Green),
             *      new SolidBrush(Color.Blue),
             *      new SolidBrush(Def.ColourBackground)
             *      };
             * pen = new Pen[]
             *      {
             *      new Pen(Def.ColourSelected, 1),				// Come sopra
             *      new Pen(Def.ColourHighlighed, 1),
             *      new Pen(Def.ColourNodo, 1),
             *      new Pen(Def.ColourRamo, 1),
             *      new Pen(Color.Green, 1),
             *      new Pen(Color.Blue, 1),
             *      new Pen(Def.ColourBackground)
             *      };
             * font = new Font[]
             *      {
             *      new Font(Def.FONT_NAME, Def.FONT_SIZE)
             *      };
             *
             * if(pen.Length != Enum.GetNames(typeof(Def.Colori)).Length)
             *      throw new Exception("Pen array and Color enum do not match");
             * if(brush.Length != Enum.GetNames(typeof(Def.Colori)).Length)
             *      throw new Exception("Brush array and Color enum do not match");
             */

            com = new Command[Def.FREE_MAX];                            // Array
#if (DEBUG)
            LOG.Write($"DisplayList.Command[{com.Length}]");
#endif
            count = 0;
        }
示例#6
0
        public override Def.ClipFlag Clip(Vista v)
        {
            Def.ClipFlag clip1 = Nd1.Clipped;
            Def.ClipFlag clip2 = Nd2.Clipped;

            if ((clip1 | clip2) == Def.ClipFlag.Inside)                     // Entrambi gli estremi all'interno (bitwise OR è zero): no clip
            {
                clipped = Def.ClipFlag.Inside;
            }
            else if ((clip1 & clip2) != Def.ClipFlag.Inside)                //	Bitwise AND non è zero: condividono una area esterna: clip
            {
                clipped = Def.ClipFlag.Outside;
            }
            else
            {
                clipped = Def.ClipFlag.Inside;                                  // Clip parziale. Non si esegue il clipping sui double, ...
            }                                                                   // ...ma si lascia fare a Windows.Graphics, su coordiante intere, più veloce
            return(clipped);
        }
示例#7
0
        public override void Draw(Graphics g, Vista v, bool high, bool sel)
        {
            Stile.Colore col = sel ? Stile.Colore.Selected : Stile.Colore.Ramo;
            if (high)
            {
                col = Stile.Colore.Highlighted;
            }

            g.DrawLine(v.Pen(col), nd[0].Ps, nd[1].Ps);                     // Disegna prima la linea, poi sovrappone una figura con il simbolo

            if (Point2D.Mod(new Point(nd[1].Ps.X - nd[0].Ps.X, nd[1].Ps.Y - nd[0].Ps.Y)) > Def.SHAPE_HALFSIZE * Def.SHAPE_HALFSIZE * 4)
            {
                GraphicsPath pth = (GraphicsPath)Def.Shape2D.GetShape(Def.Shape2D.Name.Arrow).Clone();
                pth.Transform(m);
                g.DrawPath(v.Pen(col), pth);
                //g.FillPath(br,pth);
            }

            g.DrawString(id.ToString(), v.Font(0), v.Brush(col), pc.X + Def.NODE_HALFSIZE * 2, pc.Y + Def.NODE_HALFSIZE * 2);
        }
示例#8
0
        public override void Draw(Graphics g, Vista v, bool high, bool sel)
        {
            GraphicsPath pth = (GraphicsPath)Def.Shape2D.GetShape(Def.Shape2D.Name.Circle).Clone();

            Stile.Colore col = sel ? Stile.Colore.Selected : Stile.Colore.Nodo;
            if (high)
            {
                col = Stile.Colore.Highlighted;
            }
            Matrix m = new Matrix();

            m.Translate(ps.X, ps.Y);
            pth.Transform(m);
            g.DrawPath(v.Pen(Stile.Colore.Nodo), pth);
            string str = id.ToString() + System.Environment.NewLine + "---";
            SizeF  sz  = g.MeasureString(str, v.Font(0));

            g.DrawRectangle(v.Pen(col), ps.X - 2 * Def.FONT_SIZE - Def.NODE_HALFSIZE * 2, ps.Y - Def.FONT_SIZE - Def.NODE_HALFSIZE * 2, sz.Width, sz.Height);
            //g.FillRectangle(     ,ps.X-2*Def.FONT_SIZE-Def.NODE_HALFSIZE*2, ps.Y-Def.FONT_SIZE-Def.NODE_HALFSIZE*2,sz.Width,sz.Height);
            g.DrawString(str, v.Font(0), v.Brush(col), ps.X - 2 * Def.FONT_SIZE - Def.NODE_HALFSIZE * 2, ps.Y - Def.FONT_SIZE - Def.NODE_HALFSIZE * 2);
        }
示例#9
0
        public override void Regen(Vista v, bool addToDisplayList = true)
        {
            Point2D p1 = nd[0].P;
            Point2D p2 = nd[1].P;

            if ((p1 != null) && (p2 != null))
            {
                nd[0].Regen(v, false);                              // Rigenera i nodi di estremità calcolando solo la scala...
                nd[1].Regen(v, false);                              // ... ma senza aggiungerli alla display list
                pc = v.Scala(Point2D.Midpoint(nd[0].P, nd[1].P));

                Point2D delta = p2 - p1;
                rotation = Math.Atan2(delta.Y * Math.Sign(v.Verso.Y), delta.X * Math.Sign(v.Verso.X)) * 180 / Math.PI;
                m.Reset();                                          // Torna alla matrice identità (non richiedo riallocazione)
                m.Translate(pc.X, pc.Y);
                m.Rotate((float)rotation);

                if (addToDisplayList)
                {
                    v.AddDL(this, Def.Shape.Ramo, pc.X, pc.Y);
                }
            }
        }
示例#10
0
        public void Recalc(Vista v)
        {
            int dx1, dy1, dx2, dy2;

            // Origine di World è sempre il punto Point2D(0,0).
            dx1 = (int)(v.SzWorldTopLeft.X / step) * Math.Sign(v.Verso.X);
            dy1 = (int)(v.SzWorldTopLeft.Y / step) * Math.Sign(v.Verso.Y);
            dx2 = (int)(v.SzWorldBottomRight.X / step) * Math.Sign(v.Verso.X);
            dy2 = (int)(v.SzWorldBottomRight.Y / step) * Math.Sign(v.Verso.Y);

            imin = Math.Min(dx1, dx2) - 1;
            imax = Math.Max(dx1, dx2) + 1;
            jmin = Math.Min(dy1, dy2) - 1;
            jmax = Math.Max(dy1, dy2) + 1;

            if (((imax - imin) > Def.MAX_GRID_POINTS) || ((jmax - jmin) > Def.MAX_GRID_POINTS))
            {
                visible = false;
            }
            else
            {
                visible = true;
            }
        }
示例#11
0
 public override Def.ClipFlag Clip(Vista v)
 {
     clipped = v.IsInsideWorld(p);
     return(clipped);
 }
示例#12
0
 public virtual Def.ClipFlag Clip(Vista v)
 {
     throw new Exception("public virtual Def.ClipFlag Clip() non sovrascritta nella classe derivata");
 }
示例#13
0
 //public virtual void Draw(Graphics g,Pen pn,Brush br,Font fn) {throw new Exception("public virtual void Draw() non sovrascritta nella classe derivata");}
 public virtual void Draw(Graphics g, Vista v, bool high, bool sel)
 {
     throw new Exception("public virtual void Draw() non sovrascritta nella classe derivata");
 }
示例#14
0
 public virtual void Regen(Vista v, bool addToDisplayList = true)
 {
     throw new Exception("public virtual void Regen() non sovrascritta nella classe derivata");
 }