Пример #1
0
        public CodeAdornment(IWpfTextView view)
        {
            _view           = view;
            _sourceFilePath = GetSourceFilePath();
            _adornmentLayer = view.GetAdornmentLayer("CodeAdornment");

            _adornmentLayer.RemoveAllAdornments();
            containingUnitView = ContainingUnitView.GetContainingUnitViewByName(_sourceFilePath);

            if (containingUnitView.Parent != null)
            {
                var adornmentLayer = (IAdornmentLayer)containingUnitView.Parent;
                adornmentLayer.RemoveAdornment(containingUnitView);
            }

            //TODO Some how anchor the adornment layer to prevent random moving.
            Canvas.SetTop(containingUnitView, 0);
            _adornmentLayer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, null, containingUnitView, null);

            // _view.ViewportWidthChanged += delegate { Initialize(); };
            //_view.ViewportHeightChanged += delegate { Initialize(); };
            //    _view.LayoutChanged += delegate { Initialize(); };
            //   _view.ViewportLeftChanged += delegate { Initialize(); };
            //   _view.ZoomLevelChanged += delegate { Initialize(); };
            // _view.VisualElement.SizeChanged +=delegate { Initialize(); };
        }
Пример #2
0
        public CodeAdornment(IWpfTextView view)
        {
            _view = view;
            _sourceFilePath = GetSourceFilePath();
            _adornmentLayer = view.GetAdornmentLayer("CodeAdornment");

            _adornmentLayer.RemoveAllAdornments();
            containingUnitView = ContainingUnitView.GetContainingUnitViewByName(_sourceFilePath);

            if (containingUnitView.Parent != null)
            {
                var adornmentLayer = (IAdornmentLayer)containingUnitView.Parent;
                adornmentLayer.RemoveAdornment(containingUnitView);
            }

            //TODO Some how anchor the adornment layer to prevent random moving.
            Canvas.SetTop(containingUnitView, 0);
            _adornmentLayer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, null, containingUnitView, null);

            // _view.ViewportWidthChanged += delegate { Initialize(); };
            //_view.ViewportHeightChanged += delegate { Initialize(); };
            //    _view.LayoutChanged += delegate { Initialize(); };
            //   _view.ViewportLeftChanged += delegate { Initialize(); };
            //   _view.ZoomLevelChanged += delegate { Initialize(); };
            // _view.VisualElement.SizeChanged +=delegate { Initialize(); };
        }
 public static void UpdateDataOfContainingUnits(IEnumerable<ContainingUnitViewModel> cuvModels)
 {
     foreach (var cuvModel in cuvModels)
     {
         ContainingUnitView containingUnitView = GetContainingUnitViewByName(cuvModel.Name);
         containingUnitView.DataContext = cuvModel;
     }
 }
        public static ContainingUnitView GetContainingUnitViewByName(string name)
        {
            string nameLowerCase = name.ToLower();
            ContainingUnitView cuv;
            bool found = ContainingUnitsDict.TryGetValue(nameLowerCase, out cuv);
            if(!found)
            {
                cuv = new ContainingUnitView();
                ContainingUnitsDict[nameLowerCase] = cuv;
            }

            return cuv;
        }
        public static ContainingUnitView GetContainingUnitViewByName(string name)
        {
            string nameLowerCase = name.ToLower();
            ContainingUnitView cuv;
            bool found = ContainingUnitsDict.TryGetValue(nameLowerCase, out cuv);
            if(!found)
            {
                cuv = new ContainingUnitView();
                ContainingUnitsDict[nameLowerCase] = cuv;
            }

            return cuv;
        }