private void SaveGeneralMessengers() { PageManager.Instance.NewDataScope(DatabaseContextUtility.LoadAllGeneralMessenger()); //Temporary disable the saving to application context, and shortcut it with a direct refresh from db. /*// Messenger messenger = ApplicationContext.Instance.Messengers.SingleOrDefault(c => c.Id == FocusedMessenger.Id); * Messenger messenger = ApplicationContext.Instance.findMessengerInTree(FocusedMessenger.Id); * * //Is the element already exists (Edit mode)? * if (messenger != null) * { * messenger.Name = FocusedMessenger.Name; * messenger.Image = FocusedMessenger.Image; * } * //(Create new mode) * else * { * //Should we add the new element to the currently visible elements ? * if (FocusedMessenger.Parent.Id == PageManager.Instance.ParentMessenger.Id) * { * ApplicationContext.Instance.Messengers.Add(FocusedMessenger); * PageManager.Instance.AddToMessengerCache(FocusedMessenger); * } * //Add to parent. * Messenger parentMessenger = ApplicationContext.Instance.Messengers.SingleOrDefault(c => c.Id == FocusedMessenger.Parent.Id); * if (parentMessenger != null) * { * parentMessenger.AddChild(FocusedMessenger); * } * }*/ }
public void LeaveSharingSession() { string messageBoxText = MessageIds.SHARING_SESSION_SAVE_CONFIRMATION; MessageBoxResult result = MessageBox.Show(messageBoxText, "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { DatabaseContextUtility.SaveMessengers(PageManager.Instance.MessengerCache); } IsSharingSession = false; SetRootObjects(); PageManager.Instance.NewDataScope(DatabaseContextUtility.LoadAllGeneralMessenger()); SharingStateMessage = MessageIds.SHARING_SESSION_LEAVE; }
private void SetRootObjects() { if (IsSharingSession) { return; } foreach (Messenger msg in DatabaseContextUtility.LoadAllGeneralMessenger()) { GeneralRootMessenger.AddChild(msg); } if (!Messengers.Contains(GeneralRootMessenger)) { Messengers.Add(GeneralRootMessenger); } foreach (Messenger msg in DatabaseContextUtility.GetPinnedMessengers()) { PinnedRootMessenger.AddChild(msg); } if (!Messengers.Contains(PinnedRootMessenger)) { Messengers.Add(PinnedRootMessenger); } }
public void LoadMessengers() { //AddInitData(); RenderUtil = new RenderManager(); Messengers = ApplicationContext.Instance.Messengers; PageManagerUtil = PageManager.Instance; PageManagerUtil.SetPageManagerUtil(RenderUtil.MaxRowCount, RenderUtil.MaxColumnCount, DatabaseContextUtility.LoadAllGeneralMessenger(), Messengers); }