Exemple #1
0
        private void Ex_Hold(object sender, GestureEventArgs e)
        {
            var item = (FrameworkElement)sender;

            _reorderItem = item.ParentOfType <RadDataBoundListBoxItem>();
            RadContextMenu menu = RadContextMenu.GetContextMenu(item);

            menu.DataContext = item.DataContext;
            menu.IsOpen      = true;
        }
 private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e)
 {
     _focusedItem = e.FocusedElement as RadDataBoundListBoxItem;
     if (_focusedItem == null)
     {
         // We don't want to open the menu if the focused element is not a list box item.
         // If the list box is empty focusedItem will be null.
         e.Cancel = true;
     }
 }
 private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e)
 {
     _focusedItem = e.FocusedElement as RadDataBoundListBoxItem;
     if (_focusedItem == null)
     {
         // We don't want to open the menu if the focused element is not a list box item.
         // If the list box is empty focusedItem will be null.
         e.Cancel = true;
     }
 }
 private bool CheckTappedItem(RadDataBoundListBoxItem item)
 {
     if (item == null || item.DataContext == null)
     {
         return(false);
     }
     if (!(item.DataContext is IOfflineNode))
     {
         return(false);
     }
     return(true);
 }
 private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e)
 {
     _focusedItem = e.FocusedElement as RadDataBoundListBoxItem;
     if (_focusedItem == null)
     {
         // We don't want to open the menu if the focused element is not a list box item.
         // If the list box is empty focusedItem will be null.
         e.Cancel = true;
         return;
     }
     e.Cancel = !ViewModel.CanRemoveCatalog((CatalogDataModel) _focusedItem.DataContext);
 }
 private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e)
 {
     _focusedItem = e.FocusedElement as RadDataBoundListBoxItem;
     if (_focusedItem == null)
     {
         // We don't want to open the menu if the focused element is not a list box item.
         // If the list box is empty focusedItem will be null.
         e.Cancel = true;
         return;
     }
     e.Cancel = !ViewModel.CanRemoveCatalog((CatalogDataModel)_focusedItem.DataContext);
 }
        public bool CanExecute(object parameter)
        {
            if (parameter == null)
            {
                return(false);
            }

            RadDataBoundListBoxItem item = ElementTreeHelper.FindVisualAncestor <RadDataBoundListBoxItem>(parameter as DependencyObject);

            //return item != null && item.Content is Verse;

            return(item != null);
        }
        private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e)
        {
            _focusedItem = e.FocusedElement as RadDataBoundListBoxItem;
            if (_focusedItem == null)
            {
                // We don't want to open the menu if the focused element is not a list box item.
                // If the list box is empty focusedItem will be null.
                e.Cancel = true;
                return;
            }

            var item = (DownloadItemDataModel)_focusedItem.DataContext;
            RestartMenuItem.Visibility = item.Status == DownloadStatus.Error ? Visibility.Visible : Visibility.Collapsed;
        }
        private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e)
        {
            _focusedItem = e.FocusedElement as RadDataBoundListBoxItem;
            if (_focusedItem == null)
            {
                // We don't want to open the menu if the focused element is not a list box item.
                // If the list box is empty focusedItem will be null.
                e.Cancel = true;
                return;
            }

            var item = (DownloadItemDataModel)_focusedItem.DataContext;

            RestartMenuItem.Visibility = item.Status == DownloadStatus.Error ? Visibility.Visible : Visibility.Collapsed;
        }
        private bool CheckTappedItem(RadDataBoundListBoxItem item)
        {
            // Needed on every UI interaction
            SdkService.MegaSdkFolderLinks.retryPendingConnections();

            if (item == null || item.DataContext == null)
            {
                return(false);
            }
            if (!(item.DataContext is IMegaNode))
            {
                return(false);
            }
            return(true);
        }
        private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e)
        {
            _focusedItem = e.FocusedElement as RadDataBoundListBoxItem;
            if (_focusedItem == null)
            {
                // We don't want to open the menu if the focused element is not a list box item.
                // If the list box is empty focusedItem will be null.
                e.Cancel = true;
                return;
            }
            bool onlyFavourited = ViewModel.ShowOnlyFavourites;
            RemoveFromFavouritesMenuItem.Visibility = onlyFavourited ? Visibility.Visible : Visibility.Collapsed;
            DeleteMenuItem.Visibility = onlyFavourited ? Visibility.Collapsed : Visibility.Visible;
            PinMenuItem.Visibility = onlyFavourited ? Visibility.Collapsed : Visibility.Visible;

            bool canPinToStart = ViewModel.CanPinToStart((BookModel) _focusedItem.DataContext);
            PinMenuItem.IsEnabled = canPinToStart;
        }
        private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e)
        {
            _focusedItem = e.FocusedElement as RadDataBoundListBoxItem;
            if (_focusedItem == null)
            {
                // We don't want to open the menu if the focused element is not a list box item.
                // If the list box is empty focusedItem will be null.
                e.Cancel = true;
                return;
            }
            bool onlyFavourited = ViewModel.ShowOnlyFavourites;

            RemoveFromFavouritesMenuItem.Visibility = onlyFavourited ? Visibility.Visible : Visibility.Collapsed;
            DeleteMenuItem.Visibility = onlyFavourited ? Visibility.Collapsed : Visibility.Visible;
            PinMenuItem.Visibility    = onlyFavourited ? Visibility.Collapsed : Visibility.Visible;

            bool canPinToStart = ViewModel.CanPinToStart((BookModel)_focusedItem.DataContext);

            PinMenuItem.IsEnabled = canPinToStart;
        }
Exemple #13
0
        private void Entries_SelectionChanging(object sender, Telerik.Windows.Controls.SelectionChangingEventArgs e)
        {
            var selector = this.Resources["SelectedItemSelector"] as EntryTemplateSelector;

            if (selector != null)
            {
                if (e.RemovedItems.Count > 0)
                {
                    object oldItem = e.RemovedItems[0];
                    RadDataBoundListBoxItem visualContainer = this.Entries.GetContainerForItem(oldItem) as RadDataBoundListBoxItem;
                    if (visualContainer != null)
                    {
                        EntryTemplateSelectorWrapper wrapper = new EntryTemplateSelectorWrapper()
                        {
                            IsSelected = false, Model = oldItem
                        };
                        visualContainer.ContentTemplate = selector.SelectTemplate(wrapper, visualContainer);
                        visualContainer.ApplyTemplate();
                        visualContainer.UpdateLayout();
                    }
                }
                if (e.AddedItems.Count > 0)
                {
                    object oldItem = e.AddedItems[0];
                    RadDataBoundListBoxItem visualContainer = this.Entries.GetContainerForItem(oldItem) as RadDataBoundListBoxItem;
                    if (visualContainer != null)
                    {
                        EntryTemplateSelectorWrapper wrapper = new EntryTemplateSelectorWrapper()
                        {
                            IsSelected = true, Model = oldItem
                        };
                        visualContainer.ContentTemplate = selector.SelectTemplate(wrapper, visualContainer);
                        visualContainer.ApplyTemplate();
                        visualContainer.UpdateLayout();
                    }
                }
            }
        }
        /// <summary>
        /// Retrieves a UI Automation provider for each child element that is selected.
        /// </summary>
        public IRawElementProviderSimple[] GetSelection()
        {
            List <IRawElementProviderSimple> providerSamples = new List <IRawElementProviderSimple>();

            if (this.ListBoxOwner.IsCheckModeEnabled)
            {
                foreach (object selected in this.ListBoxOwner.CheckedItems)
                {
                    RadDataBoundListBoxItem container = this.ListBoxOwner.GetContainerForItem(selected) as RadDataBoundListBoxItem;
                    if (container == null)
                    {
                        continue;
                    }

                    AutomationPeer itemPeer = (RadDataBoundListBoxItemAutomationPeer)CreatePeerForElement(container);
                    if (itemPeer != null)
                    {
                        providerSamples.Add(this.ProviderFromPeer(itemPeer));
                    }
                }
            }
            else
            {
                RadDataBoundListBoxItem container = this.ListBoxOwner.GetContainerForItem(this.ListBoxOwner.SelectedItem) as RadDataBoundListBoxItem;
                if (container != null)
                {
                    AutomationPeer itemPeer = (RadDataBoundListBoxItemAutomationPeer)CreatePeerForElement(container);
                    if (itemPeer != null)
                    {
                        providerSamples.Add(this.ProviderFromPeer(itemPeer));
                    }
                }
            }

            return(providerSamples.ToArray());
        }
Exemple #15
0
 /// <summary>
 ///  Initializes a new instance of the <see cref="RadDataBoundListBoxItemAutomationPeer"/> class.
 /// </summary>
 /// <param name="owner">The <see cref="RadDataBoundListBoxItem"/> that is associated with this <see cref="RadDataBoundListBoxItemAutomationPeer"/>.</param>
 public RadDataBoundListBoxItemAutomationPeer(RadDataBoundListBoxItem owner) : base(owner)
 {
 }
        public void Execute(object parameter)
        {
            RadDataBoundListBox listBox = ElementTreeHelper.FindVisualAncestor <RadDataBoundListBox>(parameter as DependencyObject);
            RadContextMenu      menu    = RadContextMenu.GetContextMenu(listBox);

            RadDataBoundListBoxItem item = ElementTreeHelper.FindVisualAncestor <RadDataBoundListBoxItem>(parameter as DependencyObject);

            int    chapterNo = 0;
            int    verseNo   = 0;
            string quranText = "";
            string verseText = "";

            if (item.Content is Verse)
            {
                Verse verse = (item.Content as Verse);

                int result = (Application.Current as App).db.SetLastRead(verse.chapter_id, verse.verse_id);

                if (result == 0)
                {
                    MessageBox.Show("Last Read upadate Failed.");
                }
                else
                {
                    //MessageBox.Show("Last Read Saved.");
                }
            }

            if (menu.Name == "menuVerse")
            {
                Verse verse = (item.Content as Verse);

                chapterNo = verse.chapter_id;
                verseNo   = verse.verse_id;
                quranText = verse.AyahText;
                verseText = verse.verse_text;
            }
            else if (menu.Name == "menuVerseCompare")
            {
                VerseCompare verse = (item.Content as VerseCompare);

                chapterNo = verse.SuraID;
                verseNo   = verse.VerseID;
                //quranText = verse.AyahText;
                verseText = verse.AyahText;
            }
            else if (menu.Name == "menuIndexItem")
            {
                IndexItem verse = (item.Content as IndexItem);

                chapterNo = verse.chapter_id;
                verseNo   = verse.verse_id;
                quranText = verse.AyahText;
                verseText = verse.VerseText;
            }
            else if (menu.Name == "menuTopicItem")
            {
                TopicItem verse = (item.Content as TopicItem);

                chapterNo = verse.chapter_id;
                verseNo   = verse.verse_id;
                quranText = verse.AyahText;
                verseText = verse.VerseText;
            }
            else if (menu.Name == "menuBookMark")
            {
            }
            else if (menu.Name == "menuSearchTerm")
            {
            }
            else
            {
                Verse verse = (item.Content as Verse);

                chapterNo = verse.chapter_id;
                verseNo   = verse.verse_id;
                quranText = verse.AyahText;
                verseText = verse.verse_text;
            }

            if (this.Name == "CopyCompleteCommand")
            {
                string shareTextArabTrans = quranText + " | '" + verseText + "' (" + chapterNo + ":" + verseNo + ")";
                //string shareTextTrans = "'"+verseText+"' (" + chapterNo + ":" + verseNo + ")";

                Clipboard.SetText(shareTextArabTrans);
                //MessageBox.Show("Copied to Clipboard: " + shareTextArabTrans);
            }
            else if (this.Name == "CopyCommand")
            {
                //string shareTextArabTrans = quranText + "  '" + verseText + "' (" + chapterNo + ":" + verseNo + ")";
                string shareTextTrans = "'" + verseText + "' (" + chapterNo + ":" + verseNo + ")";

                Clipboard.SetText(shareTextTrans);
                //MessageBox.Show("Copied to Clipboard: " + shareTextTrans);
            }
            else if (this.Name == "ShareCommand")
            {
                //string shareTextArabTrans = quranText + "  '" + verseText + "' (" + chapterNo + ":" + verseNo + ")";
                string shareTextTrans = "'" + verseText + "' (" + chapterNo + ":" + verseNo + ")";

                ShareStatusTask shareStatusTask = new ShareStatusTask();
                shareStatusTask.Status = shareTextTrans;
                shareStatusTask.Show();
            }
            else if (this.Name == "TweetCommand")
            {
                //string shareTextArabTrans = quranText + "  '" + verseText + "' (" + chapterNo + ":" + verseNo + ")";
                string shareTextTrans = "'" + verseText + "' (" + chapterNo + ":" + verseNo + ")";

                //http://web.quran360.com/site/verse/tr/26/ch/1/v/1

                shareTextTrans = shareTextTrans.Substring(0, 90);
                shareTextTrans = shareTextTrans + "... (cont) http://web.quran360.com/site/verse/tr/" + AppSettings.TransSetting + "/ch/" + chapterNo + "/v/" + verseNo;

                ShareStatusTask shareStatusTask = new ShareStatusTask();
                shareStatusTask.Status = shareTextTrans;
                shareStatusTask.Show();
            }
            else if (this.Name == "EmailCommand")
            {
                string shareSubject = "Quran360 Share | Quran (" + chapterNo + ":" + verseNo + ")";

                string shareTextArabTrans = quranText + "  '" + verseText + "' (" + chapterNo + ":" + verseNo + ")";
                //string shareTextTrans = "'" + verseText + "' (" + chapterNo + ":" + verseNo + ")";

                Microsoft.Phone.Tasks.EmailComposeTask email = new Microsoft.Phone.Tasks.EmailComposeTask();
                email.Subject = shareSubject;
                email.Body    = shareTextArabTrans;
                email.Show();
            }
            else if (this.Name == "SmsCommand")
            {
                string shareSubject = "Read Quran: (" + chapterNo + ":" + verseNo + ")";

                //string shareTextArabTrans = quranText + "  '" + verseText + "' (" + chapterNo + ":" + verseNo + ")";
                string shareTextTrans = "'" + verseText + "' (" + chapterNo + ":" + verseNo + ")";

                Microsoft.Phone.Tasks.SmsComposeTask sms = new Microsoft.Phone.Tasks.SmsComposeTask();
                sms.Body = shareTextTrans;
                sms.Show();
            }
            else if (this.Name == "SetCheckPointCommand")
            {
                try
                {
                    //int chapterNo = (item.Content as Verse).chapter_id;
                    //int verseNo = (item.Content as Verse).verse_id;
                    int result = (Application.Current as App).db.SetBookMark(chapterNo, verseNo, -1);

                    if (result == 0)
                    {
                        MessageBox.Show("ReadPoint Failed.");
                    }
                    else
                    {
                        //MessageBox.Show("ReadPoint Saved.");
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("SetCheckPointCommand failed: " + ex.StackTrace);
                }
            }
            else if (this.Name == "SetBookmarkCommand")
            {
                try
                {
                    //int chapterNo = (item.Content as Verse).chapter_id;
                    //int verseNo = (item.Content as Verse).verse_id;
                    int result = (Application.Current as App).db.SetBookMark(chapterNo, verseNo, (verseNo - 1));

                    if (result == 0)
                    {
                        MessageBox.Show("BookMark Failed.");
                    }
                    else
                    {
                        //MessageBox.Show("BookMark Saved.");
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("SetBookmarkCommand failed: " + ex.StackTrace);
                }
            }
            else if (this.Name == "PlayCommand")
            {
                Verse verse = (item.Content as Verse);

                String url = "http://web.quran360.com/audio/v_saad_al_ghaamidi/00" + verse.chapter_id + "/00" + verse.chapter_id + "00" + verse.verse_id + ".mp3";
            }
            else if (this.Name == "PauseCommand")
            {
            }
            else if (this.Name == "StopCommand")
            {
            }
            else if (this.Name == "DeleteBookMarkCommand")
            {
                BookMark bookMark = (item.Content as BookMark);
                int      result   = (Application.Current as App).db.DeleteBookMark(bookMark.id);

                if (result == 0)
                {
                    MessageBox.Show("Delete BookMark Failed.");
                }
                else if (result == 2)
                {
                    MessageBox.Show("Cannot Delete ReadPoint.");
                }
                else
                {
                    //MessageBox.Show("Delete BookMark Success.");
                }
            }
            else if (this.Name == "DeleteSearchTermCommand")
            {
                SearchTerm searchTerm = (item.Content as SearchTerm);
                int        result     = (Application.Current as App).db.DeleteSearchTerm(searchTerm.id);

                if (result == 0)
                {
                    MessageBox.Show("Delete Search Failed.");
                }
                else
                {
                    //MessageBox.Show("Delete Search Success.");
                }
            }
            //this.ScheduleNotification(menu, item);
        }