public BIDSHelperConfigurationAdorner(FrameworkElement adornedElement, Type type)
            : base(adornedElement)
        {
            this.m_images = new List<Tuple<Point, ImageSource>>();

            if (adornedElement == null)
            {
                throw new ArgumentNullException("adornedElement");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            this.m_type = type;
            this.m_tag = this.GetType().FullName;
            this.m_view = adornedElement;
            this.m_adornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);
            if (this.m_adornerLayer == null)
            {
                return;
            }
            System.Windows.Documents.Adorner[] adorners = this.m_adornerLayer.GetAdorners(adornedElement);
            if (adorners != null)
            {
                foreach (System.Windows.Documents.Adorner adorner in adorners)
                {
                    if (Convert.ToString(adorner.Tag) == Convert.ToString(m_tag))
                    {
                        this.m_adorner = (BIDSHelperConfigurationAdorner)adorner;
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        public BIDSHelperConfigurationAdorner(FrameworkElement adornedElement, Type type)
            : base(adornedElement)
        {
            this.m_images = new List <Tuple <Point, ImageSource> >();

            if (adornedElement == null)
            {
                throw new ArgumentNullException("adornedElement");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            this.m_type         = type;
            this.m_tag          = this.GetType().FullName;
            this.m_view         = adornedElement;
            this.m_adornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);
            if (this.m_adornerLayer == null)
            {
                return;
            }
            System.Windows.Documents.Adorner[] adorners = this.m_adornerLayer.GetAdorners(adornedElement);
            if (adorners != null)
            {
                foreach (System.Windows.Documents.Adorner adorner in adorners)
                {
                    if (Convert.ToString(adorner.Tag) == Convert.ToString(m_tag))
                    {
                        this.m_adorner = (BIDSHelperConfigurationAdorner)adorner;
                        break;
                    }
                }
            }
        }
Esempio n. 3
0
 private void DetachAdorner()
 {
     if ((this.m_adornerLayer != null) && (this.m_adorner != null))
     {
         this.m_adornerLayer.Remove(this.m_adorner);
         this.m_adornerLayer.Update();
         this.m_adorner = null;
     }
 }
Esempio n. 4
0
        public override void Highlight()
        {
            List <string> listConfigPaths;

            lock (cacheConfigPaths)
            {
                if (cacheConfigPaths.ContainsKey(package))
                {
                    listConfigPaths = cacheConfigPaths[package];
                }
                else
                {
                    listConfigPaths = new List <string>();
                }
            }

            CachedHighlightStatus status = null;

            if (!cacheTransforms.TryGetValue(transformUniqueID, out status) || Rescan)
            {
                bool bHasConfiguration = false;
                bool bHasExpression    = HasExpression(taskHost, transformName, listConfigPaths, out bHasConfiguration);
                status = new CachedHighlightStatus(package, taskHost, bHasExpression, bHasConfiguration);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("highlighting from cache for: " + transformUniqueID);
            }

#if DENALI || SQL2014
            this.dataFlowTransformModelElement.Dispatcher.BeginInvoke //enables this code to run on the application thread or something like that and avoids errors
                (System.Windows.Threading.DispatcherPriority.Normal,
                (Action)(() =>
            {
                System.Windows.FrameworkElement fe = (System.Windows.FrameworkElement) this.dataFlowTransformModelElement.View;
                if (fe != null)     //the sequence container for the Package object itself has a null view. TODO is how to add a configuration highlight to the background of the package itself
                {
                    Adorners.BIDSHelperConfigurationAdorner adorner = new Adorners.BIDSHelperConfigurationAdorner(fe, typeof(Microsoft.SqlServer.Graph.Model.ModelElement));
                    adorner.UpdateAdorner(status.bHasExpression, status.bHasConfiguration);
                }
            }
                         ));
#else
            HighlightDdsDiagramObjectIcon(dataFlowDiagram, transformManagedShape, status.bHasExpression, status.bHasConfiguration);
#endif

            if (cacheTransforms.ContainsKey(transformUniqueID))
            {
                cacheTransforms[transformUniqueID] = status;
            }
            else
            {
                cacheTransforms.Add(transformUniqueID, status);
            }
        }
        public void UpdateAdorner(bool bHasExpression, bool bHasConfiguration)
        {
            if (!bHasExpression && !bHasConfiguration)
            {
                DetachAdorner();
                return;
            }

            if (this.m_adornerLayer != null)
            {
                if (this.m_adorner == null)
                {
                    this.m_adorner = this;
                    m_adorner.Tag = this.m_tag;
                    this.m_adornerLayer.Add(this.m_adorner);
                }

                m_adorner.Images.Clear();
                System.Windows.Media.Imaging.BitmapSource s_Icon;
                if (bHasExpression && bHasConfiguration)
                {
                    s_Icon = HighlightingToDo.GetBitmapSource(ExpressionHighlighterPlugin.ExpressionColor, ExpressionHighlighterPlugin.ConfigurationColor);
                    m_adorner.ToolTip = "Controlled by expression and configuration";
                }
                else if (bHasExpression)
                {
                    s_Icon = HighlightingToDo.GetBitmapSource(ExpressionHighlighterPlugin.ExpressionColor);
                    m_adorner.ToolTip = "Controlled by expression";
                }
                else
                {
                    s_Icon = HighlightingToDo.GetBitmapSource(ExpressionHighlighterPlugin.ConfigurationColor);
                    m_adorner.ToolTip = "Controlled by configuration";
                }

                m_adorner.Images.Add(new Tuple<Point, System.Windows.Media.ImageSource>(GetImagePosition(), s_Icon));
                m_adorner.InvalidateVisual();
                this.m_adornerLayer.UpdateLayout();
            }
        }
Esempio n. 6
0
        public void UpdateAdorner(bool bHasExpression, bool bHasConfiguration)
        {
            if (!bHasExpression && !bHasConfiguration)
            {
                DetachAdorner();
                return;
            }

            if (this.m_adornerLayer != null)
            {
                if (this.m_adorner == null)
                {
                    this.m_adorner = this;
                    m_adorner.Tag  = this.m_tag;
                    this.m_adornerLayer.Add(this.m_adorner);
                }

                m_adorner.Images.Clear();
                System.Windows.Media.Imaging.BitmapSource s_Icon;
                if (bHasExpression && bHasConfiguration)
                {
                    s_Icon            = HighlightingToDo.GetBitmapSource(ExpressionHighlighterPlugin.ExpressionColor, ExpressionHighlighterPlugin.ConfigurationColor);
                    m_adorner.ToolTip = "Controlled by expression and configuration";
                }
                else if (bHasExpression)
                {
                    s_Icon            = HighlightingToDo.GetBitmapSource(ExpressionHighlighterPlugin.ExpressionColor);
                    m_adorner.ToolTip = "Controlled by expression";
                }
                else
                {
                    s_Icon            = HighlightingToDo.GetBitmapSource(ExpressionHighlighterPlugin.ConfigurationColor);
                    m_adorner.ToolTip = "Controlled by configuration";
                }

                m_adorner.Images.Add(new Tuple <Point, System.Windows.Media.ImageSource>(GetImagePosition(), s_Icon));
                m_adorner.InvalidateVisual();
                this.m_adornerLayer.UpdateLayout();
            }
        }
Esempio n. 7
0
        public override void Highlight()
        {
            List <string> listConfigPaths;

            lock (cacheConfigPaths)
            {
                if (cacheConfigPaths.ContainsKey(package))
                {
                    listConfigPaths = cacheConfigPaths[package];
                }
                else
                {
                    listConfigPaths = new List <string>();
                }
            }

            bool bHasConfiguration = false;
            bool bHasExpression    = false;

            if (Rescan || !cacheConnectionManagers.ContainsKey(connection)) //note this is not allowing highlighting of connections on event handlers tab since the event handlers tab is not loaded when you first load the package... TODO... consider changing the cacheConnectionManagers object to track which tabs have been highlighted before
            {
                System.Diagnostics.Debug.WriteLine("scanning connection manager for expressions & configurations");
                bHasExpression = HasExpression(connection, listConfigPaths, out bHasConfiguration); //also figures out whether it has configurations
                if (cacheConnectionManagers.ContainsKey(connection))
                {
                    cacheConnectionManagers[connection] = new CachedHighlightStatus(this.package, bHasExpression, bHasConfiguration);
                }
                else
                {
                    lock (cacheConnectionManagers)
                        cacheConnectionManagers.Add(connection, new CachedHighlightStatus(this.package, bHasExpression, bHasConfiguration));
                }
            }
            else
            {
                CachedHighlightStatus ccm = cacheConnectionManagers[connection];
                bHasExpression    = ccm.bHasExpression;
                bHasConfiguration = ccm.bHasConfiguration;
                System.Diagnostics.Debug.WriteLine("scanning connection manager for expressions & configurations from cache");
            }

            lock (listConnectionLVIs)
            {
                foreach (System.Windows.FrameworkElement fe in listConnectionLVIs)
                {
                    if (fe != null)
                    {
                        fe.Dispatcher.BeginInvoke //enables this code to run on the application thread or something like that and avoids errors
                            (System.Windows.Threading.DispatcherPriority.Normal,
                            (Action)(() =>
                        {
                            System.Diagnostics.Debug.WriteLine("ExpressionHighlighter - adding connection adorner " + connection.Name);
                            Adorners.BIDSHelperConfigurationAdorner adorner = new Adorners.BIDSHelperConfigurationAdorner(fe, typeof(ConnectionManagerModelElement));
                            adorner.UpdateAdorner(false, bHasConfiguration);     //only highlight configurations
                        }
                                     ));
                    }
                }
            }

            //the lvwConnMgrs_DrawItem event will take care of painting the connection managers 90% of the time
            //unfortunately we had to use the lvwConnMgrs_DrawItem to catch all the appropriate times we needed to refix the icon
        }
Esempio n. 8
0
        public override void Highlight()
        {
            List <string> listConfigPaths;

            lock (cacheConfigPaths)
            {
                if (cacheConfigPaths.ContainsKey(package))
                {
                    listConfigPaths = cacheConfigPaths[package];
                }
                else
                {
                    listConfigPaths = new List <string>();
                }
            }

            CachedHighlightStatus status = null;

            if (!cacheTasks.TryGetValue(executable, out status) || Rescan)
            {
                if (AllTransformsAreCached(transforms)) //all transforms should be cached if we're focused on the data flow window such that transforms are foreground tasks and the control flow task is a background task
                {
                    bool bTaskHasExpression    = false;
                    bool bTaskHasConfiguration = false;

                    lock (transforms)
                    {
                        foreach (string str in transforms)
                        {
                            CachedHighlightStatus transformStatus = cacheTransforms[str];
                            bTaskHasExpression    = bTaskHasExpression || transformStatus.bHasExpression;
                            bTaskHasConfiguration = bTaskHasConfiguration || transformStatus.bHasConfiguration;
                        }
                    }

                    status = new CachedHighlightStatus(package, bTaskHasExpression, bTaskHasConfiguration);
                    System.Diagnostics.Debug.WriteLine("highlighting data flow task from transforms cache");
                }
                else
                {
                    bool bHasConfiguration = false;
                    bool bHasExpression    = HasExpression(executable, listConfigPaths, out bHasConfiguration);
                    status = new CachedHighlightStatus(package, bHasExpression, bHasConfiguration);
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("highlighting task from cache");
            }

            this.controlFlowTaskModelElement.Dispatcher.BeginInvoke //enables this code to run on the application thread or something like that and avoids errors
                (System.Windows.Threading.DispatcherPriority.Normal,
                (Action)(() =>
            {
                System.Windows.FrameworkElement fe = (System.Windows.FrameworkElement) this.controlFlowTaskModelElement.View;
                if (fe != null)     //the sequence container for the Package object itself has a null view. TODO is how to add a configuration highlight to the background of the package itself... this seems to do the trick but there's more formatting work to do: fe = (System.Windows.FrameworkElement)(((Microsoft.SqlServer.IntegrationServices.Designer.Model.SequenceModelElement)(controlFlowTaskModelElement)).GraphModelElement).GraphControl
                {
                    System.Diagnostics.Debug.WriteLine("ExpressionHighlighter - adding task adorner " + controlFlowTaskModelElement.Name);
                    Adorners.BIDSHelperConfigurationAdorner adorner = new Adorners.BIDSHelperConfigurationAdorner(fe, typeof(Microsoft.SqlServer.Graph.Model.ModelElement));
                    adorner.UpdateAdorner(false, status.bHasConfiguration);     //only highlight configurations
                }
            }
                         ));


            if (cacheTasks.ContainsKey(executable))
            {
                cacheTasks[executable] = status;
            }
            else
            {
                cacheTasks.Add(executable, status);
            }
        }
 private void DetachAdorner()
 {
     if ((this.m_adornerLayer != null) && (this.m_adorner != null))
     {
         this.m_adornerLayer.Remove(this.m_adorner);
         this.m_adornerLayer.Update();
         this.m_adorner = null;
     }
 }