private void LayerControl_LayerRemoveButtonClicked(object sender) { LayerControl control = sender as LayerControl; int index = this.Controls.IndexOf(control); this.RemoveAt(index); }
private void Layer_TypeChanged(object sender, LayerType type) { LayerControl control = sender as LayerControl; int index = this.Controls.IndexOf(control); this.ItemTypeChanged?.Invoke(this, index, type); }
private void Layer_VisibleStateChanged(object sender, bool value) { LayerControl control = sender as LayerControl; int index = this.Controls.IndexOf(control); this.ItemVisibleStateChanged?.Invoke(this, index, value); }
private void LayerControl_LayerDownButtonClicked(object sender) { LayerControl control = sender as LayerControl; int index = this.Controls.IndexOf(control); this.Swap(index, index + 1); }
/// <summary> /// Met à jour la liste selon l'élément selectionné /// </summary> /// <param name="index">L'index de l'élément selectionné</param> private void RefreshSelectionState(int index) { for (int i = 0; i < this.Controls.Count; i++) { LayerControl layerControl = this.Controls[i] as LayerControl; layerControl.Selected = (index == i); } }
/// <summary> /// Ajoute l'élément sans le selectionner /// </summary> /// <param name="layer">La couche à ajouter</param> public virtual void Add(GameMapLayer layer) { LayerControl layerControl = new LayerControl(layer.Name, layer.Visible, layer.Type); this.Controls.Add(layerControl); this.ItemAdded?.Invoke(this, this.ControlsCount - 1, layer); this.ItemsCountChanged?.Invoke(this, this.ControlsCount); }
/// <summary> /// Met à jour l'affichage du control et de ses enfants /// </summary> public override void Refresh() { base.Refresh(); for (int i = 0; i < this.Controls.Count; i++) { LayerControl layerControl = this.Controls[i] as LayerControl; this.Controls[i].Location = new Point(0, i * (this.Controls[i].Height + ITEM_MARGIN_BOTTOM) - this.VerticalScroll.Value); layerControl.Index = i.ToString(); } }
/// <summary> /// Insert l'élément à la position spécifiée /// </summary> /// <param name="index">L'index de la position d'insertion</param> /// <param name="layer">La couche à insérer</param> public virtual void InsertAt(int index, GameMapLayer layer) { if (index >= 0 && layer != null) { this.Controls.Add(new LayerControl(layer.Name, layer.Visible, layer.Type)); LayerControl layerControl = this.Controls[this.Controls.Count - 1] as LayerControl; this.Controls.SetChildIndex(layerControl, index); this.Refresh(); this.SelectedIndex = index; this.ItemAdded?.Invoke(this, index, layer); this.ItemsCountChanged?.Invoke(this, this.ControlsCount); } else { throw new IndexOutOfRangeException("Insertion de la couche impossible, l'index spécifié est en dehors des limites du tableau."); } }
private void LayerControl_Click(object sender) { LayerControl control = sender as LayerControl; this.SelectedIndex = this.Controls.IndexOf(control); }