public void AddNewLayer(BitmapImage image, Point origin) { var newLayer = new LayerPanel(_window, this, ImageGrid, image, origin) { Width = ImageGrid.Width, Height = ImageGrid.Height }; //add to image ImageGrid.Children.Add(newLayer); LayerPanel.SelectedLayerIndex = newLayer.Index; _window.LayerSettingsTitle.Content = newLayer.LayerName; foreach (var layer in Layers) { layer.ClearOutline(); } newLayer.DrawOutline(); //add to list Layers.Add(newLayer); _window.LayersListView.Items.Refresh(); _window.RepeatPreview.DrawRepeat(); //TODO: update slider position and angle text here with selectedLayer.Angle? }
private void RenameLayer(LayerPanel layer) { var dialog = new CustomDialog("Rename", "Rename layer", CustomDialogType.TextInput, layer.LayerName); if (dialog.ShowDialog() == true) { layer.LayerName = dialog.DialogInputText; _window.LayersListView.Items.Refresh(); } }
private void DeleteLayer(LayerPanel layer) { //remove from image ImageGrid.Children.Remove(layer); //remove from list Layers.Remove(layer); _window.LayersListView.Items.Refresh(); //sort out layer indexes so they are consecutive foreach (var layerPanel in Layers) { int index = Layers.IndexOf(layerPanel); layerPanel.SetIndex(index); //clear outlines layerPanel.ClearOutline(); } LayerPanel.SelectedLayerIndex = 0; LayerPanel.LastUsedIndex = Layers.Count; _window.RepeatPreview.DrawRepeat(); if (Layers.Count == 0) //removed the last layer { _window.LayerRotationSlider.Value = 0; var angle = (float)_window.LayerRotationSlider.Value; _window.LayerAngleTextBox.Text = $"{angle}°"; return; } var selectedLayer = Layers[LayerPanel.SelectedLayerIndex]; selectedLayer.DrawOutline(); }