public WorkflowViewWrapper()
        {
            this.loader = new Loader();

            // Create a Workflow Design Surface
            this.surface = new DesignSurface();
            this.surface.BeginLoad(this.loader);

            // Get the Workflow Designer Host
            this.Host = this.surface.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (this.Host == null)
                return;

            // Create a Sequential Workflow by using the Workflow Designer Host
            SequentialWorkflow = (SequentialWorkflowActivity)Host.CreateComponent(typeof(SequentialWorkflowActivity));
            SequentialWorkflow.Name = "CustomOutlookWorkflow";

            // Create a Workflow View on the Workflow Design Surface
            this.workflowView = new WorkflowView(this.surface as IServiceProvider);

            // Add a message filter to the workflow view, to support panning
            MessageFilter filter = new MessageFilter(this.surface as IServiceProvider, this.workflowView);
            this.workflowView.AddDesignerMessageFilter(filter);

            // Activate the Workflow View
            this.Host.Activate();

            this.workflowView.Dock = DockStyle.Fill;
            this.Controls.Add(workflowView);
            this.Dock = DockStyle.Fill;
        }
        private const int MaxHeaderFooterLines = 5; //maximum number of lines in header/footer

        public WorkflowPrintDocument(WorkflowView workflowView)//, IServiceProvider serviceProvider)
        {
            //this.serviceProvider = serviceProvider;
            this.pageSetupData = new PageSetupData();
            this.workflowView = workflowView;
            this.previewLayout = new PrintPreviewLayout(this.workflowView, this);
        }
        protected override void Initialize(WorkflowView parentView)
        {
            base.Initialize(parentView);

            StoreUIState();
            RefreshUIState();
        }
 public WorkflowViewAccessibleObject(WorkflowView workflowView) : base(workflowView)
 {
     if (workflowView == null)
     {
         throw new ArgumentNullException("workflowView");
     }
     this.workflowView = workflowView;
 }
 protected override void Initialize(WorkflowView parentView)
 {
     base.Initialize(parentView);
     IServiceContainer service = base.GetService(typeof(IServiceContainer)) as IServiceContainer;
     if (service != null)
     {
         service.RemoveService(typeof(DynamicActionMessageFilter));
         service.AddService(typeof(DynamicActionMessageFilter), this);
     }
 }
        protected override void Initialize(WorkflowView parentView)
        {
            base.Initialize(parentView);

            IServiceContainer serviceContainer = GetService(typeof(IServiceContainer)) as IServiceContainer;
            if (serviceContainer != null)
            {
                serviceContainer.RemoveService(typeof(DragDropManager));
                serviceContainer.AddService(typeof(DragDropManager), this);
            }
        }
 public WorkflowLayout(IServiceProvider serviceProvider)
 {
     if (serviceProvider == null)
     {
         throw new ArgumentNullException("serviceProvider");
     }
     this.serviceProvider = serviceProvider;
     this.parentView = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;
     if (this.parentView == null)
     {
         throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(WorkflowView).FullName }));
     }
 }
        public WorkflowLayout(IServiceProvider serviceProvider)
        {
            Debug.Assert(serviceProvider != null);
            if (serviceProvider == null)
                throw new ArgumentNullException("serviceProvider");

            this.serviceProvider = serviceProvider;

            this.parentView = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;
            Debug.Assert(this.parentView != null);
            if (this.parentView == null)
                throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(WorkflowView).FullName));
        }
        protected override void Initialize(WorkflowView parentView)
        {
            base.Initialize(parentView);

            IServiceContainer serviceContainer = GetService(typeof(IServiceContainer)) as IServiceContainer;
            if (serviceContainer != null)
            {
                serviceContainer.RemoveService(typeof(ConnectionManager));
                serviceContainer.AddService(typeof(ConnectionManager), this);
            }

            IDesignerGlyphProviderService glyphProviderService = GetService(typeof(IDesignerGlyphProviderService)) as IDesignerGlyphProviderService;
            if (glyphProviderService != null)
                glyphProviderService.AddGlyphProvider(this);
        }
 public CommandSet(IServiceProvider serviceProvider)
 {
     this.serviceProvider = serviceProvider;
     this.menuCommandService = (IMenuCommandService) this.serviceProvider.GetService(typeof(IMenuCommandService));
     if (this.menuCommandService == null)
     {
         throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(IMenuCommandService).FullName }));
     }
     this.workflowView = serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;
     if (this.workflowView == null)
     {
         throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(WorkflowView).FullName }));
     }
     this.selectionService = (ISelectionService) this.serviceProvider.GetService(typeof(ISelectionService));
     if (this.selectionService == null)
     {
         throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(ISelectionService).FullName }));
     }
     this.commandSet = new List<System.Workflow.ComponentModel.Design.CommandSetItem>();
     this.commandSet.AddRange(new System.Workflow.ComponentModel.Design.CommandSetItem[] { 
         new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuSaveWorkflowAsImage), WorkflowMenuCommands.SaveAsImage), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuCopyToClipboard), WorkflowMenuCommands.CopyToClipboard), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusPrint), new EventHandler(this.OnMenuPrint), WorkflowMenuCommands.Print), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusPageSetup), new EventHandler(this.OnMenuPageSetup), WorkflowMenuCommands.PageSetup), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusDelete), new EventHandler(this.OnMenuDelete), StandardCommands.Delete), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusCopy), new EventHandler(this.OnMenuCopy), StandardCommands.Copy), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusCut), new EventHandler(this.OnMenuCut), StandardCommands.Cut), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusPaste), new EventHandler(this.OnMenuPaste), StandardCommands.Paste, true), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuSelectAll), StandardCommands.SelectAll), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuDesignerProperties), WorkflowMenuCommands.DesignerProperties), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnViewCode), new CommandID(StandardCommands.Cut.Guid, 0x14d)), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyCancel), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyReverseCancel), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveUp), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveDown), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveLeft), 
         new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveRight), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeySelectNext), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeySelectPrevious), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusExpandCollapse), new EventHandler(this.OnExpandCollapse), WorkflowMenuCommands.Expand), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusExpandCollapse), new EventHandler(this.OnExpandCollapse), WorkflowMenuCommands.Collapse), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusEnable), new EventHandler(this.OnEnable), WorkflowMenuCommands.Disable, true), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusEnable), new EventHandler(this.OnEnable), WorkflowMenuCommands.Enable, true), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnCreateTheme), WorkflowMenuCommands.CreateTheme), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnChangeTheme), WorkflowMenuCommands.ChangeTheme), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyDefault), MenuCommands.KeyDefaultAction), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyPageDnUp), WorkflowMenuCommands.PageUp), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyPageDnUp), WorkflowMenuCommands.PageDown)
      });
     this.zoomCommands = new System.Workflow.ComponentModel.Design.CommandSetItem[] { new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom400Mode, DR.GetString("Zoom400Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom300Mode, DR.GetString("Zoom300Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom200Mode, DR.GetString("Zoom200Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom150Mode, DR.GetString("Zoom150Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom100Mode, DR.GetString("Zoom100Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom75Mode, DR.GetString("Zoom75Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom50Mode, DR.GetString("Zoom50Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.ShowAll, DR.GetString("ZoomShowAll", new object[0])) };
     this.commandSet.AddRange(this.zoomCommands);
     this.layoutCommands = new System.Workflow.ComponentModel.Design.CommandSetItem[] { new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusLayout), new EventHandler(this.OnPageLayout), WorkflowMenuCommands.DefaultPage), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusLayout), new EventHandler(this.OnPageLayout), WorkflowMenuCommands.PrintPreviewPage), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusLayout), new EventHandler(this.OnPageLayout), WorkflowMenuCommands.PrintPreview) };
     this.commandSet.AddRange(this.layoutCommands);
     this.navigationToolCommands = new System.Workflow.ComponentModel.Design.CommandSetItem[] { new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusMessageFilter), new EventHandler(this.OnMessageFilterChanged), NavigationToolCommandIds[0]), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusMessageFilter), new EventHandler(this.OnMessageFilterChanged), NavigationToolCommandIds[1]), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusMessageFilter), new EventHandler(this.OnMessageFilterChanged), NavigationToolCommandIds[2]), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusMessageFilter), new EventHandler(this.OnMessageFilterChanged), NavigationToolCommandIds[3]) };
     this.commandSet.AddRange(this.navigationToolCommands);
     for (int i = 0; i < this.commandSet.Count; i++)
     {
         if (this.menuCommandService.FindCommand(this.commandSet[i].CommandID) == null)
         {
             this.menuCommandService.AddCommand(this.commandSet[i]);
         }
     }
     IComponentChangeService service = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
     if (service != null)
     {
         service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
     }
     IDictionaryService service2 = this.serviceProvider.GetService(typeof(IDictionaryService)) as IDictionaryService;
     if (service2 != null)
     {
         service2.SetValue(typeof(CommandID), new CommandID(new Guid("5f1c3c8d-60f1-4b98-b85b-8679f97e8eac"), 0));
     }
 }
Exemple #11
0
        private bool CommonWorkflowLoading()
        {
            Boolean result = false;

            _designSurface.BeginLoad(_wfLoader);

            IDesignerHost designer = _designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost;
            if (designer == null || designer.RootComponent == null)
            {
                return false;
            }

            IRootDesigner rootDesigner = designer.GetDesigner(designer.RootComponent) as IRootDesigner;
            if (rootDesigner != null)
            {
                SuspendLayout();

                _wfView = rootDesigner.GetView(ViewTechnology.Default) as WorkflowView;
                splitContainer1.Panel2.Controls.Add(_wfView);
                _wfView.Dock = DockStyle.Fill;
                _wfView.Focus();

                propertyGrid1.Site = designer.RootComponent.Site;

                IToolboxService toolboxService = designer.GetService(typeof(IToolboxService)) as IToolboxService;
                if (toolboxService != null)
                {
                    if (toolboxService is Control)
                    {
                        _toolboxControl = (Control)toolboxService;
                        splitContainer2.Panel1.Controls.Add(_toolboxControl);
                    }
                }

                ISelectionService selectionService = ((IServiceProvider)_wfView).GetService(typeof(ISelectionService)) as ISelectionService;
                if (selectionService != null)
                {
                    selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged);
                }

                ResumeLayout();
                result = true;
            }
            return result;
        }
        public void Highlight(List<ActivityDesigner> highlightedDesigners)
        {
            if (highlightedDesigners == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("hightlightedDesigners");
            }

            glyphProviderService = this.GetService(typeof(IDesignerGlyphProviderService)) as IDesignerGlyphProviderService;
            workflowView = GetService(typeof(WorkflowView)) as WorkflowView;

            RemoveCurrentHighlight();

            IDesignerHost designerHost = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
            DesignerHighlighterMesageFilter messageFilter = new DesignerHighlighterMesageFilter();
            highlightProvider = new HighlightGlyphProvider(designerHost.GetDesigner(designerHost.RootComponent) as ActivityDesigner, highlightedDesigners);
            glyphProviderService.AddGlyphProvider(highlightProvider);
            highlightProvider.MessageFilter = messageFilter;

            messageFilter.MouseDown += new EventHandler<System.Windows.Forms.MouseEventArgs>(messageFilter_MouseDown);
            messageFilter.KeyDown += new EventHandler<System.Windows.Forms.KeyEventArgs>(messageFilter_KeyDown);
            workflowView.AddDesignerMessageFilter(messageFilter);
            workflowView.FitToScreenSize();
        }
        public Form1()
        {
            InitializeComponent();

            // ���[�N�t���[�v���W�F�N�g�̃p�X��擾
            projectpath = Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\CustomWorkflowLibrary");

            // ���[�N�t���[�f�U�C�i�[�̏�����
            this.designSurface = new DesignSurface();
            loader = new MyWorkflowLoader(Path.Combine(projectpath, "Workflow1.xoml"));
            designSurface.BeginLoad(loader);

            this.workflowView = new WorkflowView((IServiceProvider) this.designSurface);
            splitContainer1.Panel1.Controls.Add(this.workflowView);
            this.workflowView.Dock = DockStyle.Fill;

            IDesignerHost designerHost = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
            designerHost.Activate();

            // �R���e�L�X�g���j���[�̕\��
            IMenuCommandService menuService = new WorkflowMenuCommandService((IServiceProvider)workflowView);
            designerHost.AddService(typeof(IMenuCommandService), menuService);

            // �Q�Ƃ���A�Z���u�� (�ꕔ) ��ݒ�
            // (�p�����[�^�� Validation �`�F�b�N�Ȃǂ̍ۂɁA���̃A�Z���u������ɂ�������)
            TypeProvider typeProvider = new TypeProvider((IServiceProvider)workflowView);
            typeProvider.AddAssemblyReference(@"..\..\..\CustomWorkflowLibrary\bin\Debug\CustomWorkflowLibrary.dll");
            designerHost.AddService(typeof(ITypeProvider), typeProvider);

            // (.NET 3.5 ReceiveActivity �� ServiceOperationInfo �𐳂����ݒ肵�Ȃ� (Validation Error �ƂȂ�) ���߈ȉ���lj�)
            SequentialWorkflowActivity rootActivity = (SequentialWorkflowActivity)designerHost.RootComponent;
            ReceiveActivity receiveActivity = (ReceiveActivity)rootActivity.Activities[0];
            TypedOperationInfo typedOperationInfo = new TypedOperationInfo();
            typedOperationInfo.ContractType = typeof(CustomWorkflowLibrary.IWorkflow1);
            typedOperationInfo.Name = "CalcData";
            receiveActivity.ServiceOperationInfo = typedOperationInfo;
        }
        private void UnloadWorkflow()
        {
            IDesignerHost designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost;
            if (designerHost != null && designerHost.Container.Components.Count > 0)
                WorkflowLoader.DestroyObjectGraphFromDesignerHost(designerHost, designerHost.RootComponent as Activity);
           
            if (this.designSurface != null)
            {
                this.designSurface.Dispose();
                this.designSurface = null;
            }

            if (this.workflowView != null)
            {
                Controls.Remove(this.workflowView);
                this.workflowView.Dispose();
                this.workflowView = null;
            }
        }
        private void LoadWorkflow()
        {
            SuspendLayout();
            
            DesignSurface designSurface = new DesignSurface();
            WorkflowLoader loader = new WorkflowLoader();
            loader.WorkflowType = workflowTypeValue;
            loader.Xaml = xamlValue;            
            designSurface.BeginLoad(loader);

            IDesignerHost designerHost = designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost;
            if (designerHost != null && designerHost.RootComponent != null)
            {
                IRootDesigner rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as IRootDesigner;
                if (rootDesigner != null)
                {
                    UnloadWorkflow();

                    this.designSurface = designSurface;
                    this.loader = loader;
                    this.workflowView = rootDesigner.GetView(ViewTechnology.Default) as WorkflowView;
                    this.panel1.Controls.Add(this.workflowView);
                    this.workflowView.Dock = DockStyle.Fill;
                    this.workflowView.TabIndex = 1;
                    this.workflowView.TabStop = true;
                    this.workflowView.HScrollBar.TabStop = false;
                    this.workflowView.VScrollBar.TabStop = false;
                    this.workflowView.Focus();
                    this.workflowView.FitToScreenSize();
                }
            }

            ResumeLayout(true);            
        }
 object IRootDesigner.GetView(ViewTechnology technology)
 {
     DesignSurface surface = GetService(typeof(DesignSurface)) as DesignSurface;
     IDesignerHost designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost;
     if (this.workflowView == null && surface != null && designerHost != null && designerHost.RootComponent == Activity)
         this.workflowView = CreateView(technology);
     return this.workflowView;
 }
 protected virtual WorkflowView CreateView(ViewTechnology viewTechnology)
 {
     WorkflowView workflowView = new WorkflowView(Activity.Site as IServiceProvider);
     workflowView.ShowToolContainer = true;
     return workflowView;
 }
            public WorkflowMessageDispatchData(WorkflowView workflowView, EventArgs e)
            {
                this.workflowView = workflowView;

                if (this.workflowView.RootDesigner != null && this.workflowView.stockMessageFilters.Count > 0)
                {
                    Point clientPoint = Point.Empty;
                    if (e is MouseEventArgs || e is DragEventArgs)
                    {
                        if (e is MouseEventArgs)
                        {
                            clientPoint = new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y);
                        }
                        else if (e is DragEventArgs)
                        {
                            clientPoint = this.workflowView.PointToClient(new Point(((DragEventArgs)e).X, ((DragEventArgs)e).Y));
                            this.workflowView.UpdateLayout();
                        }

                        Point logicalPoint = this.workflowView.ClientPointToLogical(clientPoint);
                        HitTestInfo hitTestInfo = this.workflowView.RootDesigner.HitTest(logicalPoint);
                        this.messageContext = (hitTestInfo != null) ? hitTestInfo : HitTestInfo.Nowhere;
                        this.workflowView.messageHitTestContexts.Push(this.messageContext);
                    }
                }
            }
Exemple #19
0
        private void Clear()
        {
            if (this.designSurface == null)
                return;
            else
                this.designSurface.Dispose();

            if (this.workflowView != null && Controls.Contains(this.workflowView))
                Controls.Remove(this.workflowView);
            this.workflowView = null;
        }
 internal static void TakeWorkflowSnapShot(WorkflowView workflowView, ViewPortData viewPortData)
 {
     Bitmap memoryBitmap = viewPortData.MemoryBitmap;
     using (Graphics graphics = Graphics.FromImage(memoryBitmap))
     {
         graphics.SmoothingMode = SmoothingMode.HighQuality;
         graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
         using (PaintEventArgs args = new PaintEventArgs(graphics, viewPortData.LogicalViewPort))
         {
             workflowView.ActiveLayout.OnPaint(args, viewPortData);
         }
         Matrix matrix = new Matrix();
         matrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);
         Point[] pts = new Point[] { viewPortData.LogicalViewPort.Location };
         matrix.TransformPoints(pts);
         matrix.Translate((float) (-pts[0].X + viewPortData.ShadowDepth.Width), (float) (-pts[0].Y + viewPortData.ShadowDepth.Height), MatrixOrder.Append);
         graphics.Transform = matrix;
         if (workflowView.RootDesigner != null)
         {
             using (Region region = new Region())
             {
                 using (GraphicsPath path = ActivityDesignerPaint.GetDesignerPath(workflowView.RootDesigner, false))
                 {
                     Region clip = graphics.Clip;
                     region.MakeEmpty();
                     region.Union(path);
                     graphics.Clip = region;
                     AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
                     graphics.FillRectangle(ambientTheme.BackgroundBrush, workflowView.RootDesigner.Bounds);
                     if (ambientTheme.ShowGrid)
                     {
                         ActivityDesignerPaint.DrawGrid(graphics, workflowView.RootDesigner.Bounds);
                     }
                     graphics.Clip = clip;
                     try
                     {
                         using (PaintEventArgs args2 = new PaintEventArgs(graphics, viewPortData.LogicalViewPort))
                         {
                             ((IWorkflowDesignerMessageSink) workflowView.RootDesigner).OnPaint(args2, viewPortData.LogicalViewPort);
                         }
                     }
                     catch (Exception)
                     {
                     }
                 }
             }
         }
         using (PaintEventArgs args3 = new PaintEventArgs(graphics, workflowView.RootDesigner.Bounds))
         {
             using (WorkflowMessageDispatchData data = new WorkflowMessageDispatchData(workflowView, EventArgs.Empty))
             {
                 foreach (WorkflowDesignerMessageFilter filter in data.Filters)
                 {
                     try
                     {
                         if (((IWorkflowDesignerMessageSink) filter).OnPaint(args3, viewPortData.LogicalViewPort))
                         {
                             goto Label_0230;
                         }
                     }
                     catch (Exception)
                     {
                     }
                 }
             }
         }
     Label_0230:
         graphics.Transform = new Matrix();
         if (!viewPortData.ShadowDepth.IsEmpty)
         {
             Bitmap image = new Bitmap(memoryBitmap);
             using (Brush brush = new SolidBrush(Color.FromArgb(220, Color.White)))
             {
                 graphics.FillRectangle(brush, new Rectangle(Point.Empty, new Size((memoryBitmap.Size.Width - viewPortData.ShadowDepth.Width) - 1, (memoryBitmap.Size.Height - viewPortData.ShadowDepth.Height) - 1)));
             }
             ImageAttributes imageAttr = new ImageAttributes();
             imageAttr.SetColorKey(viewPortData.TransparentColor, viewPortData.TransparentColor, ColorAdjustType.Default);
             imageAttr.SetColorKey(viewPortData.TransparentColor, viewPortData.TransparentColor, ColorAdjustType.Bitmap);
             graphics.DrawImage(image, new Rectangle(-viewPortData.ShadowDepth.Width, -viewPortData.ShadowDepth.Height, memoryBitmap.Width, memoryBitmap.Height), 0, 0, memoryBitmap.Width, memoryBitmap.Height, GraphicsUnit.Pixel, imageAttr);
             image.Dispose();
         }
     }
 }
 internal void SetParentView(WorkflowView parentView)
 {
     this.Initialize(parentView);
 }
 protected virtual void Initialize(WorkflowView parentView)
 {
     this.parentView = parentView;
 }
        /// <summary>
        /// Display the specified workflow type.
        /// </summary>
        /// <param name="root">Type of the workflow.</param>
        public void DisplayType(Type root)
        {
            if (!typeof(Activity).IsAssignableFrom(root))
            {
                throw new ArgumentException("WorkflowViewPanel only supports displaying Activity objects.", "root");
            }

            this.surface = new DesignSurface();
            
            this.host = this.surface.GetService(typeof(IDesignerHost)) as IDesignerHost;

            TypeProvider provider = new TypeProvider(this.surface);
            provider.AddAssembly(typeof(string).Assembly);
            IServiceContainer container = this.surface.GetService(typeof(IServiceContainer)) as IServiceContainer;
            container.AddService(typeof(ITypeProvider), provider);

            if (this.host == null)
            {
                throw new ApplicationException("Cannot work with a null host.");
            }

            Queue<Activity> toProcess = new Queue<Activity>();

            try
            {
                toProcess.Enqueue((Activity)root.InvokeMember(string.Empty, System.Reflection.BindingFlags.CreateInstance, null, null, null, CultureInfo.InvariantCulture));
            }
            catch (Exception exc)
            {
                MessageBox.Show("Could not load workflow type: " + exc.ToString());
                this.surface = null;
                this.host = null;
                return;
            }

            // Do a non-recursive walk of the activity
            // tree to display all activities.
            while (toProcess.Count > 0)
            {
                Activity activity = toProcess.Dequeue();
                host.Container.Add(activity, activity.QualifiedName);

                if (activity is CompositeActivity)
                {
                    foreach (Activity child in ((CompositeActivity)activity).Activities)
                    {
                        toProcess.Enqueue(child);
                    }
                }
            }

            this.surface.BeginLoad(new WorkflowLoader());

            workflowView = new MouseDisabledWorkflowView(host as IServiceProvider);
            workflowView.Dock = DockStyle.Fill;

            this.Controls.Add(workflowView);
        }
        public CommandSet(IServiceProvider serviceProvider)
        {
            Debug.Assert(serviceProvider != null);
            this.serviceProvider = serviceProvider;

            this.menuCommandService = (IMenuCommandService)this.serviceProvider.GetService(typeof(IMenuCommandService));
            if (this.menuCommandService == null)
                throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(IMenuCommandService).FullName));

            this.workflowView = serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;
            if (this.workflowView == null)
                throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(WorkflowView).FullName));

            this.selectionService = (ISelectionService)this.serviceProvider.GetService(typeof(ISelectionService));
            if (this.selectionService == null)
                throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(ISelectionService).FullName));

            this.commandSet = new List<CommandSetItem>();
            this.commandSet.AddRange(new CommandSetItem[] {
                        //Save commands
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnMenuSaveWorkflowAsImage), WorkflowMenuCommands.SaveAsImage), 
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnMenuCopyToClipboard), WorkflowMenuCommands.CopyToClipboard), 

                        // Printing commands
                        new CommandSetItem(new EventHandler(OnStatusPrint), new EventHandler(OnMenuPrint), WorkflowMenuCommands.Print), 
                        new CommandSetItem(new EventHandler(OnStatusPageSetup), new EventHandler(OnMenuPageSetup), WorkflowMenuCommands.PageSetup), 

                        // Editing commands
                        new CommandSetItem(new EventHandler(OnStatusDelete), new EventHandler(OnMenuDelete), MenuCommands.Delete), 
                        new CommandSetItem(new EventHandler(OnStatusCopy), new EventHandler(OnMenuCopy), MenuCommands.Copy), 
                        new CommandSetItem(new EventHandler(OnStatusCut), new EventHandler(OnMenuCut), MenuCommands.Cut), 
                        new CommandSetItem(new EventHandler(OnStatusPaste), new EventHandler(OnMenuPaste), MenuCommands.Paste, true),
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnMenuSelectAll), MenuCommands.SelectAll),

                        // Properties
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnMenuDesignerProperties), WorkflowMenuCommands.DesignerProperties),

                        // IMPORTANT: [....] does not handle this command, so VS.NET sends it to solution explorer
                        // window, which enables this meu item on the for the current file node
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnViewCode), new CommandID(StandardCommands.Cut.Guid, 333)),

                        // Keyboard commands
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnKeyCancel), MenuCommands.KeyCancel), 
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnKeyCancel), MenuCommands.KeyReverseCancel), 
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnKeyMove), MenuCommands.KeyMoveUp), 
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnKeyMove), MenuCommands.KeyMoveDown), 
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnKeyMove), MenuCommands.KeyMoveLeft), 
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnKeyMove), MenuCommands.KeyMoveRight),
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnKeyMove), MenuCommands.KeySelectNext), 
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnKeyMove), MenuCommands.KeySelectPrevious),
                        new CommandSetItem(new EventHandler(OnStatusExpandCollapse), new EventHandler(OnExpandCollapse), WorkflowMenuCommands.Expand),
                        new CommandSetItem(new EventHandler(OnStatusExpandCollapse), new EventHandler(OnExpandCollapse), WorkflowMenuCommands.Collapse),
                        new CommandSetItem(new EventHandler(OnStatusEnable), new EventHandler(OnEnable), WorkflowMenuCommands.Disable, true),
                        new CommandSetItem(new EventHandler(OnStatusEnable), new EventHandler(OnEnable), WorkflowMenuCommands.Enable, true),
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnCreateTheme), WorkflowMenuCommands.CreateTheme),
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnChangeTheme), WorkflowMenuCommands.ChangeTheme),
                        new CommandSetItem(new EventHandler(OnStatusAnySelection), new EventHandler(OnKeyDefault), MenuCommands.KeyDefaultAction),
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnKeyPageDnUp), WorkflowMenuCommands.PageUp),
                        new CommandSetItem(new EventHandler(OnStatusAlways), new EventHandler(OnKeyPageDnUp), WorkflowMenuCommands.PageDown),

                    });


            //WorkflowView commands
            this.zoomCommands = new CommandSetItem[] 
                    {
                        new CommandSetItem(new EventHandler(OnStatusZoom), new EventHandler(OnZoom), WorkflowMenuCommands.Zoom400Mode, DR.GetString(DR.Zoom400Mode)),
                        new CommandSetItem(new EventHandler(OnStatusZoom), new EventHandler(OnZoom), WorkflowMenuCommands.Zoom300Mode, DR.GetString(DR.Zoom300Mode)),
                        new CommandSetItem(new EventHandler(OnStatusZoom), new EventHandler(OnZoom), WorkflowMenuCommands.Zoom200Mode, DR.GetString(DR.Zoom200Mode)),
                        new CommandSetItem(new EventHandler(OnStatusZoom), new EventHandler(OnZoom), WorkflowMenuCommands.Zoom150Mode, DR.GetString(DR.Zoom150Mode)),
                        new CommandSetItem(new EventHandler(OnStatusZoom), new EventHandler(OnZoom), WorkflowMenuCommands.Zoom100Mode, DR.GetString(DR.Zoom100Mode)),
                        new CommandSetItem(new EventHandler(OnStatusZoom), new EventHandler(OnZoom), WorkflowMenuCommands.Zoom75Mode, DR.GetString(DR.Zoom75Mode)),
                        new CommandSetItem(new EventHandler(OnStatusZoom), new EventHandler(OnZoom), WorkflowMenuCommands.Zoom50Mode, DR.GetString(DR.Zoom50Mode)),
                        new CommandSetItem(new EventHandler(OnStatusZoom), new EventHandler(OnZoom), WorkflowMenuCommands.ShowAll, DR.GetString(DR.ZoomShowAll)),
                    };
            this.commandSet.AddRange(this.zoomCommands);

            this.layoutCommands = new CommandSetItem[] 
                    {
                        new CommandSetItem(new EventHandler(OnStatusLayout), new EventHandler(OnPageLayout), WorkflowMenuCommands.DefaultPage), 
                        new CommandSetItem(new EventHandler(OnStatusLayout), new EventHandler(OnPageLayout), WorkflowMenuCommands.PrintPreviewPage), 
                        new CommandSetItem(new EventHandler(OnStatusLayout), new EventHandler(OnPageLayout), WorkflowMenuCommands.PrintPreview),
                    };
            this.commandSet.AddRange(this.layoutCommands);

            this.navigationToolCommands = new CommandSetItem[] 
                    {
                        new CommandSetItem(new EventHandler(OnStatusMessageFilter), new EventHandler(OnMessageFilterChanged), NavigationToolCommandIds[0]), 
                        new CommandSetItem(new EventHandler(OnStatusMessageFilter), new EventHandler(OnMessageFilterChanged), NavigationToolCommandIds[1]),
                        new CommandSetItem(new EventHandler(OnStatusMessageFilter), new EventHandler(OnMessageFilterChanged), NavigationToolCommandIds[2]), 
                        new CommandSetItem(new EventHandler(OnStatusMessageFilter), new EventHandler(OnMessageFilterChanged), NavigationToolCommandIds[3]),
                    };

            this.commandSet.AddRange(this.navigationToolCommands);

            // add all menu commands
            for (int i = 0; i < this.commandSet.Count; i++)
            {
                if (this.menuCommandService.FindCommand(this.commandSet[i].CommandID) == null)
                    this.menuCommandService.AddCommand(this.commandSet[i]);
            }

            IComponentChangeService changeService = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
            if (changeService != null)
                changeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);

            // Now setup the default command GUID for this designer.  This GUID is also used in our toolbar
            // definition file to identify toolbars we own.  We store the GUID in a command ID here in the
            // dictionary of the root component.  Our host may pull this GUID out and use it.
            IDictionaryService ds = this.serviceProvider.GetService(typeof(IDictionaryService)) as IDictionaryService;
            if (ds != null)
                ds.SetValue(typeof(CommandID), new CommandID(new Guid("5f1c3c8d-60f1-4b98-b85b-8679f97e8eac"), 0));
        }
 public WorkflowPrintDocument(WorkflowView workflowView)
 {
     this.workflowView = workflowView;
     this.previewLayout = new System.Workflow.ComponentModel.Design.PrintPreviewLayout(this.workflowView, this);
 }
 public WorkflowMessageDispatchData(WorkflowView workflowView, EventArgs e)
 {
     this.workflowView = workflowView;
     if ((this.workflowView.RootDesigner != null) && (this.workflowView.stockMessageFilters.Count > 0))
     {
         Point empty = Point.Empty;
         if ((e is MouseEventArgs) || (e is DragEventArgs))
         {
             if (e is MouseEventArgs)
             {
                 empty = new Point(((MouseEventArgs) e).X, ((MouseEventArgs) e).Y);
             }
             else if (e is DragEventArgs)
             {
                 empty = this.workflowView.PointToClient(new Point(((DragEventArgs) e).X, ((DragEventArgs) e).Y));
                 this.workflowView.UpdateLayout();
             }
             Point point = this.workflowView.ClientPointToLogical(empty);
             System.Workflow.ComponentModel.Design.HitTestInfo info = this.workflowView.RootDesigner.HitTest(point);
             this.messageContext = (info != null) ? info : System.Workflow.ComponentModel.Design.HitTestInfo.Nowhere;
             this.workflowView.messageHitTestContexts.Push(this.messageContext);
         }
     }
 }
Exemple #27
0
        // Loads precreated workflow. The function is similar to the above function except
        // instead of creating an empty workflow we create workflow with contents
        internal void LoadDefaultWorkflow()
        {
            Clear();

            this.designSurface = new WorkflowDesignSurface(this);
            WorkflowLoader loader = new WorkflowLoader();
            this.designSurface.BeginLoad(loader);
            
            this.designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost;
            if (this.designerHost != null)
            {
                this.rootActivity = (SequentialWorkflowActivity)this.designerHost.CreateComponent(typeof(SequentialWorkflowActivity));
                this.rootActivity.Name = "Service1";

                CodeActivity codeActivity1 = new CodeActivity();
                this.rootActivity.Activities.Add(codeActivity1);
                this.designerHost.RootComponent.Site.Container.Add(codeActivity1);

                this.workflowView = new WorkflowView(this.designSurface as IServiceProvider);
                this.workflowView.AddDesignerMessageFilter(new CustomMessageFilter(this.designSurface as IServiceProvider, this.workflowView, loader));

                Controls.Add(this.workflowView);
                this.designerHost.Activate();

                ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService));
                if (selectionService != null)
                {
                    selectionService.SelectionChanged += new EventHandler(OnSelectionChanged);
                    IComponent[] selection = new IComponent[] { rootActivity };
                    selectionService.SetSelectedComponents(selection);
                }
            }
        }
        /// <summary>
        /// Disposes the resources held by the designer.
        /// </summary>
        /// <param name="disposing">True if the designer is being disposed, false if the designer is being finalized.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (IsRootDesigner)
                {
                    if (this.workflowView != null)
                    {
                        this.workflowView.Dispose();
                        this.workflowView = null;
                    }

                    IDesignerHost designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost;
                    if (designerHost != null && InvokingDesigner == null && Activity == designerHost.RootComponent)
                        designerHost.LoadComplete -= new EventHandler(OnLoadComplete);

                    IComponentChangeService changeService = GetService(typeof(IComponentChangeService)) as IComponentChangeService;
                    if (changeService != null)
                    {
                        changeService.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged);
                        changeService.ComponentRename -= new ComponentRenameEventHandler(OnComponentRenamed);
                    }
                }
            }
        }
Exemple #29
0
 public CustomMessageFilter(IServiceProvider provider, WorkflowView workflowView, WorkflowDesignerLoader loader)
 {
     this.serviceProvider = provider;
     this.workflowView = workflowView;
     this.loader = loader;
 }
        //This function will give snapshot of what is drawn on the screen at any point of time
        //It will scale and translate the designers and drawing based on the viewport data
        //We need this function in OnPaint and taking snapshot of magnifier bitmap
        //At the end of this function; the ViewPortData.MemoryBitmap will contain the bitmap of the 
        //workflow to be drawn as per layout
        internal static void TakeWorkflowSnapShot(WorkflowView workflowView, ViewPortData viewPortData)
        {
            //Get the drawing canvas
            Bitmap memoryBitmap = viewPortData.MemoryBitmap;
            Debug.Assert(memoryBitmap != null);

            using (Graphics viewPortGraphics = Graphics.FromImage(memoryBitmap))
            {
                //We set the highest quality interpolation so that we do not loose the image quality
                viewPortGraphics.SmoothingMode = SmoothingMode.HighQuality;
                viewPortGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

                using (PaintEventArgs eventArgs = new PaintEventArgs(viewPortGraphics, viewPortData.LogicalViewPort))
                {
                    workflowView.ActiveLayout.OnPaint(eventArgs, viewPortData);
                }

                //Create the scaling matrix 
                Matrix transformationMatrix = new Matrix();
                transformationMatrix.Scale(viewPortData.Scaling.Width, viewPortData.Scaling.Height, MatrixOrder.Prepend);

                //When we draw on the viewport we draw in scaled and translated. 
                //So that we minimize the calls to DrawImage
                //Make sure that we scale down the logical view port origin in order to take care of scaling factor
                //Before we select the transform factor we make sure that logicalviewport origin is scaled down
                Point[] logicalViewPortOrigin = new Point[] { viewPortData.LogicalViewPort.Location };
                transformationMatrix.TransformPoints(logicalViewPortOrigin);

                //For performance improvement and to eliminate one extra DrawImage...we draw the designers on the viewport
                //bitmap with visual depth consideration
                transformationMatrix.Translate(-logicalViewPortOrigin[0].X + viewPortData.ShadowDepth.Width, -logicalViewPortOrigin[0].Y + viewPortData.ShadowDepth.Height, MatrixOrder.Append);

                //Select the transform into viewport graphics.
                //Viewport bitmap has the scaled and translated designers which we then map to
                //the actual graphics based on page layout
                viewPortGraphics.Transform = transformationMatrix;

                //Draw the designers on bitmap
                if (workflowView.RootDesigner != null)
                {
                    using (Region clipRegion = new Region())
                    using (GraphicsPath designerPath = ActivityDesignerPaint.GetDesignerPath(workflowView.RootDesigner, false))
                    {
                        Region oldRegion = viewPortGraphics.Clip;

                        //First draw the grid and rectangle with the designer clip region
                        clipRegion.MakeEmpty();
                        clipRegion.Union(designerPath);
                        viewPortGraphics.Clip = clipRegion;
                        AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
                        viewPortGraphics.FillRectangle(ambientTheme.BackgroundBrush, workflowView.RootDesigner.Bounds);
                        if (ambientTheme.ShowGrid)
                            ActivityDesignerPaint.DrawGrid(viewPortGraphics, workflowView.RootDesigner.Bounds);
                        viewPortGraphics.Clip = oldRegion;

                        //Then draw the root with clip region extended
                        try
                        {
                            using (PaintEventArgs paintEventArgs = new PaintEventArgs(viewPortGraphics, viewPortData.LogicalViewPort))
                            {
                                ((IWorkflowDesignerMessageSink)workflowView.RootDesigner).OnPaint(paintEventArgs, viewPortData.LogicalViewPort);
                            }
                        }
                        catch (Exception e)
                        {
                            //Eat the exception thrown in draw
                            Debug.WriteLine(e);
                        }
                    }
                }

                //Draw all the filters


                using (PaintEventArgs paintArgs = new PaintEventArgs(viewPortGraphics, workflowView.RootDesigner.Bounds))
                {
                    using (WorkflowMessageDispatchData dispatchData = new WorkflowMessageDispatchData(workflowView, EventArgs.Empty))
                    {
                        foreach (WorkflowDesignerMessageFilter filter in dispatchData.Filters)
                        {
                            try
                            {
                                if (((IWorkflowDesignerMessageSink)filter).OnPaint(paintArgs, viewPortData.LogicalViewPort))
                                    break;
                            }
                            catch (Exception e)
                            {
                                Debug.WriteLine(e);
                            }
                        }
                    }
                }

                viewPortGraphics.Transform = new Matrix();

                //Now that we have a bitmap which is bit offseted based visual depth we need to take copy of it
                //This is done so as to avoid expensive DrawImage call, what I am assuming here is that time it 
                //will take to create a new bitmap from an existing one is less expensive in terms of speed than space
                //As you just need to copy bitmap bits in memory than to perform expesive Image Drawing operation
                if (!viewPortData.ShadowDepth.IsEmpty)
                {
                    Bitmap temporaryBitmap = new Bitmap(memoryBitmap);

                    //THEMETODO: WE JUST NEED TO GRAYSCALE THIS, RATHER THAN DRAWING A SHADOW
                    //Now that we have taken a copy we will draw over the existing bitmap so that we can make it as shadow bitmap
                    using (Brush shadowDepthBrush = new SolidBrush(Color.FromArgb(220, Color.White)))
                        viewPortGraphics.FillRectangle(shadowDepthBrush, new Rectangle(Point.Empty, new Size(memoryBitmap.Size.Width - viewPortData.ShadowDepth.Width - 1, memoryBitmap.Size.Height - viewPortData.ShadowDepth.Height - 1)));

                    //Now make sure that we draw the image from the temporary bitmap with white color set as transparent 
                    //so that we achive the 3D effect
                    //Make sure that we take into consideration the transparency key
                    ImageAttributes transparentColorKey = new ImageAttributes();
                    transparentColorKey.SetColorKey(viewPortData.TransparentColor, viewPortData.TransparentColor, ColorAdjustType.Default);
                    transparentColorKey.SetColorKey(viewPortData.TransparentColor, viewPortData.TransparentColor, ColorAdjustType.Bitmap);
                    viewPortGraphics.DrawImage(temporaryBitmap, new Rectangle(-viewPortData.ShadowDepth.Width, -viewPortData.ShadowDepth.Height, memoryBitmap.Width, memoryBitmap.Height), 0, 0, memoryBitmap.Width, memoryBitmap.Height, GraphicsUnit.Pixel, transparentColorKey);

                    //Now dispose the temporary bitmap
                    temporaryBitmap.Dispose();
                }
            }
        }