示例#1
0
        void buildApplicationBar()
        {
            if (ApplicationBar != null || companyBox.Visibility == Visibility.Visible)
            {
                return;
            }
            var appBar = ExtensionMethods.CreateApplicationBar();

            ApplicationBar = appBar;
            bool showCancel = IsLogining;
            var  icon       = new Uri(!showCancel ? "/Toolkit.Content/ApplicationBar.Check.png" : "/Toolkit.Content/ApplicationBar.Cancel.png", UriKind.Relative);
            ApplicationBarIconButton button1 = new ApplicationBarIconButton(icon);

            button1.Click += new EventHandler(btnLogin_Click);
            button1.Text   = showCancel ? ApplicationStrings.CancelButton : ApplicationStrings.LoginButton;
            appBar.Buttons.Add(button1);

            ApplicationBarMenuItem registerMenu = new ApplicationBarMenuItem(ApplicationStrings.Login_CreateAccount);

            registerMenu.Click += new EventHandler(registerMenu_Click);
            appBar.MenuItems.Add(registerMenu);

            ApplicationBarMenuItem offlineMode = new ApplicationBarMenuItem(ApplicationStrings.Login_OfflineMode);

            offlineMode.Click += new EventHandler(offlineMode_Click);
            appBar.MenuItems.Add(offlineMode);

            ApplicationBarMenuItem forgotPassword = new ApplicationBarMenuItem(ApplicationStrings.Login_ForgotPassword);

            forgotPassword.Click += new EventHandler(forgotPassword_Click);
            appBar.MenuItems.Add(forgotPassword);
        }
示例#2
0
        protected virtual void buildApplicationBar()
        {
            if (ApplicationState.Current == null || ApplicationState.Current.TrainingDay == null)
            {
                return;
            }
            ApplicationBar = ExtensionMethods.CreateApplicationBar();
            ApplicationBarIconButton button1;
            ApplicationBarMenuItem   menu;

            if (!ReadOnly)
            {
                btnSave        = new ApplicationBarIconButton(new Uri("/icons/appbar.save.rest.png", UriKind.Relative));
                btnSave.Click += new EventHandler(btnSave_Click);
                btnSave.Text   = ApplicationStrings.AppBarButton_Save;
                ApplicationBar.Buttons.Add(btnSave);
            }
            button1        = new ApplicationBarIconButton(new Uri("/icons/appbar.back.rest.png", UriKind.Relative));
            button1.Click += new EventHandler(btnShowPrevious_Click);
            button1.Text   = ApplicationStrings.AppBarButton_Previous;
            ApplicationBar.Buttons.Add(button1);

            button1        = new ApplicationBarIconButton(new Uri("/icons/appbar.next.rest.png", UriKind.Relative));
            button1.Click += new EventHandler(btnShowNext_Click);
            button1.Text   = ApplicationStrings.AppBarButton_Next;
            ApplicationBar.Buttons.Add(button1);

            if (!ReadOnly)
            {
                if (!ApplicationState.Current.IsOffline)
                {
                    menu        = new ApplicationBarMenuItem(ApplicationStrings.AppBarMenu_Delete);
                    menu.Click += new EventHandler(btnDelete_Click);
                    ApplicationBar.MenuItems.Add(menu);
                }
                //we add copy to today menu only when the current entry is not from today
                if (ApplicationState.Current.TrainingDay.TrainingDay.TrainingDate.Date != DateTime.Now.Date)
                {
                    menu        = new ApplicationBarMenuItem(ApplicationStrings.AppBarMenu_CopyToToday);
                    menu.Click += new EventHandler(mnuCopyEntryToToday_Click);
                    ApplicationBar.MenuItems.Add(menu);
                }
            }
            //ApplicationBar.IsMenuEnabled = !ApplicationState.Current.IsOffline;

            if (!ApplicationState.Current.IsOffline)
            {
                menu        = new ApplicationBarMenuItem(ApplicationStrings.AppBarButton_Refresh);
                menu.Click += new EventHandler(mnuRefresh_Click);
                ApplicationBar.MenuItems.Add(menu);
            }
        }
        public void BuildApplicationBar()
        {
            try
            {
                var page = this.GetParent <MainPage>();
                if (page != null && page.mainPanorama.SelectedIndex <= 0 && ApplicationState.Current != null)
                {
                    page.ApplicationBar         = ExtensionMethods.CreateApplicationBar();
                    page.ApplicationBar.Opacity = .9;
                    page.ApplicationBar.Mode    = ApplicationBarMode.Minimized;

                    if (!ApplicationState.Current.IsOffline)
                    {
                        ApplicationBarMenuItem menuItem = new ApplicationBarMenuItem(ApplicationStrings.AppBarButton_Refresh);
                        menuItem.Click += new EventHandler(mnuRefresh_Click);
                        page.ApplicationBar.MenuItems.Add(menuItem);
                    }
#if !DEBUG
                    if (ApplicationState.Current.IsOffline)
#endif
                    {
                        var mnuOfflineMode = new ApplicationBarMenuItem(ApplicationState.Current.IsOffline
                                                           ? ApplicationStrings.MyProfileControl_GoOnline
                                                           : ApplicationStrings.MyProfileControl_GoOffline);
                        mnuOfflineMode.Click += new EventHandler(mnuOfflineMode_Click);
                        page.ApplicationBar.MenuItems.Add(mnuOfflineMode);
                    }

                    if (!ApplicationState.Current.IsOffline)
                    {
                        var mnuStatus = new ApplicationBarMenuItem(ApplicationStrings.MainPage_Status);
                        mnuStatus.Click += new EventHandler(mnuStatus_Click);
                        page.ApplicationBar.MenuItems.Add(mnuStatus);

                        var mnuLogout = new ApplicationBarMenuItem(ApplicationStrings.MainPage_LogoutLink);
                        mnuLogout.Click += new EventHandler(mnuLogout_Click);
                        page.ApplicationBar.MenuItems.Add(mnuLogout);
                    }
                }
            }
            catch (Exception)
            {
                //exception occures when we press back button very fast. for example we are in profile edit page and now we start pressing back many times to close application.
                //IN this case when applicaion is closed this exception occures. It doesn't have any bad impact. so we covert it in this catch block
            }
        }