partial void InitializeBusyIndicator()
        {
            if (_busyIndicator != null)
            {
                return;
            }

            _grid = new Grid();
            _grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
            _grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
            _grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
            _grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });

            var backgroundBorder = new Border();
            backgroundBorder.Background = new SolidColorBrush(Colors.Gray);
            backgroundBorder.Opacity = 0.5;
            backgroundBorder.SetValue(Grid.RowSpanProperty, 4);
            _grid.Children.Add(backgroundBorder);

            _statusTextBlock = new TextBlock();
            _statusTextBlock.Style = (Style)Application.Current.Resources["PhoneTextNormalStyle"];
            _statusTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
            _statusTextBlock.SetValue(Grid.RowProperty, 1);
            _grid.Children.Add(_statusTextBlock);

            _busyIndicator = ConstructBusyIndicator();
            _busyIndicator.SetValue(Grid.RowProperty, 2);
            _grid.Children.Add(_busyIndicator);

            _containerPopup = new Popup();
            _containerPopup.VerticalAlignment = VerticalAlignment.Center;
            _containerPopup.HorizontalAlignment = HorizontalAlignment.Center;
            _containerPopup.Child = _grid;

            double rootWidth = Application.Current.Host.Content.ActualWidth;
            double rootHeight = Application.Current.Host.Content.ActualHeight;

            _busyIndicator.Width = rootWidth;

            _grid.Width = rootWidth;
            _grid.Height = rootHeight;

            _containerPopup.UpdateLayout();

            return;
        }
Beispiel #2
0
        /// <summary>
        /// Launches the specified popup menu. Note that if the previous popup menu shown by this function
        /// is still open then it is closed before showing the new one.
        /// </summary>
        public static void LaunchPopup(System.Windows.Controls.Primitives.Popup popup, MouseEventArgs e)
        {
            // If a previous popup was open, close it first
            if (null != s_popup)
            {
                s_popup.IsOpen = false;
                s_popup        = null;
            }

            // Position the popup
            Point pt = e.GetPosition(s_mainPage);

            popup.HorizontalOffset = pt.X;
            popup.VerticalOffset   = pt.Y;

            // Store a reference to it so that it can be hidden when the user clicks elsewhere
            s_popup = popup;

            // Show the menu (required before getting its size)
            popup.IsOpen = true;
            popup.UpdateLayout();

            // Get sizes
            Size popSize = (popup.Child as Control).DesiredSize;
            Size s       = s_mainPage.LayoutRoot.DesiredSize;

            // Make sure we don't fly off an edge
            if (popup.HorizontalOffset + popSize.Width > s.Width)
            {
                popup.HorizontalOffset = s.Width - popSize.Width;
            }
            if (popup.HorizontalOffset < 0.0)
            {
                popup.HorizontalOffset = 0.0;
            }
            if (popup.VerticalOffset + popSize.Height > s.Height)
            {
                popup.VerticalOffset = s.Height - popSize.Height;
            }
            if (popup.VerticalOffset < 0.0)
            {
                popup.VerticalOffset = 0.0;
            }
        }
        private List<ExportFile> GetImages()
        {
            List<ExportFile> images = new List<ExportFile>();

              foreach(Symbol symbol in mUsedSymbols)
              {
            SymbolDisplay symDisplay = new SymbolDisplay();

            symDisplay.Symbol = symbol;
            symDisplay.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            symDisplay.VerticalAlignment = System.Windows.VerticalAlignment.Center;

            //Need to put panel in popup and open popup, so panel ends up in control visual tree.
            //Otherwise when bitmap is rendered, panel will not include any child controls.
            Popup popUp = new System.Windows.Controls.Primitives.Popup();
            popUp.Child = symDisplay;
            popUp.IsOpen = true;
            popUp.UpdateLayout();

            WriteableBitmap bmp = new WriteableBitmap(symDisplay, null);
            ImageTools.Image img = ImageTools.ImageExtensions.ToImage(bmp);

            MemoryStream stream = new MemoryStream();

            ImageTools.ImageExtensions.WriteToStream(img, stream);

            images.Add(new ExportFile()
            {
              Title = symbol.GetHashCode().ToString(),
              Path = string.Format("files/{0}.png", symbol.GetHashCode().ToString()),
              Data = stream.ToArray()
            });

            stream.Dispose();

            popUp.IsOpen = false;
              }

              return images;
        }