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
- {
- //OpacityMask Setting
- 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;
- /// <summary>
- /// 拖動隱藏區塊顯示設定
- /// </summary>
- 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;
- }
- //判斷允許後面顯示的區域~
- //不管螢幕個數~最多為三個可畫分的區塊~在SetDisplayPart 函數中~已經將工具加入
- //判斷方式 : 取用時~必須判斷為連續幾個 isusing 後 ~ 為一個區塊將計算值放到第一個區塊中~
- //一般來說一個螢幕指會需要用到一個該工具~如果今天是雙或者三螢幕
- //則必須按照第一個取用方式~去設定第二個甚至第三個~
- 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;
- //Console.WriteLine("起點 : " + Leftwidth);
- #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)
- {
- //因為左邊縮小的話只有右邊 - ExtraUnitGridList[index].ShrinkValueOne 顧~不用除以2
- Leftwidth += MainEventWidth - NoneUseRange - (ExtraUnitGridList[index].ShrinkValueOne);
- }
- else
- {
- Leftwidth += MainEventWidth - NoneUseRange;
- }
- }
- else
- {
- Leftwidth += ExtraUnitGridList[index].Width;
- }
- }
- endvalue = Leftwidth / (double)ResolutionValueWidth;
- //Console.WriteLine("終點 : " + Leftwidth);
- 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
- }
- //或者最後一個Grid
- 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;
- }
- }
- }
- }
|