Exemplo n.º 1
0
        public void ChangeWidth(double pWidth)
        {
            _assemblyCanvas.Width = pWidth;

            // sync background.
            _topNaviMiddle.Width = _assemblyCanvas.Width - 11 - _topNaviLeft.Width - _topNaviRight.Width;
            _topNaviRight.SetValue <double>(Canvas.LeftProperty, (double)_topNaviMiddle.GetValue(Canvas.LeftProperty) + _topNaviMiddle.Width);
            _btnRight.SetValue <double>(Canvas.LeftProperty, (double)_topNaviRight.GetValue(Canvas.LeftProperty) - 48);

            // sync dividor
            _dividorB.SetValue <double>(Canvas.LeftProperty, (double)_topNaviRight.GetValue(Canvas.LeftProperty) - 59);

            _holderClip.Width = (double)_btnRight.GetValue(Canvas.LeftProperty) - (double)_holderClip.GetValue(Canvas.LeftProperty) - 15;
            // make _thumHolder's clip
            RectangleGeometry thumHolderClip = new RectangleGeometry();

            thumHolderClip.Rect = new Rect(0, 0, _holderClip.Width, _holderClip.Height);
            _holderClip.Clip    = thumHolderClip;

            Canvas currentDisplay = _assemblyCanvas.FindName("CurrentDisplay") as Canvas;

            currentDisplay.SetValue <double>(Canvas.LeftProperty, (_assemblyCanvas.Width - currentDisplay.Width) / 2);

            // if the last slice's inside...
            ThumSlice lastThum = _thumHolder.Children[_thumHolder.Children.Count - 1] as ThumSlice;

            if ((double)_thumHolder.GetValue(Canvas.LeftProperty) < (_thumHolder.Width - 15 - (double)lastThum.GetValue(Canvas.LeftProperty) - lastThum.Width))
            {
                _thumHolder.SetValue <double>(Canvas.LeftProperty, (_thumHolder.Width - 15 - (double)lastThum.GetValue(Canvas.LeftProperty) - lastThum.Width));
            }
            if (((double)(lastThum.GetValue(Canvas.LeftProperty)) + lastThum.Width) < _holderClip.Width)
            {
                _thumHolder.SetValue <double>(Canvas.LeftProperty, 0);
            }
        }
Exemplo n.º 2
0
        public void MoveHighlightFrameTo(ThumSlice pSlice)
        {
            //(_assemblyCanvas.FindName("HighlightDesX") as SplineDoubleKeyFrame).Value = (double)pSlice.GetValue(Canvas.LeftProperty) - 2;
            //(_assemblyCanvas.FindName("HighlightDesY") as SplineDoubleKeyFrame).Value = (double)pSlice.GetValue(Canvas.TopProperty) - 1;
            //(_assemblyCanvas.FindName("MoveHighlightFrameTo") as Storyboard).Begin();

            // Sync text
            string lStr = (pSlice.ID + 1).ToString();

            while (lStr.Length < 3)
            {
                lStr = " " + lStr;
            }
            (_assemblyCanvas.FindName("IndexText1") as TextBlock).Text = lStr;
            (_assemblyCanvas.FindName("IndexText2") as TextBlock).Text = (_thumHolder.Children.Count).ToString();

            // if the high light's out of range, move it back inside.
            ThumSlice lastThum = _thumHolder.Children[_thumHolder.Children.Count - 1] as ThumSlice;

            if (((double)(lastThum.GetValue(Canvas.LeftProperty)) + lastThum.Width) < _holderClip.Width)
            {
                _thumHolder.SetValue <double>(Canvas.LeftProperty, GetLegalPosition(0));
            }
            else
            {
                // if the thum's too left...
                if ((double)_thumHolder.GetValue(Canvas.LeftProperty) + (double)pSlice.GetValue(Canvas.LeftProperty) < 30)
                {
                    // new holder position
                    double newpos = 30 - (double)pSlice.GetValue(Canvas.LeftProperty);
                    _thumHolder.SetValue <double>(Canvas.LeftProperty, GetLegalPosition(newpos));
                }
                // else if thum's too right...
                else if ((double)_thumHolder.GetValue(Canvas.LeftProperty) + (double)pSlice.GetValue(Canvas.LeftProperty) > (_holderClip.Width - 30 - pSlice.Width))
                {
                    // new holder position
                    double newpos = _holderClip.Width - 30 - pSlice.Width - (double)pSlice.GetValue(Canvas.LeftProperty);
                    _thumHolder.SetValue <double>(Canvas.LeftProperty, GetLegalPosition(newpos));
                }
            }

            for (int i = 0; i < _thumHolder.Children.Count; i++)
            {
                ThumSlice loopSlice = _thumHolder.Children[i] as ThumSlice;
                if (loopSlice == pSlice)
                {
                    loopSlice.DimIn();
                }
                else
                {
                    loopSlice.DimOut();
                }
            }

            _currentThum = pSlice;
        }
Exemplo n.º 3
0
        private double GetLegalPosition(double pInput)
        {
            ThumSlice lastThum = _thumHolder.Children[_thumHolder.Children.Count - 1] as ThumSlice;

            if (((double)(lastThum.GetValue(Canvas.LeftProperty)) + lastThum.Width) < _holderClip.Width)
            {
                return(0);
            }
            if (pInput > 0)
            {
                pInput = 0;
            }
            else if (pInput < (_holderClip.Width - (double)(lastThum.GetValue(Canvas.LeftProperty)) - lastThum.Width - 1))
            {
                pInput = _holderClip.Width - (double)(lastThum.GetValue(Canvas.LeftProperty)) - lastThum.Width - 1;
            }

            return(pInput);
        }
Exemplo n.º 4
0
        public void MoveHighlightFrameTo(ThumSlice pSlice)
        {
            //(_assemblyCanvas.FindName("HighlightDesX") as SplineDoubleKeyFrame).Value = (double)pSlice.GetValue(Canvas.LeftProperty) - 2;
            //(_assemblyCanvas.FindName("HighlightDesY") as SplineDoubleKeyFrame).Value = (double)pSlice.GetValue(Canvas.TopProperty) - 1;
            //(_assemblyCanvas.FindName("MoveHighlightFrameTo") as Storyboard).Begin();

            // Sync text
            string lStr = (pSlice.ID + 1).ToString();
            while (lStr.Length < 3)
                lStr = " " + lStr;
            (_assemblyCanvas.FindName("IndexText1") as TextBlock).Text = lStr;
            (_assemblyCanvas.FindName("IndexText2") as TextBlock).Text = (_thumHolder.Children.Count).ToString();

            // if the high light's out of range, move it back inside.
            ThumSlice lastThum = _thumHolder.Children[_thumHolder.Children.Count - 1] as ThumSlice;
            if (((double)(lastThum.GetValue(Canvas.LeftProperty)) + lastThum.Width) < _holderClip.Width)
            {
                _thumHolder.SetValue<double>(Canvas.LeftProperty, GetLegalPosition(0));
            }
            else
            {
                // if the thum's too left...
                if ((double)_thumHolder.GetValue(Canvas.LeftProperty) + (double)pSlice.GetValue(Canvas.LeftProperty) < 30)
                {
                    // new holder position
                    double newpos = 30 - (double)pSlice.GetValue(Canvas.LeftProperty);
                    _thumHolder.SetValue<double>(Canvas.LeftProperty, GetLegalPosition(newpos));
                }
                // else if thum's too right...
                else if ((double)_thumHolder.GetValue(Canvas.LeftProperty) + (double)pSlice.GetValue(Canvas.LeftProperty) > (_holderClip.Width - 30 - pSlice.Width))
                {
                    // new holder position
                    double newpos = _holderClip.Width - 30 - pSlice.Width - (double)pSlice.GetValue(Canvas.LeftProperty);
                    _thumHolder.SetValue<double>(Canvas.LeftProperty, GetLegalPosition(newpos));
                }
            }

            for (int i = 0; i < _thumHolder.Children.Count; i++)
            {
                ThumSlice loopSlice = _thumHolder.Children[i] as ThumSlice;
                if (loopSlice == pSlice)
                    loopSlice.DimIn();
                else
                    loopSlice.DimOut();
            }

            _currentThum = pSlice;
        }