Esempio n. 1
0
        /// <summary>
        /// Update the favorite list, attaching all required event handlers.
        /// We will load favorites from isolated storage, on the state of the
        /// input parameter
        /// </summary>
        /// <param name="favoritesListView">List view for the favorites</param>
        /// <param name="favoritesNoItems">Text block for the favorites</param>
        internal void UpdateFavoriteList(
            ListBox favoritesListView,
            TextBlock favoritesNoItems)
        {
            FavoriteCollection favCollection = ApplicationState.Favorites == null ?
                                               favCollection = FavoriteCollection.LoadFromFile() : ApplicationState.Favorites;

            if (favCollection.Count > 0)
            {
                // show listbox, hide no favorites label
                favoritesListView.Visibility  = Visibility.Visible;
                favoritesNoItems.Visibility   = Visibility.Collapsed;
                favoritesListView.ItemsSource = favCollection;
            }
            else
            {
                // hide listbox, show no favorites label
                favoritesListView.Visibility = Visibility.Collapsed;
                favoritesNoItems.Visibility  = Visibility.Visible;
            }

            // We need to instal these handlers in the order below to be sure they don't get
            // eaten by the ListView control
            this.lastSelectedFavorite = null;
        }
Esempio n. 2
0
        /// <summary>
        /// Clear the list of favorites, remove the selected item from isolated storage,
        /// and remove installed event handlers
        /// </summary>
        internal void DeleteSelectedFavorite()
        {
            // Remove favorite and store.
            FavoriteCollection favCollection = ApplicationState.Favorites;

            favCollection.Remove(this.lastSelectedFavorite);
            FavoriteCollection.SaveToFile(favCollection);
            this.lastSelectedFavorite = null;
        }
        /// <summary>
        /// Add the current set of units to the Favorit list
        /// </summary>
        /// <param name="signalCompleted">Delegate to call when the thread pool
        /// operation has completed</param>
        /// <returns>True signals that the favorite is already added ( no need to save).
        /// False indicates that we are in process of saving</returns>
        internal bool AddToFavorite(Action signalCompleted)
        {
            FavoriteCollection favCollection = ApplicationState.Favorites;
            FavoriteData       favorite      = new FavoriteData(this.ConversionSettings, 0);
            bool favoriteExists = favCollection.AddNewItem(favorite);

            if (!favoriteExists)
            {
                // Thread pool queue operation
                FavoriteCollection.BeginSaveToFile(favCollection, signalCompleted, null);
            }
            return(favoriteExists);
        }
        /// <summary>
        /// Background thread work for loading
        /// The loading of the supported conversions from the Xap as well as the
        /// favorites from isolated storage is done on a non UI thread to allow the
        /// fastest possible page render
        /// </summary>
        /// <param name="sender">worker thread object</param>
        /// <param name="e">Action delegate for completion</param>
        private void DeferStartupWork(object sender, DoWorkEventArgs e)
        {
            Action completed = e.Argument as Action;

            lock (threadLock)
            {
                ApplicationState.AppLaunchInitialization();

                this.SetDefaultCategoryAndUnits();
                ApplicationState.Favorites =
                    FavoriteCollection.LoadFromFile() ?? new FavoriteCollection();
            }

            if (completed != null)
            {
                completed();
            }
        }
Esempio n. 5
0
        public void MainWindowLoad()
        {
            #region Hide Script Error
            MainWebBrowser.Navigated += (sender, e) => HideScriptErrors(sender as WebBrowser, true);
            #endregion

            SetMenuButtons();

            sourceParser = new SourceParser();
            imageParser = new ImageParser(sourceParser);

            resizer = new WindowResizer(this);

            MainWebBrowser.Navigating += onNavigating;
            MainWebBrowser.Navigated += onNavigated;
            MainWebBrowser.LoadCompleted += MyWebBrowser_LoadCompleted;

            collection = Resources["ImageItemsKey"] as ImageItemCollection;

            #region MethodInvoker
            GetURL = new Func<string>(() => { return URLTextBox.Text; });

            ClearList = new Action(() =>
            {
                collection.Clear();
            });
            Contains = new Func<string, bool>((url) => { return collection.Contains(url); });
            InsertItem = new Action<ImageItem>((item) => collection.Add(item));
            #endregion

            #region Animation
            appearAnimation = new DoubleAnimation();
            appearAnimation.BeginTime = TimeSpan.FromSeconds(0.5);
            appearAnimation.From = 1;
            appearAnimation.To = 0.5;
            appearAnimation.Duration = new Duration(TimeSpan.FromSeconds(2.5));
            appearAnimation.AutoReverse = true;
            #endregion

            favoriteColleciton = Application.Current.Resources["FavoriteCollection"] as FavoriteCollection;
            if (favoriteColleciton == null)
                throw new NullReferenceException();
        }
Esempio n. 6
0
 static FavortiesDialog()
 {
     FavCollection = Application.Current.Resources["FavoriteCollection"] as FavoriteCollection;
 }
        /// <summary>
        /// Gets the favorite collection.
        /// </summary>
        /// <returns>Favorite collection for test purposes</returns>
        internal static FavoriteCollection GetFavoriteCollection()
        {
            FavoriteCollection favCollection = ApplicationState.Favorites;

            return(favCollection);
        }
Esempio n. 8
0
 /// <summary>
 ///     Updates the list of favorite contacts of the current extension. Favorite contacts include both company contacts
 ///     (extensions) and personal contacts (address book records).**Please note**: currently personal address book size is
 ///     limited to 10 000 contacts.
 ///     HTTP Method: put
 ///     Endpoint: /restapi/{apiVersion}/account/{accountId}/extension/{extensionId}/favorite
 ///     Rate Limit Group: Medium
 ///     App Permission: Contacts
 ///     User Permission: EditPersonalContacts
 /// </summary>
 public async Task <FavoriteContactList> Put(FavoriteCollection favoriteCollection,
                                             RestRequestConfig restRequestConfig = null)
 {
     return(await rc.Put <FavoriteContactList>(Path(), favoriteCollection, null, restRequestConfig));
 }