//Adds a given layer to the layer manager, and sets up all events as well public void AddLayer(LayersBox layerBox) { MainLayerStack.Children.Insert(0, layerBox); foreach (LayersBox b in layers) { b.SetActive(false); } layerBox.SetActive(true); LayerCount++; layers.Add(layerBox); MainWindow.LayerGrid.Children.Add(layerBox.layerInfo); //Events layerBox.MouseDown += LayerBox_MouseDown; layerBox.layerInfo.MouseDown += Layer_MouseDown; layerBox.layerInfo.MouseUp += Layer_MouseUp; layerBox.layerInfo.MouseLeave += Layer_MouseLeave; layerBox.layerInfo.MouseMove += Layer_MouseMove; layerBox.DeleteButtonClicked += LayerBox_DeleteButtonClicked; }
//Creates transparent backdrop public void RenderInitialCanvas() { Layer layer0 = new Layer(0, CreateInitialPixelLayer(CanvasHeight, CanvasWidth, DefaultPixelSize, false), new Size(CanvasHeight, CanvasWidth), DefaultPixelSize); layer0.SetActive(true); layer0.name = "Background"; Visibility = Visibility.Visible; LayersBox box0 = new LayersBox(true); box0.AddLayerInfo(layer0); AddLayer(box0); CreateNewLayer(); SetCanvasSize((int)layer0.Height, (int)layer0.Width); }
//Creates a new layer! public void CreateNewLayer() { if (CanvasHeight == 0 || CanvasWidth == 0) { throw new LayerManagerNotInitializedCompletelyException("Canvas height and width not set."); } LayersBox box = new LayersBox(); Layer lay = new Layer(LayerCount, CreateInitialPixelLayer(CanvasHeight, CanvasWidth, DefaultPixelSize, true), new Size(CanvasWidth, CanvasHeight), DefaultPixelSize); lay.name = "Layer " + LayerCount; box.AddLayerInfo(lay); AddLayer(box); }