Пример #1
0
        private Setting GetConfigFromVisualStudioSettings()
        {
            try
            {
                var config = new Setting();

                var _DTE2 = (DTE2)ServiceProvider.GetService(typeof(DTE));
                var props = _DTE2.Properties["ClaudiaIDE", "General"];

                config.BackgroundImagesDirectoryAbsolutePath = Setting.ToFullPath(props.Item("BackgroundImageDirectoryAbsolutePath").Value);
                config.BackgroundImageAbsolutePath = Setting.ToFullPath(props.Item("BackgroundImageAbsolutePath").Value);
                config.Opacity = props.Item("Opacity").Value;
                config.PositionHorizon = (PositionH)props.Item("PositionHorizon").Value;
                config.PositionVertical = (PositionV)props.Item("PositionVertical").Value;
                config.UpdateImageInterval = (TimeSpan) props.Item("UpdateImageInterval").Value;
                config.Extensions = (string)props.Item("Extensions").Value;
                config.ImageBackgroundType = (ImageBackgroundType)props.Item("ImageBackgroundType").Value;
                config.ImageFadeAnimationInterval = (TimeSpan)props.Item("ImageFadeAnimationInterval").Value;
                return config;
            }
            catch (Exception)
            {
                return Setting.Deserialize();
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a square image and attaches an event handler to the layout changed event that
        /// adds the the square in the upper right-hand corner of the TextView via the adornment layer
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        /// <param name="imageProvider">The <see cref="IImageProvider"/> which provides bitmaps to draw</param>
        /// <param name="setting">The <see cref="Setting"/> contains user image preferences</param>
        public ClaudiaIDE(IWpfTextView view, List<IImageProvider> imageProvider, Setting setting)
		{
		    try
		    {
		        _dispacher = Dispatcher.CurrentDispatcher;
                _imageProviders = imageProvider;
                _imageProvider = imageProvider.FirstOrDefault(x=>x.ProviderType == setting.ImageBackgroundType);
                _setting = setting;
                if (_imageProvider == null)
                {
                    _imageProvider = new SingleImageProvider(_setting);
                }
                _view = view;
                _image = new Image
                {
                    Opacity = setting.Opacity,
                    IsHitTestVisible = false
                };
                _adornmentLayer = view.GetAdornmentLayer("ClaudiaIDE");
				_view.ViewportHeightChanged += delegate { RepositionImage(); };
				_view.ViewportWidthChanged += delegate { RepositionImage(); };     
                _view.ViewportLeftChanged += delegate { RepositionImage(); };
                _setting.OnChanged += delegate { ReloadSettings(); };

                _imageProviders.ForEach(x => x.NewImageAvaliable += delegate { InvokeChangeImage(); });

                ChangeImage();
            }
			catch
			{
			}
		}
Пример #3
0
 /// <summary>
 /// Creates a square image and attaches an event handler to the layout changed event that
 /// adds the the square in the upper right-hand corner of the TextView via the adornment layer
 /// </summary>
 /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
 /// <param name="imageProvider">The <see cref="IImageProvider"/> which provides bitmaps to draw</param>
 /// <param name="setting">The <see cref="Setting"/> contains user image preferences</param>
 public ClaudiaIDE(IWpfTextView view, IImageProvider imageProvider, Setting setting)
 {
     try
     {
         _dispacher = Dispatcher.CurrentDispatcher;
         _imageProvider = imageProvider;
         _view = view;
         _positionHorizon = setting.PositionHorizon;
         _positionVertical = setting.PositionVertical;
         _imageOpacity = setting.Opacity;
         _fadeTime = setting.ImageFadeAnimationInterval;
         _image = new Image
         {
             Opacity = setting.Opacity,
             IsHitTestVisible = false
         };
         _adornmentLayer = view.GetAdornmentLayer("ClaudiaIDE");
         _view.ViewportHeightChanged += delegate { RepositionImage(); };
         _view.ViewportWidthChanged += delegate { RepositionImage(); };
         _view.ViewportLeftChanged += delegate { RepositionImage(); };
         _imageProvider.NewImageAvaliable += delegate { _dispacher.Invoke(ChangeImage); };
         ChangeImage();
     }
     catch (Exception)
     {
     }
 }
Пример #4
0
 public SingleImageProvider(Setting setting)
 {
     var fileUri = new Uri(setting.BackgroundImageAbsolutePath, UriKind.Absolute);
     var fileInfo = new FileInfo(fileUri.AbsolutePath);
     _bitmap = new BitmapImage();
     if(fileInfo.Exists)
     {
         _bitmap.BeginInit();
         _bitmap.UriSource = fileUri;
         _bitmap.EndInit();
     }
 }
        public SildeShowImageProvider(Setting setting)
        {
            _updateInterval = setting.UpdateImageInterval;
            _lastUpdateTime = DateTime.Now;
            _extensions = setting.Extensions.Split(new[]{",", " "}, StringSplitOptions.RemoveEmptyEntries);

            CreateBitmaps(setting.BackgroundImagesDirectoryAbsolutePath);
            if (!_bitmaps.Any())
            {
                return;
            }
            Timer.Elapsed += (o, e) =>
            {
                if (DateTime.Now - _lastUpdateTime >= _updateInterval)
                {
                    _lastUpdateTime = DateTime.Now;
                    _currentImageIndex = (_currentImageIndex + 1) % _bitmaps.Count;
                    NewImageAvaliable?.Invoke(this, EventArgs.Empty);
                }
            };
        }
Пример #6
0
 private IImageProvider GetImageProvider(Setting settings)
 {
     switch (settings.ImageBackgroundType)
     {
         case ImageBackgroundType.Slideshow:
             return _sildeShowImageProvider;
         default:
             return _singleImageProvider;
     }
 }
Пример #7
0
 public SingleImageProvider(Setting setting)
 {
     _setting = setting;
     LoadImage();
 }