Esempio n. 1
0
        public TrackControl AddDockColumn(VMPlaylist playlist)
        {
            TrackControl tc = new TrackControl(playlist);

            DockTrackControl(tc);
            return(tc);
        }
Esempio n. 2
0
        //remove track control
        internal void RemoveFromPlaylistControl(TrackControl trackControl)
        {
            //reorder the controls if the removed control is not last in order
            List <TrackControl> reorderedControls = new List <TrackControl>();

            for (int i = 0; i < trackControls.Count; i++)
            {
                TrackControl tc = trackControls[i];
                if (tc != trackControl)
                {
                    if (tc.ColumnIndex > trackControl.ColumnIndex)
                    {
                        tc.ColumnIndex   -= 2;
                        tc.SplitterIndex -= 2;
                        reorderedControls.Add(tc);
                    }
                }
            }
            trackControl.UndockControlFromParent();
            trackControls.Remove(trackControl);
            foreach (TrackControl tc in reorderedControls)
            {
                SetColumnsPosition(tc);
            }
        }
        public void AddDockColumn(Playlist playlist)
        {
            GridSplitter gs = new GridSplitter();

            gs.ResizeBehavior      = GridResizeBehavior.PreviousAndNext;
            gs.ResizeDirection     = GridResizeDirection.Columns;
            gs.VerticalAlignment   = VerticalAlignment.Stretch;
            gs.HorizontalAlignment = HorizontalAlignment.Stretch;
            gs.Width      = 5;
            gs.Background = new SolidColorBrush(Colors.Black);

            ColumnDefinition subcolumn2 = new ColumnDefinition();

            subcolumn2.Width = GridLength.Auto;
            maingrid.ColumnDefinitions.Add(subcolumn2);
            Grid.SetColumn(gs, maingrid.ColumnDefinitions.Count - 1);
            maingrid.Children.Add(gs);

            TrackControl c = new TrackControl(playlist);

            c.VerticalAlignment   = VerticalAlignment.Stretch;
            c.HorizontalAlignment = HorizontalAlignment.Stretch;
            c.Width  = Double.NaN;
            c.Height = Double.NaN;

            Grid.SetColumn(c, maingrid.ColumnDefinitions.Count);
            maingrid.Children.Add(c);
            ColumnDefinition subcolumn = new ColumnDefinition();

            maingrid.ColumnDefinitions.Add(subcolumn);
        }
Esempio n. 4
0
        internal void SetColumnsPosition(TrackControl trackControl)
        {
            Grid.SetColumn(trackControl.split, trackControl.SplitterIndex);
            Grid.SetColumn(trackControl, trackControl.ColumnIndex);
            //for debugging

            /*
             * trackControl.ToolTip = trackControl.ColumnIndex;
             * trackControl.split.ToolTip = trackControl.SplitterIndex;
             */
        }
Esempio n. 5
0
        internal void DockTrackControl(TrackControl tc)
        {
            //if one of the docked controls has been resized then we need to reset the default
            //column back to star, otherwise newly docked controls will be super narrow
            maingrid.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Star);

            //create grid splitter
            GridSplitter gs = new GridSplitter();

            gs.ResizeBehavior      = GridResizeBehavior.PreviousAndNext;
            gs.ResizeDirection     = GridResizeDirection.Columns;
            gs.VerticalAlignment   = VerticalAlignment.Stretch;
            gs.HorizontalAlignment = HorizontalAlignment.Stretch;
            gs.Width      = 5;
            gs.Background = new SolidColorBrush(Colors.PaleGoldenrod);
            //gridsplitter needs it's own column
            ColumnDefinition splitterColumn = new ColumnDefinition();

            splitterColumn.Width = GridLength.Auto;
            //later on we will need to  link the control to a column number
            //columndef.count means it will add a column to the far right
            //store in the trackcontrol because we will need it for reorrdering
            //the controls after a trackcontrol is removed
            //the splitter's column comes first
            tc.SplitterIndex = maingrid.ColumnDefinitions.Count;
            maingrid.ColumnDefinitions.Add(splitterColumn);
            //set trackcontrol size behaviour
            tc.VerticalAlignment   = VerticalAlignment.Stretch;
            tc.HorizontalAlignment = HorizontalAlignment.Stretch;
            tc.Width  = Double.NaN;
            tc.Height = Double.NaN;
            //column for the track control itself
            ColumnDefinition subcolumn = new ColumnDefinition();

            //As above, use the column.def count as the index
            tc.ColumnIndex = maingrid.ColumnDefinitions.Count;
            maingrid.ColumnDefinitions.Add(subcolumn);
            //we need to add the controls to the grid as well
            maingrid.Children.Add(gs);
            maingrid.Children.Add(tc);
            //trackcontrol needs to know about it's containing parent for removal
            tc.playlistControlParent = this;
            //so that a docked track control and clean itself up
            tc.SetDockingControls(subcolumn, splitterColumn, gs, maingrid);
            //maintain a list of docked track controls
            trackControls.Add(tc);
            //now we can set the column index for the splitter and track control
            SetColumnsPosition(tc);
        }
Esempio n. 6
0
        public static void RestorePlaylistControl(PlaylistControl playlistControl)
        {
            foreach (string s in Properties.Settings.Default.ManagedPlaylists)
            {
                playlistControl.listView.playlistManager.AddPlaylistFromFile(s);
            }

            if (playlistControl.listView.Items.Count < 0)
            {
                return;
            }
            VMPlaylist p = playlistControl.FindPlaylist(Properties.Settings.Default.LastPlaylist);

            if (p == null)
            {
                return;
            }

            TrackControl tc = playlistControl.AddDockColumn(p);

            tc.viewModel.PlaySong(Properties.Settings.Default.CurrentSong, false);

            PlayState ps = (PlayState)Properties.Settings.Default.PlayState;

            if (ps == PlayState.IsPaused)
            {
                MusicPlayer.Player.Pause();
            }
            if (ps == PlayState.Stopped)
            {
                MusicPlayer.Player.Stop();
            }
            if (ps == PlayState.IsPlaying)
            {
                MusicPlayer.Player.Resume(Properties.Settings.Default.TrackPosition);
            }
        }