public override bool UpdateLayout(LayoutingType layoutType) { GenericStack gs = Parent as GenericStack; if (layoutType == LayoutingType.Width) { if (gs.Orientation == Orientation.Horizontal) { Width = thickness; } else { Width = Measure.Stretched; } } else if (layoutType == LayoutingType.Height) { if (gs.Orientation == Orientation.Vertical) { Height = thickness; } else { Height = Measure.Stretched; } } return(base.UpdateLayout(layoutType)); }
public override void onMouseUp(object sender, MouseButtonEventArgs e) { base.onMouseUp(sender, e); GenericStack gs = Parent as GenericStack; if (init1 >= 0 && u1 == Unit.Percent) { if (gs.Orientation == Orientation.Horizontal) { go1.Width = new Measure((int)Math.Ceiling( go1.Width.Value * 100.0 / (double)gs.Slot.Width), Unit.Percent); } else { go1.Height = new Measure((int)Math.Ceiling( go1.Height.Value * 100.0 / (double)gs.Slot.Height), Unit.Percent); } } if (init2 >= 0 && u2 == Unit.Percent) { if (gs.Orientation == Orientation.Horizontal) { go2.Width = new Measure((int)Math.Floor( go2.Width.Value * 100.0 / (double)gs.Slot.Width), Unit.Percent); } else { go2.Height = new Measure((int)Math.Floor( go2.Height.Value * 100.0 / (double)gs.Slot.Height), Unit.Percent); } } }
protected override void loadTemplate(GraphicObject template = null) { base.loadTemplate(template); _list = this.child.FindByName("List") as Group; if (_list == null) { throw new Exception("ListBox Template MUST contain a Goup widget named 'List'."); } _gsList = _list as GenericStack; }
public override void onMouseDown(object sender, MouseButtonEventArgs e) { base.onMouseDown(sender, e); go1 = go2 = null; init1 = init2 = -1; delta = 0; GenericStack gs = Parent as GenericStack; int ptrSplit = gs.Children.IndexOf(this); if (ptrSplit == 0 || ptrSplit == gs.Children.Count - 1) { return; } go1 = gs.Children [ptrSplit - 1]; go2 = gs.Children [ptrSplit + 1]; if (gs.Orientation == Orientation.Horizontal) { initSplit(go1.Width, go1.Slot.Width, go2.Width, go2.Slot.Width); min1 = go1.MinimumSize.Width; min2 = go2.MinimumSize.Width; max1 = go1.MaximumSize.Width; max2 = go2.MaximumSize.Width; if (init1 >= 0) { go1.Width = init1; } if (init2 >= 0) { go2.Width = init2; } } else { initSplit(go1.Height, go1.Slot.Height, go2.Height, go2.Slot.Height); min1 = go1.MinimumSize.Height; min2 = go2.MinimumSize.Height; max1 = go1.MaximumSize.Height; max2 = go2.MaximumSize.Height; if (init1 >= 0) { go1.Height = init1; } if (init2 >= 0) { go2.Height = init2; } } }
public override void onMouseMove(object sender, MouseMoveEventArgs e) { base.onMouseMove(sender, e); if (!IsActive) { return; } GenericStack gs = Parent as GenericStack; int newDelta = delta, size1 = init1, size2 = init2; if (gs.Orientation == Orientation.Horizontal) { newDelta -= e.XDelta; if (size1 < 0) { size1 = go1.Slot.Width + delta; } if (size2 < 0) { size2 = go2.Slot.Width - delta; } } else { newDelta -= e.YDelta; if (size1 < 0) { size1 = go1.Slot.Height + delta; } if (size2 < 0) { size2 = go2.Slot.Height - delta; } } if (size1 - newDelta < min1 || (max1 > 0 && size1 - newDelta > max1) || size2 + newDelta < min2 || (max2 > 0 && size2 + newDelta > max2)) { return; } delta = newDelta; if (gs.Orientation == Orientation.Horizontal) { if (init1 >= 0) { go1.Width = init1 - delta; } if (init2 >= 0) { go2.Width = init2 + delta; } } else { if (init1 >= 0) { go1.Height = init1 - delta; } if (init2 >= 0) { go2.Height = init2 + delta; } } }
void loadPage(int pageNum) { #if DEBUG_LOAD Stopwatch loadingTime = new Stopwatch(); loadingTime.Start(); #endif Group page; if (typeof(Wrapper).IsAssignableFrom(items.GetType())) { page = items; itemPerPage = int.MaxValue; } else if (typeof(GenericStack).IsAssignableFrom(items.GetType())) { GenericStack gs = new GenericStack(); gs.CurrentInterface = items.CurrentInterface; gs.Initialize(); gs.Orientation = (items as GenericStack).Orientation; gs.Width = items.Width; gs.Height = items.Height; gs.VerticalAlignment = items.VerticalAlignment; gs.HorizontalAlignment = items.HorizontalAlignment; page = gs; page.Name = "page" + pageNum; isPaged = true; } else { page = Activator.CreateInstance(items.GetType()) as Group; page.Name = "page" + pageNum; isPaged = true; } for (int i = (pageNum - 1) * itemPerPage; i < pageNum * itemPerPage; i++) { if (i >= data.Count) { break; } if (cancelLoading) { return; } loadItem(i, page); } if (page == items) { return; } lock (CurrentInterface.LayoutMutex) items.AddChild(page); #if DEBUG_LOAD loadingTime.Stop(); Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms", loadingTime.ElapsedTicks, loadingTime.ElapsedMilliseconds, this.ToString()); #endif }
void loadPage(int pageNum) { #if DEBUG_LOAD Stopwatch loadingTime = new Stopwatch (); loadingTime.Start (); #endif Group page; if (typeof(Wrapper).IsAssignableFrom (items.GetType ())){ page = items; itemPerPage = int.MaxValue; }else if (typeof(GenericStack).IsAssignableFrom (items.GetType ())) { GenericStack gs = new GenericStack (); gs.CurrentInterface = items.CurrentInterface; gs.initialize (); gs.Orientation = (items as GenericStack).Orientation; gs.Width = items.Width; gs.Height = items.Height; gs.VerticalAlignment = items.VerticalAlignment; gs.HorizontalAlignment = items.HorizontalAlignment; page = gs; }else page = Activator.CreateInstance (items.GetType ()) as Group; page.Name = "page" + pageNum; for (int i = (pageNum - 1) * itemPerPage; i < pageNum * itemPerPage; i++) { if (i >= data.Count) break; if (cancelLoading) return; loadItem (i, page); } if (page == items) return; lock (CurrentInterface.LayoutMutex) items.AddChild (page); #if DEBUG_LOAD loadingTime.Stop (); Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms", loadingTime.ElapsedTicks, loadingTime.ElapsedMilliseconds, this.ToString()); #endif }
public override void onMouseMove(object sender, MouseMoveEventArgs e) { base.onMouseMove(sender, e); if (!IsActive) { return; } GenericStack gs = Parent as GenericStack; int ptrSplit = gs.Children.IndexOf(this); if (ptrSplit == 0 || ptrSplit == gs.Children.Count - 1) { return; } if (gs.Orientation == Orientation.Horizontal) { if ((gs.Children [ptrSplit - 1].Width + e.XDelta < gs.Children [ptrSplit - 1].MinimumSize.Width) || (gs.Children [ptrSplit + 1].Width - e.XDelta < gs.Children [ptrSplit + 1].MinimumSize.Width)) { return; } if (!gs.Children [ptrSplit - 1].Width.IsFixed) { gs.Children [ptrSplit - 1].Width = gs.Children [ptrSplit - 1].Slot.Width; } if (!gs.Children [ptrSplit + 1].Width.IsFixed) { gs.Children [ptrSplit + 1].Width = gs.Children [ptrSplit + 1].Slot.Width; } gs.Children [ptrSplit - 1].Width = gs.Children [ptrSplit - 1].Width + e.XDelta; gs.Children [ptrSplit + 1].Width = gs.Children [ptrSplit + 1].Width - e.XDelta; } else { if ((gs.Children [ptrSplit - 1].Height + e.YDelta < gs.Children [ptrSplit - 1].MinimumSize.Height) || (gs.Children [ptrSplit + 1].Height - e.YDelta < gs.Children [ptrSplit + 1].MinimumSize.Height)) { return; } if (!gs.Children [ptrSplit - 1].Height.IsFixed) { gs.Children [ptrSplit - 1].Height = gs.Children [ptrSplit - 1].Slot.Height; } if (!gs.Children [ptrSplit + 1].Height.IsFixed) { gs.Children [ptrSplit + 1].Height = gs.Children [ptrSplit + 1].Slot.Height; } gs.Children [ptrSplit - 1].Height = gs.Children [ptrSplit - 1].Height + e.YDelta; gs.Children [ptrSplit + 1].Height = gs.Children [ptrSplit + 1].Height - e.YDelta; } }