示例#1
0
 public void UpdateLexim(LeximDTView leximDT)
 {
     if (this.SelectedIndex != -1)
     {
         StackPanel stackPanel = (StackPanel)((ListBoxItem)this.SelectedItem).Content;
         ((TextBlock)stackPanel.Children[0]).Text          = leximDT.Word;
         ((BitmapImage)stackPanel.Children[1]).GDIBitmap   = leximDT.Picture;
         ((BitmapImage)stackPanel.Children[1]).Source      = Imaging.CreateBitmapSourceFromHBitmap(leximDT.Picture.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(60, 45));
         ((AudioButton)stackPanel.Children[2]).AudioStream = leximDT.Sound;
     }
 }
示例#2
0
        public void AddLexim(LeximDTView lexim, PlayAudio play)
        {
            ResourceDictionary resource = ((ResourceDictionary)((MyApplication)Application.Current).MyResources["resSliderStyle"]);
            SoundImage         im       = new SoundImage();

            this.Children.Add(im);
            IntPtr       intPt = lexim.Picture.GetHbitmap();
            BitmapSource bs    = Imaging.CreateBitmapSourceFromHBitmap(intPt, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(60, 45));

            im.Style       = resource["SoundImage"] as Style;
            im.Source      = bs;
            im.AudioStream = lexim.Sound;
            im.Play        = play;
            im.MouseEnter += new System.Windows.Input.MouseEventHandler(im_MouseEnter);
            baseWindow.DeleteObject(intPt);
        }
示例#3
0
        private ListBoxItem MapToItem(LeximDTView leximDT, PlayAudio play)
        {
            ResourceDictionary resource = ((ResourceDictionary)((MyApplication)Application.Current).MyResources["resLeximListBox"]);
            ListBoxItem        lbi      = new ListBoxItem();

            lbi.Tag      = leximDT.ID.ToString() + "_" + leximDT.ParentThemeID.ToString();
            lbi.Template = resource["listBoxItem"] as ControlTemplate;

            StackPanel stackPanel = new StackPanel();

            lbi.Content            = stackPanel;
            stackPanel.Style       = resource["stackListItem"] as Style;
            stackPanel.Orientation = Orientation.Horizontal;

            TextBlock tb = new TextBlock();

            stackPanel.Children.Add(tb);
            tb.Text      = leximDT.Word;
            tb.Style     = resource["tbName"] as Style;
            tb.GotFocus += new RoutedEventHandler(tb_GotFocus);

            BitmapImage im = new BitmapImage();

            stackPanel.Children.Add(im);
            im.Style     = resource["imageListBox"] as Style;
            im.GDIBitmap = leximDT.Picture;
            IntPtr          imagePointer = leximDT.Picture.GetHbitmap();
            WriteableBitmap b            = null;

            im.Source = Imaging.CreateBitmapSourceFromHBitmap(imagePointer, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(60, 45));
            baseWindow.DeleteObject(imagePointer);

            AudioButton button = new AudioButton();

            stackPanel.Children.Add(button);
            button.AudioStream = leximDT.Sound;
            button.Play        = play;
            button.Style       = resource["buttonListBox"] as Style;
            button.Template    = (resource["tcPlayButton"] as ControlTemplate);
            button.Click      += new RoutedEventHandler(button_Click);
            button.GotFocus   += new RoutedEventHandler(button_GotFocus);
            return(lbi);
        }
示例#4
0
        public void DisplayLexim(LeximDTView lexim, PlayAudio play)
        {
            tbLeximName.Tag  = lexim.ID.ToString() + "_" + lexim.ParentThemeID.ToString();
            tbLeximName.Text = lexim.Word;
            tbLeximName.Focus();
            tbLeximName.CaretIndex = tbLeximName.Text.Length;

            imLexim.Source    = null;
            imLexim.GDIBitmap = null;
            if (lexim.Picture != null)
            {
                imLexim.GDIBitmap = lexim.Picture;
                IntPtr       imagePointer = lexim.Picture.GetHbitmap();
                BitmapSource bs           = Imaging.CreateBitmapSourceFromHBitmap(imagePointer, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(80, 60));
                imLexim.Source = bs;
                baseWindow.DeleteObject(imagePointer);
            }

            btLeximPlay.AudioStream = lexim.Sound;
            btLeximPlay.Play        = play;
            btLeximPlay.Click      += new RoutedEventHandler(btLeximPlay_Click);
            // button.Style = resource["buttonListBox"] as Style;
            // button.Template = (resource["tcPlayButton"] as ControlTemplate);
        }
示例#5
0
        public void InsertLexim(int index, LeximDTView leximDT, PlayAudio play)
        {
            ListBoxItem lbi = MapToItem(leximDT, play);

            this.Items.Insert(0, lbi);
        }
示例#6
0
        public void AddDisplayLexim(LeximDTView lexim, PlayAudio play)
        {
            ListBoxItem lbi = MapToItem(lexim, play);

            this.Items.Add(lbi);
        }