コード例 #1
0
ファイル: Panel.cs プロジェクト: pacificIT/MediaPortal-2
        void Init()
        {
            FrameworkElementCollection coll = new FrameworkElementCollection(this);

            coll.CollectionChanged += OnChildrenChanged;
            _childrenProperty       = new SProperty(typeof(FrameworkElementCollection), coll);
            _backgroundProperty     = new SProperty(typeof(Brush), null);
        }
コード例 #2
0
ファイル: Panel.cs プロジェクト: pacificIT/MediaPortal-2
        public override void DeepCopy(IDeepCopyable source, ICopyManager copyManager)
        {
            Detach();
            base.DeepCopy(source, copyManager);
            Panel p = (Panel)source;

            Background  = copyManager.GetCopy(p.Background);
            IsItemsHost = p.IsItemsHost;
            FrameworkElementCollection children = Children;

            foreach (FrameworkElement el in p.Children)
            {
                children.Add(copyManager.GetCopy(el), false);
            }
            Attach();
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        public PropertyGrid()
        {
            Buttons = new FrameworkElementCollection();

            CommandBindings.Add(new CommandBinding(EditCollectionCommand, this.EditCollectionCommand_Executed, this.EditCollectionCommand_CanExecute));
            CommandBindings.Add(new CommandBinding(ResetCommand, this.ResetCommand_Executed, this.ResetCommand_CanExecute));

            Properties         = new PropertyModelCollection();
            ListCollectionView = new ListCollectionView(Properties);

            PropertyColumnWidth = new DataGridLength(40d, DataGridLengthUnitType.Star);
            ValueColumnWidth    = new DataGridLength(60d, DataGridLengthUnitType.Star);

            InitializeComponent();

            Sort();
        }
コード例 #4
0
        protected override SizeF CalculateInnerDesiredSize(SizeF totalSize)
        {
            FrameworkElementCollection children = Children;

            lock (Children.SyncRoot)
            {
                if (_newItemProvider != null)
                {
                    if (children.Count > 0)
                    {
                        children.Clear(false);
                    }
                    if (_itemProvider != null)
                    {
                        MPF.TryCleanupAndDispose(_itemProvider);
                    }
                    _itemProvider      = _newItemProvider;
                    _newItemProvider   = null;
                    _updateRenderOrder = true;
                }
                _assumedLineExtendsInNonOrientationDirection = 0;
                IItemProvider itemProvider = ItemProvider;
                if (itemProvider == null)
                {
                    return(base.CalculateInnerDesiredSize(totalSize));
                }
                int numItems = itemProvider.NumItems;
                if (numItems == 0)
                {
                    return(new SizeF());
                }

                // CalculateInnerDesiredSize is called before ArrangeChildren!
                // under the precondition that all items use the same template and are equally sized
                // calulate just one line to find number of items and required size of a line
                LineMeasurement exemplaryLine = _firstArrangedLineIndex < 0 ? CalculateLine(0, totalSize, false) : _arrangedLines[_firstArrangedLineIndex];
                _assumedLineExtendsInNonOrientationDirection = exemplaryLine.TotalExtendsInNonOrientationDirection;
                var itemsPerLine = exemplaryLine.EndIndex - exemplaryLine.StartIndex + 1;
                var estimatedExtendsInNonOrientationDirection = (float)Math.Ceiling((float)numItems / itemsPerLine) * _assumedLineExtendsInNonOrientationDirection;

                return(Orientation == Orientation.Horizontal ? new SizeF(exemplaryLine.TotalExtendsInOrientationDirection, estimatedExtendsInNonOrientationDirection) :
                       new SizeF(estimatedExtendsInNonOrientationDirection, exemplaryLine.TotalExtendsInOrientationDirection));
            }
        }
コード例 #5
0
ファイル: Panel.cs プロジェクト: pacificIT/MediaPortal-2
 void OnChildrenChanged(FrameworkElementCollection coll)
 {
     _updateRenderOrder = true;
     InvalidateLayout(true, true);
 }
コード例 #6
0
        private void InitializeBars()
        {
            IAudioPlayerAnalyze player = ActiveSpectrumPlayer;

            if (player == null)
            {
                _barWidth = 1;
                _maximumFrequencyIndex = -1;
                _minimumFrequencyIndex = 0;
                return;
            }

            if (!_refreshShapes || _spectrumCanvas == null)
            {
                return;
            }

            int  maxIndex;
            int  minIndex;
            bool res = player.GetFFTFrequencyIndex(MaximumFrequency, out maxIndex);

            res |= player.GetFFTFrequencyIndex(MinimumFrequency, out minIndex);
            if (!res)
            {
                return;
            }
            _maximumFrequencyIndex = Math.Min(maxIndex + 1, FREQUENCY_BUFFER_SIZE - 1);
            _minimumFrequencyIndex = Math.Min(minIndex, FREQUENCY_BUFFER_SIZE - 1);

            _barWidth = Math.Max(((_spectrumCanvas.ActualWidth - (BarSpacing * (BarCount + 1))) / BarCount), 1);
            int actualBarCount = _barWidth >= 1.0d ? BarCount : Math.Max((int)((_spectrumCanvas.ActualWidth - BarSpacing) / (_barWidth + BarSpacing)), 1);

            _channelPeakData = new float[actualBarCount];

            int        indexCount            = _maximumFrequencyIndex - _minimumFrequencyIndex;
            int        linearIndexBucketSize = (int)Math.Round(indexCount / (double)actualBarCount, 0);
            List <int> maxIndexList          = new List <int>();
            List <int> maxLogScaleIndexList  = new List <int>();
            double     maxLog = Math.Log(actualBarCount, actualBarCount);

            for (int i = 1; i < actualBarCount; i++)
            {
                maxIndexList.Add(_minimumFrequencyIndex + (i * linearIndexBucketSize));
                int logIndex = (int)((maxLog - Math.Log((actualBarCount + 1) - i, (actualBarCount + 1))) * indexCount) + _minimumFrequencyIndex;
                maxLogScaleIndexList.Add(logIndex);
            }
            maxIndexList.Add(_maximumFrequencyIndex);
            maxLogScaleIndexList.Add(_maximumFrequencyIndex);
            _barIndexMax         = maxIndexList.ToArray();
            _barLogScaleIndexMax = maxLogScaleIndexList.ToArray();

            FrameworkElementCollection canvasChildren = _spectrumCanvas.Children;

            canvasChildren.StartUpdate();
            try
            {
                canvasChildren.Clear();

                double height        = _spectrumCanvas.ActualHeight;
                double peakDotHeight = Math.Max(_barWidth / 2.0f, 1);
                for (int i = 0; i < actualBarCount; i++)
                {
                    // Deep copy the styles to each bar
                    Style barStyleCopy  = MpfCopyManager.DeepCopyCutLVPs(BarStyle);
                    Style peakStyleCopy = MpfCopyManager.DeepCopyCutLVPs(PeakStyle);

                    double  xCoord     = BarSpacing + (_barWidth * i) + (BarSpacing * i) + 1;
                    Control barControl = new Control
                    {
                        Width  = _barWidth,
                        Height = height,
                        Style  = barStyleCopy
                    };
                    Canvas.SetLeft(barControl, xCoord);
                    Canvas.SetBottom(barControl, height);
                    _barShapes.Add(barControl);
                    canvasChildren.Add(barControl);

                    Control peakControl = new Control
                    {
                        Width  = _barWidth,
                        Height = peakDotHeight,
                        Style  = peakStyleCopy
                    };
                    Canvas.SetLeft(peakControl, xCoord);
                    Canvas.SetBottom(peakControl, height);
                    _peakShapes.Add(peakControl);
                    canvasChildren.Add(peakControl);
                }
            }
            finally
            {
                canvasChildren.EndUpdate();
            }
            ActualBarWidth = _barWidth;
            _refreshShapes = false;
        }
コード例 #7
0
ファイル: BasicWindow.cs プロジェクト: thrmotta/Imagin.NET
 /// <summary>
 ///
 /// </summary>
 public BasicWindow() : base()
 {
     DefaultStyleKey = typeof(BasicWindow);
     Buttons         = new FrameworkElementCollection();
 }
コード例 #8
0
 public AnimatedExpander()
 {
     DefaultStyleKey = typeof(AnimatedExpander);
     Items = new FrameworkElementCollection();
 }