private void setSelectedGradient() { if (ColorGradientsListBox != null) { GradientStopCollection stopInfos = null; ConfigurableHeatMapLayer layerInfo = DataContext as ConfigurableHeatMapLayer; if (layerInfo != null) { stopInfos = layerInfo.Gradient; } foreach (ListBoxItem item in ColorGradientsListBox.Items) { Rectangle rectangle = item.Content as Rectangle; if (rectangle == null) { continue; } LinearGradientBrush brush = rectangle.Fill as LinearGradientBrush; if (brush == null) { continue; } if (isMatchingGradientStopCollection(stopInfos, brush.GradientStops)) { _fireSelectionChangedEvent = false; ColorGradientsListBox.SelectedItem = item; _fireSelectionChangedEvent = true; break; } } } }
private void AdvancedHeatMapProperties_Click(object sender, RoutedEventArgs e) { ConfigurableHeatMapLayer layerInfo = this.DataContext as ConfigurableHeatMapLayer; if (layerInfo == null) { return; } (sender as Button).IsEnabled = false; if (heatMapWindow == null) { heatMapWindow = new ChildWindow(); //heatMapWindow.ResizeMode = ResizeMode.NoResize; TextBlock title = new TextBlock { Foreground = new SolidColorBrush(Colors.White), FontSize = 12, FontWeight = FontWeights.Bold, Text = "Advanced Properties" }; heatMapWindow.Title = title; double dialogWidth = 325; double dialogHeight = 268; heatMapWindow.Height = dialogHeight; heatMapWindow.Width = dialogWidth; //heatMapWindow.HorizontalOffset = (Application.Current.RootVisual.RenderSize.Width - heatMapWindow.Width) / 2; //heatMapWindow.VerticalOffset = (Application.Current.RootVisual.RenderSize.Height - heatMapWindow.Height) / 2; configWindow = new HeatMapPropertiesConfigWindow(); configWindow.OkClicked += (o, args) => { heatMapWindow.DialogResult = true; }; configWindow.CancelClicked += (o, args) => { heatMapWindow.DialogResult = false; // automatically calls close }; configWindow.GradientStopsChanged += (o, args) => { //layerInfo.HeatMapInfo.Gradients = args.GradientStops; }; heatMapWindow.Closed += (o, args) => { (sender as Button).IsEnabled = true; if (heatMapWindow.DialogResult != true) // && !heatMapWindow.IsAppExit) { restoreHeatMapProperties(); } }; } //if (layerInfo.HeatMapInfo == null) // layerInfo.HeatMapInfo = new HeatMapInfo(); //currentHeatMapInfo = layerInfo.HeatMapInfo != null ? layerInfo.HeatMapInfo.Clone() : new HeatMapInfo(); configWindow.DataContext = layerInfo; //Grid g = new Grid() { Width = 310, Height = 245-20 }; //g.Children.Add(configWindow); //(Application.Current.RootVisual as Grid).Children.Add(g); heatMapWindow.Content = configWindow; heatMapWindow.DialogResult = null; //heatMapWindow.ShowWindow(false); heatMapWindow.Show(); }
private void loadColorGradientsListBox() { if (ColorGradientsListBox == null) { return; } if (ColorGradientsListBox.Items.Count == 0) { GradientStopCollection stopInfos = null; ConfigurableHeatMapLayer layerInfo = DataContext as ConfigurableHeatMapLayer; if (layerInfo != null) { stopInfos = layerInfo.Gradient; } bool foundSelectedItem = false; foreach (GradientStopCollection stops in PreDefinedGradients.GradientStops) { bool isSelectedItem = false; if (!foundSelectedItem) { isSelectedItem = isMatchingGradientStopCollection(stopInfos, stops); } ListBoxItem item = new ListBoxItem() { Content = createColorGradientRectangle(stops), IsSelected = isSelectedItem }; if (isSelectedItem) { ColorGradientsListBox.SelectedItem = item; foundSelectedItem = true; } ColorGradientsListBox.Items.Add(item); } } else { setSelectedGradient(); } }