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); }
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); }
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); }
private async void Grid_Initialized(object sender, EventArgs e) { await GI.FadeIn(this); }
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); } } }