/// <summary> /// Initialize the page by providing CALL ID to load /// </summary> /// <param name="callId">When given, open an already existing call</param> public CallView(int CallId = 0) { InitializeComponent(); Model.Log.Write("Initialized call view for call #:CallId", new Dictionary<string, string>(){{":CallId", CallId.ToString()}}); CurrentCall = new Model.Call(CallId); LabelCallID.Content = CallId.ToString(); // Call ID label // Bind data about the caller only if not null if (CurrentCall.caller_id > 0) { userBox.Text = CurrentCall.CallerName; companyBox.Text = CurrentCall.Caller.Company.name; phoneBox.Text = CurrentCall.Caller.Phone; // Previous calls by caller lastCallsData.ItemsSource = new Model.Person(CurrentCall.Caller.id) .PreviousCalls(CurrentCall.received); } summaryBox.Text = CurrentCall.summary; try { companyPic.Source = new BitmapImage(new Uri("pack://application:,,,/SIP Agent;component/Images/Avatars/" + CurrentCall.Caller.Company.id.ToString() + ".gif")); } catch (Exception) // The default pic remains on exception (404) { } lastEntry.ItemsSource = new Model.Task().GetTasks(CurrentCall.AssociatedTasks()); // Tasks associated with the call }
/// <summary> /// Switch to call info screen /// Call is loaded with the selected person's info (as caller) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, RoutedEventArgs e) { int callerID = SelectedPerson(); // Caller has to be selected if (callerID == 0) { Helper.UI.flash(sender, Helper.UI.ERROR_BRUSH); return; } Call current = new Model.Call(); int CallId = current.New(); current.caller_id = callerID; current.Save(); // Switch to a new view (pass on selected person ID) Switcher.Switch(new CallView(CallId)); }