private StackPanel SetHeader(string title, string filename) { StackPanel stackPanel = new StackPanel(); Uri uri = new Uri(@"pack://*****:*****@"pack://application:,,,/Resources/Close.ico", UriKind.RelativeOrAbsolute); Image close = new Image(); close.Source = ((BitmapDecoder)(IconBitmapDecoder.Create(uri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default))).Frames[0]; Button closeButton = new Button(); closeButton.Content = close; closeButton.Margin = new Thickness(10, 0, 0, 0); title = title.Replace(' ', '_'); closeButton.Name = title; closeButton.Click += new RoutedEventHandler(closeButton_Click); closeButton.Height = 12; closeButton.Width = 12; closeButton.ToolTip = "Close Tab"; stackPanel.Orientation = Orientation.Horizontal; stackPanel.Children.Add(image); stackPanel.Children.Add(textBlock); stackPanel.Children.Add(closeButton); return(stackPanel); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { ImageSource imageSource = null; if (value is IImmagine) { imageSource = ((ImmagineWic)value).bitmapSource as ImageSource; } else if (value is Digiphoto.Lumen.Model.Fotografia) { // Prendo il provino IImmagine immagine = ((Digiphoto.Lumen.Model.Fotografia)value).imgProvino; if (immagine != null) { imageSource = ((ImmagineWic)immagine).bitmapSource as ImageSource; } } else if (value is Digiphoto.Lumen.Eventi.Esito) { // Carico una icona dal file delle risorse Esito esito = (Esito)value; System.IO.Stream stream = null; if (esito == Esito.Ok) { stream = this.GetType().Assembly.GetManifestResourceStream("Digiphoto.Lumen.UI.Resources.information.ico"); } else if (esito == Esito.Errore) { stream = this.GetType().Assembly.GetManifestResourceStream("Digiphoto.Lumen.UI.Resources.error.ico"); } if (stream != null) { //Decode the icon from the stream and set the first frame to the BitmapSource BitmapDecoder decoder = IconBitmapDecoder.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.None); imageSource = decoder.Frames [0]; } } else if (value is String) { imageSource = caricaImmagine(value as string); } else { return(value); } return(imageSource); }
public ViewModeViewModel(string viewMode) { _viewMode = viewMode; _viewModeIcon = new Lazy <ImageSource>( () => { try { Stream imgStream = Application.GetResourceStream( new Uri(String.Format(iconPathMask, ViewMode.ToLower()))).Stream; BitmapDecoder decoder = IconBitmapDecoder.Create(imgStream, BitmapCreateOptions.None, BitmapCacheOption.None); return(decoder.Frames[0]); } catch (Exception ex) { throw ex; } }); }
static void Main() { try { // install Nevron Open Vision for WPF NNovApplicationInstaller.Install( NTextModule.Instance, NChartModule.Instance, NDiagramModule.Instance, NScheduleModule.Instance, NGridModule.Instance, NBarcodeModule.Instance); // show the main window Window window = new Window(); window.Title = "Nevron Open Vision Examples for WPF"; window.WindowState = WindowState.Maximized; // load icon from stream using (Stream stream = typeof(Program).Assembly.GetManifestResourceStream("Nevron.Nov.Examples.Wpf.Resources.NevronOpenVision.ico")) { // Decode the icon from the stream and set the first frame to the BitmapSource BitmapDecoder decoder = IconBitmapDecoder.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.None); BitmapSource source = decoder.Frames[1]; // set image source window.Icon = source; } // place a NOV UI Element that contains an NExampleContent widget window.Content = new NNovWidgetHost <NExamplesContent>(); // show the window Application app = new Application(); app.Run(window); } catch (Exception ex) { NTrace.WriteException("Exception in Main", ex); } }