コード例 #1
0
        private async void Grid_Initialized(object sender, EventArgs e)
        {
            int  Count       = 0;
            Type brushesType = typeof(Brushes);
            var  properties  = brushesType.GetProperties(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);

            for (int i = 0; i < ColorGrid.RowDefinitions.Count; i++)
            {
                for (int j = 0; j < ColorGrid.ColumnDefinitions.Count; j++)
                {
                    Button NewColorButton = new Button();
                    NewColorButton.Background = (SolidColorBrush) new BrushConverter().ConvertFromString(properties[Count].Name);
                    NewColorButton.Click     += ColorClick_Click;
                    Grid.SetRow(NewColorButton, i);
                    Grid.SetColumn(NewColorButton, j);
                    ColorGrid.Children.Add(NewColorButton);
                    Count++;
                    if (Count >= properties.Length)
                    {
                        i = ColorGrid.RowDefinitions.Count;
                        break;
                    }
                }
            }

            await GI.FadeIn(this);
        }
コード例 #2
0
        private async void ColorClick_Click(object sender, RoutedEventArgs e)
        {
            await GI.FadeOut(this);

            SelectedColor = (sender as Button).Background;
            SelectionMade = true;
        }
コード例 #3
0
        private async void ListSelectionButton_Click(object sender, RoutedEventArgs e)
        {
            await GI.FadeOut(this);

            SelectedIndex = (int)(sender as Button).Tag;
            SelectionMade = true;
        }
コード例 #4
0
        private async void ColorPickerCancel_Click(object sender, RoutedEventArgs e)
        {
            await GI.FadeOut(this);

            SelectedColor = null;
            SelectionMade = true;
        }
コード例 #5
0
        private async void Grid_Initialized(object sender, EventArgs e)
        {
            if (SenderWindow.Clip.Bounds.Width == 260)
            {
                RetractAgain = true;
            }
            await GI.ExpandWindow(SenderWindow, true);

            await GI.FadeIn(this);
        }
コード例 #6
0
        private async void WarningYesButton_Click(object sender, RoutedEventArgs e)
        {
            await GI.FadeOut(this);

            if (RetractAgain)
            {
                await GI.ExpandWindow(SenderWindow, false);
            }
            YesBool       = true;
            SelectionMade = true;
        }
コード例 #7
0
        private async void ExitButton_Click(object sender, RoutedEventArgs e)
        {
            await GI.FadeOut(this);

            ExitSave          = true;
            RefreshModeChange = true;

            while (!SaveComplete)
            {
                await Task.Delay(100);
            }

            Application.Current.Shutdown();
        }
コード例 #8
0
        public void UpdateStatisticals(List <GI.GraphColunm> GraphData, double TotalValue, int Statistical_UseIndexIs, bool IsPieChartEnabled, int TimeElementsIndex)
        {
            int Index = SenderWindow.ItemStack.Children.IndexOf(this);

            if (ItemURLTextBox.Text != "" && ItemXPathTextBox.Text != "")
            {
                if (GraphData[0].GraphElements != null && GraphData[1].GraphElements != null)
                {
                    if (GraphData[0].GraphElements.Count > 0 && GraphData[1].GraphElements.Count > 0)
                    {
                        ItemValueLabel.Content = "Value: " + GraphData[0].GraphElements[Index].Value[Statistical_UseIndexIs];
                        ItemValueLabel.ToolTip = "( " + GraphData[0].TimeTable + " )";

                        if (IsPieChartEnabled)
                        {
                            double ShareVal = (((double)GraphData[0].GraphElements[Index].Value[Statistical_UseIndexIs] / TotalValue) * 100);
                            ItemShareLabel.Content = "Share: " + (int)ShareVal + "%";
                        }
                        else
                        {
                            ItemShareLabel.Content = "Share: Disabled";
                        }
                        ItemShareLabel.ToolTip = "( " + GraphData[0].TimeTable + " )";

                        double ChangeVal = GraphData[0].GraphElements[Index].Value[0] - GraphData[1].GraphElements[Index].Value[0];
                        ItemChangeLabel.Foreground = GI.GetColorFromPosNegNeuValue(ChangeVal, (Brush)Application.Current.FindResource("StandartItemDesignGoodColor"), (Brush)Application.Current.FindResource("StandartItemDesignBadColor"), (Brush)Application.Current.FindResource("StandartItemDesignLabelsForground"));
                        ItemChangeLabel.Content    = "Change: " + ChangeVal;
                        ItemChangeLabel.ToolTip    = "( " + GraphData[0].TimeTable + " )";

                        double AvrChange = 0;
                        for (int j = 1; j < TimeElementsIndex - 1; j++)
                        {
                            if (GraphData[j].GraphElements.Count > 0)
                            {
                                if (GraphData[j + 1].GraphElements.Count > 0)
                                {
                                    AvrChange += GraphData[j].GraphElements[Index].Value[Statistical_UseIndexIs] - GraphData[j + 1].GraphElements[Index].Value[Statistical_UseIndexIs];
                                }
                            }
                        }
                        AvrChange = AvrChange / (TimeElementsIndex - 1);

                        ItemAvrChangeLabel.Foreground = GI.GetColorFromPosNegNeuValue(AvrChange, (Brush)Application.Current.FindResource("StandartItemDesignGoodColor"), (Brush)Application.Current.FindResource("StandartItemDesignBadColor"), (Brush)Application.Current.FindResource("StandartItemDesignLabelsForground"));
                        ItemAvrChangeLabel.Content    = "Avr Change: " + Math.Round(AvrChange, 2);
                        ItemAvrChangeLabel.ToolTip    = "( " + GraphData[0].TimeTable + " )";
                    }
                }
            }
        }
コード例 #9
0
        private async void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            RefreshModeChange = true;

            e.Cancel = true;

            await GI.FadeOut(this);

            while (!SaveComplete)
            {
                await Task.Delay(100);
            }

            Application.Current.Shutdown();
        }
コード例 #10
0
        void UpdateVisualData(List <GI.GraphColunm> Values)
        {
            //Avr change label

            double AvrChange = 0;

            for (int i = 0; i < (int)TimeElementsCombobox.SelectedValue - 1; i++)
            {
                AvrChange += SumOfList(Values[i], GMCValues.General_UseIndexIs) - SumOfList(Values[i + 1], GMCValues.General_UseIndexIs);
            }
            AvrChange = AvrChange / ((int)TimeElementsCombobox.SelectedValue - 1);

            AvrChangeLabel.Foreground = GI.GetColorFromPosNegNeuValue(AvrChange, (Brush)Application.Current.FindResource("StandartFrontGoodColor"), (Brush)Application.Current.FindResource("StandartFrontBadColor"), (Brush)Application.Current.FindResource("StandartFrontColor"));
            AvrChangeLabel.Content    = "Avr Change: " + Math.Round(AvrChange, 2);
            AvrChangeLabel.ToolTip    = new ToolTip {
                Content = "AVR(Value - Previous value)"
            };;

            //Total Label
            double HighestVal = 0;

            for (int i = 0; i < (int)TimeElementsCombobox.SelectedValue; i++)
            {
                double Moment = Math.Abs(SumOfList(Values[i], GMCValues.General_UseIndexIs));

                if (Moment > HighestVal)
                {
                    HighestVal = Moment;
                }
            }
            TotalLabel.Content = "Total: " + HighestVal;
            TotalLabel.ToolTip = new ToolTip {
                Content = "Total value on graph"
            };

            //Charts
            UpdateColumnChart(Values, HighestVal);

            UpdatePieChart(Values, HighestVal);

            //Individual items data
            UpdateItemsStatisticalData(Values, HighestVal);
        }
コード例 #11
0
        async Task ShowColorPickerTask(bool FillColorOrBorderColor)
        {
            bool RetractAgain = false;

            if (SenderWindow.Clip.Bounds.Width == 260)
            {
                RetractAgain = true;
            }
            await GI.ExpandWindow(SenderWindow, true);

            ColorPicker PickColor = new ColorPicker(SenderWindow);

            SenderWindow.MainGrid.Children.Add(PickColor);
            while (true)
            {
                if (PickColor.SelectionMade)
                {
                    if (FillColorOrBorderColor)
                    {
                        if (PickColor.SelectedColor != null)
                        {
                            ItemFillColorButton.Background = PickColor.SelectedColor;
                        }
                    }
                    else
                    {
                        if (PickColor.SelectedColor != null)
                        {
                            ItemBorderColorButton.Background = PickColor.SelectedColor;
                        }
                    }
                    SenderWindow.MainGrid.Children.Remove(PickColor);
                    break;
                }
                await Task.Delay(100);
            }

            if (RetractAgain)
            {
                await GI.ExpandWindow(SenderWindow, false);
            }
        }
コード例 #12
0
        private async void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            this.Clip = new RectangleGeometry {
                Rect = new Rect(0, 0, 260, 300)
            };

            List <GI.GraphColunm> GraphData = new List <GI.GraphColunm>();

            TimeFrameCombobox.Items.Add("Days");
            TimeFrameCombobox.Items.Add("Hours");
            TimeFrameCombobox.Items.Add("Minutes");
            TimeFrameCombobox.Items.Add("Seconds");
            TimeFrameCombobox.SelectedIndex = 0;

            for (int i = 0; i < DataCacheSize; i++)
            {
                GraphData.Add(new GI.GraphColunm(DateTime.Now, new List <GI.GraphElement>()));
            }

            for (int i = 5; i < DataCacheSize + 5; i += 5)
            {
                TimeElementsCombobox.Items.Add(i);
            }
            TimeElementsCombobox.SelectedIndex = 0;

            SaveAndLoadClass.LoadSettings(GraphData, this, DataCacheSize, GraphModes.Count - 1);

            RunCommandList(CurrentGraphMode, GraphModes[CurrentGraphMode].GraphModeCommandList, null, null, 0);
            Application.Current.Resources.MergedDictionaries.Clear();
            Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
            {
                Source = new Uri("/Themes/" + ThemeInfos[CurrentThemeIndex].URI, UriKind.Relative)
            });

            UpdateVisualData(GraphData);

            await GI.FadeIn(this);

            await RunMainLoop(GraphData);
        }
コード例 #13
0
        public static void LoadSettings(List <GI.GraphColunm> GraphData, MainWindow SenderWindow, int DataCacheSize, int GraphModeCount)
        {
            try
            {
                FI SaveConfigs = new FI();
                SaveConfigs.LoadFromFile("cfg.txt");
                FI.CategoryData CurrentCategory = new FI.CategoryData("MainWindow Data", 0);
                Application.Current.MainWindow.Left             = SaveConfigs.FindtItemInItemstack_INT(CurrentCategory, new FI.ItemData("Location X", 0));
                Application.Current.MainWindow.Top              = SaveConfigs.FindtItemInItemstack_INT(CurrentCategory, new FI.ItemData("Location Y", 0));
                SenderWindow.TimeFrameCombobox.SelectedIndex    = SaveConfigs.FindtItemInItemstack_INT(CurrentCategory, new FI.ItemData("TimeFrame Index", 0));
                SenderWindow.TimeElementsCombobox.SelectedIndex = SaveConfigs.FindtItemInItemstack_INT(CurrentCategory, new FI.ItemData("Time Elements Index", 0));
                SenderWindow.CurrentGraphMode  = SaveConfigs.FindtItemInItemstack_INT(CurrentCategory, new FI.ItemData("Current Mode", 0));
                SenderWindow.CurrentThemeIndex = SaveConfigs.FindtItemInItemstack_INT(CurrentCategory, new FI.ItemData("Theme Index", 0));

                CurrentCategory = new FI.CategoryData("Item", 0);
                while (SaveConfigs.IsAnyMoreOfCat(CurrentCategory))
                {
                    GI.MakeNewItemPanel(
                        SenderWindow,
                        SaveConfigs.FindtItemInItemstack_STR(CurrentCategory, new FI.ItemData("Name", 0)),
                        SaveConfigs.FindtItemInItemstack_STR(CurrentCategory, new FI.ItemData("URL", 0)),
                        SaveConfigs.FindtItemInItemstack_STR(CurrentCategory, new FI.ItemData("XPath", 0)),
                        (SolidColorBrush)SaveConfigs.FindtItemInItemstack_BRS(CurrentCategory, new FI.ItemData("BorderColor", 0)),
                        (SolidColorBrush)SaveConfigs.FindtItemInItemstack_BRS(CurrentCategory, new FI.ItemData("FillColor", 0)),
                        true
                        );

                    CurrentCategory.Offset++;
                }

                CurrentCategory = new FI.CategoryData("HistoricData", 0);
                while (SaveConfigs.IsAnyMoreOfCat(CurrentCategory))
                {
                    GI.GraphColunm NewData = new GI.GraphColunm();
                    NewData.TimeTable     = SaveConfigs.FindtItemInItemstack_DAT(CurrentCategory, new FI.ItemData("Timestamp", 0));
                    NewData.GraphElements = new List <GI.GraphElement>();

                    FI.ItemData MomentItem = new FI.ItemData("Name", 0);
                    while (SaveConfigs.IsAnyMoreWithinCat(CurrentCategory, MomentItem))
                    {
                        GI.GraphElement NewElement = new GI.GraphElement();
                        NewElement.Name = SaveConfigs.FindtItemInItemstack_STR(CurrentCategory, MomentItem);
                        double[] MomentValues = new double[2];
                        MomentValues[0]        = SaveConfigs.FindtItemInItemstack_INT(CurrentCategory, new FI.ItemData("Value1", MomentItem.Offset));
                        MomentValues[1]        = SaveConfigs.FindtItemInItemstack_INT(CurrentCategory, new FI.ItemData("Value2", MomentItem.Offset));
                        NewElement.Value       = MomentValues;
                        NewElement.BorderColor = (SolidColorBrush)SaveConfigs.FindtItemInItemstack_BRS(CurrentCategory, new FI.ItemData("BorderColor", MomentItem.Offset));
                        NewElement.FillColor   = (SolidColorBrush)SaveConfigs.FindtItemInItemstack_BRS(CurrentCategory, new FI.ItemData("FillColor", MomentItem.Offset));
                        NewData.GraphElements.Add(NewElement);

                        MomentItem.Offset++;
                    }

                    GraphData[CurrentCategory.Offset] = NewData;
                    CurrentCategory.Offset++;
                }
            }
            catch
            {
                MessageBox.Show("Could not load cfg");
                Application.Current.Shutdown();
            }
        }
コード例 #14
0
 private void AddNewItemButton_Click(object sender, RoutedEventArgs e)
 {
     GI.MakeNewItemPanel(this, "Name", "", "", Brushes.White, Brushes.White, false);
 }
コード例 #15
0
 private async void Grid_Initialized(object sender, EventArgs e)
 {
     await GI.FadeIn(this);
 }
コード例 #16
0
        private async void ListSelectionCancelButton_Click(object sender, RoutedEventArgs e)
        {
            await GI.FadeOut(this);

            SelectionMade = true;
        }
コード例 #17
0
        async Task RunMainLoop(List <GI.GraphColunm> GraphData)
        {
            while (true)
            {
                if (ExitSave)
                {
                    if (!SaveComplete)
                    {
                        SaveAndLoadClass.SaveSettings(GraphData, this, DataCacheSize, CurrentGraphMode, CurrentThemeIndex);
                    }
                    SaveComplete = true;
                    while (true)
                    {
                        await Task.Delay(100);
                    }
                }

                if (ClearGraphData)
                {
                    GraphData.Clear();
                    ClearGraphData = false;
                    for (int i = 0; i < DataCacheSize; i++)
                    {
                        GraphData.Add(new GI.GraphColunm(DateTime.Now, new List <GI.GraphElement>()));
                    }
                }

                if (FlatlineGraphData)
                {
                    FlatlineGraphData = false;
                    for (int i = 1; i < DataCacheSize; i++)
                    {
                        GraphData[i] = new GI.GraphColunm(GraphData[0].TimeTable, GraphData[0].GraphElements);
                    }
                }

                GraphLoadingControl NewLoading = new GraphLoadingControl(GraphCanvas, GraphCanvas.ActualWidth, GraphCanvas.ActualHeight);
                GraphCanvas.Children.Add(NewLoading);

                GraphLoadingControl NewLoading2 = null;
                if (GMCValues.IsPieChartEnabled)
                {
                    NewLoading2 = new GraphLoadingControl(PieGraphCanvas, PieGraphCanvas.ActualWidth, PieGraphCanvas.ActualHeight);
                    PieGraphCanvas.Children.Add(NewLoading2);
                }

                if (ItemStack.Children.Count > 0)
                {
                    for (int i = 0; i < ItemStack.Children.Count; i++)
                    {
                        ItemDesign SenderDesign = ItemStack.Children[i] as ItemDesign;
                        SenderDesign.ResetWarningLabels();
                    }

                    GI.GraphColunm NewDataSet = new GI.GraphColunm(DateTime.Now, new List <GI.GraphElement>());
                    try
                    {
                        if (IsTimeOver(DateTime.Now, GraphData[0].TimeTable, TimeFrameCombobox.SelectedIndex) || ManualRefresh)
                        {
                            for (int i = 0; i < ItemStack.Children.Count; i++)
                            {
                                if (ExitSave)
                                {
                                    break;
                                }

                                ItemDesign SenderDesign = ItemStack.Children[i] as ItemDesign;

                                SenderDesign.URLErrorLabel.Foreground   = (Brush)Application.Current.FindResource("StandartItemDesignBadColor");
                                SenderDesign.XPathErrorLabel.Foreground = (Brush)Application.Current.FindResource("StandartItemDesignBadColor");

                                if (SenderDesign.ItemURLTextBox.Text != "" && SenderDesign.ItemXPathTextBox.Text != "")
                                {
                                    HtmlWeb      web = new HtmlWeb();
                                    HtmlDocument doc = await web.LoadFromWebAsync(SenderDesign.ItemURLTextBox.Text);

                                    SenderDesign.URLErrorLabel.Visibility = Visibility.Hidden;

                                    HtmlNode node = doc.DocumentNode.SelectSingleNode(SenderDesign.ItemXPathTextBox.Text.Replace("/tbody", ""));

                                    if (node == null)
                                    {
                                        break;
                                    }

                                    SenderDesign.XPathErrorLabel.Visibility = Visibility.Hidden;

                                    double[] NewData = new double[GraphModes.Count];
                                    for (int j = 0; j < GraphModes.Count; j++)
                                    {
                                        NewData[j] = RunCommandList(j, GraphModes[j].ValueProcessingList, node, GraphData, i);
                                    }

                                    NewDataSet.GraphElements.Add(new GI.GraphElement(NewData, SenderDesign.ItemNameTextBox.Text, (SolidColorBrush)SenderDesign.ItemFillColorButton.Background, (SolidColorBrush)SenderDesign.ItemBorderColorButton.Background));

                                    doc = null;
                                    GC.Collect();
                                }
                            }
                        }

                        if (!ExitSave)
                        {
                            if (IsTimeOver(DateTime.Now, GraphData[0].TimeTable, TimeFrameCombobox.SelectedIndex) || ManualRefresh)
                            {
                                for (int i = GraphData.Count - 1; i > 0; i--)
                                {
                                    GraphData[i] = GraphData[i - 1];
                                }
                                GraphData[0] = NewDataSet;
                            }

                            if (EqualizeColorsData)
                            {
                                EqualizeColorsData = false;
                                for (int i = 1; i < DataCacheSize; i++)
                                {
                                    for (int j = 0; j < ItemStack.Children.Count; j++)
                                    {
                                        int TargetJ = j;
                                        while (GraphData[i].GraphElements[TargetJ].Name != GraphData[0].GraphElements[j].Name)
                                        {
                                            TargetJ++;
                                            if (TargetJ > ItemStack.Children.Count - 1)
                                            {
                                                TargetJ = 0;
                                            }
                                            if (TargetJ == j)
                                            {
                                                break;
                                            }
                                        }
                                        GraphData[i].GraphElements[TargetJ] = new GI.GraphElement(GraphData[i].GraphElements[TargetJ].Value, GraphData[i].GraphElements[TargetJ].Name, GraphData[0].GraphElements[j].FillColor, GraphData[0].GraphElements[j].BorderColor);
                                    }
                                }
                            }

                            UpdateVisualData(GraphData);
                        }

                        SaveAndLoadClass.SaveSettings(GraphData, this, DataCacheSize, CurrentGraphMode, CurrentThemeIndex);
                        SettingsSavedLabel.Visibility = Visibility.Visible;
                        await GI.FadeIn(SettingsSavedLabel);

                        await Task.Delay(1000);

                        await GI.FadeOut(SettingsSavedLabel);

                        SettingsSavedLabel.Visibility = Visibility.Hidden;
                    }
                    catch
                    {
                        ErrorInLoading = true;
                    }
                }

                NewLoading.DoRemove();
                if (GMCValues.IsPieChartEnabled)
                {
                    NewLoading2.DoRemove();
                }

                ManualRefresh = false;

                if (ErrorInLoading)
                {
                    await Task.Delay(10000);

                    ErrorInLoading = false;
                }
                else
                {
                    await WaitUntil(TimeFrameCombobox.SelectedIndex, GraphData);
                }
            }
        }