예제 #1
0
        public void SetStatus(byte Percent)
        {
            try
            {
                byte                   bCount            = 2;
                byte                   bPercent          = Percent;
                Ellipse                StatusBubble      = null;
                BediaTransitions       bediaTransitions  = new BediaTransitions();
                BediaStoryboardOptions storyboardOptions = new BediaStoryboardOptions();


                storyboardOptions.Milliseconds = 400;

                if (Percent != 100 && Percent != 5)
                {
                    SetWindowsVolume(0); //To insure that the Windows Volume is hidden
                }

                if (Percent < 11)
                {
                    bCount = 1;
                }
                else if (Percent == 100)
                {
                    bCount   = 11;
                    bPercent = 10;
                }
                else
                {
                    bCount   = Convert.ToByte(Percent.ToString().Substring(0, 1));
                    bPercent = Convert.ToByte(Percent - (bCount * 10));
                    bCount  += 1;
                }


                //Hide non-used bubbles
                for (byte b = bCount; b < 10; b++)
                {
                    StatusBubble = (Ellipse)this.FindName("Status" + b.ToString() + "Outline");
                    storyboardOptions.uiElement = StatusBubble;
                    storyboardOptions.To        = 0.25;
                    bediaTransitions.UIOpacity(storyboardOptions);

                    StatusBubble = (Ellipse)this.FindName("Status" + b.ToString());
                    storyboardOptions.uiElement = StatusBubble;
                    storyboardOptions.To        = 0.0;
                    bediaTransitions.UIOpacity(storyboardOptions);
                }


                //Show bubbles that have some value
                for (byte b = 0; b < bCount; b++)
                {
                    StatusBubble = (Ellipse)this.FindName("Status" + b.ToString() + "Outline");
                    //StatusBubble.Opacity = 1.0;
                    storyboardOptions.uiElement = StatusBubble;
                    storyboardOptions.To        = 1.0;
                    bediaTransitions.UIOpacity(storyboardOptions);

                    StatusBubble = (Ellipse)this.FindName("Status" + b.ToString());
                    //StatusBubble.Opacity = 1.0;
                    storyboardOptions.uiElement = StatusBubble;
                    storyboardOptions.To        = 1.0;
                    bediaTransitions.UIOpacity(storyboardOptions);

                    if (b == (bCount - 1))
                    {
                        StatusBubble.StrokeThickness = (StatusBubble.ActualWidth / 2) * (bPercent * 0.1);
                    }
                    else
                    {
                        StatusBubble.StrokeThickness = (StatusBubble.ActualWidth / 2);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
        public void SetWindowsVolume(byte Percent)
        {
            try
            {
                BediaTransitions       bediaTransitions  = new BediaTransitions();
                BediaStoryboardOptions storyboardOptions = new BediaStoryboardOptions();
                Ellipse WindowsVolumeBubble = null;
                byte    bCount   = 0;
                byte    bPercent = Percent;


                storyboardOptions.Milliseconds = 400;
                storyboardOptions.To           = 0.0;

                if (Percent < 11)
                {
                    bCount = 0;
                }
                else if (Percent == 100)
                {
                    bCount   = 11;
                    bPercent = 10;
                }
                else
                {
                    bCount   = Convert.ToByte(Percent.ToString().Substring(0, 1));
                    bPercent = Convert.ToByte(Percent - (bCount * 10));
                    bCount  += 1;
                }


                //Hide non-used bubbles
                for (byte b = bCount; b < 10; b++)
                {
                    WindowsVolumeBubble         = (Ellipse)this.FindName("WindowsVolume" + b.ToString());
                    storyboardOptions.uiElement = WindowsVolumeBubble;
                    bediaTransitions.UIOpacity(storyboardOptions);
                }

                if (Percent <= 0)
                {
                    return;
                }

                storyboardOptions.To = 1.0;

                //Show bubbles that have some value
                for (byte b = 0; b < bCount; b++)
                {
                    WindowsVolumeBubble         = (Ellipse)this.FindName("WindowsVolume" + b.ToString());
                    storyboardOptions.uiElement = WindowsVolumeBubble;
                    bediaTransitions.UIOpacity(storyboardOptions);

                    if (b == (bCount - 1))
                    {
                        WindowsVolumeBubble.StrokeThickness = (WindowsVolumeBubble.ActualWidth / 2) * (bPercent * 0.1);
                    }
                    else
                    {
                        WindowsVolumeBubble.StrokeThickness = (WindowsVolumeBubble.ActualWidth / 2);
                    }
                }


                bediaTransitions  = null;
                storyboardOptions = null;
            }
            catch (Exception)
            {
                throw;
            }
        }