Exemplo n.º 1
0
        public void ExportOrchestrationOverviews(IEnumerable <BtsOrchestration> omOrchestrations)
        {
            Log.Info("Exports orchestrations");

            foreach (var omOrchestration in omOrchestrations)
            {
                if (!_generatedOrchestrations.Contains(omOrchestration.FullName))
                {
                    try
                    {
                        var filePath = Path.Combine(_orchestrationExportPath, string.Concat(omOrchestration.FullName, ".jpg"));

                        Log.Debug("Exports overview image for orchestration {0}", omOrchestration.FullName);

                        var orchestrationOverviewImage = new OrchestrationOverviewImage(omOrchestration);
                        using (var image = orchestrationOverviewImage.GetImage())
                        {
                            image.Save(filePath);
                            using (var thumbnail = image.GetThumbnailImage(150, 150, null, IntPtr.Zero))
                            {
                                thumbnail.Save(Path.Combine(_orchestrationExportPath, string.Concat(omOrchestration.FullName, "_thumb.jpg")));
                            }
                        }

                        _generatedOrchestrations.Add(omOrchestration.FullName);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(string.Format("Couldn't generate image for orchestration {0}", omOrchestration.FullName), ex);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static void GetSelectionAreas(Graphics g, BaseShape shape, OrchestrationOverviewImage orchestration)
        {
            try
            {
                foreach (BaseShape bc in shape.Shapes)
                {
                    if (bc is ReceiveShape ||
                        bc is SendShape ||
                        bc is MessageAssignmentShape ||
                        bc is VariableAssignmentShape)
                    {
                        OrchShape os = CreateOrchShape(bc);

                        if (os != null)
                        {
                            if (orchestration.ShapeMap != null)
                            {
                                orchestration.ShapeMap.Add(os);
                            }
                            //if (drawHotspots)
                            //{
                            //    DrawDebugRect(g, os.SelectionArea.GetRectangle());
                            //}
                        }
                    }

                    GetSelectionAreas(g, bc, orchestration);
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }
Exemplo n.º 3
0
        public void ExportOrchestrationOverviews(IEnumerable<BtsOrchestration> omOrchestrations)
        {
            Log.Info("Exports orchestrations");

            foreach (var omOrchestration in omOrchestrations)
            {
                if (!_generatedOrchestrations.Contains(omOrchestration.FullName))
                {
                    try
                    {
                        var filePath = Path.Combine(_orchestrationExportPath, string.Concat(omOrchestration.FullName, ".jpg"));

                        Log.Debug("Exports overview image for orchestration {0}", omOrchestration.FullName);

                        var orchestrationOverviewImage = new OrchestrationOverviewImage(omOrchestration);
                        using (var image = orchestrationOverviewImage.GetImage())
                        {
                            image.Save(filePath);
                            using (var thumbnail = image.GetThumbnailImage(150, 150, null, IntPtr.Zero))
                            {
                                thumbnail.Save(Path.Combine(_orchestrationExportPath, string.Concat(omOrchestration.FullName, "_thumb.jpg")));
                            }
                        }

                        _generatedOrchestrations.Add(omOrchestration.FullName);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(string.Format("Couldn't generate image for orchestration {0}", omOrchestration.FullName), ex);
                    }
                }
            }
        }
Exemplo n.º 4
0
        private static Rectangle GetOrchImageSize(OrchestrationOverviewImage orchestration)
        {
            var    ov      = new OrchViewer();
            string text1   = string.Empty;
            var    maxRect = new Rectangle(0, 0, 0, 0);

            if (orchestration.ViewData != string.Empty)
            {
                const int width  = 1;
                const int height = 1;

                var bmp        = new Bitmap(width, height);
                var memGraphic = Graphics.FromImage(bmp);

                XLANGView.XsymFile.ReadXsymFromString(ov.Root, orchestration.ViewData, false, ref text1);

                var ps           = new PageSettings();
                var marginBounds = new Rectangle(0, 0, width, height);

                var args = new PrintPageEventArgs(
                    memGraphic,
                    marginBounds,
                    marginBounds,
                    ps);

                maxRect = ov.DoPrintWithSize(args);

                ps   = null;
                args = null;
                memGraphic.Dispose();
                bmp.Dispose();
            }

            ov.Dispose();
            return(maxRect);
        }
Exemplo n.º 5
0
        //TODO: clean up futher
        public static Bitmap GetOrchestationImage(OrchestrationOverviewImage orchestrationImage, BtsOrchestration orchestration)
        {
            var ov = new OrchViewer();
            string text1 = string.Empty;

            if (!string.IsNullOrEmpty(orchestrationImage.ViewData))
            {
                XLANGView.XsymFile.ReadXsymFromString(ov.Root, orchestrationImage.ViewData, false, ref text1);

                var ps = new PageSettings();

                Rectangle maxRect = GetOrchImageSize(orchestrationImage);

                const int maxWidth = 6000;
                const int maxHeight = 6000;
                int w = maxRect.Width, h = maxRect.Height;

                float scaleX = 1, scaleY = 1;

                if (w > maxWidth)
                {
                    scaleX = maxWidth / (float)w;
                    scaleY = scaleX;
                    w = maxWidth;
                    h = (int)Math.Floor(h * scaleY);
                }

                if (h > maxHeight)
                {
                    scaleY *= maxWidth / (float)h;
                    scaleX *= scaleY;
                    h = maxHeight;
                    w = (int)Math.Floor(w * scaleX);
                }

                var realBmp = new Bitmap(w, h);
                var realGraphic = Graphics.FromImage(realBmp);
                realGraphic.ScaleTransform(scaleX, scaleY);

                realGraphic.SmoothingMode = SmoothingMode.AntiAlias;
                realGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic;

                var realArgs = new PrintPageEventArgs(
                    realGraphic,
                    maxRect,
                    maxRect,
                    ps);

                // Set background colour
                //realGraphic.FillRectangle(new SolidBrush(Color.White), maxRect);
                realGraphic.Clear(Color.White);

                // Draw the orch image
                ov.DoPrintWithSize(realArgs);

                //bool drawHotspots = false;

                //try
                //{
                //    // Decide whether we need hotspots or not
                //    object drawHotspotsObj = new AppSettingsReader().GetValue("ShowHotSpots", typeof(int));

                //    if (drawHotspotsObj != null)
                //    {
                //        int tmp = Convert.ToInt32(drawHotspotsObj);
                //        if (tmp == 1) drawHotspots = true;
                //    }
                //}
                //catch(Exception ex)
                //{
                //    ErrorLogger.Log(TraceEventType.Error, ex.NestedExceptionMessage());
                //}

                GetSelectionAreas(realGraphic, ov.Root, orchestrationImage);

                ps = null;
                realArgs = null;
                ov.Dispose();
                realGraphic.Dispose();
                return realBmp;
            }
            else
            {
                const string errorText = "Unable to load image for orchestration";
                var f = new Font("Arial", 9, FontStyle.Bold);
                int fontHeight = (int)f.GetHeight() + 5;
                int errorWidth = MeasureStringWidth(errorText, f);
                int nameWidth = MeasureStringWidth(orchestration.FullName, f);
                int w = Math.Max(errorWidth, nameWidth) + 50;
                const int h = 100;

                var titleBrush = new SolidBrush(Color.Black);
                var bmp = new Bitmap(w, h);
                var g = Graphics.FromImage(bmp);

                g.FillRectangle(new SolidBrush(Color.White), 0, 0, w, h);
                g.DrawString(errorText, f, titleBrush, (bmp.Width / 2) - (errorWidth / 2), 10);
                g.DrawString(orchestration.FullName, f, titleBrush, (bmp.Width / 2) - (nameWidth / 2), 10 + fontHeight);
                return bmp;
            }
        }
Exemplo n.º 6
0
        private static void GetSelectionAreas(Graphics g, BaseShape shape, OrchestrationOverviewImage orchestration)
        {
            try
            {
                foreach (BaseShape bc in shape.Shapes)
                {
                    if (bc is ReceiveShape ||
                        bc is SendShape ||
                        bc is MessageAssignmentShape ||
                        bc is VariableAssignmentShape)
                    {
                        OrchShape os = CreateOrchShape(bc);

                        if (os != null)
                        {
                            if (orchestration.ShapeMap != null)
                            {
                                orchestration.ShapeMap.Add(os);
                            }
                            //if (drawHotspots)
                            //{
                            //    DrawDebugRect(g, os.SelectionArea.GetRectangle());
                            //}
                        }
                    }

                    GetSelectionAreas(g, bc, orchestration);
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }
Exemplo n.º 7
0
        private static Rectangle GetOrchImageSize(OrchestrationOverviewImage orchestration)
        {
            var ov = new OrchViewer();
            string text1 = string.Empty;
            var maxRect = new Rectangle(0, 0, 0, 0);

            if (orchestration.ViewData != string.Empty)
            {
                const int width = 1;
                const int height = 1;

                var bmp = new Bitmap(width, height);
                var memGraphic = Graphics.FromImage(bmp);

                XLANGView.XsymFile.ReadXsymFromString(ov.Root, orchestration.ViewData, false, ref text1);

                var ps = new PageSettings();
                var marginBounds = new Rectangle(0, 0, width, height);

                var args = new PrintPageEventArgs(
                    memGraphic,
                    marginBounds,
                    marginBounds,
                    ps);

                maxRect = ov.DoPrintWithSize(args);

                ps = null;
                args = null;
                memGraphic.Dispose();
                bmp.Dispose();
            }

            ov.Dispose();
            return maxRect;
        }
Exemplo n.º 8
0
        //TODO: clean up futher
        public static Bitmap GetOrchestationImage(OrchestrationOverviewImage orchestrationImage, BtsOrchestration orchestration)
        {
            var    ov    = new OrchViewer();
            string text1 = string.Empty;

            if (!string.IsNullOrEmpty(orchestrationImage.ViewData))
            {
                XLANGView.XsymFile.ReadXsymFromString(ov.Root, orchestrationImage.ViewData, false, ref text1);

                var ps = new PageSettings();

                Rectangle maxRect = GetOrchImageSize(orchestrationImage);

                const int maxWidth = 6000;
                const int maxHeight = 6000;
                int       w = maxRect.Width, h = maxRect.Height;

                float scaleX = 1, scaleY = 1;

                if (w > maxWidth)
                {
                    scaleX = maxWidth / (float)w;
                    scaleY = scaleX;
                    w      = maxWidth;
                    h      = (int)Math.Floor(h * scaleY);
                }

                if (h > maxHeight)
                {
                    scaleY *= maxWidth / (float)h;
                    scaleX *= scaleY;
                    h       = maxHeight;
                    w       = (int)Math.Floor(w * scaleX);
                }

                var realBmp     = new Bitmap(w, h);
                var realGraphic = Graphics.FromImage(realBmp);
                realGraphic.ScaleTransform(scaleX, scaleY);

                realGraphic.SmoothingMode     = SmoothingMode.AntiAlias;
                realGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic;

                var realArgs = new PrintPageEventArgs(
                    realGraphic,
                    maxRect,
                    maxRect,
                    ps);

                // Set background colour
                //realGraphic.FillRectangle(new SolidBrush(Color.White), maxRect);
                realGraphic.Clear(Color.White);

                // Draw the orch image
                ov.DoPrintWithSize(realArgs);

                //bool drawHotspots = false;

                //try
                //{
                //    // Decide whether we need hotspots or not
                //    object drawHotspotsObj = new AppSettingsReader().GetValue("ShowHotSpots", typeof(int));

                //    if (drawHotspotsObj != null)
                //    {
                //        int tmp = Convert.ToInt32(drawHotspotsObj);
                //        if (tmp == 1) drawHotspots = true;
                //    }
                //}
                //catch(Exception ex)
                //{
                //    ErrorLogger.Log(TraceEventType.Error, ex.NestedExceptionMessage());
                //}

                GetSelectionAreas(realGraphic, ov.Root, orchestrationImage);

                ps       = null;
                realArgs = null;
                ov.Dispose();
                realGraphic.Dispose();
                return(realBmp);
            }
            else
            {
                const string errorText  = "Unable to load image for orchestration";
                var          f          = new Font("Arial", 9, FontStyle.Bold);
                int          fontHeight = (int)f.GetHeight() + 5;
                int          errorWidth = MeasureStringWidth(errorText, f);
                int          nameWidth  = MeasureStringWidth(orchestration.FullName, f);
                int          w          = Math.Max(errorWidth, nameWidth) + 50;
                const int    h          = 100;

                var titleBrush = new SolidBrush(Color.Black);
                var bmp        = new Bitmap(w, h);
                var g          = Graphics.FromImage(bmp);

                g.FillRectangle(new SolidBrush(Color.White), 0, 0, w, h);
                g.DrawString(errorText, f, titleBrush, (bmp.Width / 2) - (errorWidth / 2), 10);
                g.DrawString(orchestration.FullName, f, titleBrush, (bmp.Width / 2) - (nameWidth / 2), 10 + fontHeight);
                return(bmp);
            }
        }