public override void SelectionChanged (XuniCalendar sender, CalendarRange selectedDates) { NSDateFormatter dateFormatter = new NSDateFormatter(); dateFormatter.DateFormat = "dd/MM/yyyy"; maskedField.Text = dateFormatter.ToString (sender.NativeSelectedDate); d.IsDropDownOpen = false; }
void TrendGraph_MouseWheel(object sender, MouseWheelEventArgs e) { if (e.Delta != 0) { int spinIndex = e.Delta / 120; int direction = spinIndex < 0 ? -1 : 1; spinIndex = Math.Abs(spinIndex); if (spinIndex >= mouseWheelDateSteps.Length) { spinIndex = mouseWheelDateSteps.Length - 1; } CalendarRange scrollAmount = mouseWheelDateSteps[spinIndex]; if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { // pan this.start = Step(this.start, scrollAmount, 1, direction); this.end = Step(this.end, scrollAmount, 1, direction); this.yearToDate = false; this.showAll = false; } else { // zoom. this.start = Step(this.start, scrollAmount, 1, direction); this.yearToDate = false; this.showAll = false; } Pin(); delayedActions.StartDelayedAction("update_graph", GenerateGraph, TimeSpan.FromMilliseconds(100)); } }
static DateTime Step(DateTime start, CalendarRange range, int years, int direction) { switch (range) { case CalendarRange.Annually: return(start.AddYears(years * direction)); case CalendarRange.BiMonthly: return(start.AddMonths(2 * direction)); case CalendarRange.Daily: return(start.AddDays(direction)); case CalendarRange.Monthly: return(start.AddMonths(direction)); case CalendarRange.Quarterly: return(start.AddMonths(4 * direction)); case CalendarRange.SemiAnnually: return(start.AddMonths(6 * direction)); case CalendarRange.TriMonthly: return(start.AddMonths(3 * direction)); case CalendarRange.Weekly: return(start.AddDays(7 * direction)); case CalendarRange.BiWeekly: return(start.AddDays(14 * direction)); } return(start); }
public override void SelectionChanged(XuniCalendar sender, CalendarRange selectedDates) { NSDateFormatter dateFormatter = new NSDateFormatter(); dateFormatter.DateFormat = "dd/MM/yyyy"; maskedField.Text = dateFormatter.ToString(sender.NativeSelectedDate); d.IsDropDownOpen = false; }
public void SetGraphState(GraphState state) { this.range = state.Range; this.years = state.Years; this.start = state.Start; this.end = state.End; this.yearToDate = state.YearToDate; this.menuItemYearToDate.IsChecked = this.yearToDate; this.series = state.Series; GenerateGraph(); }
void OnZoomOut(object sender, RoutedEventArgs e) { if (range == CalendarRange.Annually) { this.years++; } else { range = (CalendarRange)(range + 1); } this.end = Step(this.start, this.range, this.years, 1); Pin(); GenerateGraph(); }
public void ReadXml(XmlReader r) { while (r.Read() && r.NodeType != XmlNodeType.EndElement) { if (r.NodeType == XmlNodeType.Element) { switch (r.LocalName) { case "Range": this.Range = (CalendarRange)StringHelpers.ParseEnum(typeof(CalendarRange), r.ReadString(), (int)CalendarRange.Annually); break; case "Years": this.Years = ReadInt(r, 1); break; case "Start": this.Start = ReadDateTime(r, DateTime.Today.AddYears(1)); break; case "End": this.End = ReadDateTime(r, DateTime.Today); break; case "YearToDate": this.YearToDate = ReadBoolean(r, true); break; case "ShowAll": this.ShowAll = ReadBoolean(r, true); break; case "Series": this.Series = ReadInt(r, 1); break; case "ShowBalance": this.ShowBalance = ReadBoolean(r, false); break; case "ShowBudget": this.ShowBudget = ReadBoolean(r, true); break; } } } }
void OnZoomIn(object sender, RoutedEventArgs e) { if (range > CalendarRange.Daily) { if (years > 1) { years--; } else { range = (CalendarRange)(range - 1); } this.end = Step(this.start, this.range, this.years, 1); Pin(); GenerateGraph(); } }
private void ShowActual() { textBoxBudgetActual.Text = string.Empty; if (this.category != null) { HistoryRange history = PastRange.SelectedItem as HistoryRange; Predicate <Transaction> filter = null; if (history != null) { filter = history.Filter; } CalendarRange range = CalendarRange.Monthly; IList <Transaction> data = this.money.Transactions.GetTransactionsByCategory(this.category, filter); DateTime start = DateTime.Now; DateTime end = DateTime.Now; bool first = true; decimal balance = 0; foreach (Transaction t in data) { if (!t.IsDeleted && t.Status != TransactionStatus.Void) { balance += t.CurrencyNormalizedAmount(t.AmountMinusTax); if (first) { start = t.Date; first = false; } end = t.Date; } } TimeSpan span = end - start; decimal d = (decimal)span.Days; decimal actual = 0; if (d != 0) { actual = Category.DailyToRange(balance / d, range, 1); actual = Math.Abs(actual); } textBoxBudgetActual.Text = actual.ToString("n", this.nfi); } }