public void GoToNextTransactionEntry() { try { if (SalesVM.Instance.TransactionData == null) { return; } SalesVM.Instance.SaveTransaction(); if (SalesLst.SelectedIndex == SalesLst.Items.Count - 1) { padPos = PadPosition.Below; SalesVM.Instance.TransactionData.CurrentTransactionEntry = null; SalesLst.SelectedItem = null; Canvas.SetTop(SalesLst, 0); SalesLst.UpdateLayout(); Canvas.SetTop(SalesPad, 0); SalesPad.Margin = SalesPadMargin; Canvas.SetTop(SalesPad, SalesLst.ActualHeight + 8); SetSalesPadtoSelectedItem(); } else { SalesLst.SelectedIndex += 1; // selected index don't change when more than list } } catch (Exception ex) { Logger.Log(LoggingLevel.Error, ex.Message + ex.StackTrace); throw ex; } }
private void SetSalesPadtoSelectedItem() { SalesLst.UpdateLayout(); f = (FrameworkElement)SalesLst.ItemContainerGenerator.ContainerFromItem(SalesLst.SelectedItem); if (f != null) //&& f.Parent != null { Rect r = ((FrameworkElement)f).TransformToAncestor(ppcan).TransformBounds(new Rect(0, 0, 0, 0)); SalesPad.Margin = new Thickness(r.Left, r.Top, r.Right, r.Bottom); } }
public void MoveSalesPadDown() { try { SalesLst.UpdateLayout(); SalesPad.Margin = SalesPadMargin; if (padPos == PadPosition.Above && SalesLst.SelectedIndex != -1) { Canvas.SetTop(SalesLst, 0); SetSalesPadtoSelectedItem(); padPos = PadPosition.Middle; } if (padPos == PadPosition.Middle) { if (SalesLst.SelectedIndex == -1) { Canvas.SetTop(SalesLst, 0); // SalesPad.Margin = SalesPadMargin; Canvas.SetTop(SalesPad, SalesLst.ActualHeight + 8); SetSalesPadtoSelectedItem(); if (SalesLst.SelectedIndex == -1) { padPos = PadPosition.Below; } } else { Canvas.SetTop(SalesLst, 0); SetSalesPadtoSelectedItem(); } } if (SalesLst.SelectedIndex != -1 && padPos == PadPosition.Below) { Canvas.SetTop(SalesLst, 0); Canvas.SetTop(SalesPad, 0); SalesPad.Margin = SalesPadMargin; SetSalesPadtoSelectedItem(); if (SalesLst.SelectedIndex == 0) { padPos = PadPosition.Middle; } // padPos = PadPosition.Below; } } catch (Exception ex) { Logger.Log(LoggingLevel.Error, GetCurrentMethodClass.GetCurrentMethod() + ": --- :" + ex.Message + ex.StackTrace); throw ex; } }
private void GotoBlankTransactionEntry() { if (SalesLst.SelectedIndex == SalesLst.Items.Count - 1) { SalesLst.SelectedIndex = -1; SalesLst.UpdateLayout(); MoveSalesPadDown(); } else { SalesLst.SelectedIndex += 1; } }
public void MoveSalesPadDown() { SalesLst.UpdateLayout(); SalesPad.Margin = SalesPadMargin; if (padPos == PadPosition.Above && SalesLst.SelectedIndex != -1) { Canvas.SetTop(SalesLst, 0); SetSalesPadtoSelectedItem(); padPos = PadPosition.Middle; } if (padPos == PadPosition.Middle) { if (SalesLst.SelectedIndex == -1) { Canvas.SetTop(SalesLst, 0); // SalesPad.Margin = SalesPadMargin; Canvas.SetTop(SalesPad, SalesLst.ActualHeight + 8); SetSalesPadtoSelectedItem(); if (SalesLst.SelectedIndex == -1) { padPos = PadPosition.Below; } } else { Canvas.SetTop(SalesLst, 0); SetSalesPadtoSelectedItem(); } } if (SalesLst.SelectedIndex != -1 && padPos == PadPosition.Below) { Canvas.SetTop(SalesLst, 0); Canvas.SetTop(SalesPad, 0); SalesPad.Margin = SalesPadMargin; SetSalesPadtoSelectedItem(); if (SalesLst.SelectedIndex == 0) { padPos = PadPosition.Middle; } // padPos = PadPosition.Below; } }
public void GoToNextTransactionEntry() { if (SalesLst.SelectedIndex == SalesLst.Items.Count - 1) { padPos = PadPosition.Below; salesvm.CurrentTransactionEntry = null; SalesLst.SelectedItem = null; Canvas.SetTop(SalesLst, 0); SalesLst.UpdateLayout(); Canvas.SetTop(SalesPad, 0); SalesPad.Margin = SalesPadMargin; Canvas.SetTop(SalesPad, SalesLst.ActualHeight + 8); SetSalesPadtoSelectedItem(); } else { SalesLst.SelectedIndex += 1; // selected index don't change when more than list } }
private void SetSalesPadtoSelectedItem() { try { SalesLst.UpdateLayout(); f = (FrameworkElement)SalesLst.ItemContainerGenerator.ContainerFromItem(SalesLst.SelectedItem); if (f != null)//&& f.Parent != null { var transformToAncestor = ((FrameworkElement)f).TransformToAncestor(ppcan); if (transformToAncestor != null) { Rect r = transformToAncestor.TransformBounds(new Rect(0, 0, 0, 0)); SalesPad.Margin = new Thickness(r.Left, r.Top, r.Right, r.Bottom); } } } catch (Exception ex) { Logger.Log(LoggingLevel.Error, GetCurrentMethodClass.GetCurrentMethod() + ": --- :" + ex.Message + ex.StackTrace); throw ex; } }
void SalesPad_LayoutUpdated(object sender, EventArgs e) { if (pkey != Key.Down && pkey != Key.Up) { if (SalesLst.SelectedIndex != -1) { Canvas.SetTop(SalesLst, 0); Canvas.SetTop(SalesPad, 0); SetSalesPadtoSelectedItem(); return; } } if (pkey == Key.Up) { SalesPad.Margin = SalesPadMargin; SalesLst.UpdateLayout(); if (padPos == PadPosition.Middle && SalesLst.SelectedIndex == -1) { Canvas.SetTop(SalesPad, 0); Canvas.SetTop(SalesLst, SalesPad.ActualHeight + 8); //SetSalesPadtoSelectedItem(); if (SalesLst.SelectedIndex == -1) { padPos = PadPosition.Above; } //return; } if (padPos == PadPosition.Middle && SalesLst.SelectedIndex != -1) { Canvas.SetTop(SalesLst, 0); Canvas.SetTop(SalesPad, 0); SetSalesPadtoSelectedItem(); } if (SalesLst.SelectedIndex != -1 && padPos == PadPosition.Above) { // set the index to the last one and goto that one Canvas.SetTop(SalesLst, 0); //SalesLst.SelectedIndex = SalesLst.Items.Count - 1; SetSalesPadtoSelectedItem(); padPos = PadPosition.Middle; } if (padPos == PadPosition.Below) { // set the index to the last one and goto that one Canvas.SetTop(SalesLst, 0); Canvas.SetTop(SalesPad, 0); SetSalesPadtoSelectedItem(); padPos = PadPosition.Middle; SalesLst.SelectedIndex = SalesLst.Items.Count - 1; } pkey = Key.None; } if (pkey == Key.Down) { MoveSalesPadDown(); pkey = Key.None; } // pkey = Key.None; //} }