Esempio n. 1
0
        //-------------------------------------------------------------------------
        // Rebuild the layers control. This is usually done after a picture change
        //-------------------------------------------------------------------------
        public void RebuildLayerControls()
        {
            // Delete current layer controls

            SuspendDraw.Suspend(LayerDisplayPanel); //suspend redraw to reduce lag
            //LayerDisplayPanel.SuspendLayout();
            LayerDisplayPanel.Controls.Clear();
            m_layerControls.Clear();
            // Cycle through each layer
            List <LayerControl> controls = new List <LayerControl>();

            foreach (Layer layer in m_canvasSession.GetPicture().layers)
            {
                LayerControl lc = new LayerControl(layer.Name, layer.ID);
                lc.layerNameChanged     += new LayerNameChaged(OnLayerNameChange);
                lc.layerControlSelected += new LayerControlSelected(OnLayerSelectionChange);
                lc.layerDragStart       += LayerControl_StartDrag;
                m_layerControls.Add(lc.GetLayerID(), lc);
                this.LayerDisplayPanel.Controls.Add(lc);
                controls.Add(lc);
            }
            foreach (Layer layer in m_canvasSession.GetPicture().layers)
            {
                UpdateThumbnail(layer.ID);
            }
            if (selectedIndex != null && m_layerControls.ContainsKey(selectedIndex))
            {
                OnLayerSelectionChange(m_layerControls[selectedIndex]);
            }
            //LayerDisplayPanel.ResumeLayout();
            SuspendDraw.Resume(LayerDisplayPanel);
        }
        //-------------------------------------------------------------------------
        // Rebuild the layers control. This is usually done after a picture change
        //-------------------------------------------------------------------------
        public void RebuildLayerControls()
        {
            // Delete current layer controls

            SuspendDraw.Suspend(LayerDisplayPanel); //suspend redraw to reduce lag
            //LayerDisplayPanel.SuspendLayout();
            LayerDisplayPanel.Controls.Clear();
            m_layerControls.Clear();
            // Cycle through each layer
            List<LayerControl> controls = new List<LayerControl>();
            foreach (Layer layer in m_canvasSession.GetPicture().layers)
            {
                LayerControl lc = new LayerControl(layer.Name, layer.ID);
                lc.layerNameChanged += new LayerNameChaged(OnLayerNameChange);
                lc.layerControlSelected += new LayerControlSelected(OnLayerSelectionChange);
                lc.layerDragStart += LayerControl_StartDrag;
                m_layerControls.Add(lc.GetLayerID(), lc);
                this.LayerDisplayPanel.Controls.Add(lc);
                controls.Add(lc);
            }
            foreach (Layer layer in m_canvasSession.GetPicture().layers) {
                UpdateThumbnail(layer.ID);
            }
            if (m_layerControls.ContainsKey(selectedIndex)) {
                OnLayerSelectionChange(m_layerControls[selectedIndex]);
            }
            //LayerDisplayPanel.ResumeLayout();
            SuspendDraw.Resume(LayerDisplayPanel);
        }
Esempio n. 3
0
 private void LayerControl_StartDrag(object sender, MouseEventArgs e)
 {
     _draggedLayer = sender as LayerControl;
     if (_draggedLayer != null)
     {
         _draggedLayerStartIndex = LayerDisplayPanel.Controls.IndexOf(_draggedLayer);
         this.LayerDisplayPanel.DoDragDrop(_draggedLayer, DragDropEffects.Move);
     }
 }
        //-------------------------------------------------------------------------
        // Set the selected layer index
        //-------------------------------------------------------------------------
        public void SetActiveLayerControl(int layerIndex)
        {
            // Deactivate the currently selected layer
            if (selectedLayerControl != null)
            {
                selectedLayerControl.LayerDeactivated();
            }

            // Set the currently selected layer to the new layer
            selectedLayerControl = (LayerControl)LayerDisplayPanel.Controls[layerIndex];

            // Activate the newly selected layer
            selectedLayerControl.LayerActivated();
        }
        //-------------------------------------------------------------------------
        // Set the selected layer
        //-------------------------------------------------------------------------
        public void SetActiveLayerControl(LayerControl layerControl)
        {
            // Deactivate the currently selected layer
            if (selectedLayerControl != null)
            {
                selectedLayerControl.LayerDeactivated();
            }

            // Activate the newly selected layer
            layerControl.LayerActivated();

            // Set the currently selected layer to the new layer
            selectedLayerControl = layerControl;
        }
Esempio n. 6
0
        private void LayerDisplayPanel_DragDrop(object sender, DragEventArgs e)
        {
            int resultingIndex = LayerDisplayPanel.Controls.IndexOf(_draggedLayer);

            if (_draggedLayerStartIndex != resultingIndex)
            {
                var order = new List <string>();
                foreach (LayerControl lc in LayerDisplayPanel.Controls)
                {
                    order.Add(lc.GetLayerID());
                }
                m_canvasSession.Gui_SetLayerOrder(order.ToArray());
            }
            _draggedLayer = null;
        }
Esempio n. 7
0
 //-------------------------------------------------------------------------
 // Event handler for a layer selection event
 //-------------------------------------------------------------------------
 private void OnLayerSelectionChange(LayerControl layerControl)
 {
     selectedIndex = layerControl.GetLayerID();
     foreach (LayerControl lc in m_layerControls.Values)
     {
         if (lc == layerControl)
         {
             lc.LayerActivated();
         }
         else
         {
             lc.LayerDeactivated();
         }
     }
 }
        //-------------------------------------------------------------------------
        // Rebuild the layers control. This is usually done after a picture change
        //-------------------------------------------------------------------------
        public void RebuildLayerControls()
        {
            // Delete current layer controls
            LayerDisplayPanel.Controls.Clear();

            // Cycle through each layer
            int layerIndex = 0;
            foreach (Layer layer in currentPicture.layers)
            {
                LayerControl lc = new LayerControl(layer, layerIndex++);
                lc.layerNameChanged += new LayerNameChaged(OnLayerNameChange);
                lc.layerControlSelected += new LayerControlSelected(OnLayerSelectionChange);
                if(layerIndex == active)
                this.LayerDisplayPanel.Controls.Add(lc);
            }
        }
        //-------------------------------------------------------------------------
        // Rebuild the layers control. This is usually done after a picture change
        //-------------------------------------------------------------------------
        public void RebuildLayerControls()
        {
            // Delete current layer controls
            LayerDisplayPanel.Controls.Clear();

            // Cycle through each layer
            int layerIndex = 0;

            foreach (Layer layer in currentPicture.layers)
            {
                LayerControl lc = new LayerControl(layer, layerIndex++);
                lc.layerNameChanged     += new LayerNameChaged(OnLayerNameChange);
                lc.layerControlSelected += new LayerControlSelected(OnLayerSelectionChange);
                if (layerIndex == active)
                {
                    this.LayerDisplayPanel.Controls.Add(lc);
                }
            }
        }
        //-------------------------------------------------------------------------
        // Set the selected layer index
        //-------------------------------------------------------------------------
        public void SetActiveLayerControl(int layerIndex)
        {
            // Deactivate the currently selected layer
            if (selectedLayerControl != null)
                selectedLayerControl.LayerDeactivated();

            // Set the currently selected layer to the new layer
            selectedLayerControl = (LayerControl)LayerDisplayPanel.Controls[layerIndex];

            // Activate the newly selected layer
            selectedLayerControl.LayerActivated();
        }
 //-------------------------------------------------------------------------
 // Event handler for a layer selection event
 //-------------------------------------------------------------------------
 private void OnLayerSelectionChange(LayerControl layerControl)
 {
     selectedIndex = layerControl.GetLayerID();
     foreach(LayerControl lc in m_layerControls.Values)
     {
         if (lc == layerControl)
             lc.LayerActivated();
         else
             lc.LayerDeactivated();
     }
 }
 private void LayerDisplayPanel_DragDrop(object sender, DragEventArgs e)
 {
     int resultingIndex = LayerDisplayPanel.Controls.IndexOf(_draggedLayer);
     if (_draggedLayerStartIndex != resultingIndex) {
         var order = new List<string>();
         foreach (LayerControl lc in LayerDisplayPanel.Controls)
             order.Add(lc.GetLayerID());
         m_canvasSession.Gui_SetLayerOrder(order.ToArray());
     }
     _draggedLayer = null;
 }
 private void LayerControl_StartDrag(object sender, MouseEventArgs e)
 {
     _draggedLayer = sender as LayerControl;
     if (_draggedLayer != null) {
         _draggedLayerStartIndex = LayerDisplayPanel.Controls.IndexOf(_draggedLayer);
         this.LayerDisplayPanel.DoDragDrop(_draggedLayer, DragDropEffects.Move);
     }
 }
        //-------------------------------------------------------------------------
        // Set the selected layer
        //-------------------------------------------------------------------------
        public void SetActiveLayerControl(LayerControl layerControl)
        {
            // Deactivate the currently selected layer
            if (selectedLayerControl != null)
                selectedLayerControl.LayerDeactivated();

            // Activate the newly selected layer
            layerControl.LayerActivated();

            // Set the currently selected layer to the new layer
            selectedLayerControl = layerControl;
        }
 //-------------------------------------------------------------------------
 // Contructor
 //-------------------------------------------------------------------------
 public LayerControlForm()
 {
     InitializeComponent();
     selectedLayerControl = null;
 }
 //-------------------------------------------------------------------------
 // Event handler for a layer selection event
 //-------------------------------------------------------------------------
 private void OnLayerSelectionChange(LayerControl layerControl)
 {
     SetActiveLayerControl(layerControl);
 }
 //-------------------------------------------------------------------------
 // Event handler for a layer selection event
 //-------------------------------------------------------------------------
 private void OnLayerSelectionChange(LayerControl layerControl)
 {
     SetActiveLayerControl(layerControl);
 }
 //-------------------------------------------------------------------------
 // Contructor
 //-------------------------------------------------------------------------
 public LayerControlForm()
 {
     InitializeComponent();
     selectedLayerControl = null;
 }