void updateButtons(bool operationStarted)
        {
            bool logged = !operationStarted && user != null && UserContext.Current.LoginStatus == LoginStatus.Logged;

            ShowEditProfile         = logged && user.User.IsMe();
            ShowInvite              = logged && !user.User.IsMe() && !user.User.IsFriend() && !user.User.IsInInvitation() && !user.User.IsDeleted;
            ShowReject              = logged && (user.User.IsFriend() || user.User.IsInInvitation());
            ShowAccept              = logged && user.User.IsInviter();
            ShowCalendar            = logged && !user.User.IsMe() && user.User.HaveAccess(user.User.Privacy.CalendarView);
            ShowReports             = ShowCalendar;
            ShowAddToFavorites      = logged && !user.User.IsMe() && !user.User.IsFriend() && !user.User.IsFavorite() && !user.User.IsDeleted;
            ShowRemoveFromFavorites = logged && !user.User.IsMe() && !user.User.IsFriend() && user.User.IsFavorite() && !user.User.IsDeleted;
            ShowSocialGroup         = logged && !user.User.IsMe();
            ShowUserTab             = logged;
            ShowSendMessage         = logged && !user.User.IsMe() && !user.User.IsDeleted;

            foreach (AccordionItem band in accordionCtrl.Items)
            {
                //if (band.Controls.Count > 0)
                {
                    IUserDetailControl ctrl = band.Content as IUserDetailControl;
                    if (ctrl != null)
                    {
                        band.SetVisible(ctrl.UpdateGui(user));
                    }
                }
            }
        }
Exemple #2
0
        void updateButtons(bool operationStarted)
        {
            bool logged = !operationStarted && user != null && UserContext.LoginStatus == LoginStatus.Logged;

            btnEditProfile.Visible         = logged && user.User.IsMe();
            btnInviteAFriend.Visible       = logged && !user.User.IsMe() && !user.User.IsFriend() && !user.User.IsInInvitation() && !user.User.IsDeleted;
            btnRefresh.Visible             = logged && user.User.IsMe();
            btnRejectFriendship.Visible    = logged && (user.User.IsFriend() || user.User.IsInInvitation());
            btnReports.Visible             = btnOpenWorkoutsLog.Visible = logged && !user.User.IsMe() && user.User.HaveAccess(user.User.Privacy.CalendarView);
            btnAcceptFriend.Visible        = logged && user.User.IsInviter();
            btnSendMessage.Visible         = logged && !user.User.IsMe() && !user.User.IsDeleted;
            btnAddToFavorites.Visible      = logged && !user.User.IsMe() && !user.User.IsFriend() && !user.User.IsFavorite() && !user.User.IsDeleted;
            btnRemoveFromFavorites.Visible = logged && !user.User.IsMe() && !user.User.IsFriend() && user.User.IsFavorite() && !user.User.IsDeleted;
            //flowLayoutPanel1.Visible = !operationStarted;



            foreach (NaviBand band in naviBar1.Bands)
            {
                if (band.ClientArea.Controls.Count > 0)
                {
                    IUserDetailControl ctrl = band.ClientArea.Controls[0] as IUserDetailControl;
                    if (ctrl != null)
                    {
                        band.Visible = ctrl.UpdateGui(user);
                    }
                }
            }
        }
        public void ClearContent()
        {
            user = null;
            if (currentTask != null)
            {
                currentTask.Cancel();
                currentTask = null;
            }
            showProgress(false);
            //foreach (NaviBand band in naviBar1.Bands)
            //{
            //    if (band.ClientArea.Controls.Count > 0)
            //    {
            //        IUserDetailControl ctrl = band.ClientArea.Controls[0] as IUserDetailControl;
            //        if (ctrl != null)
            //        {
            //            ctrl.Fill(null, naviBar1.ActiveBand == band);
            //        }
            //    }
            //}
            foreach (AccordionItem band in accordionCtrl.Items)
            {
                //if (band.Controls.Count > 0)
                {
                    IUserDetailControl ctrl = band.Content as IUserDetailControl;
                    if (ctrl != null)
                    {
                        ctrl.Fill(null, accordionCtrl.SelectedItem == band);
                    }
                }
            }

            updateButtons(false);
        }
Exemple #4
0
 private void naviBar1_ActiveBandChanged(object sender, EventArgs e)
 {
     if (naviBar1.ActiveBand != null)
     {
         IUserDetailControl ctrl = (IUserDetailControl)naviBar1.ActiveBand.Tag;
         ctrl.Fill(user, true);
     }
 }
Exemple #5
0
        public void Fill(UserDTO user)
        {
            if (currentTask != null)
            {
                currentTask.Cancel();
                currentTask = null;
                updateButtons(false);
            }
            this.ClearContent();
            showProgress(true);
            currentTask = ParentWindow.TasksManager.RunAsynchronousOperation(delegate(OperationContext ctx)
            {
                GetProfileInformationCriteria criteria = new GetProfileInformationCriteria();
                criteria.UserId = user.Id;
                ProfileInformationDTO usr;
                if (user.IsMe())
                {
                    usr = UserContext.ProfileInformation;
                }
                else
                {
                    usr = ServiceManager.GetProfileInformation(criteria);
                }

                if (ctx.CancellatioToken.IsCancellationRequested)
                {
                    return;
                }
                this.user = usr;
                ParentWindow.SynchronizationContext.Send(delegate
                {
                    foreach (NaviBand band in naviBar1.Bands)
                    {
                        if (ctx.CancellatioToken.IsCancellationRequested)
                        {
                            return;
                        }
                        if (band.ClientArea.Controls.Count > 0)
                        {
                            IUserDetailControl ctrl = band.ClientArea.Controls[0] as IUserDetailControl;
                            if (ctrl != null)
                            {
                                ctrl.Fill(this.user, naviBar1.ActiveBand == band);
                                band.Text = ctrl.Caption;
                            }
                        }
                    }
                    //updateButtons();
                    //without these caption of navi bar was not refreshed in some cases
                    naviBar1.Refresh();
                    naviBar1.Update();
                    showProgress(false);
                }, null);
            }, asyncOperationStateChange, null, false);
        }
        public void Fill(UserDTO user)
        {
            if (currentTask != null)
            {
                currentTask.Cancel();
                currentTask = null;
                updateButtons(false);
            }
            this.ClearContent();
            if (accordionCtrl.SelectedItem == null)
            {
                ShowUserInfo();
            }
            showProgress(true);
            currentTask = ParentWindow.RunAsynchronousOperation(delegate(OperationContext ctx)
            {
                GetProfileInformationCriteria criteria = new GetProfileInformationCriteria();
                criteria.UserId = user.GlobalId;
                ProfileInformationDTO usr;
                if (user.IsMe())
                {
                    usr = UserContext.Current.ProfileInformation;
                }
                else
                {
                    usr = ServiceManager.GetProfileInformation(criteria);
                }

                if (ctx.CancellatioToken.IsCancellationRequested)
                {
                    return;
                }
                this.user = usr;
                UIHelper.BeginInvoke(new Action(delegate
                {
                    foreach (AccordionItem band in accordionCtrl.Items)
                    {
                        if (ctx.CancellatioToken.IsCancellationRequested)
                        {
                            return;
                        }
                        if (band.Content != null)
                        {
                            IUserDetailControl ctrl = band.Content as IUserDetailControl;
                            if (ctrl != null)
                            {
                                ctrl.Fill(this.user, accordionCtrl.SelectedItem == band);
                            }
                        }
                    }
                    updateButtons(false);
                    showProgress(false);
                }), Dispatcher);
            }, asyncOperationStateChange, null);
        }
Exemple #7
0
        private NaviBand addDetailControl(IUserDetailControl detailControl)
        {
            NaviBand band = new NaviBand();

            band.Text       = detailControl.Caption;
            band.Tag        = detailControl;
            band.LargeImage = detailControl.SmallImage;
            band.SmallImage = detailControl.SmallImage;
            Control ctrl = (Control)detailControl;

            ctrl.Dock = DockStyle.Fill;
            band.ClientArea.Controls.Add(ctrl);
            naviBar1.Controls.Add(band);
            return(band);
        }
        private AccordionItem addDetailControl(IUserDetailControl detailControl)
        {
            AccordionItem band = new AccordionItem();

            band.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            band.VerticalContentAlignment   = VerticalAlignment.Stretch;

            //Bug fixing: MEF tworzy singletony i po pierwszym dodaniu kontroki jako dziecko parenta przy drugim mamy wyjątek dlatego trzeba odłączyc od starego
            FrameworkElement element = detailControl as FrameworkElement;

            if (element != null && element.Parent != null)
            {
                ((ContentControl)element.Parent).Content = null;
                element.Tag = band;
            }
            //band.Text = detailControl.Caption;

            band.Tag         = detailControl;
            band.DataContext = detailControl;
            band.Content     = detailControl;

            StackPanel panel = new StackPanel();

            panel.Orientation = Orientation.Horizontal;
            Image img = new Image();

            img.Source = detailControl.SmallImage;
            img.Width  = img.Height = 16;
            panel.Children.Add(img);
            TextBlock textBlock = new TextBlock();
            Binding   result    = new Binding("Caption");

            result.Source = detailControl;
            textBlock.SetBinding(TextBlock.TextProperty, result);

            textBlock.Style = (Style)this.FindResource("accordionHeaderText");
            panel.Children.Add(textBlock);
            band.Header = panel;

            //band.LargeImage = detailControl.SmallImage;
            //band.SmallImage = detailControl.SmallImage;
            //Control ctrl = (Control)detailControl;
            //ctrl.Dock = DockStyle.Fill;
            //band.ClientArea.Controls.Add(ctrl);
            //naviBar1.Controls.Add(band);))
            return(band);
        }
Exemple #9
0
        public void ClearContent()
        {
            user = null;
            if (currentTask != null)
            {
                currentTask.Cancel();
                currentTask = null;
            }
            showProgress(false);
            foreach (NaviBand band in naviBar1.Bands)
            {
                if (band.ClientArea.Controls.Count > 0)
                {
                    IUserDetailControl ctrl = band.ClientArea.Controls[0] as IUserDetailControl;
                    if (ctrl != null)
                    {
                        ctrl.Fill(null, naviBar1.ActiveBand == band);
                    }
                }
            }

            updateButtons(false);
        }