private void stackLayer_PointerPressed(object sender, PointerRoutedEventArgs e) { if (sender as LayerIcon != null) { SelectLayerIcon = sender as LayerIcon; } }
public void ClearSelect() { for (int i = 0; i < stackLayer.Children.Count; i++) { LayerIcon li = stackLayer.Children[i] as LayerIcon; li.UnSelect(); } }
public void setLayersZIndex() { for (int i = 0; i < stackLayer.Children.Count; i++) { LayerIcon li = stackLayer.Children[i] as LayerIcon; PhotoLayer pl = li.getLayer(); Canvas.SetZIndex(pl, stackLayer.Children.Count - stackLayer.Children.IndexOf(li)); } }
{ //support photo load and scale/rotate/transform //support draw some geometry //mergin layer public PhotoLayer() { InitializeComponent(); li = new LayerIcon(this); acm = new ActionMove(this, this); acm.Enable = false; ar = new ActionResize(Layer, Layer, new LynxResized(_Resized)); ar.Enable = false;//默认不可缩放 }
public void AddLayer(PhotoLayer o)//层永远加在最上面 { setLayersZIndex(); Canvas.SetZIndex(o, pc.getLayers().Children.Count); SelectLayerIcon = new LayerIcon(o); SelectLayerIcon.selectLayer += new LayerEventHandler(SelectLayerIcon_selectLayer); o.Selected(); //li.Init(o); SelectLayerIcon.PointerPressed += new PointerEventHandler(LayerIcon_PointerPressed); SelectLayerIcon.PointerReleased += new PointerEventHandler(LayerIcon_PointerReleased); stackLayer.Children.Add(SelectLayerIcon); pc.PhotoLayers.Children.Add(SelectLayerIcon.getLayer()); }
//public void SelectLayer(LayerIcon li) //{ // pc.SelectLayer = li.getLayer(); //} public void CutLayer() { pc.PhotoLayers.Children.Remove(SelectLayerIcon.getLayer()); stackLayer.Children.Remove(SelectLayerIcon); if (stackLayer.Children.Count != 0) { SelectLayerIcon = stackLayer.Children[0] as LayerIcon; setLayersZIndex(); } else { pc.SelectLayer = null; } }
private void LayerIcon_PointerReleased(object sender, PointerRoutedEventArgs e) { LayerIcon tli = sender as LayerIcon; if (tli != SelectLayerIcon) { if (stackLayer.Children.Contains(SelectLayerIcon)) { stackLayer.Children.Remove(SelectLayerIcon); } stackLayer.Children.Insert(stackLayer.Children.IndexOf(tli), SelectLayerIcon); setLayersZIndex(); } }
public void ReadLayers() { Canvas ls = pc.getLayers(); stackLayer.Children.Clear(); for (int i = 0; i < ls.Children.Count; i++) { PhotoLayer pl = ls.Children[i] as PhotoLayer; stackLayer.Children.Add(pl.li); pl.li.ReadInfor(); LayerIcon li = stackLayer.Children[i] as LayerIcon; li.selectLayer += new LayerEventHandler(SelectLayerIcon_selectLayer); li.ReadInfor(); } }
public void DeleteLayer() { pc.PhotoLayers.Children.Remove(SelectLayerIcon.getLayer()); stackLayer.Children.Remove(SelectLayerIcon); SelectLayerIcon.selectLayer -= new LayerEventHandler(SelectLayerIcon_selectLayer); SelectLayerIcon.PointerPressed -= new PointerEventHandler(LayerIcon_PointerPressed); SelectLayerIcon.PointerReleased -= new PointerEventHandler(LayerIcon_PointerReleased); if (stackLayer.Children.Count != 0) { SelectLayerIcon = stackLayer.Children[0] as LayerIcon; setLayersZIndex(); } else { pc.SelectLayer = null; } }
void SelectLayerIcon_selectLayer(object sender, LynxPhotoLayerEventArgs e) { if (e.IsSelected) { ClearSelect(); e.currentIcon.Select(); SelectLayerIcon = e.currentIcon; } else { if (e.currentIcon != SelectLayerIcon) { if (stackLayer.Children.Contains(SelectLayerIcon)) { stackLayer.Children.Remove(SelectLayerIcon); } stackLayer.Children.Insert(stackLayer.Children.IndexOf(e.currentIcon), SelectLayerIcon); setLayersZIndex(); } } }
private void LayerIcon_PointerPressed(object sender, PointerRoutedEventArgs e) { ClearSelect(); SelectLayerIcon = sender as LayerIcon; SelectLayerIcon.Select(); }