Пример #1
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            AudioButton but = ((AudioButton)sender);

            //but.AudioStream.Position = 0;
            but.Play(but.AudioStream, false);
        }
Пример #2
0
        private void btLeximPlay_Click(object sender, RoutedEventArgs e)
        {
            AudioButton but = ((AudioButton)sender);

            //but.AudioStream.Position = 0;
            if (but.AudioStream != null)
            {
                but.Play(but.AudioStream, false);
            }
        }
Пример #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);
        }