示例#1
0
        /// <summary>
        /// Export the specified plot model to an xaml string.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="background">The background.</param>
        /// <returns>A xaml string.</returns>
        public static string ExportToString(PlotModel model, double width, double height, OxyColor background = null)
        {
            var g = new Grid();
            if (background != null)
            {
                g.Background = background.ToBrush();
            }

            var c = new Canvas();
            g.Children.Add(c);

            var size = new Size(width, height);
            g.Measure(size);
            g.Arrange(new Rect(0, 0, width, height));
            g.UpdateLayout();

            var rc = new ShapesRenderContext(c) { UseStreamGeometry = false };
            model.Update();
            model.Render(rc, width, height);

            var sb = new StringBuilder();
            using (var sw = new StringWriter(sb))
            {
                var xw = XmlWriter.Create(sw, new XmlWriterSettings { Indent = true });
                XamlWriter.Save(c, xw);
            }

            return sb.ToString();
        }
示例#2
0
        /// <summary>
        ///     Разлинеивает таблицу
        /// </summary>
        /// <param name="grid">Таблица</param>
        /// <param name="column">Количество колонок</param>
        /// <param name="row">Количество строчек</param>
        public static void InitalizeGrid(Grid grid, int column, int row)
        {
            for (int i = 0; i < column; i++)
            {
                for (int j = 0; j < row; j++)
                {
                    var rectengle = new Rectangle { Stroke = StrokeColor, StrokeThickness = 0 };

                    Grid.SetColumn(rectengle, i);
                    Grid.SetRow(rectengle, j);
                    grid.Children.Add(rectengle);
                    grid.UpdateLayout();
                }
            }
        }
示例#3
0
        private static void InitGrid(Grid grid, DtoTableViewModel vm)
        {
            if (vm != null && grid != null)
            {
                grid.RowDefinitions.Clear();
                grid.ColumnDefinitions.Clear();
                foreach (var row in vm.Rows)
                {
                    grid.RowDefinitions.Add(new RowDefinition());
                }
                foreach (var col in vm.Columns)
                {
                    grid.ColumnDefinitions.Add(new ColumnDefinition() { SharedSizeGroup = "col" + col.Column.ToString() });
                }

                grid.InvalidateArrange();
                grid.UpdateLayout();
            }
        }
        public void RenderAndSave(ImageRendererArguments args, out string fileName)
        {
            var mainContainer = new Grid();

            mainContainer.Children.Add(args.UiContainer);
            mainContainer.Measure(new Size(args.Width, args.Height));
            mainContainer.Arrange(new Rect(0, 0, args.Width, args.Height));
            mainContainer.UpdateLayout();

            var encoder = new PngBitmapEncoder();
            var render = RenderBitmap(mainContainer, args.Dpi);

            var workingDirectory = @"c:\temp";
            fileName = Path.Combine(workingDirectory, $"dwg_{Guid.NewGuid()}.png");

            render.Render(mainContainer);
            encoder.Frames.Add(BitmapFrame.Create(render));
            using (var s = File.Open(fileName, FileMode.Create))
            {
                encoder.Save(s);
            }
        }
示例#5
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void AutoCol_MinWidth ()
		{
			var grid = new Grid ();
			grid.AddColumns(Auto, Star);
			grid.ColumnDefinitions[0].MinWidth = 10;
			grid.AddChild(ContentControlWithChild(), 0, 0, 0, 0);

			CreateAsyncTest(grid, () => {
				grid.UpdateLayout();
				Assert.AreEqual(50, grid.ColumnDefinitions[0].ActualWidth, "#1");
			});
		}
示例#6
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void AutoCol_Empty_MinWidth ()
		{
			// Ensure MinWidth is respected in an empty Auto segment
			var grid = new Grid();
			grid.AddColumns(Auto, Star);
			grid.ColumnDefinitions[0].MinWidth = 10;
			grid.AddChild(ContentControlWithChild(), 0, 1, 0, 0);

			CreateAsyncTest(grid, () => {
				grid.UpdateLayout();
				Assert.AreEqual(10, grid.ColumnDefinitions[0].ActualWidth, "#1");
			});
		}
示例#7
0
        private void OnContentNameChanged(DependencyObject content, string oldName, string newName)
        {
            ContentPresenter oldPresenter = GetPresenter(oldName);
            if (oldPresenter != null) {
                oldPresenter.Content = null;
            }

            ContentPresenter newPresenter = GetPresenter(newName);
            if (newPresenter != null) {
                Grid grid = new Grid();
                grid.Children.Add((UIElement)content);

                newPresenter.Content = grid;
                grid.UpdateLayout();
            }
        }
示例#8
0
        private void OnContentListCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add) {
                UIElement content = (UIElement)e.NewItems[0];

                TemplatePanel currentOwner = TemplatePanel.GetContainer(content);
                if (currentOwner != null) {
                    currentOwner.ContentList.Remove(content);
                }

                TemplatePanel.SetContainer(content, this);

                string contentName = TemplatePanel.GetContentName(content);

                ContentPresenter contentPresenter = GetPresenter(contentName);
                if (contentPresenter != null) {
                    Grid grid = new Grid();
                    grid.Children.Add(content);

                    contentPresenter.Content = grid;
                    grid.UpdateLayout();
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove) {
                UIElement content = (UIElement)e.OldItems[0];

                string contentName = TemplatePanel.GetContentName(content);

                ContentPresenter contentPresenter = GetPresenter(contentName);
                if (contentPresenter != null) {
                    contentPresenter.Content = null;
                }
            }
        }
示例#9
0
        /// <internalonly />
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (_contentList.Count != 0) {
                Dispatcher.BeginInvoke(delegate() {
                    foreach (UIElement content in _contentList) {
                        string contentName = TemplatePanel.GetContentName(content);
                        ContentPresenter contentPresenter = GetPresenter(contentName);

                        if (contentPresenter != null) {
                            Grid grid = new Grid();
                            grid.Children.Add(content);

                            contentPresenter.Content = grid;
                            grid.UpdateLayout();
                        }
                    }
                });
            }
        }
示例#10
0
        public string ExecuteThread(FileItem item,string infile, string dest, ValuePairEnumerator configData)
        {
            try
            {

            var conf = new OverlayTransformViewModel(configData);
            using (var fileStream = new MemoryStream(File.ReadAllBytes(infile)))
            {
                BitmapDecoder bmpDec = BitmapDecoder.Create(fileStream,
                    BitmapCreateOptions.PreservePixelFormat,
                    BitmapCacheOption.OnLoad);
                WriteableBitmap writeableBitmap = BitmapFactory.ConvertToPbgra32Format(bmpDec.Frames[0]);
                writeableBitmap.Freeze();

                Grid grid = new Grid
                {
                    Width = writeableBitmap.PixelWidth,
                    Height = writeableBitmap.PixelHeight,
                    ClipToBounds = true,
                    SnapsToDevicePixels = true
                };
                grid.UpdateLayout();
                var size = new Size(writeableBitmap.PixelWidth, writeableBitmap.PixelWidth);
                grid.Measure(size);
                grid.Arrange(new Rect(size));

                Image overlay = new Image();
                Image image = new Image { Width = writeableBitmap.PixelWidth, Height = writeableBitmap.PixelHeight };
                image.BeginInit();
                image.Source = writeableBitmap;
                image.EndInit();
                image.Stretch = Stretch.Fill;
                grid.Children.Add(image);
                grid.UpdateLayout();

                string text = "";
                if (!string.IsNullOrEmpty(conf.Text))
                {
                    Regex regPattern = new Regex(@"\[(.*?)\]", RegexOptions.Singleline);
                    MatchCollection matchX = regPattern.Matches(conf.Text);
                    text = matchX.Cast<Match>()
                        .Aggregate(conf.Text,
                            (current1, match) =>
                                item.FileNameTemplates.Where(
                                    template =>
                                        String.Compare(template.Name, match.Value,
                                            StringComparison.InvariantCultureIgnoreCase) == 0).Aggregate(current1,
                                                (current, template) => current.Replace(match.Value, template.Value)));
                }
                TextBlock textBlock = new TextBlock
                {
                    Text = text,
                    Foreground = (SolidColorBrush) new BrushConverter().ConvertFromString(conf.FontColor),
                    FontFamily = (FontFamily) new FontFamilyConverter().ConvertFromString(conf.Font),
                    FontSize = conf.FontSize,
                    Opacity = conf.Transparency/100.00
                };
                if (conf.A11)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Left;
                    textBlock.VerticalAlignment = VerticalAlignment.Top;
                }
                if (conf.A12)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Center;
                    textBlock.VerticalAlignment = VerticalAlignment.Top;
                }
                if (conf.A13)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Right;
                    textBlock.VerticalAlignment = VerticalAlignment.Top;
                }
                if (conf.A21)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Left;
                    textBlock.VerticalAlignment = VerticalAlignment.Center;
                }
                if (conf.A22)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Center;
                    textBlock.VerticalAlignment = VerticalAlignment.Center;
                }
                if (conf.A23)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Right;
                    textBlock.VerticalAlignment = VerticalAlignment.Center;
                }
                if (conf.A31)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Left;
                    textBlock.VerticalAlignment = VerticalAlignment.Bottom;
                }
                if (conf.A32)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Center;
                    textBlock.VerticalAlignment = VerticalAlignment.Bottom;
                }
                if (conf.A33)
                {
                    textBlock.HorizontalAlignment = HorizontalAlignment.Right;
                    textBlock.VerticalAlignment = VerticalAlignment.Bottom;
                }

                textBlock.Margin = new Thickness(conf.Margins);
                if (File.Exists(conf.OverlayFile))
                {
                    overlay.Source = BitmapLoader.Instance.LoadImage(conf.OverlayFile, 0, 0);
                    overlay.Opacity = textBlock.Opacity;
                    if (!conf.StrechOverlay)
                    {
                        overlay.HorizontalAlignment = textBlock.HorizontalAlignment;
                        overlay.VerticalAlignment = textBlock.VerticalAlignment;
                        overlay.Stretch = Stretch.None;
                    }
                    else
                    {
                        overlay.HorizontalAlignment = HorizontalAlignment.Stretch;
                        overlay.VerticalAlignment = VerticalAlignment.Stretch;
                        overlay.Stretch = Stretch.UniformToFill;
                    }
                    grid.Children.Add(overlay);
                    grid.UpdateLayout();
                }

                grid.Children.Add(textBlock);
                grid.UpdateLayout();

                BitmapLoader.Save2Jpg(
                    BitmapLoader.SaveImageSource(grid, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight), dest);
            }
            }
            catch (Exception ex)
            {
                Log.Error("Overlay Transform Plugin error ", ex);
            }
            return dest;
        }
        /// <summary>
        /// This method constructs the document page (visual) to print
        /// </summary>
        private DocumentPage ConstructPage(Grid content, int pageNumber)
        {
            if (content == null)
                return null;

            //Build the page inc header and footer
            Grid pageGrid = new Grid();

            //Header row
            AddGridRow(pageGrid, GridLength.Auto);

            //Content row
            AddGridRow(pageGrid, new GridLength(1.0d, GridUnitType.Star));

            //Footer row
            AddGridRow(pageGrid, GridLength.Auto);

            ContentControl pageHeader = new ContentControl();
            pageHeader.Content = this.CreateDocumentHeader();
            pageGrid.Children.Add(pageHeader);

            if (content != null)
            {
                content.SetValue(Grid.RowProperty, 1);
                pageGrid.Children.Add(content);
            }

            ContentControl pageFooter = new ContentControl();
            pageFooter.Content = CreateDocumentFooter(pageNumber + 1);
            pageFooter.SetValue(Grid.RowProperty, 2);

            pageGrid.Children.Add(pageFooter);

            double width = this.PageSize.Width - (this.PageMargin.Left + this.PageMargin.Right);
            double height = this.PageSize.Height - (this.PageMargin.Top + this.PageMargin.Bottom);
            
            Border border = CreateBorder();
            border.Measure(new Size(this.PageSize.Width, this.PageSize.Width));
            border.Arrange(new Rect(this.PageMargin.Left, this.PageMargin.Top, width, height));
            border.UpdateLayout();

            pageGrid.Measure(new Size(width*0.98 , height*0.98));
            pageGrid.Arrange(new Rect(this.PageMargin.Left, this.PageMargin.Top, width * 0.98, height * 0.98));

            pageGrid.UpdateLayout();
             border.Child = pageGrid;
            border.UpdateLayout();

            return new DocumentPage(border);
        }
示例#12
0
        // Calculated content height
        protected virtual void initialChildren()
        {
            double w = System.Windows.Application.Current.Host.Content.ActualWidth;

            topShadow = GetTemplateChild("TopShadow") as Rectangle;
            bottomShadow = GetTemplateChild("BottomShadow") as Rectangle;
            contentView = GetTemplateChild("ContentView") as Grid;
            buttonContainer = GetTemplateChild("ButtonContainer") as StackPanel;
            curtain = GetTemplateChild("Curtain") as Rectangle;

            // Add an optional title label
            titleLabel = null;
            if (title != null)
            {
                titleLabel = new TextBlock();
                titleLabel.Text = title;
                titleLabel.Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0xd9, 0xf3));
                titleLabel.FontSize = 42;
                titleLabel.HorizontalAlignment = HorizontalAlignment.Center;
                titleLabel.TextWrapping = TextWrapping.Wrap;
                titleLabel.TextAlignment = TextAlignment.Center;
                titleLabel.Margin = new Thickness(0, 8, 0, 8);
                titleLabel.SetValue(Grid.RowProperty, 0);
                contentView.Children.Add(titleLabel);
            }

            // Add any custom content
            if (contentElement != null)
            {
                contentElement.SetValue(Grid.RowProperty, 1);
                contentView.Children.Add(contentElement);
                contentView.InvalidateArrange();
                contentView.UpdateLayout();

                double measuredWidth = contentElement.ActualWidth + contentElement.Margin.Left + contentElement.Margin.Right;
                double measuredHeight = 0;
                if (titleLabel != null)
                {
                    measuredHeight += titleLabel.ActualHeight;
                }

                double contentHeight = Math.Max(contentElement.ActualHeight, contentElement.Height);
                if(!double.IsNaN(contentHeight))
                    measuredHeight += contentHeight + contentElement.Margin.Top + contentElement.Margin.Bottom;
                else
                    measuredHeight += 240 + contentElement.Margin.Top + contentElement.Margin.Bottom;

                expectedContentSize = new Size(measuredWidth, measuredHeight);
            }
            else
            {
                expectedContentSize = new Size(w, 240);
            }

            // Add custom buttons
            if (buttonTitles.Count > 0)
            {
                foreach (string buttonTitle in buttonTitles)
                {
                    var button = new Avarice.Controls.Button();
                    button.Content = buttonTitle;
                    button.Margin = new Thickness(20, 0, 20, 0);
                    button.HorizontalAlignment = HorizontalAlignment.Right;
                    buttonContainer.Children.Add(button);
                    button.Click += OnButtonClick;
                }
            }
            else if(Buttons.Count > 0)
            {
                foreach (var button in Buttons)
                {
                    button.Margin = new Thickness(20, 0, 20, 0);
                    button.HorizontalAlignment = HorizontalAlignment.Right;
                    buttonContainer.Children.Add(button);
                    button.Click += OnButtonClick;
                }

            }
        }
示例#13
0
        private void expandFeaturesPermissions_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            int row = -1;
            Grid gridContainer = new Grid();
            if ((sender as ExpanderView).Name == "expanderFeatures")
            {
                gridContainer = expanderFeatures.Parent as Grid;
                row = 1;
            }
            else
                if ((sender as ExpanderView).Name == "expanderPermissions")
                {
                    gridContainer = expanderPermissions.Parent as Grid;
                    row = 2;
                }

            var height = gridContainer.RowDefinitions[row].Height;
            if (height == new GridLength(40))
                gridContainer.RowDefinitions[row].Height = new GridLength();
            else
                gridContainer.RowDefinitions[row].Height = new GridLength(40);

            gridContainer.UpdateLayout();
        }
示例#14
0
        protected static string WriteTileToDisk(string year, string description, int width, int height, string fontSize, Thickness margins)
        {
            Grid container = new Grid()
            {
                Width = width,
                Height = height,
                Background = (Brush)Application.Current.Resources["TransparentBrush"]
            };

            container.Children.Add(GetTextBlockToRender(description, fontSize, margins));

            // Force the container to render itself
            container.UpdateLayout();
            container.Arrange(new Rect(0, 0, width, height));

            var writeableBitmap = new WriteableBitmap(container, null);

            string fileName = SharedImagePath + "tile" + height + width + ".png";
            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (var stream = new IsolatedStorageFileStream(fileName, FileMode.Create, storage))
                {
                    if (writeableBitmap.PixelHeight > 0)
                    {
                        writeableBitmap.WritePNG(stream);
                    }
                }
            }

            return fileName;
        }
		void CreateBasicPageParameter ()
			{
			BrushConverter BRConverter = new BrushConverter ();
			GridLengthConverter GLConverter = new GridLengthConverter ();
			m_GlobalGrid_2 = new Grid ();
			m_GlobalGrid_2.Visibility = Visibility.Visible;
			this.Content = m_GlobalGrid_2;
			m_GlobalGrid_2.IsEnabled = true;
			ColumnDefinition GlobalGrid_2_Column = new ColumnDefinition ();
			m_GlobalGrid_2.ColumnDefinitions.Add (GlobalGrid_2_Column);
			RowDefinition GlobalGrid_2_NameRow = new RowDefinition ();
			GlobalGrid_2_NameRow.Height = (GridLength)GLConverter.ConvertFromString ("10*");
			RowDefinition GlobalGrid_2_Filler_1 = new RowDefinition ();
			GlobalGrid_2_Filler_1.Height = (GridLength)GLConverter.ConvertFromString ("*");
			RowDefinition GlobalGrid_2_PictureRow = new RowDefinition ();
			GlobalGrid_2_PictureRow.Height = (GridLength)GLConverter.ConvertFromString ("80*");
			RowDefinition GlobalGrid_2_Filler_2 = new RowDefinition ();
			GlobalGrid_2_Filler_2.Height = (GridLength)GLConverter.ConvertFromString ("*");
			RowDefinition GlobalGrid_2_InfoRow = new RowDefinition ();
			GlobalGrid_2_InfoRow.Height = (GridLength)GLConverter.ConvertFromString ("10*");
			m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_NameRow);
			m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_Filler_1);
			m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_PictureRow);
			m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_Filler_2);
			m_GlobalGrid_2.RowDefinitions.Add (GlobalGrid_2_InfoRow);

			m_Name_2_Canvas = new Canvas ();
			m_Name_2_Canvas.Visibility = Visibility.Visible;
			m_GlobalGrid_2.Children.Add (m_Name_2_Canvas);
			Grid.SetColumn (m_Name_2_Canvas, 0);
			Grid.SetRow (m_Name_2_Canvas, 0);

			m_Picture_2_Canvas = new Canvas ();
			m_Picture_2_Canvas.Visibility = Visibility.Visible;
			m_GlobalGrid_2.Children.Add (m_Picture_2_Canvas);
			Grid.SetColumn (m_Picture_2_Canvas, 0);
			Grid.SetRow (m_Picture_2_Canvas, 2);
			NameScope.SetNameScope (m_GlobalGrid_2, new NameScope ());
			m_Picture_2_Canvas.Background = (Brush)BRConverter.ConvertFromString (WeatherDetailBackGroundColor);

			m_Info_2_Canvas = new Canvas ();
			m_Info_2_Canvas.Visibility = Visibility.Visible;
			m_GlobalGrid_2.Children.Add (m_Info_2_Canvas);
			Grid.SetColumn (m_Info_2_Canvas, 0);
			Grid.SetRow (m_Info_2_Canvas, 4);
			m_Info_2_Canvas.Background = (Brush)BRConverter.ConvertFromString (WeatherHeadlineBackGroundColor);

			m_GlobalGrid_2.UpdateLayout ();
			}
示例#16
0
/*
	private static void ReloadDefaultFormatDefinitions(WCFStandardsNS.WCFStandards DataBase, DataSet FormatierDataSet)
		{
		CommonValues m_CVM = new CommonValues ();
		XAMLHandling m_XAML = new XAMLHandling (m_CVM);
		m_XAML.CreateDefaultFormatDataSet (DataBase, FormatierDataSet,
			CommonDataBase.DataBase.GetLocalWPMediaRoot ());
		}
*/

/*	
	public static List<PositioningEntry> ShowIdentifiedFrames (
				double DrawingWidth, Grid RootGridForAllDrawings, DataSet FormatierDataSet,
			String PageIDToProcess, String LocalWPMediaRoot, RedrawMeEvent RedrawMeEventCall)
		{
		Singleton SingletonInstance = Singleton.Instance;
		int LastSelectedIndex = DeleteExistingFrames (SingletonInstance.ListOfPositioningEntryInstances);
		double TargetPictureWidth = Convert.ToDouble (FormatierDataSet.Tables ["TableDefinitions"].Rows [0] ["TargetWidth"]);
		double TargetPictureHeight = Convert.ToDouble (FormatierDataSet.Tables ["TableDefinitions"].Rows [0] ["TargetHeight"]);
		double TargetAspectRatio = TargetPictureWidth / TargetPictureHeight;
		double ResizingFactor = TargetPictureWidth / DrawingWidth;
		TargetPictureWidth /= ResizingFactor;
		TargetPictureHeight /= ResizingFactor;
		int LocalRootGridLastIndexNotToDelete = RootGridForAllDrawings.Children.Count;
		if (SingletonInstance.ListOfPositioningEntryInstances == null)
			SingletonInstance.ListOfPositioningEntryInstances = new List<PositioningEntry> ();
		SingletonInstance.FormatierDataSet = FormatierDataSet;
		foreach (DataRow PictureRow in FormatierDataSet.Tables ["PictureDefinitions"].Select
			("PageID = '" + PageIDToProcess + "'", "PicturePlayingOrder"))
			{
			PositioningEntry PictureWindow = new PositioningEntry ();
			PictureWindow.RootUIElement = RootGridForAllDrawings;
			PictureWindow.TypeOfPositioning = "Picture";
			PictureWindow.ConnectedID = PictureRow ["ID"].ToString ();
			PictureWindow.PositionPercentageTop = Convert.ToDouble (PictureRow ["PositionTop"]);
			PictureWindow.PositionPercentageLeft = Convert.ToDouble (PictureRow ["PositionLeft"]);
			PictureWindow.PositionPercentageBottom = Convert.ToDouble (PictureRow ["PositionBottom"]);
			PictureWindow.PositionPercentageRight = Convert.ToDouble (PictureRow ["PositionRight"]);
			PictureWindow.AddOnText = PictureRow ["NameID"].ToString ();
			PictureWindow.OriginRow = PictureRow;
			SingletonInstance.ListOfPositioningEntryInstances.Add (PictureWindow);
			}

		foreach (DataRow TextBlockRow in FormatierDataSet.Tables ["BlockDefinitions"].Select
			("PageID = '" + PageIDToProcess + "'", "BlockPlayingOrder"))
			{
			PositioningEntry TextWindow = new PositioningEntry ();
			TextWindow.RootUIElement = RootGridForAllDrawings;
			TextWindow.TypeOfPositioning = "Text";
			TextWindow.ConnectedID = TextBlockRow ["ID"].ToString ();
			TextWindow.PositionPercentageTop = Convert.ToDouble (TextBlockRow ["MinPositionTop"]);
			TextWindow.PositionPercentageLeft = Convert.ToDouble (TextBlockRow ["MinPositionLeft"]);
			TextWindow.PositionPercentageBottom = Convert.ToDouble (TextBlockRow ["MaxPositionBottom"]);
			TextWindow.PositionPercentageRight = Convert.ToDouble (TextBlockRow ["MaxPositionRight"]);
			TextWindow.AddOnText = TextBlockRow ["NameID"].ToString ();
			TextWindow.OriginRow = TextBlockRow;
			TextWindow.BlockRotation = 0;
			if (!Convert.IsDBNull (TextBlockRow ["BlockRotation"]))
				TextWindow.BlockRotation = Convert.ToDouble (TextBlockRow ["BlockRotation"]);
			SingletonInstance.ListOfPositioningEntryInstances.Add (TextWindow);
			}

		CVM.CloseRequested PosWindow_CloseRequestedEntry = new CloseRequested (PosWindow_CloseRequestedCall);
		Canvas PositioningCanvas = new Canvas ();
		PositioningCanvas.MinWidth = TargetPictureWidth;
		PositioningCanvas.Width = TargetPictureWidth;
		PositioningCanvas.MinHeight = TargetPictureHeight;
		PositioningCanvas.Height = TargetPictureHeight;
		PositioningCanvas.AllowDrop = true;
		RootGridForAllDrawings.Children.Add (PositioningCanvas);
		int Index = 0;
		PositioningEntry PosWindowToSelect = null;
		foreach (PositioningEntry PosWindow in SingletonInstance.ListOfPositioningEntryInstances)
			{
			PosWindow.RootGrid = RootGridForAllDrawings;
			PosWindow.RootGridLastIndexNotToDelete = LocalRootGridLastIndexNotToDelete;
			PosWindow.AllFrames = SingletonInstance.ListOfPositioningEntryInstances;
			PosWindow.PositioningCanvas = PositioningCanvas;
			PosWindow.CloseRequestedCall += PosWindow_CloseRequestedEntry;
			PosWindow.TargetPictureWidth = TargetPictureWidth;
			PosWindow.TargetPictureHeight = TargetPictureHeight;
			PosWindow.TargetAspectRatio = TargetAspectRatio;
			PosWindow.ResizingFactor = ResizingFactor;
			PosWindow.FramingRectangle = PosWindow.ShowPositioningEntry (PosWindow.TypeOfPositioning, PosWindow.AddOnText);
			PositioningCanvas.Children.Add (PosWindow.FramingRectangle);
			Canvas.SetLeft (PosWindow.FramingRectangle, PosWindow.Left);
			Canvas.SetTop (PosWindow.FramingRectangle, PosWindow.Top);
			PosWindow.RedrawMeEventCall += RedrawMeEventCall;
			PosWindow.PageID = PageIDToProcess;
			if (Index == LastSelectedIndex)
				PosWindowToSelect = PosWindow;
			Index++;
			}
		if (PosWindowToSelect != null)
			{
			PosWindowToSelect.PositionableEntry_MouseDown (PosWindowToSelect.FramingRectangle, null);
			}
		return SingletonInstance.ListOfPositioningEntryInstances;
		}
*/



	public static DrawingGroup InsertPageLayerFramingRectangles (XAMLHandling m_Xaml, DataSet FormatierDataSet, String LocalWPMediaRoot,
					DataRow ContentRow, String PageID,
					double OriginalWidth, double OriginalHeight)
		{
		DataRow [] PictureRows = FormatierDataSet.Tables ["PictureDefinitions"].Select
			("PageID = '" + PageID + "'", "PicturePlayingOrder");
		Image FullPicture = new Image ();
		Grid PageGrid = m_Xaml.CreateGrid (new int [] { 100, FramingAroundPercentage },
			new int [] { 100, FramingAroundPercentage });
		FullPicture.MinWidth = OriginalWidth * MaxFactor;
		FullPicture.MinHeight = OriginalHeight * MaxFactor;
		FullPicture.Width = OriginalWidth * MaxFactor;
		FullPicture.Height = OriginalHeight * MaxFactor;
		PageGrid.Children.Add (FullPicture);
		Grid.SetColumnSpan (FullPicture, 2);
		Grid.SetRowSpan (FullPicture, 2);
		Grid PictureGrid = new Grid ();
		PageGrid.Children.Add (PictureGrid);
		Image PageImage = new Image ();
		PictureGrid.Children.Add (PageImage);
		DrawingGroup FramingGroup = new DrawingGroup ();
		FramingGroup.ClipGeometry = new RectangleGeometry (new Rect (0, 0, OriginalWidth, OriginalHeight));
		DrawingImage AllDrawingsImage = new DrawingImage (FramingGroup);
		PageImage.Source = AllDrawingsImage;
		//InsertDisposeableElement (PageImage);
		//InsertDisposeableElement (FullPicture);
		//InsertDisposeableElement (FramingGroup);
		//InsertDisposeableElement (AllDrawingsImage);
		PictureGrid.UpdateLayout ();

		foreach (DataRow PictureRow in PictureRows)
			{
			DataRow [] PhysicalPictureRows = FormatierDataSet.Tables ["ConnectPictures"]
				.Select ("PictureID = '" + PictureRow ["ID"].ToString () + "'");
			foreach (DataRow PhysicalPictureRow in PhysicalPictureRows)
				{
				String NameID = PhysicalPictureRow ["PictureNameID"].ToString ();
				if ((NameID == "VideoOverlay")
					&& (m_Xaml.ShowGridLines == false))
					continue;
				if (!Path.IsPathRooted (PhysicalPictureRow ["PictureFileName"].ToString ()))
					PhysicalPictureRow ["PictureFileName"]
						= Path.Combine (LocalWPMediaRoot, PhysicalPictureRow ["PictureFileName"].ToString ());
				//InsertPictureLayer (PictureRow, FramingGroup, PhysicalPictureRow, OriginalWidth, OriginalHeight);
				}
			}
		PictureGrid.UpdateLayout ();

		DataRow [] BlockRows = FormatierDataSet.Tables ["BlockDefinitions"].Select
			("PageID = '" + PageID + "'", "BlockPlayingOrder");
		Grid TextGrid = new Grid ();
		PageGrid.Children.Add (TextGrid);
		Grid.SetColumn (TextGrid, 0);
		Grid.SetColumnSpan (TextGrid, 2);
		Grid.SetRow (TextGrid, 0);
		Grid.SetRowSpan (TextGrid, 2);
		TextGrid.UpdateLayout ();
		foreach (DataRow BlockRow in BlockRows)
			{
			//InsertBlockLayer (FormatierDataSet, BlockRow, TextGrid, ContentRow,
			//    OriginalWidth, OriginalHeight);
			}
		PageGrid.Arrange (new Rect (0, 0, OriginalWidth * MaxFactor, OriginalHeight * MaxFactor));
		return FramingGroup;	// PageGrid;
		}
        /// <summary>
        /// Response for Branding Info
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pharmacyinfoforbrandingwebservicecall_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            GetPharmacyInformationResponse objPhBrandingInfoResponse = null;
            try
            {
                if (e.Result != null)
                {
                    var response = e.Result.ToString();
                    objPhBrandingInfoResponse = Utils.JsonHelper.Deserialize<GetPharmacyInformationResponse>(response);
                    if ((objPhBrandingInfoResponse.payload != null) && (objPhBrandingInfoResponse.status == 0))
                    {
                        App.ObjBrandingResponse = objPhBrandingInfoResponse;

                        App.BrandingHash = objPhBrandingInfoResponse.payload.branding_hash;
                        App.AdvtHash = objPhBrandingInfoResponse.payload.advert_hash;
                        App.DrugsData = objPhBrandingInfoResponse.payload.drugs_data;
                        App.DrugDBHash = objPhBrandingInfoResponse.payload.drugs_hash;
                        App.AddImages = null;
                        foreach (var item in objPhBrandingInfoResponse.payload.advert_data)
                        {
                            if (App.AddImages == null)
                            {
                                App.AddImages = new List<BitmapImage>();
                                App.ImagesUrl = new List<string>();
                                App.ImagesName = new List<string>();
                            }
                            if (item.image_url != null)
                            {
                                Uri uri = new Uri(item.image_url.Replace("https", "http"));
                                BitmapImage bmi = new BitmapImage(uri);
                                App.ImagesUrl.Add(item.url);
                                App.ImagesName.Add(item.name);
                                App.AddImages.Add(bmi);
                            }
                            else
                            {
                                Color backgroundColor = ConvertStringToColor(item.image_builder.background_color);
                                Color foreroundColor2 = ConvertStringToColor(item.image_builder.font_color);
                                SolidColorBrush backgroundBrush = new SolidColorBrush(backgroundColor);
                                SolidColorBrush foregroundBrush = new SolidColorBrush(foreroundColor2);
                                string text = item.image_builder.line1 + Environment.NewLine +Environment.NewLine + item.image_builder.line2;
                                WriteableBitmap bmpSmall = new WriteableBitmap(200, 120);

                                Grid grid = new Grid();
                                grid.Width = bmpSmall.PixelWidth;
                                grid.Height = bmpSmall.PixelHeight;

                                var background = new Canvas();
                                background.Width = bmpSmall.PixelWidth;
                                background.Height = bmpSmall.PixelHeight;
                                background.Background = backgroundBrush;
                                var textBlock = new TextBlock();
                                textBlock.Width = bmpSmall.PixelWidth;
                                textBlock.FontFamily = new FontFamily("Segoe WP Light");
                                textBlock.Text = text;
                                textBlock.HorizontalAlignment = HorizontalAlignment.Stretch;
                                textBlock.VerticalAlignment = VerticalAlignment.Center;
                                textBlock.FontSize = 12;
                                textBlock.TextWrapping = TextWrapping.Wrap;
                                textBlock.Foreground = foregroundBrush;
                                textBlock.TextAlignment = TextAlignment.Center;
                                grid.Children.Add(background);
                                grid.Children.Add(textBlock);
                                grid.Measure(new Size(bmpSmall.PixelWidth, bmpSmall.PixelHeight));
                                grid.Arrange(new Rect(0, 0, bmpSmall.PixelWidth, bmpSmall.PixelHeight));
                                grid.UpdateLayout();
                                bmpSmall.Render(grid, null);
                                bmpSmall.Invalidate();

                                using (MemoryStream ms = new MemoryStream())
                                {
                                    bmpSmall.SaveJpeg(ms, 200, 120, 0, 100);
                                    BitmapImage bmp = new BitmapImage();
                                    bmp.SetSource(ms);
                                    App.ImagesUrl.Add(item.url);
                                    App.ImagesName.Add(item.name);
                                    App.AddImages.Add(bmp);
                                }  
                            }
                        }
                    }
                    LoginUserDetailsWebService();
                }
            }
            catch (Exception ex)
            {
                objSignUpViewModel.ProgressBarVisibilty = Visibility.Collapsed;
                objSignUpViewModel.HitVisibility = true;
                MessageBox.Show("Sorry, Unable to process your request.");
               
            }
            
        }