Пример #1
0
        private void ApplyProgressBarFunction(D2DViewControl pViewControl)
        {
            var progressBar = pViewControl as ThermometerProgressBar;

            if (progressBar == null)
            {
                return;
            }

            progressBar.ScrollChanged += (sender, e) =>
            {
                AppMain.MediaManager.SetCurrentPos(Convert.ToInt32(progressBar.Value));
            };

            AppMain.MediaManager.MediaProgressChanged += new MediaProgressChangedHandler(
                (sender, eventArgs) =>
            {
                progressBar.Value = eventArgs.MediaPosition;
            });

            AppMain.MediaManager.MediaChanged += new MediaChangedHandler(
                (sender, eventArgs) =>
            {
                progressBar.Value        = 0;
                progressBar.MaximumValue = AppMain.MediaManager.GetSongLength();
            });
        }
Пример #2
0
        public D2DViewControl GetViewControlContainingPoint(Point pPoint)
        {
            D2DViewControl control = GetViewControlContainingPoint(this, pPoint);

            if (control == this && GetScreenBounds().Contains(pPoint))
            {
                return(this);
            }

            return(control == this ? null : control);
        }
Пример #3
0
        private void ApplyMediaChangeStateFunction(D2DViewControl pViewControl, Action pStateChanger)
        {
            var button = pViewControl as IButton;

            if (button == null)
            {
                return;
            }

            button.Click += (s, e) => pStateChanger();
        }
Пример #4
0
 public void AddViewControl(D2DViewControl pViewControl)
 {
     lock (_viewControls)
     {
         pViewControl.Parent = this;
         _viewControls.Add(pViewControl);
         if (pViewControl is IMessageObserver)
         {
             AppMain.Messanger.AddMessageObserver(pViewControl as IMessageObserver);
         }
     }
 }
Пример #5
0
        public void ApplyFunction(ViewControlFunction pFuncion, string pParameter, D2DViewControl pViewControl)
        {
            switch (pFuncion)
            {
            case ViewControlFunction.MediaProgressBar:
                ApplyProgressBarFunction(pViewControl);
                break;

            case ViewControlFunction.MediaProgressText:
                ApplyProgressTextFunction(pViewControl);
                break;

            case ViewControlFunction.MediaPause:
                ApplyMediaChangeStateFunction(pViewControl, () => AppMain.MediaManager.PausePlayback());
                break;

            case ViewControlFunction.MediaPlay:
                ApplyMediaChangeStateFunction(pViewControl, () => AppMain.MediaManager.StartPlayback());
                break;

            case ViewControlFunction.MediaStop:
                ApplyMediaChangeStateFunction(pViewControl, () => AppMain.MediaManager.StopPlayback());
                break;

            case ViewControlFunction.MediaNext:
                ApplyMediaChangeStateFunction(pViewControl, () => AppMain.MediaManager.MediaNext());
                break;

            case ViewControlFunction.MediaPrevious:
                ApplyMediaChangeStateFunction(pViewControl, () => AppMain.MediaManager.MediaPrevious());
                break;

            case ViewControlFunction.MediaDisplayName:
                ApplyMediaDisplayName(pViewControl);
                break;

            case ViewControlFunction.MediaArt:
                ApplyMediaArt(pViewControl);
                break;

            case ViewControlFunction.TriggerToggle:
                ApplyTriggerToggle(pViewControl, pParameter);
                break;

            case ViewControlFunction.SwitchView:
                ApplySwitchView(pViewControl, pParameter);
                break;

            case ViewControlFunction.MediaGroupHistory:
                ApplyMediaGroupHistory(pViewControl);
                break;
            }
        }
Пример #6
0
        private void ApplyMediaDisplayName(D2DViewControl pViewControl)
        {
            var text = pViewControl as IText;

            if (text == null)
            {
                return;
            }
            AppMain.MediaManager.MediaChanged += (sender, e) =>
            {
                text.TextString = e.MediaDetail.DisplayName;;
            };
        }
Пример #7
0
        private void ApplyTriggerToggle(D2DViewControl pViewControl, string pParameter)
        {
            var trigger = pViewControl as ITrigger;

            if (trigger == null || pParameter == null)
            {
                return;
            }

            trigger.Trigger += (obj) => AppMain.Messanger.SendMessage(
                new Message(XmlHelper.GetSeparatedList(pParameter),
                            MessageType.Trigger,
                            obj));
        }
Пример #8
0
        private void ApplySwitchView(D2DViewControl pViewControl, string pParameter)
        {
            var trigger = pViewControl as ITrigger;

            if (trigger == null)
            {
                return;
            }

            trigger.Trigger += (obj) => AppMain.Messanger.SendMessage(
                new Message(null,
                            MessageType.SwitchView,
                            pParameter));
        }
Пример #9
0
        private void ApplyMediaGroupHistory(D2DViewControl pViewControl)
        {
            var navigationHistory = pViewControl as INavigationHistory;

            if (navigationHistory == null)
            {
                return;
            }

            navigationHistory.GetHistorySource = () =>
            {
                return(AppMain.MediaManager.MediaListHistory.Select <MediaHistory, KeyValuePair <int, string> >(
                           (mh) => new KeyValuePair <int, string>(mh.ListIndex, mh.DisplayString)));
            };
            navigationHistory.HistoryClick += AppMain.MediaManager.SetList;
        }
Пример #10
0
        private void ApplyProgressTextFunction(D2DViewControl pViewControl)
        {
            var text = pViewControl as Text;

            if (text == null)
            {
                return;
            }

            AppMain.MediaManager.MediaProgressChanged += new MediaProgressChangedHandler(
                (sender, eventArgs) =>
            {
                text.TextString = ((eventArgs.MediaPosition / 1000) / 60)
                                  + ":"
                                  + ((eventArgs.MediaPosition / 1000) % 60).ToString().PadLeft(2, '0');
            });
        }
Пример #11
0
        private void ApplyMediaArt(D2DViewControl pViewControl)
        {
            var commonbase = pViewControl as ViewControlCommonBase;

            if (commonbase == null)
            {
                return;
            }

            AppMain.MediaManager.MediaChanged += (sender, e) =>
            {
                var artPath = AppMain.MediaManager.GetCurrentSmallAlbumArt();
                if (!string.IsNullOrEmpty(artPath))
                {
                    commonbase.SetBackground(artPath);
                }
            };
        }
Пример #12
0
        // Overrided Events

        protected override void PreRender()
        {
            this.Clear();
            int itemZero = ListItemViewIndexZero;

            for (int i = 0; i < this._listDisplayCount; i++)
            {
                if (itemZero + i < _listItemCollection.Count)
                {
                    D2DViewControl control = this._listItemCollection[itemZero + i];
                    int            col     = i % itemPerScrollaleRow;
                    int            row     = (i / itemPerScrollaleRow);

                    float shiftPx = (_listItemSize * row) - ListLocOffsetPx;

                    Rectangle currentRect;
                    if (ListOrientation == Orientation.Vertical)
                    {
                        float left = col * control.Width;
                        currentRect = new Rectangle(
                            left,
                            shiftPx,
                            ItemSize.Width,
                            ItemSize.Height);
                    }
                    else
                    {
                        float top = col * control.Height;
                        currentRect = new Rectangle(
                            shiftPx,
                            top,
                            ItemSize.Width,
                            ItemSize.Height);
                    }

                    control.Bounds = currentRect;
                    this.AddViewControl(control);
                }
            }
        }
Пример #13
0
 public D2DViewControl GetViewControlContainingPoint(D2DViewControl pViewControl, Point pPoint)
 {
     if (pViewControl != null)
     {
         lock (pViewControl._viewControls)
         {
             int c = pViewControl._viewControls.Count;
             for (int i = pViewControl._viewControls.Count - 1;
                  i >= 0;
                  i--)
             {
                 if (c != pViewControl._viewControls.Count)
                 {
                     System.Diagnostics.Debugger.Break();
                 }
                 if (pViewControl._viewControls[i].GetScreenBounds().Contains(pPoint))
                 {
                     return(GetViewControlContainingPoint(pViewControl._viewControls[i], pPoint));
                 }
             }
         }
     }
     return(pViewControl);
 }
Пример #14
0
 public int IndexOf(D2DViewControl pViewControl)
 {
     return(_viewControls.IndexOf(pViewControl));
 }
Пример #15
0
 public void Remove(D2DViewControl pViewControl)
 {
     lock (_viewControls)
         _viewControls.Remove(pViewControl);
 }
Пример #16
0
 public D2DViewControl()
 {
     _canRender        = true;
     _mouseDownControl = null;
     _viewControls     = new List <D2DViewControl>();
 }