public SnapLabel GetFirstSnapLabel <T>(T snap) where T : Code.Interface.ISnapWindow { foreach (var panel in new[] { SP_Right, SP_Left, SP_Bottom, SP_Top }) { foreach (var it in panel.Children) { if (it is SnapLabel) { SnapLabel label = it as SnapLabel; TAG_Label tag = label.Tag as TAG_Label; if (tag.window.Window.Equals(snap)) { return(label); } } } } throw new ArgumentException("Snap not yet added"); }
public List <T> FindSnaps <T>(bool onlyFocused = false) { var list = new List <T>(); foreach (var panel in new [] { SP_Right, SP_Left, SP_Bottom, SP_Top }) { foreach (var it in panel.Children) { if (it is SnapLabel) { SnapLabel label = it as SnapLabel; TAG_Label tag = label.Tag as TAG_Label; if (tag.window.WindowContent is T && (!onlyFocused || label.IsDisplayed)) { list.Add((T)tag.window.WindowContent); } } } } return(list); }
private void SnapLabel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { SnapLabel l = sender as SnapLabel; TAG_Label tag = l.Tag as TAG_Label; var wasDisplayed = l.IsDisplayed; StackPanel panel; Frame frame; switch (l.DockedAt) { default: throw new ArgumentException(); case Dock.Top: panel = SP_Top; frame = F_Top; break; case Dock.Left: panel = SP_Left; frame = F_Left; break; case Dock.Bottom: panel = SP_Bottom; frame = F_Bottom; break; case Dock.Right: panel = SP_Right; frame = F_Right; break; } var currentWindow = GetFocusedSnapWindow(l.DockedAt); foreach (var it in panel.Children) { if (it is SnapLabel) { (it as SnapLabel).IsDisplayed = false; var tmp = ((it as SnapLabel).Tag as TAG_Label).window; if (tmp.IsDisplayed) { tmp.HideSnap(); } } } if (!wasDisplayed) { tag.window.DisplaySnap(frame); l.IsDisplayed = true; if (OnSnapFocusChange != null) { OnSnapFocusChange(this, new OnSnapFocusChangeEventArgs(tag.window, currentWindow, l.DockedAt)); } } else { if (OnSnapFocusChange != null) { OnSnapFocusChange(this, new OnSnapFocusChangeEventArgs(null, currentWindow, l.DockedAt)); } } }