/// <summary>
        /// Detach project editor from container control.
        /// </summary>
        public void DetachEditor()
        {
            if (_projectEditor != null && _containerControl != null && _zoomBorder != null)
            {
                _projectEditor.Invalidate  = null;
                _projectEditor.ResetZoom   = null;
                _projectEditor.AutoFitZoom = null;
                _projectEditor.LoadLayout  = null;
                _projectEditor.SaveLayout  = null;
                _projectEditor.ResetLayout = null;

                _zoomBorder.InvalidatedChild = null;

                _inputProcessor.Dispose();
            }

            _projectEditor    = null;
            _containerControl = null;
            _zoomBorder       = null;
        }
Beispiel #2
0
        /// <summary>
        /// Detach project editor from container control.
        /// </summary>
        public void DetachEditor()
        {
            if (_projectEditor != null && _containerControl != null && _zoomBorder != null)
            {
                _projectEditor.Invalidate  = null;
                _projectEditor.ResetZoom   = null;
                _projectEditor.AutoFitZoom = null;
                _projectEditor.LoadLayout  = null;
                _projectEditor.SaveLayout  = null;
                _projectEditor.ResetLayout = null;

                _zoomBorder.InvalidatedChild = null;
                _zoomBorder.PointerPressed  -= ZoomBorder_PointerPressed;
                _zoomBorder.PointerReleased -= ZoomBorder_PointerReleased;
                _zoomBorder.PointerMoved    -= ZoomBorder_PointerMoved;
            }

            _projectEditor    = null;
            _containerControl = null;
            _zoomBorder       = null;
        }
Beispiel #3
0
        /// <summary>
        /// Attach project editor to container control.
        /// </summary>
        public void AttachEditor()
        {
            _projectEditor    = this.DataContext as ProjectEditor;
            _containerControl = this.Find <ContainerViewControl>("containerControl");
            _zoomBorder       = this.Find <ZoomBorder>("zoomBorder");

            if (_projectEditor != null && _containerControl != null && _zoomBorder != null)
            {
                _projectEditor.Invalidate  = () => _containerControl.InvalidateVisual();
                _projectEditor.ResetZoom   = () => _zoomBorder.Reset();
                _projectEditor.AutoFitZoom = () => _zoomBorder.AutoFit();
                _projectEditor.LoadLayout  = () => { };
                _projectEditor.SaveLayout  = () => { };
                _projectEditor.ResetLayout = () => { };

                _zoomBorder.InvalidatedChild = InvalidateChild;
                _zoomBorder.PointerPressed  += ZoomBorder_PointerPressed;
                _zoomBorder.PointerReleased += ZoomBorder_PointerReleased;
                _zoomBorder.PointerMoved    += ZoomBorder_PointerMoved;
            }
        }
        /// <summary>
        /// Attach project editor to container control.
        /// </summary>
        public void AttachEditor()
        {
            _projectEditor    = this.DataContext as ProjectEditor;
            _containerControl = this.Find <ContainerControl>("containerControl");
            _zoomBorder       = this.Find <ZoomBorder>("zoomBorder");

            if (_projectEditor != null && _containerControl != null && _zoomBorder != null)
            {
                _projectEditor.Canvas.Invalidate  = () => _containerControl.InvalidateVisual();
                _projectEditor.Canvas.ResetZoom   = () => _zoomBorder.Reset();
                _projectEditor.Canvas.AutoFitZoom = () => _zoomBorder.AutoFit();
                _projectEditor.Canvas.Zoom        = _zoomBorder;

                _zoomBorder.InvalidatedChild = InvalidateChild;

                _inputProcessor = new InputProcessor(
                    new AvaloniaInputSource(
                        _zoomBorder,
                        _containerControl,
                        _zoomBorder.FixInvalidPointPosition),
                    _projectEditor);
            }
        }
Beispiel #5
0
 public MainWindow()
 {
     InitializeComponent();
     SetDirectory();
     KeyDown += KeyPressed;
     _filters = new List <FileDialogFilter>
     {
         new FileDialogFilter
         {
             Extensions = new List <string> {
                 "bhds"
             },
             Name = "BetterHades File"
         }
     };
     Closing              += OnClose;
     _zoomBorder           = this.Find <ZoomBorder>("zoomBorder");
     _saveButton           = this.Find <MenuItem>("saveButton");
     _saveButton.IsEnabled = false;
     RightClickContextMenu = new RightClickContextMenu(this.Find <ContextMenu>("contextMenu"));
     GridCanvas            = new GridCanvas(_zoomBorder);
     Config.Init();
     UpdateFileHistory();
     Dispatcher.UIThread.InvokeAsync(
         () =>
     {
         var args = Environment.GetCommandLineArgs();
         if (args.Length <= 1)
         {
             return;
         }
         File.WriteAllText("test.txt", "test\n" + args[1]);
         FileHandler.Load(args[1]);
         _saveButton.IsEnabled = true;
         Config.AddFileToHistory(args[1]);
     }, DispatcherPriority.Loaded);
 }
Beispiel #6
0
        public GridCanvas(ZoomBorder parent)
        {
            Canvas = new Canvas
            {
                Background = Brushes.White,
                Width      = MainWindow.GridSize,
                Height     = MainWindow.GridSize
            };
            Canvas.PointerMoved   += MouseMoveHandler;
            Canvas.PointerPressed += ClickHandler;
            parent.Child           = Canvas;

            DrawGrid();

            Dispatcher.UIThread.InvokeAsync
            (
                () =>
            {
                parent.StartPan(0, 0);
                parent.PanTo(-(MainWindow.GridSize - App.MainWindow.Width) / 2,
                             -(MainWindow.GridSize - App.MainWindow.Height) / 2);
            },
                DispatcherPriority.Render
            );

            Components            = new List <Component>();
            Connections           = new List <Connection>();
            _previewComponentData = new string[2];
            Canvas.Children.Add(_previewComponent = new Rectangle
            {
                Width           = 2 * MainWindow.GridCellSize,
                Height          = 2 * MainWindow.GridCellSize,
                Stroke          = Brushes.Black,
                IsVisible       = false,
                StrokeThickness = 1
            });
        }
Beispiel #7
0
        private async void DisplayMedia(Media media)
        {
            //the devURL, description and update notes only need to be
            //re-parsed if the package has changed
            if (CurrentDispalyMedia == null || (!CurrentDispalyMedia.Equals(media)))
            {
                //check if devurl, desciption, update notes need to be changed if selectablePackage changed as well
                if (CurrentDisplaySP == null || (!CurrentDisplaySP.Equals(media.SelectablePackageParent)))
                {
                    //check if devURL element should be enabled or not
                    if (string.IsNullOrWhiteSpace(media.SelectablePackageParent.DevURL))
                    {
                        DevUrlHeader.IsEnabled  = false;
                        DevUrlHeader.Visibility = Visibility.Hidden;
                        DevUrlHolder.IsEnabled  = false;
                        DevUrlHolder.Visibility = Visibility.Hidden;
                    }
                    else
                    {
                        //devURL is now array of elements separated by newline
                        //load the stack with textblocks with tooltips for the URLs
                        string[] devURLS = media.SelectablePackageParent.DevURLList;

                        //clear last list of URL links
                        DevUrlHolder.Children.Clear();

                        for (int i = 0; i < devURLS.Count(); i++)
                        {
                            //make a URI to hold the goto devurl link
                            Uri goTo = null;
                            try
                            {
                                goTo = new Uri(devURLS[i].Trim());
                            }
                            catch (UriFormatException)
                            {
                                Logging.Error("Invalid URI string, skipping: {0}", devURLS[i].Trim());
                            }
                            if (goTo == null)
                            {
                                continue;
                            }

                            //make a textbox to hold the hyperlink object
                            TextBlock block = new TextBlock()
                            {
                                ToolTip = devURLS[i].Trim()
                            };
                            //https://stackoverflow.com/questions/21214450/how-to-add-a-hyperlink-in-a-textblock-in-code?noredirect=1&lq=1
                            block.Inlines.Clear();

                            //make a run to display the number of the link
                            Run inline = new Run(i.ToString());

                            //and the hyperlink will display the run
                            Hyperlink h = new Hyperlink(inline)
                            {
                                NavigateUri = goTo
                            };
                            h.RequestNavigate += OnHyperLinkClick;

                            //add hyperlink to textbox
                            block.Inlines.Add(h);

                            //add to developer url textbox
                            DevUrlHolder.Children.Add(block);
                        }
                    }

                    //set the name of the window to be the package name
                    if (EditorMode)
                    {
                        Title = "EDITOR_TEST_MODE";
                    }
                    else if (ComboBoxItemsInsideMode)
                    {
                        Title = string.Format("{0}: {1}", Translations.GetTranslatedString("dropDownItemsInside"), media.SelectablePackageParent.NameFormatted);
                    }
                    else
                    {
                        Title = media.SelectablePackageParent.NameFormatted;
                    }

                    //set description
                    PreviewDescriptionBox.Text = media.SelectablePackageParent.DescriptionFormatted;

                    //set update notes
                    PreviewUpdatesBox.Text = media.SelectablePackageParent.UpdateCommentFormatted;

                    //update the last currentDisplayedSP
                    CurrentDisplaySP = media.SelectablePackageParent;
                }
            }
            CurrentDispalyMedia = media;

            //if the child is our media player, then stop and dispose
            if (MainPreviewBorder.Child != null && MainPreviewBorder.Child is RelhaxMediaPlayer player)
            {
                player.StopPlaybackIfPlaying();
                player.Dispose();
            }

            //null the child element and make it again
            MainPreviewBorder.Child = null;
            Logging.Debug("loading preview of MediaType {0}, URL={1}", media.MediaType.ToString(), media.URL);
            Image pictureViewer;

            switch (media.MediaType)
            {
            case MediaType.Unknown:
            default:
                Logging.Error("Invalid MediaType: {0}", media.MediaType.ToString());
                return;

            case MediaType.HTML:
                if (browser != null)
                {
                    browser.Dispose();
                    browser = null;
                }
                browser = new WebBrowser();
                //https://stackoverflow.com/questions/2585782/displaying-html-from-string-in-wpf-webbrowser-control
                browser.NavigateToString(media.URL);
                MainPreviewBorder.Child = browser;
                break;

            case MediaType.MediaFile:
                //show progress first
                MainPreviewBorder.Child = new ProgressBar()
                {
                    Minimum             = 0,
                    Maximum             = 1,
                    Value               = 0,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Margin              = new Thickness(0, 20, 0, 0),
                    Height              = 20
                };
                using (WebClient client = new WebClient()
                {
                })
                {
                    client.DownloadProgressChanged += Client_DownloadProgressChanged;

                    //now load the media
                    try
                    {
                        byte[] data = await client.DownloadDataTaskAsync(media.URL);

                        MainPreviewBorder.Child = new RelhaxMediaPlayer(media.URL, data);
                    }
                    catch (Exception ex)
                    {
                        Logging.Exception("failed to load audio data");
                        Logging.Exception(ex.ToString());
                        pictureViewer = new Image
                        {
                            ClipToBounds = true
                        };
                        pictureViewer.Source    = Utils.BitmapToImageSource(Properties.Resources.error_loading_picture);
                        MainPreviewBorder.Child = pictureViewer;
                    }
                }
                break;

            case MediaType.Picture:
                //https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.image?view=netframework-4.7.2
                pictureViewer = new Image
                {
                    ClipToBounds = true
                };
                MainContentControl.MouseRightButtonDown    += MainContentControl_MouseRightButtonDown;
                MainContentControl.PreviewMouseDoubleClick += MainContentControl_PreviewMouseDoubleClick;
                MainPreviewBorder.Child = new ProgressBar()
                {
                    Minimum             = 0,
                    Maximum             = 1,
                    Value               = 0,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Margin              = new Thickness(0, 20, 0, 0),
                    Height              = 20
                };
                //https://stackoverflow.com/questions/9173904/byte-array-to-image-conversion
                //https://stackoverflow.com/questions/18134234/how-to-convert-system-io-stream-into-an-image
                using (WebClient client = new WebClient()
                {
                })
                {
                    client.DownloadProgressChanged += Client_DownloadProgressChanged;
                    try
                    {
                        byte[] image = await client.DownloadDataTaskAsync(media.URL);

                        ImageStream = new MemoryStream(image);
                        BitmapImage bitmapImage = new BitmapImage();
                        bitmapImage.BeginInit();
                        bitmapImage.StreamSource = ImageStream;
                        bitmapImage.EndInit();
                        pictureViewer.Source = bitmapImage;
                    }
                    catch (Exception ex)
                    {
                        Logging.Exception("failed to load picture");
                        Logging.Exception(ex.ToString());
                        pictureViewer.Source = Utils.BitmapToImageSource(Properties.Resources.error_loading_picture);
                    }
                }
                //put the zoom border inside the main preview one. already set, might as well use it
                zoomBorder = new ZoomBorder()
                {
                    Child = pictureViewer,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch,
                    BorderThickness     = new Thickness(1.0),
                    BorderBrush         = Brushes.Black,
                    ClipToBounds        = true
                };
                zoomBorder.SizeChanged           += ZoomBorder_SizeChanged;
                MainPreviewBorder.ClipToBounds    = true;
                MainPreviewBorder.BorderThickness = new Thickness(0.0);
                MainPreviewBorder.Child           = zoomBorder;
                break;

            case MediaType.Webpage:
                if (browser != null)
                {
                    browser.Dispose();
                    browser = null;
                }
                browser = new WebBrowser();
                //https://stackoverflow.com/questions/2585782/displaying-html-from-string-in-wpf-webbrowser-control
                browser.Navigate(media.URL);
                MainPreviewBorder.Child = browser;
                break;
            }
        }
Beispiel #8
0
        private async void DisplayMedia(Media media)
        {
            CurrentDispalyMedia = media;
            //if the child is our media player, then stop and dispose
            if (MainPreviewBorder.Child != null && MainPreviewBorder.Child is RelhaxMediaPlayer player)
            {
                player.StopPlaybackIfPlaying();
                player.Dispose();
            }
            //null the child element and make it again
            MainPreviewBorder.Child = null;
            Logging.Debug("loading preview of MediaType {0}, URL={1}", media.MediaType.ToString(), media.URL);
            Image pictureViewer;

            switch (media.MediaType)
            {
            case MediaType.Unknown:
            default:
                Logging.Error("Invalid MediaType: {0}", media.MediaType.ToString());
                return;

            case MediaType.HTML:
                if (browser != null)
                {
                    browser.Dispose();
                    browser = null;
                }
                browser = new WebBrowser();
                //https://stackoverflow.com/questions/2585782/displaying-html-from-string-in-wpf-webbrowser-control
                browser.NavigateToString(media.URL);
                MainPreviewBorder.Child = browser;
                break;

            case MediaType.MediaFile:
                //show progress first
                MainPreviewBorder.Child = new ProgressBar()
                {
                    Minimum             = 0,
                    Maximum             = 1,
                    Value               = 0,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Margin              = new Thickness(0, 20, 0, 0),
                    Height              = 20
                };
                using (WebClient client = new WebClient()
                {
                })
                {
                    client.DownloadProgressChanged += Client_DownloadProgressChanged;

                    //now load the media
                    try
                    {
                        byte[] data = await client.DownloadDataTaskAsync(media.URL);

                        MainPreviewBorder.Child = new RelhaxMediaPlayer(media.URL, data);
                    }
                    catch (Exception ex)
                    {
                        Logging.Exception("failed to load audio data");
                        Logging.Exception(ex.ToString());
                        pictureViewer = new Image
                        {
                            ClipToBounds = true
                        };
                        pictureViewer.Source    = Utils.BitmapToImageSource(Properties.Resources.error_loading_picture);
                        MainPreviewBorder.Child = pictureViewer;
                    }
                }
                break;

            case MediaType.Picture:
                //https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.image?view=netframework-4.7.2
                pictureViewer = new Image
                {
                    ClipToBounds = true
                };
                MainContentControl.MouseRightButtonDown    += MainContentControl_MouseRightButtonDown;
                MainContentControl.PreviewMouseDoubleClick += MainContentControl_PreviewMouseDoubleClick;
                MainPreviewBorder.Child = new ProgressBar()
                {
                    Minimum             = 0,
                    Maximum             = 1,
                    Value               = 0,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Margin              = new Thickness(0, 20, 0, 0),
                    Height              = 20
                };
                //https://stackoverflow.com/questions/9173904/byte-array-to-image-conversion
                //https://stackoverflow.com/questions/18134234/how-to-convert-system-io-stream-into-an-image
                using (WebClient client = new WebClient()
                {
                })
                {
                    client.DownloadProgressChanged += Client_DownloadProgressChanged;
                    try
                    {
                        byte[] image = await client.DownloadDataTaskAsync(media.URL);

                        ImageStream = new MemoryStream(image);
                        BitmapImage bitmapImage = new BitmapImage();
                        bitmapImage.BeginInit();
                        bitmapImage.StreamSource = ImageStream;
                        bitmapImage.EndInit();
                        pictureViewer.Source = bitmapImage;
                    }
                    catch (Exception ex)
                    {
                        Logging.Exception("failed to load picture");
                        Logging.Exception(ex.ToString());
                        pictureViewer.Source = Utils.BitmapToImageSource(Properties.Resources.error_loading_picture);
                    }
                }
                //put the zoom border inside the main preview one. already set, might as well use it
                zoomBorder = new ZoomBorder()
                {
                    Child = pictureViewer,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch,
                    BorderThickness     = new Thickness(1.0),
                    BorderBrush         = Brushes.Black,
                    ClipToBounds        = true
                };
                zoomBorder.SizeChanged           += ZoomBorder_SizeChanged;
                MainPreviewBorder.ClipToBounds    = true;
                MainPreviewBorder.BorderThickness = new Thickness(0.0);
                MainPreviewBorder.Child           = zoomBorder;
                break;

            case MediaType.Webpage:
                if (browser != null)
                {
                    browser.Dispose();
                    browser = null;
                }
                browser = new WebBrowser();
                //https://stackoverflow.com/questions/2585782/displaying-html-from-string-in-wpf-webbrowser-control
                browser.Navigate(media.URL);
                MainPreviewBorder.Child = browser;
                break;
            }
        }
Beispiel #9
0
 private void ResetZoom(object sender, RoutedEventArgs e)
 {
     ZoomBorder.SetFitToWindow();
 }
Beispiel #10
0
 private void ResetActualSize(object sender, RoutedEventArgs e)
 {
     ZoomBorder.SetActualSize((int)Layers.Document.Dpi, 109, (int)Layers.Document.WidthInch);
 }
Beispiel #11
0
 private void SetPixelPerfect(object sender, RoutedEventArgs e)
 {
     ZoomBorder.SetPerPixel();
 }
Beispiel #12
0
        private async void DisplayMedia(Media media, bool fullRedraw)
        {
            //don't need to update if it's the same as what is currently displayed
            if (media != null && CurrentDispalyMedia != null && CurrentDispalyMedia.Equals(media))
            {
                Logging.Debug(LogOptions.ClassName, "No need to display media, is the same");
                return;
            }
            CurrentDispalyMedia = media;

            //devurl, description, update notes need to be changed if the parent package being displayed changed
            //this would happen only if we are in combobox mode (displaying medias of multiple packages)
            if (ComboBoxItemsInsideMode && media != null && (!CurrentDisplaySP.Equals(media.SelectablePackageParent)))
            {
                fullRedraw       = true;
                CurrentDisplaySP = media.SelectablePackageParent;
            }

            if (fullRedraw)
            {
                ToggleDevUrlList(media, media == null? false : string.IsNullOrWhiteSpace(media.SelectablePackageParent.DevURL));

                //set the name of the window to be the package name
                if (EditorMode)
                {
                    Title = "EDITOR_TEST_MODE";
                }
                else if (ComboBoxItemsInsideMode)
                {
                    Title = string.Format("{0}: {1}", Translations.GetTranslatedString("dropDownItemsInside"), CurrentDisplaySP.NameFormatted);
                }
                else
                {
                    Title = CurrentDisplaySP.NameFormatted;
                }

                //set description
                PreviewDescriptionBox.Text = CurrentDisplaySP.DescriptionFormatted;

                //set update notes
                PreviewUpdatesBox.Text = CurrentDisplaySP.UpdateCommentFormatted;
            }

            //clear media url list and re-build it
            if (MediaIndexer.Children.Count > 0)
            {
                MediaIndexer.Children.Clear();
            }

            //make the linked labels in the link box
            for (int i = 0; i < Medias.Count; i++)
            {
                TextBlock block = new TextBlock();
                block.Inlines.Clear();
                Hyperlink h = new Hyperlink(new Run(i.ToString()))
                {
                    Tag = Medias[i],
                    //dummy URI just to make the request navigate work
                    NavigateUri = new Uri("https://google.com")
                };
                h.RequestNavigate += OnMediaHyperlinkClick;
                block.Inlines.Add(h);
                MediaIndexer.Children.Add(block);
            }

            HandlePlayerDisposal();

            //null the child element and make it again
            MainPreviewBorder.Child = null;
            if (media != null)
            {
                Logging.Debug(LogOptions.ClassName, "Loading preview of MediaType {0}, URL={1}", media.MediaType.ToString(), media.URL);
                Image pictureViewer;
                switch (media.MediaType)
                {
                case MediaType.Unknown:
                default:
                    Logging.Error("Invalid MediaType: {0}", media.MediaType.ToString());
                    return;

                case MediaType.HTML:
                    if (browser != null)
                    {
                        browser.Dispose();
                        browser = null;
                    }
                    browser = new WebBrowser();
                    //https://stackoverflow.com/questions/2585782/displaying-html-from-string-in-wpf-webbrowser-control
                    browser.NavigateToString(media.URL);
                    MainPreviewBorder.Child = browser;
                    break;

                case MediaType.MediaFile:
                    //show progress first
                    MainPreviewBorder.Child = new ProgressBar()
                    {
                        Minimum             = 0,
                        Maximum             = 1,
                        Value               = 0,
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                        VerticalAlignment   = VerticalAlignment.Top,
                        Margin              = new Thickness(0, 20, 0, 0),
                        Height              = 20
                    };
                    using (WebClient client = new WebClient()
                    {
                    })
                    {
                        client.DownloadProgressChanged += Client_DownloadProgressChanged;

                        //now load the media
                        try
                        {
                            byte[] data = await client.DownloadDataTaskAsync(media.URL);

                            MainPreviewBorder.Child = new RelhaxMediaPlayer(media.URL, data);
                        }
                        catch (Exception ex)
                        {
                            Logging.Exception("failed to load audio data");
                            Logging.Exception(ex.ToString());
                            pictureViewer = new Image
                            {
                                ClipToBounds = true
                            };
                            pictureViewer.Source    = CommonUtils.BitmapToImageSource(Properties.Resources.error_loading_picture);
                            MainPreviewBorder.Child = pictureViewer;
                        }
                    }
                    break;

                case MediaType.Picture:
                    //https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.image?view=netframework-4.7.2
                    pictureViewer = new Image
                    {
                        ClipToBounds = true
                    };
                    MainContentControl.MouseRightButtonDown    += MainContentControl_MouseRightButtonDown;
                    MainContentControl.PreviewMouseDoubleClick += MainContentControl_PreviewMouseDoubleClick;
                    MainPreviewBorder.Child = new ProgressBar()
                    {
                        Minimum             = 0,
                        Maximum             = 1,
                        Value               = 0,
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                        VerticalAlignment   = VerticalAlignment.Top,
                        Margin              = new Thickness(0, 20, 0, 0),
                        Height              = 20
                    };
                    //https://stackoverflow.com/questions/9173904/byte-array-to-image-conversion
                    //https://stackoverflow.com/questions/18134234/how-to-convert-system-io-stream-into-an-image
                    using (WebClient client = new WebClient()
                    {
                    })
                    {
                        client.DownloadProgressChanged += Client_DownloadProgressChanged;
                        try
                        {
                            byte[] image = await client.DownloadDataTaskAsync(media.URL);

                            ImageStream = new MemoryStream(image);
                            BitmapImage bitmapImage = new BitmapImage();
                            bitmapImage.BeginInit();
                            bitmapImage.StreamSource = ImageStream;
                            bitmapImage.EndInit();
                            pictureViewer.Source = bitmapImage;
                        }
                        catch (Exception ex)
                        {
                            Logging.Exception("failed to load picture");
                            Logging.Exception(ex.ToString());
                            pictureViewer.Source = CommonUtils.BitmapToImageSource(Properties.Resources.error_loading_picture);
                        }
                    }
                    //put the zoom border inside the main preview one. already set, might as well use it
                    zoomBorder = new ZoomBorder()
                    {
                        Child = pictureViewer,
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                        VerticalAlignment   = VerticalAlignment.Stretch,
                        BorderThickness     = new Thickness(1.0),
                        BorderBrush         = Brushes.Black,
                        ClipToBounds        = true
                    };
                    zoomBorder.SizeChanged           += ZoomBorder_SizeChanged;
                    MainPreviewBorder.ClipToBounds    = true;
                    MainPreviewBorder.BorderThickness = new Thickness(0.0);
                    MainPreviewBorder.Child           = zoomBorder;
                    break;

                case MediaType.Webpage:
                    if (browser != null)
                    {
                        browser.Dispose();
                        browser = null;
                    }
                    browser = new WebBrowser();
                    //https://stackoverflow.com/questions/2585782/displaying-html-from-string-in-wpf-webbrowser-control
                    browser.Navigate(media.URL);
                    MainPreviewBorder.Child = browser;
                    break;
                }
            }
        }
Beispiel #13
0
 public static void Init(ZoomBorder zoomBorder)
 {
     _zoomBorder = zoomBorder;
 }
Beispiel #14
0
        public CustomNodeView(ContextManager cm, ZoomBorder zb, INode bn) : base(cm, zb, bn)
        {
            base.NodeMainSpace.Children.Clear();

            NodeMainSpace.Children.Add(Elem);
        }