Ejemplo n.º 1
0
 public Preview AddPreview(DEngine de, DViewer dv, DEngine sibling)
 {
     // suspend layout
     SuspendLayout();
     // index of new preview
     int idx;
     if (sibling != null)
         idx = GetPreviewIndex(sibling) + 1;
     else
         idx = Controls.Count;
     // create preview
     Preview p = new Preview(de);
     p.Parent = this;
     Controls.SetChildIndex(p, idx);
     // set preview properties
     p.Height = PreviewHeight;
     SetPreviewPositions();
     p.Click += new EventHandler(p_Click);
     p.PreviewContext += new PreviewContextHandler(p_PreviewContext);
     p.PreviewMove += new PreviewMoveHandler(p_PreviewMove);
     p.PreviewFigureDrop += new PreviewFigureDropHandler(p_PreviewFigureDrop);
     p.PreviewNameChanged += new PreviewNameChangedHandler(p_PreviewNameChanged);
     p.DragOver += new DragEventHandler(p_DragOver);
     // select it
     p.Selected = true;
     DoPreviewSelected(p);
     // resume layout
     ResumeLayout();
     // return p
     return p;
 }
Ejemplo n.º 2
0
        public void MatchPreviewsToEngines(IList<DEngine> engines, DViewer dv)
        {
            // Remove previews that dont have a matching preview
            for (int i = Controls.Count-1; i >= 0; i--)
            {
                Preview p = (Preview)Controls[i];

                if (engines.IndexOf(p.DEngine) == -1)
                    RemovePreview(p.DEngine);
            }
            // Add previews for engines that dont have them
            for (int i = 0; i < engines.Count; i++)
            {
                if (GetPreviewIndex(engines[i]) == -1)
                {
                    if (i > 0)
                        AddPreview(engines[i], dv, engines[i - 1]);
                    else
                        AddPreview(engines[i], dv, null);
                }
            }
            // Move previews that dont match engine order
            bool reorder = false;
            for (int i = 0; i < engines.Count; i++)
            {
                int idx = GetPreviewIndex(engines[i]);
                if (idx != i)
                {
                    Controls.SetChildIndex(Controls[idx], i);
                    reorder = true;
                }
            }
            if (reorder)
                SetPreviewPositions();
        }