Exemplo n.º 1
0
        private void RepositionLayer(int originalLayerIndex, int newLayerIndex)
        {
            int          layerCount = LiveTopToBottomLayers.Count;
            LayerBoxItem layerItem  = null;

            bool changeEffected = false;

            // 1. Remove from old position.

            if (originalLayerIndex >= 0 && originalLayerIndex < layerCount)
            {
                layerItem = LiveTopToBottomLayers[originalLayerIndex];
                LiveTopToBottomLayers.RemoveAt(originalLayerIndex);

                changeEffected = true;
            }


            // 2. Add into new position.

            layerCount = LiveTopToBottomLayers.Count;
            if (newLayerIndex >= 0 && newLayerIndex <= layerCount)
            {
                if (layerItem == null)
                {
                    if (_LayerObjectCreator != null)
                    {
                        layerItem = _LayerObjectCreator.CreateLayer(layerCount);
                    }
                }

                if (layerItem != null)
                {
                    LiveTopToBottomLayers.Insert(newLayerIndex, layerItem);

                    SelectedIndex = newLayerIndex;

                    changeEffected = true;
                }
            }


            if (changeEffected)
            {
                // Layers starting from the new position and up (lower indexes in the ListBox) must have their position in the Fontogram updated.
                layerCount = LiveTopToBottomLayers.Count;
                for (int i = 0; i < layerCount; i++)
                {
                    LiveTopToBottomLayers[i].Position = layerCount - i - 1;
                }

                LayersChanged?.Invoke();
            }
        }
Exemplo n.º 2
0
 protected void OnLayersChanged()
 {
     LayersChanged?.Invoke();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Raise a ValueChanged event on this control
 /// </summary>
 /// <param name="d"></param>
 /// <param name="e"></param>
 public void RaiseLayersChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     LayersChanged?.Invoke(d, e);
 }