private void OnBusyIndicatorAnimationAdapterSizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (this.Animation == null)
            {
                return;
            }

            if (this.Animation.Children.Count == 0)
            {
                return;
            }

            FrameworkElement owner = ElementTreeHelper.FindVisualAncestor <RadBusyIndicator>(this);

            if (owner == null)
            {
                return;
            }

            BusyIndicatorAnimation animation = ElementTreeHelper.FindVisualAncestor <BusyIndicatorAnimation>(this);

            if (animation == null)
            {
                return;
            }

            Point animationLocation = ElementTreeHelper.SafeTransformPoint(animation, owner, new Point(-10, 0));

            this.AdaptAnimation(this.Animation, owner.RenderSize.Width + 10, animationLocation.X);
        }
        /// <inheritdoc />
        protected override string GetNameCore()
        {
            var nameCore = base.GetNameCore();

            var dateTimePickerParent = ElementTreeHelper.FindVisualAncestor <DateTimePicker>(this.DateTimePickerButton);

            if (dateTimePickerParent != null)
            {
                var dateTimePickerPeer = FrameworkElementAutomationPeer.FromElement(dateTimePickerParent) as DateTimePickerAutomationPeer;
                if (dateTimePickerPeer != null)
                {
                    var datePickerHeader = dateTimePickerPeer.GetName();
                    if (!string.IsNullOrEmpty(datePickerHeader) && dateTimePickerParent.Header != null)
                    {
                        return(string.Format("{0} {1}", datePickerHeader, nameCore));
                    }
                }
            }

            if (!string.IsNullOrEmpty(nameCore))
            {
                return(nameCore);
            }

            return(string.Empty);
        }
Пример #3
0
        /// <summary>
        /// Called in the measure layout pass to determine the desired size.
        /// </summary>
        /// <param name="availableSize">The available size that was given by the layout system.</param>
        /// <returns>Returns the desired size of the indicator.</returns>
        protected override Size MeasureOverride(Size availableSize)
        {
            if (this.MeasureCallback != null)
            {
                this.MeasureCallback();
            }

            if (this.ownerPanel == null)
            {
                this.ownerPanel = ElementTreeHelper.FindVisualAncestor <GaugePanel>(this);
            }

            Size result = RadGauge.NormalizeSize(availableSize);

            if (result.Width == 0 || result.Height == 0)
            {
                result = this.ownerPanel.LastMeasureSize;
            }

            this.Update(result);

            this.LastMeasureSize = result;

            return(result);
        }
        private void TopAppBar_Loaded(object sender, RoutedEventArgs e)
        {
            this.SetBinding(TrackerProperty, new Binding()
            {
                Path = new PropertyPath("BottomAppBar")
            });

            this.DataContext = ElementTreeHelper.FindVisualAncestor <Page>(this);
        }
Пример #5
0
        public void AddButtonClick(object sender, RoutedEventArgs e)
        {
            var ownerPage = ElementTreeHelper.FindVisualAncestor <Page>(this);

            if (ownerPage != null)
            {
                ownerPage.Frame.Navigate(typeof(FindCityPage));
            }
        }
Пример #6
0
        /// <inheritdoc />
        protected override AutomationPeer OnCreateAutomationPeer()
        {
            RadCalendar calendar = ElementTreeHelper.FindVisualAncestor <RadCalendar>(this);

            if (calendar != null)
            {
                return(new CalendarViewHostAutomationPeer(this, calendar));
            }
            return(null);
        }
Пример #7
0
        /// <inheritdoc />
        protected override AutomationPeer OnCreateAutomationPeer()
        {
            RadNumericBox parent = ElementTreeHelper.FindVisualAncestor <RadNumericBox>(this);

            if (parent != null)
            {
                return(new NumericTextBoxAutomationPeer(this, parent));
            }
            return(base.OnCreateAutomationPeer());
        }
Пример #8
0
        protected override AutomationPeer OnCreateAutomationPeer()
        {
            var parent = ElementTreeHelper.FindVisualAncestor <RadRadialMenu>(this);

            if (parent != null)
            {
                return(new RadialMenuItemControlAutomationPeer(this, parent));
            }

            return(base.OnCreateAutomationPeer());
        }
Пример #9
0
        private void Initialize()
        {
            if (this.Owner == null)
            {
                RadRating parent = ElementTreeHelper.FindVisualAncestor <RadRating>(this);
                if (parent == null)
                {
                    throw new InvalidOperationException(InvalidOwnerException);
                }

                this.Owner = parent;
            }
        }
        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);
        }
Пример #11
0
        private void TryFocus(FocusState state)
        {
            if (!this.IsTabStop)
            {
                return;
            }

            var focusedElement = FocusManager.GetFocusedElement() as DependencyObject;

            if (focusedElement == null || ElementTreeHelper.FindVisualAncestor <CalendarViewHost>(focusedElement) == null)
            {
                this.Focus(state);
            }
        }
Пример #12
0
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            RadSlideView view = ElementTreeHelper.FindVisualAncestor <RadSlideView>(container);

            if (view == null)
            {
                return(null);
            }

            if ((item as Concept).HasSound)
            {
                return(this.DefaultTemplate);
            }
            return(NoSoundTemplate);
        }
Пример #13
0
        internal static void StartDrag(object sender, PointerRoutedEventArgs e, DragDropTrigger trigger, object initializeContext = null)
        {
            var dragDropElement = sender as IDragDropElement;
            var uiSource        = sender as UIElement;

            if (dragDropElement == null)
            {
                dragDropElement = ElementTreeHelper.FindVisualAncestor <IDragDropElement>(uiSource);
            }

            if (GetRunningOperation(dragDropElement as DependencyObject) != null)
            {
                return;
            }

            UIElement uiDragDropElement = dragDropElement as UIElement;

            var    frameworkElementSource = dragDropElement as FrameworkElement;
            double leftMargin             = 0d;
            double topMargin = 0d;

            if (frameworkElementSource != null)
            {
                leftMargin = frameworkElementSource.Margin.Left;
                topMargin  = frameworkElementSource.Margin.Top;
            }

            if (dragDropElement == null || !dragDropElement.CanStartDrag(trigger, initializeContext))
            {
                return;
            }

            var context = dragDropElement.DragStarting(trigger, initializeContext);

            if (context == null)
            {
                return;
            }

            var startDragPosition         = e.GetCurrentPoint(context.DragSurface.RootElement).Position;
            var relativeStartDragPosition = e.GetCurrentPoint(uiDragDropElement).Position;
            var dragPositionMode          = DragDrop.GetDragPositionMode(uiDragDropElement);

            AddOperation(new DragDropOperation(context, dragDropElement, dragPositionMode, e.Pointer, startDragPosition, relativeStartDragPosition));
        }
Пример #14
0
        internal void TryFocus(FocusState state, bool force)
        {
            if (!this.IsTabStop)
            {
                return;
            }

            if (force)
            {
                this.Focus(state);
            }
            else
            {
                var focusedElement = FocusManager.GetFocusedElement() as DependencyObject;
                if (focusedElement == null || ElementTreeHelper.FindVisualAncestor <DataGridCellsPanel>(focusedElement) == null)
                {
                    this.Focus(state);
                }
            }
        }
Пример #15
0
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            RadSlideView view = ElementTreeHelper.FindVisualAncestor <RadSlideView>(container);

            if (view == null)
            {
                return(null);
            }

            GuideBasePage page = item as GuideBasePage;

            switch (page.Type)
            {
            case GuidesPageTypes.Intro:
                return(Intro);

            case GuidesPageTypes.Step:
                return(Step);

            default:
                throw new ArgumentException("Don´t know how to render this");
            }
        }
        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);
        }