123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media;
- namespace HistoryDLL
- {
- public partial class CyclicScroller : UserControl
- {
-
- LinearGradientBrush myLinearGradientBrush = new LinearGradientBrush();
- GradientStopCollection myGradientStopCollection = new GradientStopCollection();
- GradientStop LeftLineLeftPointStopFirst = new GradientStop();
- GradientStop LeftLineRightPointStopFirst = new GradientStop();
- GradientStop RightLineLeftPointStopFirst = new GradientStop();
- GradientStop RightLineRightPointStopFirst = new GradientStop();
- GradientStop LeftLineLeftPointStopSecond = new GradientStop();
- GradientStop LeftLineRightPointStopSecond = new GradientStop();
- GradientStop RightLineLeftPointStopSecond = new GradientStop();
- GradientStop RightLineRightPointStopSecond = new GradientStop();
- GradientStop LeftLineLeftPointStopThree = new GradientStop();
- GradientStop LeftLineRightPointStopThree = new GradientStop();
- GradientStop RightLineLeftPointStopThree = new GradientStop();
- GradientStop RightLineRightPointStopThree = new GradientStop();
- bool IsUsingFirst = false, IsUsingSecond = false, IsUsingThree = false;
-
-
-
- private void SetDisplayPart()
- {
- #region First
- LeftLineLeftPointStopFirst.Offset = 0.0;
- Color c1 = new Color();
- c1 = GetColorRGB(true);
- LeftLineLeftPointStopFirst.Color = c1;
- LeftLineRightPointStopFirst.Offset = 0.0;
- Color c2 = new Color();
- c2 = GetColorRGB(false);
- LeftLineRightPointStopFirst.Color = c2;
- RightLineLeftPointStopFirst.Offset = 0.0;
- Color c3 = new Color();
- c3 = GetColorRGB(false);
- RightLineLeftPointStopFirst.Color = c3;
- RightLineRightPointStopFirst.Offset = 0.0;
- Color c4 = new Color();
- c4 = GetColorRGB(true);
- RightLineRightPointStopFirst.Color = c4;
- #endregion
- #region Second
- LeftLineLeftPointStopSecond.Offset = 0.0;
- Color c5 = new Color();
- c5 = GetColorRGB(true);
- LeftLineLeftPointStopSecond.Color = c5;
- LeftLineRightPointStopSecond.Offset = 0.0;
- Color c6 = new Color();
- c6 = GetColorRGB(false);
- LeftLineRightPointStopSecond.Color = c6;
- RightLineLeftPointStopSecond.Offset = 0.0;
- Color c7 = new Color();
- c7 = GetColorRGB(false);
- RightLineLeftPointStopSecond.Color = c7;
- RightLineRightPointStopSecond.Offset = 0.0;
- Color c8 = new Color();
- c8 = GetColorRGB(true);
- RightLineRightPointStopSecond.Color = c8;
- #endregion
- #region Three
- LeftLineLeftPointStopThree.Offset = 0.0;
- Color c9 = new Color();
- c9 = GetColorRGB(true);
- LeftLineLeftPointStopThree.Color = c9;
- LeftLineRightPointStopThree.Offset = 0.0;
- Color c10 = new Color();
- c10 = GetColorRGB(false);
- LeftLineRightPointStopThree.Color = c10;
- RightLineLeftPointStopThree.Offset = 0.0;
- Color c11 = new Color();
- c11 = GetColorRGB(false);
- RightLineLeftPointStopThree.Color = c11;
- RightLineRightPointStopThree.Offset = 0.0;
- Color c12 = new Color();
- c12 = GetColorRGB(true);
- RightLineRightPointStopThree.Color = c12;
- #endregion
- #region add GradientStop into Collection
- myGradientStopCollection.Add(LeftLineLeftPointStopThree);
- myGradientStopCollection.Add(LeftLineRightPointStopThree);
- myGradientStopCollection.Add(RightLineLeftPointStopThree);
- myGradientStopCollection.Add(RightLineRightPointStopThree);
- myGradientStopCollection.Add(LeftLineLeftPointStopSecond);
- myGradientStopCollection.Add(LeftLineRightPointStopSecond);
- myGradientStopCollection.Add(RightLineLeftPointStopSecond);
- myGradientStopCollection.Add(RightLineRightPointStopSecond);
- myGradientStopCollection.Add(LeftLineLeftPointStopFirst);
- myGradientStopCollection.Add(LeftLineRightPointStopFirst);
- myGradientStopCollection.Add(RightLineLeftPointStopFirst);
- myGradientStopCollection.Add(RightLineRightPointStopFirst);
- #endregion
- myLinearGradientBrush.StartPoint = new Point(0, 0);
- myLinearGradientBrush.EndPoint = new Point(1, 0);
- myLinearGradientBrush.GradientStops = myGradientStopCollection;
- uxCyclicGrid.OpacityMask = myLinearGradientBrush;
- }
- private Color GetColorRGB(bool Show)
- {
- Color result = new Color();
- result.R = 255;
- result.G = 255;
- result.B = 255;
- if (Show)
- {
- result.A = 255;
- }
- else
- {
- result.A = 0;
- }
- return result;
- }
-
-
-
-
-
- private void CheckDisplayRange()
- {
- int startindex = -1, endindex = -1;
- int useTools = 1;
- bool HaveUsing = false;
- double startvalue = 0;
- double endvalue = 0;
- IsUsingFirst = IsUsingSecond = IsUsingThree = false;
- for (int i = 0; i < ExtraUnitGridList.Count; i++)
- {
- if (ExtraUnitGridList[i].IsUsing != 0 && !HaveUsing)
- {
- #region GradientStop 的起始位置
- HaveUsing = true;
- startindex = i;
- startvalue = 0;
- double Leftwidth = 0;
-
- for (int index = 0; index < startindex; index++)
- {
- if (index == 0)
- {
-
- if (ExtraUnitGridList[index].Width <= MainEventWidth - (ExtraUnitGridList[index].ShrinkValueOne))
- {
-
- Leftwidth += MainEventWidth - NoneUseRange - (ExtraUnitGridList[index].ShrinkValueOne);
- }
- else
- {
-
- Leftwidth += MainEventWidth - NoneUseRange;
- }
- }
- else
- {
- Leftwidth += ExtraUnitGridList[index].Width;
- }
- }
- startvalue = Leftwidth / (double)ResolutionValueWidth;
-
- #endregion
- }
- else
- {
- if (HaveUsing && ExtraUnitGridList[i].IsUsing == 0)
- {
- #region GradientStop 的停止位置 (還沒找到最後一個)
- endindex = i;
- HaveUsing = false;
- endvalue = 0;
- double Leftwidth = 0;
-
- for (int index = 0; index < endindex; index++)
- {
- if (index == 0)
- {
- if (ExtraUnitGridList[index].Width < MainEventWidth)
- {
-
- Leftwidth += MainEventWidth - NoneUseRange - (ExtraUnitGridList[index].ShrinkValueOne);
- }
- else
- {
- Leftwidth += MainEventWidth - NoneUseRange;
- }
- }
- else
- {
- Leftwidth += ExtraUnitGridList[index].Width;
- }
- }
- endvalue = Leftwidth / (double)ResolutionValueWidth;
-
- if (useTools == 1)
- {
- LeftLineLeftPointStopFirst.Offset = startvalue;
- LeftLineRightPointStopFirst.Offset = startvalue;
- RightLineLeftPointStopFirst.Offset = endvalue;
- RightLineRightPointStopFirst.Offset = endvalue;
- IsUsingFirst = true;
- useTools++;
- }
- else if (useTools == 2)
- {
- LeftLineLeftPointStopSecond.Offset = startvalue;
- LeftLineRightPointStopSecond.Offset = startvalue;
- RightLineLeftPointStopSecond.Offset = endvalue;
- RightLineRightPointStopSecond.Offset = endvalue;
- IsUsingSecond = true;
- useTools++;
- }
- else if (useTools == 3)
- {
- LeftLineLeftPointStopThree.Offset = startvalue;
- LeftLineRightPointStopThree.Offset = startvalue;
- RightLineLeftPointStopThree.Offset = endvalue;
- RightLineRightPointStopThree.Offset = endvalue;
- IsUsingThree = true;
- useTools = 1;
- }
- #endregion
- }
-
- else if (HaveUsing && i + 1 == ExtraUnitGridList.Count)
- {
- #region GradientStop 的停止位置 (最後一個的話)
- HaveUsing = false;
- endvalue = 1;
- if (useTools == 1)
- {
- LeftLineLeftPointStopFirst.Offset = startvalue;
- LeftLineRightPointStopFirst.Offset = startvalue;
- RightLineLeftPointStopFirst.Offset = endvalue;
- RightLineRightPointStopFirst.Offset = endvalue;
- IsUsingFirst = true;
- useTools++;
- }
- else if (useTools == 2)
- {
- LeftLineLeftPointStopSecond.Offset = startvalue;
- LeftLineRightPointStopSecond.Offset = startvalue;
- RightLineLeftPointStopSecond.Offset = endvalue;
- RightLineRightPointStopSecond.Offset = endvalue;
- IsUsingSecond = true;
- useTools++;
- }
- else if (useTools == 3)
- {
- LeftLineLeftPointStopThree.Offset = startvalue;
- LeftLineRightPointStopThree.Offset = startvalue;
- RightLineLeftPointStopThree.Offset = endvalue;
- RightLineRightPointStopThree.Offset = endvalue;
- IsUsingThree = true;
- useTools = 1;
- }
- #endregion
- }
- }
- }
- if (!IsUsingFirst)
- {
- LeftLineLeftPointStopFirst.Offset = 0;
- LeftLineRightPointStopFirst.Offset = 0;
- RightLineLeftPointStopFirst.Offset = 0;
- RightLineRightPointStopFirst.Offset = 0;
- }
- if (!IsUsingSecond)
- {
- LeftLineLeftPointStopSecond.Offset = 0;
- LeftLineRightPointStopSecond.Offset = 0;
- RightLineLeftPointStopSecond.Offset = 0;
- RightLineRightPointStopSecond.Offset = 0;
- }
- if (!IsUsingThree)
- {
- LeftLineLeftPointStopThree.Offset = 0;
- LeftLineRightPointStopThree.Offset = 0;
- RightLineLeftPointStopThree.Offset = 0;
- RightLineRightPointStopThree.Offset = 0;
- }
- }
- }
- }
|