示例#1
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();
        }