Example #1
0
        private XElement ExtractTagFromControl(Control uc)
        {
            XElement componentTag = null;

            if (uc.GetType() == typeof(CManager.ItBox))
            {
                ItBox ibox = (ItBox)uc;
                var   lbi  = (ListBoxItem)ibox.Parent;
                lbi.IsSelected = true;
                componentTag   = (XElement)lbi.Tag;
            }
            else if (uc.GetType() == typeof(ListBox))
            {
                ListBox lbox = (ListBox)uc;
                lbox.UnselectAll();
                var selected = (TreeViewItem)this.treeView1.SelectedItem;
                var v        = selected.Tag;
                componentTag = (XElement)v;
            }
            else if (uc.GetType() == typeof(TreeViewItem))
            {
                componentTag = (XElement)uc.Tag;
            }
            else if (uc.GetType() == typeof(TVItem))
            {
                componentTag = (XElement)(uc.Parent as Control).Tag;
            }
            else
            {
            }
            return(componentTag);
        }
Example #2
0
 /// <summary>
 /// Построение разных видов айтема в (правой) панели визуализации 
 /// </summary>
 /// <param name="xtag"></param>
 private void ViewItem(XElement xitem)
 {
     string itemId = xitem == null ? cass.Wastebasket : xitem.Attribute(ONames.rdfabout).Value;
     wrapPanel1.Visibility = Visibility.Collapsed;
     itemViewPanel.Visibility = Visibility.Collapsed;
     if(xitem==null || xitem.Name == ONames.TagCollection || xitem.Name == ONames.TagCassette)
     {
         wrapPanel1.Visibility = Visibility.Visible;
         var subitems = this.cass.GetSubItems(itemId);
         wrapPanel1.Items.Clear();
         // почистим чекбоксы юзеровского меню
         //digest_checkBox1.IsChecked = false;
         foreach(CheckBox chb in user_menu_list.Select(r => r.usedCheckbox)) chb.IsChecked = false;
         foreach(var xe in subitems.OrderBy(xe => xe.Name == ONames.TagCollection ? 0 : 1))
         {
             var xtype = xe.Name;
             var iisstore = xe.Element(ONames.TagIisstore);
             string uri = iisstore == null ? null : iisstore.Attribute(ONames.AttUri).Value;
             ImageSource iSource =
                 xtype == ONames.TagDocument ? (iisstore != null && iisstore.Attribute(ONames.AttDocumenttype).Value == "scanned/dz" ? iconScannerLarge : iconDocumentLarge) :
                 //(xtype == ONames.TagPhotodoc ? MakeImageSourceFromFile(cass.Dir + "/documents/small/" + uri.Substring(uri.Length-9,9) + ".jpg")   : //(UriInd.ContainsKey(uri) ? UriInd[uri] : zz)
                 (xtype == ONames.TagVideo ? iconVideoLarge :
                 (xtype == ONames.TagAudio ? iconAudioLarge :
                 (xtype == ONames.TagCollection ? iconClosedFolderLarge : iconDocumentLarge)));
             // Отдельно обработаем вариант фотодокумента, чтобы правильно сформировать источник для иконки
             if(xtype == ONames.TagPhotodoc)
             {
                 iSource = GetCachedImageSource(uri);
             }
             var ib = new ItBox();
             ib.ContextMenu = this.item_contextMenu1;
             var xname = xe.Element(ONames.TagName);
             ib.label.Text = xname==null?"noname": xname.Value;
             if(iSource!=null && iSource.Width > iSource.Height) ib.image1.Width = 100;
             else ib.image1.Height = 100;
             ib.image1.Source = iSource;
             ListBoxItem lbi = new ListBoxItem();
             lbi.Tag = xe;
             lbi.Content = ib;
             wrapPanel1.Items.Add(lbi);
         }
     }
     else if(xitem.Name == ONames.TagPhotodoc)
     {
         itemViewPanel.Visibility = Visibility.Visible;
         imageView1.Visibility = Visibility.Visible;
         mediaElement1.Visibility = Visibility.Collapsed;
         // Это нужно, чтобы фотки не "застревали"
         wrapPanel1.Items.Clear();
         var iisstore = xitem.Element(ONames.TagIisstore);
         string uri = iisstore.Attribute(ONames.AttUri).Value;
         ImageSource imageSource = MakeImageSourceFromFile(cass.Dir.FullName + "/" + cass.GetPreviewPhotodocumentPath(uri, "normal"));
         //ImageSource imageSource = GetCachedImageSource(uri);
         //Image imageView = new Image();
         if(imageSource != null) CalculateImageViewSize(imageSource);
         imageView1.Source = imageSource;
         //itemViewPanel.Children.Clear();
         //itemViewPanel.Children.Add(imageView);
         SetState(); // Установка checkBox
     }
     else if(xitem.Name == ONames.TagVideo || xitem.Name == ONames.TagAudio)
     {
         var iisstore = xitem.Element(ONames.TagIisstore);
         string uri = iisstore.Attribute(ONames.AttUri).Value;
         itemViewPanel.Visibility = Visibility.Visible;
         imageView1.Visibility = Visibility.Collapsed;
         mediaElement1.Visibility = Visibility.Visible;
         if(xitem.Name == ONames.TagVideo)
         {
             mediaElement1.Source = new Uri(cass.Dir.FullName + "/" + "documents/medium/" + uri.Substring(uri.Length - 9, 9) + ".flv");
         }
         else
         {
             mediaElement1.Source = new Uri(cass.Dir.FullName + "/originals/" + uri.Substring(uri.Length - 9, 9) + ".mp3");
         }
         mediaElement1.Height = 288;
         mediaElement1.LoadedBehavior = MediaState.Manual;
         mediaElement1.Play();
         //// Это нужно, чтобы фотки не "застревали"
         //wrapPanel1.Items.Clear();
         //var iisstore = xitem.Element(ONames.TagIisstore);
         //string uri = iisstore.Attribute(ONames.AttUri).Value;
         //ImageSource imageSource = MakeImageSourceFromFile(cass.Dir.FullName + "/" + cass.GetPreviewPhotodocumentPath(uri, "normal"));
         ////ImageSource imageSource = GetCachedImageSource(uri);
         ////Image imageView = new Image();
         //CalculateImageViewSize(imageSource);
         //imageView1.Source = imageSource;
         SetState(); // Установка checkBox
     }
 }