コード例 #1
0
        void RemoveItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem      mi = (MenuItem)sender;
            RowDefinition rd = null;

            if (mi.Tag is Control)
            {
                ListOfContentControls.Remove((Control)mi.Tag);
            }

            if (mi.Tag is CtrlRoundImage)
            {
                rd = (RowDefinition)((CtrlRoundImage)mi.Tag).Tag;
            }
            else if (mi.Tag is CtrlRoundLabel)
            {
                rd = (RowDefinition)((CtrlRoundLabel)mi.Tag).Tag;
            }
            else if (mi.Tag is CtrlAudioPlayer)
            {
                CtrlAudioPlayer mp = (CtrlAudioPlayer)mi.Tag;
                mp.CloseStram();
                rd = (RowDefinition)((CtrlAudioPlayer)mi.Tag).Tag;
            }
            else
            {
                return;
            }

            rd.Height = new GridLength(0);
            try
            {
                ContentItem content_item = (ContentItem)rd.Tag;
                string      file_name    = content_item.ContentFile;
                Globals.DeleteFile(file_name);
                Contents.Remove(content_item);
            }
            catch
            {
                //
            }
        }
コード例 #2
0
        private void AddContent(ContentItem ContentInstance)
        {
            Contents.Add(ContentInstance);
            string uri = "file:///" + ContentInstance.ContentFile;

            var rd = new RowDefinition();

            rd.Height = GridLength.Auto;
            int GridRowIndex = grdContent.RowDefinitions.Count;

            grdContent.RowDefinitions.Add(rd);

            rd.Tag = ContentInstance;
            ContentInstance.Tag = rd;

            switch (ContentInstance.MimeType)
            {
            //case ".bmp":
            //case ".png":
            //case ".jpg":
            case ".rip":
                CtrlRoundImage ri = new CtrlRoundImage();
                ListOfContentControls.Add(ri);
                ri.SetValue(Grid.RowProperty, GridRowIndex);
                ri.SetValue(Grid.ColumnProperty, 1);
                ri.PictureImageSource = Globals.LoadImage(ContentInstance.ContentFile);
                grdContent.Children.Add(ri);
                ri.Tag               = rd;
                ri.ContextMenu       = mnuContentMenu;
                ri.MouseUp          += new MouseButtonEventHandler(ContentItem_MouseUp);
                ri.MouseDoubleClick += new MouseButtonEventHandler(ImageContent_MouseDoubleClick);
                break;

            //case ".txt":
            case ".rit":
                string         TextString = File.ReadAllText(ContentInstance.ContentFile);
                CtrlRoundLabel rl         = new CtrlRoundLabel();
                ListOfContentControls.Add(rl);
                rl.SetValue(Grid.RowProperty, GridRowIndex);
                rl.SetValue(Grid.ColumnProperty, 1);
                rl.LabelText = TextString;
                grdContent.Children.Add(rl);
                rl.Tag         = rd;
                rl.ContextMenu = mnuContentMenu;
                rl.MouseUp    += new MouseButtonEventHandler(ContentItem_MouseUp);
                break;

            //case ".wav":
            //case ".mp3":
            case ".ria":
                string          media_file_name = ContentInstance.ContentFile;
                CtrlAudioPlayer ap = new CtrlAudioPlayer();
                ListOfContentControls.Add(ap);
                ap.SetValue(Grid.RowProperty, GridRowIndex);
                ap.SetValue(Grid.ColumnProperty, 1);
                ap.MediaFileName = media_file_name;
                grdContent.Children.Add(ap);
                ap.Tag         = rd;
                ap.ContextMenu = mnuContentMenu;
                ap.MouseUp    += new MouseButtonEventHandler(ContentItem_MouseUp);
                break;
            }
            scScroll.ScrollToBottom();
            //this.Build();
        }