private void AvailableEntries_MouseDoubleClick (object sender, MouseButtonEventArgs e) { ListView Items = sender as ListView; ListViewItem SelectedItem = (ListViewItem) Items.SelectedItem; if (SelectedItem == null) return; String PackageToProcessName = SelectedItem.Tag as String; m_GraphicsHandling = new GraphicsHandling (IntermediateStorageDirectory); Pkg = new PackagingHandler (); if (Pkg.OpenReadWrite (PackageToProcessName) == null) return; m_GraphicsHandling.DoStartupProcessing (Pkg); List<double> Durations = m_GraphicsHandling.PageDurations; ImageTabControl.Items.Clear (); int PageIndex = 0; if (m_GraphicsHandling.PageIDsToPlay == null) { MessageBox.Show ("Fehler", "Keine Pages To Play bei \"" + PackageToProcessName + "\""); Pkg.ClosePackage (); return; } foreach (String PageID in m_GraphicsHandling.PageIDsToPlay) { Image PageImage = new Image (); PageImage.Tag = new CVM.RedrawInformation (PageID, m_GraphicsHandling.PageOrdersToPlay [PageIndex], PageImage); BitmapSource BitmapSourceDrawing = m_GraphicsHandling.GetCreatedFrameBitmapSource (PageImage.Tag as CVM.RedrawInformation); TabItem ImageTab = new TabItem (); ImageTabControl.Items.Add (ImageTab); ImageTab.Header = m_GraphicsHandling.ActuallTableName + " " + Convert.ToString (++PageIndex); PageImage.Width = 640; PageImage.Height = 360; ImageTab.Content = PageImage; PageImage.Source = BitmapSourceDrawing; } Pkg.ClosePackage (); }
TabItem DrawOneFinalPage (GraphicsHandling GraphicsHandlingInstance, String PageID) { double TargetAspectRatio = GraphicsHandlingInstance.TargetPictureWidth / GraphicsHandlingInstance.TargetPictureHeight; double ResizingFactor = GraphicsHandlingInstance.TargetPictureWidth / DrawingWidth; Thickness BorderThickness = new Thickness (); BorderThickness.Left = 3; BorderThickness.Right = 3; BorderThickness.Top = 3; BorderThickness.Bottom = 3; BrushConverter BRConverter = new BrushConverter (); TabItem NewItem = new TabItem (); NewItem.ContextMenuOpening += new ContextMenuEventHandler (NewItem_ContextMenuOpening); NewItem.Tag = PageID; PicturesTabControl.Items.Add (NewItem); PicturesTabControl.SelectedItem = NewItem; int PageIndex = GraphicsHandlingInstance.PageIDsToPlay.FindIndex (delegate (String Entry) { return (PageID == Entry); } ); Grid TabItemGrid = m_XAML.CreateGrid (new int [] { 1 }, new int [] { 20, 1 }); String PlayTime = " (" + GraphicsHandlingInstance.GetPageDuration (PageID).ToString () + ")"; String PageName = "Seite " + Convert.ToString (PageIndex + 1) + PlayTime; NewItem.Content = TabItemGrid; NewItem.Header = PageName; Image JustifiedImage = new Image (); JustifiedImage.ContextMenuOpening += new ContextMenuEventHandler (JustifiedImage_ContextMenuOpening); RedrawInformation RedrawData = new RedrawInformation (PageID, ++PageIndex, JustifiedImage); JustifiedImage.Tag = RedrawData; BitmapSource ImageSource = GraphicsHandlingInstance.GetCreatedFrameBitmapSource (RedrawData); if (!String.IsNullOrEmpty (m_WebLinkData)) { m_WebSizing.Width /= (float) ResizingFactor; m_WebSizing.Height /= (float) ResizingFactor; return NewItem; } JustifiedImage.BeginInit (); JustifiedImage.Source = ImageSource; JustifiedImage.Width = GraphicsHandlingInstance.TargetPictureWidth / ResizingFactor; JustifiedImage.EndInit (); Border ImageBorder = new Border (); TabItemGrid.Children.Add (ImageBorder); ImageBorder.BorderThickness = BorderThickness; ImageBorder.BorderBrush = (Brush) BRConverter.ConvertFromString ("Black"); ImageBorder.Child = JustifiedImage; ImageBorder.Width = (GraphicsHandlingInstance.TargetPictureWidth / ResizingFactor) + BorderThickness.Left + BorderThickness.Right; ImageBorder.Height = (GraphicsHandlingInstance.TargetPictureHeight / ResizingFactor) + BorderThickness.Top + BorderThickness.Bottom; Grid.SetColumn (ImageBorder, 0); Grid.SetRow (ImageBorder, 0); Grid DescriptionTextGrid = m_XAML.CreateGrid (new int [] { 70, 30 }, new int [] { 10 }); TabItemGrid.Children.Add (DescriptionTextGrid); Grid.SetColumn (DescriptionTextGrid, 0); Grid.SetRow (DescriptionTextGrid, 1); TextBox BasePictureText = new TextBox (); DescriptionTextGrid.Children.Add (BasePictureText); Grid.SetColumn (BasePictureText, 1); Grid.SetRow (BasePictureText, 0); BasePictureText.Text = "(" + Convert.ToString ((int) GraphicsHandlingInstance.TargetPictureWidth) + " * " + Convert.ToString ((int) GraphicsHandlingInstance.TargetPictureHeight) + " - " + String.Format ("{0:0.000}", GraphicsHandlingInstance.TargetPictureWidth / GraphicsHandlingInstance.TargetPictureHeight) + ") " + PageName; BasePictureText.TextAlignment = TextAlignment.Right; return NewItem; }
public BitmapSource GetPictureFromPackage (String PackageFileName, int PageIndex, int TargetHeight = -1) { PackageFileName = GetCorrectPackageFileName (PackageFileName); if (String.IsNullOrEmpty (PackageFileName)) return null; GraphicsHandling GraphicsHandler = new GraphicsHandling (); GraphicsHandler.GetInstatiatedPackage (PackageFileName, false); BitmapSource Result = GraphicsHandler.GetCreatedFrameBitmapSource (PageIndex); GraphicsHandler.Close(); if (TargetHeight == -1) return Result; return Basics.ResizeBitmapSourceToNewHeight(Result, TargetHeight); }