示例#1
0
        private void Tool_MA_Button_Do(object sender, EventArgs e)
        {
            var count = tool_MA_Count.Value;

            if (movingAves.ContainsKey(count) || DataBase.Data.Count <= 0)
            {
                return;
            }
            var array   = new Vector2F[DataBase.Data.Count - count];
            var rawData = this.rawData.Data;
            var current = 0f;

            for (int i = 0; i < count; i++)
            {
                current += rawData[i].Y;
            }
            for (int i = count; i < rawData.Length; i++)
            {
                array[i - count] = new Vector2F(i, current / count);
                current         += rawData[i].Y - rawData[i - count].Y;
            }
            var graphLine = graph.AddData(array);
            var color     = tool_MA_LineColor.Color;

            graphLine.Color = color;
            movingAves.Add(count, graphLine);
            var button = new CheckBox(count.ToString(), true);

            button.ChangeChecked += (x, y) =>
            {
                var c = graphLine.Color;
                c.A             = y.NewValue ? byte.MaxValue : default;
                graphLine.Color = c;
            };
            var lineComponent = new Line();

            lineComponent.AddComponent(button);
            var colorEdit = new ColorEdit(count.ToString(), color)
            {
                EditAlpha = false,
                InputType = IToolColorEdit.ColorEditInputType.None,
                ShowLabel = false
            };

            colorEdit.ColorChanged += (x, y) =>
            {
                var c = y.NewValue;
                c.A             = graphLine.Color.A;
                graphLine.Color = c;
            };
            lineComponent.AddComponent(colorEdit);
            graphButtonGroup.AddComponent(lineComponent);
        }