コード例 #1
0
ファイル: Navigation.xaml.cs プロジェクト: soundanny23/stoffi
        /// <summary>
        /// Invoked when the user selects to rename a playlist item.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        public void RenamePlaylist_Clicked(object sender, RoutedEventArgs e)
        {
            EditableTextBlock etb = sender as EditableTextBlock;

            if (etb == null && sender is TreeViewItem)
            {
                etb = Tvi2Etb(sender as TreeViewItem);
            }
            if (etb == null)
            {
                etb = Tvi2Etb(NavigationTree.SelectedItem as TreeViewItem);
            }
            if (etb == null || !etb.IsEditable)
            {
                return;
            }
            var playlist = PlaylistManager.FindPlaylist(etb.Text);

            // do not rename playlists we don't own
            if (PlaylistManager.IsSomeoneElses(playlist))
            {
                return;
            }

            etb.IsInEditMode = true;
        }
コード例 #2
0
        /// <summary>
        /// Invoked when the user edits the value of a property
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        /// <remarks>Will save the text to the temporary structure</remarks>
        private void EditableTextBlock_Edited(object sender, EditableTextBlockEventArgs e)
        {
            EditableTextBlock etb  = sender as EditableTextBlock;
            string            prop = etb.Tag as string;
            PropertyData      p    = null;

            foreach (PropertyData pd in properties)
            {
                if (pd.Name == prop)
                {
                    p = pd;
                    break;
                }
            }

            if (p != null)
            {
                p.Value = e.NewText;
                bool   multi  = p.Value == U.T("PropertiesDetailsMultipleValues");
                object curObj = GetTag(tempTrack, p.Name);
                string cur    = curObj as string;
                p.Edited =
                    curObj == null ||
                    (p.Value != curObj.ToString() &&
                     !(p.Name == "Track" && tempTrack.Track == 881102 && multi) &&
                     !(p.Name == "Year" && tempTrack.Year == 881102 && multi));
            }

            ToggleButtons();
        }
コード例 #3
0
ファイル: Navigation.xaml.cs プロジェクト: soundanny23/stoffi
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private void CreateNewPlaylist_Selected(object sender, RoutedEventArgs e)
        {
            TreeViewItem      item = sender as TreeViewItem;
            DockPanel         dp   = item.Header as DockPanel;
            EditableTextBlock etb  = dp.Children[1] as EditableTextBlock;

            etb.IsInEditMode = etb.IsEditable;
        }
コード例 #4
0
ファイル: Navigation.xaml.cs プロジェクト: soundanny23/stoffi
        /// <summary>
        /// Invoked when a playlist is being canceled from editing it's name.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        public void Playlist_Canceled(object sender, EventArgs e)
        {
            EditableTextBlock etb = sender as EditableTextBlock;

            if (etb != null)
            {
                SelectPlaylist(etb.Text);
            }
        }
コード例 #5
0
ファイル: Navigation.xaml.cs プロジェクト: soundanny23/stoffi
        /// <summary>
        /// Returns the playlist corresponding to a TreeViewItem if possible
        /// </summary>
        /// <param name="tvi">The playlist item in the TreeView</param>
        /// <returns>The corresponding playlist if such could be found, otherwise null</returns>
        private PlaylistData Tvi2Pl(TreeViewItem tvi)
        {
            EditableTextBlock etb = Tvi2Etb(tvi);

            if (etb == null)
            {
                return(null);
            }
            return(PlaylistManager.FindPlaylist(etb.Text));
        }
コード例 #6
0
ファイル: Navigation.xaml.cs プロジェクト: soundanny23/stoffi
        /// <summary>
        /// Gets the item given its name.
        /// </summary>
        /// <param name="name">The name of the item</param>
        /// <returns>The item in the tree corresponding to the name</returns>
        private TreeViewItem GetItem(string name)
        {
            switch (name)
            {
            case "NowPlaying":
            case "Now playing":
                return(NowPlaying);

            case "Video":
                return(Video);

            case "Visualizer":
                return(Visualizer);

            case "Music":
                return(Music);

            case "Library":
            case "Files":
                return(Files);

            case "YouTube":
                return(Youtube);

            case "SoundCloud":
                return(SoundCloud);

            case "Radio":
                return(Radio);

            case "History":
                return(History);

            case "Queue":
                return(Queue);

            case "Playlists":
                return(Playlists);

            default:
                if (name.StartsWith("Playlist:"))
                {
                    foreach (TreeViewItem tvi in Playlists.Items)
                    {
                        EditableTextBlock etb = Tvi2Etb(tvi);
                        if (etb != null && name == "Playlist:" + etb.Text)
                        {
                            return(tvi);
                        }
                    }
                }
                break;
            }
            return(null);
        }
コード例 #7
0
ファイル: Navigation.xaml.cs プロジェクト: soundanny23/stoffi
 /// <summary>
 /// Selects the TreeViewItem of a playlist with a given name.
 /// </summary>
 /// <param name="name">The name of the playlist</param>
 private void SelectPlaylist(string name)
 {
     foreach (TreeViewItem tvi in Playlists.Items)
     {
         EditableTextBlock etb = Tvi2Etb(tvi);
         if (etb != null && etb.Text == name)
         {
             tvi.Focus();
             return;
         }
     }
 }
コード例 #8
0
        /// <summary>
        /// Adds a text field
        /// </summary>
        /// <param name="name">The name of the field</param>
        /// <param name="value">The value of the field</param>
        /// <param name="editable">Whether the field can be edited</param>
        public void AddField(string name, string value, bool editable = false)
        {
            EditableTextBlock etb = new EditableTextBlock();

            etb.IsEditable        = editable;
            etb.ClickToEdit       = editable;
            etb.Text              = value;
            etb.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            etb.Edited           += new EditableTextBlockDelegate(Field_Edited);
            etb.EnteredEditMode  += new EventHandler(Field_EnteredEditMode);
            AddField(name, etb);
        }
コード例 #9
0
ファイル: Navigation.xaml.cs プロジェクト: soundanny23/stoffi
        /// <summary>
        /// Invoked when a drop occurs on a playlist item.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        public void Playlist_Drop(object sender, DragEventArgs e)
        {
            List <object>     DraggedItems = e.Data.GetData(typeof(List <object>)) as List <object>;
            TreeViewItem      tvi          = sender as TreeViewItem;
            DockPanel         dp           = tvi.Header as DockPanel;
            EditableTextBlock etb          = dp.Children[1] as EditableTextBlock;

            if (etb.Text == U.T("NavigationCreateNew"))
            {
                AddToPlaylistQueue.Clear();
                foreach (TrackData track in DraggedItems)
                {
                    AddToPlaylistQueue.Add(track);
                }
                CreateNewPlaylistETB.IsInEditMode = true;
            }
            else
            {
                PlaylistManager.AddToPlaylist(DraggedItems, etb.Text);
            }
        }
コード例 #10
0
        /// <summary>
        /// Adds a text field with a binding to an object.
        /// </summary>
        /// <param name="name">The text to display as the label of the field</param>
        /// <param name="source">The object source which holds the value of the field</param>
        /// <param name="field">The name of the property which should be displayed in the field</param>
        /// <param name="editable">Whether or not the field can be edited</param>
        /// <param name="converter">A converter to use to convert the value of the binding</param>
        /// <remarks>TODO: Appearantly not working for some reason... :(</remarks>
        public void AddTextField(string name, object source, string field, bool editable = false, IValueConverter converter = null)
        {
            Binding binding = new Binding(field);

            binding.Source = source;
            binding.Mode   = BindingMode.OneWay;
            if (converter != null)
            {
                binding.Converter = converter;
            }

            EditableTextBlock etb = new EditableTextBlock();

            etb.IsEditable  = editable;
            etb.ClickToEdit = editable;
            etb.DataContext = source;
            etb.SetBinding(EditableTextBlock.TextProperty, binding);
            etb.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            etb.Edited           += new EditableTextBlockDelegate(Field_Edited);
            etb.EnteredEditMode  += new EventHandler(Field_EnteredEditMode);
            AddField(name, etb);
        }
コード例 #11
0
ファイル: Details.xaml.cs プロジェクト: uQr/stoffi
 /// <summary>
 /// Adds a text field
 /// </summary>
 /// <param name="name">The name of the field</param>
 /// <param name="value">The value of the field</param>
 /// <param name="editable">Whether the field can be edited</param>
 public void AddField(string name, string value, bool editable = false)
 {
     EditableTextBlock etb = new EditableTextBlock();
     etb.IsEditable = editable;
     etb.ClickToEdit = editable;
     etb.Text = value;
     etb.VerticalAlignment = System.Windows.VerticalAlignment.Center;
     etb.Edited += new EditableTextBlockDelegate(Field_Edited);
     etb.EnteredEditMode += new EventHandler(Field_EnteredEditMode);
     AddField(name, etb);
 }
コード例 #12
0
ファイル: Details.xaml.cs プロジェクト: uQr/stoffi
        /// <summary>
        /// Adds a text field with a binding to an object.
        /// </summary>
        /// <param name="name">The text to display as the label of the field</param>
        /// <param name="source">The object source which holds the value of the field</param>
        /// <param name="field">The name of the property which should be displayed in the field</param>
        /// <param name="editable">Whether or not the field can be edited</param>
        /// <param name="converter">A converter to use to convert the value of the binding</param>
        /// <remarks>TODO: Appearantly not working for some reason... :(</remarks>
        public void AddTextField(string name, object source, string field, bool editable = false, IValueConverter converter = null)
        {
            Binding binding = new Binding(field);
            binding.Source = source;
            binding.Mode = BindingMode.OneWay;
            if (converter != null)
                binding.Converter = converter;

            EditableTextBlock etb = new EditableTextBlock();
            etb.IsEditable = editable;
            etb.ClickToEdit = editable;
            etb.DataContext = source;
            etb.SetBinding(EditableTextBlock.TextProperty, binding);
            etb.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            etb.Edited += new EditableTextBlockDelegate(Field_Edited);
            etb.EnteredEditMode += new EventHandler(Field_EnteredEditMode);
            AddField(name, etb);
        }
コード例 #13
0
 /// <summary>
 /// Invoked when the left mouse button is pressed
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The event data</param>
 private void Window_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (etbInEdit != null && etbInEdit.IsInEditMode)
     {
         EditableTextBlock etb = Utilities.TryFindParent<EditableTextBlock>((DependencyObject)e.OriginalSource);
         if (etb == null || etb != etbInEdit)
         {
             etbInEdit.Done();
             etbInEdit = null;
         }
     }
     Menu mb = Utilities.TryFindParent<Menu>((DependencyObject)e.OriginalSource);
     if (mb == null && !SettingsManager.MenuBarVisible && MenuBar.Visibility == Visibility.Visible)
         MenuBar.Visibility = Visibility.Collapsed;
 }
コード例 #14
0
        /// <summary>
        /// Invoked when the window becomes inactive
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private void Window_Deactivated(object sender, EventArgs e)
        {
            if (!glassEffect && System.Windows.Forms.VisualStyles.VisualStyleInformation.DisplayName != "")
                Background = SystemColors.GradientInactiveCaptionBrush;

            if (etbInEdit != null)
            {
                etbInEdit.IsInEditMode = false;
                etbInEdit = null;
            }

            if (!SettingsManager.MenuBarVisible && MenuBar.Visibility == Visibility.Visible)
                MenuBar.Visibility = Visibility.Collapsed;
        }
コード例 #15
0
 /// <summary>
 /// Invoked when an editable text block enters edit mode
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The event data</param>
 private void EditableTextBlock_EnteredEditMode(object sender, EventArgs e)
 {
     etbInEdit = sender as EditableTextBlock;
 }
コード例 #16
0
        /// <summary>
        /// Creates a playlist track list and navigation items
        /// </summary>
        /// <param name="playlist">The data for the playlist to create</param>
        /// <param name="select">Whether to select the playlist after it has been created</param>
        private void CreatePlaylist(PlaylistData playlist, bool select = true)
        {
            Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate()
            {
                if (playlist.ListConfig == null)
                {
                    ViewDetailsConfig vdc = SettingsManager.CreateListConfig();
                    SettingsManager.InitViewDetailsConfig(vdc);
                    vdc.HasNumber = true;
                    vdc.Sorts.Add("asc:Title");
                    vdc.Sorts.Add("asc:Track");
                    vdc.Sorts.Add("asc:Album");
                    vdc.Sorts.Add("asc:Artist");

                    if (SettingsManager.SearchPolicy == SearchPolicy.Global)
                        vdc.Filter = SettingsManager.FileListConfig.Filter;
                    else if (SettingsManager.SearchPolicy == SearchPolicy.Partial && SettingsManager.Playlists.Count > 1)
                        vdc.Filter = SettingsManager.Playlists[0].ListConfig.Filter;

                    playlist.ListConfig = vdc;
                }

                PlaylistTrackLists.Add(playlist.Name, null);
                playlist.Tracks.CollectionChanged +=
                    new NotifyCollectionChangedEventHandler(PlaylistTracks_CollectionChanged);

                // create the item in the navigation tree
                TreeViewItem item = new TreeViewItem();
                item.Selected += NavigationPane.Playlist_Selected;
                item.Drop += NavigationPane.Playlist_Drop;
                item.KeyDown += NavigationPlaylist_KeyDown;
                item.Tag = playlist.Name;
                item.Padding = new Thickness(8, 0, 0, 0);
                item.HorizontalAlignment = HorizontalAlignment.Stretch;
                item.HorizontalContentAlignment = HorizontalAlignment.Stretch;

                DockPanel dp = new DockPanel();
                dp.LastChildFill = false;
                dp.HorizontalAlignment = HorizontalAlignment.Stretch;

                Image img = new Image();
                img.Source = Utilities.GetIcoImage("pack://application:,,,/Platform/Windows 7/GUI/Images/Icons/DiscAudio.ico", 16, 16);
                img.Width = 16;
                img.Height = 16;
                img.Style = (Style)TryFindResource("HandHover");
                dp.Children.Add(img);

                EditableTextBlock etb = new EditableTextBlock();
                etb.EnteredEditMode += new EventHandler(EditableTextBlock_EnteredEditMode);
                etb.Text = playlist.Name;
                etb.Margin = new Thickness(5, 0, 5, 0);
                etb.Edited += NavigationPane.Playlist_Edited;
                etb.Canceled += NavigationPane.Playlist_Canceled;
                etb.HandHover = true;
                dp.Children.Add(etb);

                Image simg = new Image();
                simg.Source = Utilities.GetIcoImage("pack://application:,,,/Platform/Windows 7/GUI/Images/Icons/Search.ico", 16, 16);
                simg.Width = 16;
                simg.Height = 16;
                simg.Margin = new Thickness(5, 0, 5, 0);
                simg.Visibility = Visibility.Collapsed;
                DockPanel.SetDock(simg, Dock.Right);
                dp.Children.Add(simg);

                item.Header = dp;
                item.ContextMenuOpening += new ContextMenuEventHandler(NavigationPane.Playlist_ContextMenuOpening);
                item.ContextMenuClosing += new ContextMenuEventHandler(NavigationPane.Playlist_ContextMenuClosing);
                item.ContextMenu = NavigationPane.playlistMenu;
                NavigationPane.Playlists.Items.Insert(NavigationPane.Playlists.Items.Count - 1, item);
                if (select)
                    item.Focus();

                // create list context menu items
                MenuItem miAdd = new MenuItem();
                miAdd.Header = playlist.Name;
                miAdd.Click += new RoutedEventHandler(listMenuAddToPlaylist_Click);
                listMenuAddToPlaylist.Visibility = System.Windows.Visibility.Visible;
                listMenuAddToPlaylist.Items.Insert(listMenuAddToPlaylist.Items.Count - 1, miAdd);

                MenuItem miDel = new MenuItem();
                miDel.Header = playlist.Name;
                miDel.Click += new RoutedEventHandler(listMenuRemoveFromPlaylist_Click);
                listMenuRemoveFromPlaylist.Visibility = System.Windows.Visibility.Visible;
                listMenuRemoveFromPlaylist.Items.Add(miDel);

                PlaybackControls.Search.AddPlaylist(playlist);

                NavigationPane.SetSearchIndicator("Playlist:" + playlist.Name, playlist.ListConfig);
            }));
        }
コード例 #17
0
        /// <summary>
        /// Invoked when a field has been edited
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private void Field_Edited(object sender, EditableTextBlockEventArgs e)
        {
            EditableTextBlock etb = sender as EditableTextBlock;

            OnFieldEdited(etb.Tag as string, e.NewText);
        }