/// <summary> /// Initializes a new instance of the <see cref="AngularGauge"/> class. /// </summary> public AngularGauge() { Canvas = new Canvas(); Content = Canvas; StickRotateTransform = new RotateTransform(180); Stick = new Path { Data = Geometry.Parse("m0,90 a5,5 0 0 0 20,0 l-8,-88 a2,2 0 0 0 -4 0 z"), Fill = Brushes.CornflowerBlue, Stretch = Stretch.Fill, RenderTransformOrigin = new Point(0.5, 0.9), RenderTransform = StickRotateTransform }; Canvas.Children.Add(Stick); Panel.SetZIndex(Stick, 1); Canvas.SetBinding(WidthProperty, new Binding { Path = new PropertyPath(ActualWidthProperty), Source = this }); Canvas.SetBinding(HeightProperty, new Binding { Path = new PropertyPath(ActualHeightProperty), Source = this }); SetCurrentValue(SectionsProperty, new List<AngularSection>()); SetCurrentValue(NeedleFillProperty, new SolidColorBrush(Color.FromRgb(69, 90, 100))); Stick.SetBinding(Shape.FillProperty, new Binding {Path = new PropertyPath(NeedleFillProperty), Source = this}); SetCurrentValue(AnimationsSpeedProperty, TimeSpan.FromMilliseconds(500)); SetCurrentValue(TicksForegroundProperty, new SolidColorBrush(Color.FromRgb(210, 210, 210))); Func<double, string> defaultFormatter = x => x.ToString(CultureInfo.InvariantCulture); SetCurrentValue(LabelFormatterProperty, defaultFormatter); SetCurrentValue(LabelsEffectProperty, new DropShadowEffect {ShadowDepth = 2, RenderingBias = RenderingBias.Performance}); SizeChanged += (sender, args) => { IsControlLaoded = true; Draw(); }; Slices = new Dictionary<AngularSection, PieSlice>(); }
private void LockMouseOutside(bool doLock) { if (doLock) { Debug.Assert(WindowElement.ModalContainerPanel != null); Binding wBinding = new Binding("ActualWidth"); Binding hBinding = new Binding("ActualHeight"); Canvas fence = new Canvas(); wBinding.Source = WindowElement.ModalContainerPanel; hBinding.Source = WindowElement.ModalContainerPanel; fence.SetBinding(Canvas.WidthProperty, wBinding); fence.SetBinding(Canvas.HeightProperty, hBinding); fence.Background = new SolidColorBrush(Color.FromArgb(141, 162, 174, 255)); fence.Opacity = 0.5; WindowElement.ModalContainerPanel.Children.Add(this); WindowElement.ModalContainerPanel.Children.Add(fence); WindowElement.ModalContainerPanel.BringToBottom(fence); WindowElement.ModalContainerPanel.Visibility = System.Windows.Visibility.Visible; } else { Debug.Assert(WindowElement.ModalContainerPanel != null); for (int i = 0; i < WindowElement.ModalContainerPanel.Children.Count; i++) { UIElement target = WindowElement.ModalContainerPanel.Children[i]; if (target is Panel) { WindowElement.ModalContainerPanel.Children.Remove(target); break; } } WindowElement.ModalContainerPanel.Children.Remove(this); WindowElement.ModalContainerPanel.Visibility = System.Windows.Visibility.Hidden; } }
public HexGlyphMargin(IMenuService menuService, WpfHexViewHost wpfHexViewHost, HexViewTagAggregatorFactoryService viewTagAggregatorFactoryService, HexEditorFormatMapService editorFormatMapService, Lazy<HexGlyphMouseProcessorProvider, IGlyphMouseProcessorProviderMetadata>[] glyphMouseProcessorProviders, Lazy<HexGlyphFactoryProvider, IGlyphMetadata>[] glyphFactoryProviders, HexMarginContextMenuService marginContextMenuHandlerProviderService) { if (menuService == null) throw new ArgumentNullException(nameof(menuService)); if (wpfHexViewHost == null) throw new ArgumentNullException(nameof(wpfHexViewHost)); if (viewTagAggregatorFactoryService == null) throw new ArgumentNullException(nameof(viewTagAggregatorFactoryService)); if (editorFormatMapService == null) throw new ArgumentNullException(nameof(editorFormatMapService)); if (glyphMouseProcessorProviders == null) throw new ArgumentNullException(nameof(glyphMouseProcessorProviders)); if (glyphFactoryProviders == null) throw new ArgumentNullException(nameof(glyphFactoryProviders)); canvas = new Canvas(); glyphFactories = new Dictionary<Type, GlyphFactoryInfo>(); childCanvases = Array.Empty<Canvas>(); this.wpfHexViewHost = wpfHexViewHost; this.viewTagAggregatorFactoryService = viewTagAggregatorFactoryService; this.editorFormatMapService = editorFormatMapService; lazyGlyphMouseProcessorProviders = glyphMouseProcessorProviders; lazyGlyphFactoryProviders = glyphFactoryProviders; var binding = new Binding { Path = new PropertyPath(Panel.BackgroundProperty), Source = canvas, }; canvas.SetBinding(DsImage.BackgroundBrushProperty, binding); wpfHexViewHost.HexView.Options.OptionChanged += Options_OptionChanged; wpfHexViewHost.HexView.ZoomLevelChanged += HexView_ZoomLevelChanged; canvas.IsVisibleChanged += GlyphMargin_IsVisibleChanged; UpdateVisibility(); canvas.Width = MARGIN_WIDTH; canvas.ClipToBounds = true; menuService.InitializeContextMenu(VisualElement, new Guid(MenuConstants.GUIDOBJ_GLYPHMARGIN_GUID), marginContextMenuHandlerProviderService.Create(wpfHexViewHost, this, PredefinedHexMarginNames.Glyph), null, new Guid(MenuConstants.GLYPHMARGIN_GUID)); }
public AdvancedContentPresenter () { Control = new ScrollViewer (); ControlContainer = new Canvas (); Scaling = new TranslateTransform (); IsShiftAble = true; Control.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden; Control.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden; ControlContainer.MouseLeftButtonDown += ContentEditor_MouseLeftButtonDown; ControlContainer.MouseLeftButtonUp += ContentEditor_MouseLeftButtonUp; ControlContainer.MouseMove += ContentEditor_MouseMove; ControlContainer.RenderTransform = Scaling; Control.PreviewMouseWheel += OuterContainer_MouseWheel; Control.Content = ControlContainer; ScaleFactor = 1; TransformGroup group = new TransformGroup (); Binding binding = new Binding ("ScaleFactor"); binding.Source = this; ControlContainer.SetBinding (Canvas.TagProperty, binding); ScaleTransform scaling = new ScaleTransform (); BindingOperations.SetBinding (scaling, ScaleTransform.ScaleXProperty, binding); BindingOperations.SetBinding (scaling, ScaleTransform.ScaleYProperty, binding); group.Children.Add (scaling); ControlContainer.LayoutTransform = group; }
private void AddFreqGrid(string strataVar, string value, string crosstabVar, string groupReference, DataTable table) { StackPanel crosstabPanel = new StackPanel(); StackPanel groupPanel = new StackPanel(); bool strataSummaryOnly = (bool)checkboxStrataSummaryOnly.IsChecked; bool isGrouped = this.DashboardHelper.GetAllGroupsAsList().Contains(GadgetOptions.MainVariableName); if (isGrouped && strataGroupPanel == null) { strataGroupPanel = new GadgetStrataListPanel(StrataListPanelMode.GroupMode); strataGroupPanel.SnapsToDevicePixels = true; panelMain.Children.Add(strataGroupPanel); } groupPanel.Tag = groupReference; bool inList = false; foreach (StackPanel panel in groupList) { if (panel.Tag == groupPanel.Tag) { groupPanel = panel; inList = true; } } if (!inList) { groupList.Add(groupPanel); } int columnCount = table.Columns.Count; Expander expander = new Expander(); TextBlock txtExpanderHeader = new TextBlock(); txtExpanderHeader.Text = value; txtExpanderHeader.Style = this.Resources["genericOutputExpanderText"] as Style; string formattedValue = value; if (string.IsNullOrEmpty(strataVar) && GadgetOptions.StrataVariableNames.Count == 0) { formattedValue = crosstabVar; } else { if (value.EndsWith(" = ")) { formattedValue = value + DashboardHelper.Config.Settings.RepresentationOfMissing; } } if (isGrouped) { formattedValue = groupReference + ", " + formattedValue; } txtExpanderHeader.Text = formattedValue; expander.Header = txtExpanderHeader; if (columnCount == 3 && table.Rows.Count == 2 && (isRunningGrouped2x2 == null || isRunningGrouped2x2 == true)) // is 2x2 { isRunningGrouped2x2 = true; decimal yyVal = decimal.Parse(table.Rows[0][1].ToString()); decimal ynVal = decimal.Parse(table.Rows[0][2].ToString()); decimal nyVal = decimal.Parse(table.Rows[1][1].ToString()); decimal nnVal = decimal.Parse(table.Rows[1][2].ToString()); Controls.GadgetTwoByTwoPanel twoByTwoPanel = null; try { twoByTwoPanel = new Controls.GadgetTwoByTwoPanel(yyVal, ynVal, nyVal, nnVal); } catch (DivideByZeroException ex) { return; } twoByTwoPanel.ValuesUpdated += new TwoByTwoValuesUpdatedHandler(twoByTwoPanel_ValuesUpdated); if (checkboxHorizontal.IsChecked == true) { twoByTwoPanel.Orientation = Orientation.Vertical; } else { twoByTwoPanel.Orientation = Orientation.Horizontal; } twoByTwoPanel.Margin = new Thickness(5); if (isGrouped) { twoByTwoPanel.ExposureVariable = groupReference; } else { twoByTwoPanel.ExposureVariable = this.GadgetOptions.MainVariableName; if (strataSummaryOnly) { twoByTwoPanel.Visibility = System.Windows.Visibility.Collapsed; expander.Visibility = System.Windows.Visibility.Collapsed; } } twoByTwoPanel.OutcomeVariable = this.GadgetOptions.CrosstabVariableName; twoByTwoPanel.OutcomeYesLabel = table.Columns[1].ColumnName; twoByTwoPanel.OutcomeNoLabel = table.Columns[2].ColumnName; twoByTwoPanel.ExposureYesLabel = table.Rows[0][0].ToString(); twoByTwoPanel.ExposureNoLabel = table.Rows[1][0].ToString(); if (YesValues != null && YesValues.Count > 0 && NoValues != null && NoValues.Count > 0) { twoByTwoPanel.OutcomeYesLabel = Config.Settings.RepresentationOfYes; twoByTwoPanel.OutcomeNoLabel = Config.Settings.RepresentationOfNo; twoByTwoPanel.ExposureYesLabel = Config.Settings.RepresentationOfYes; twoByTwoPanel.ExposureNoLabel = Config.Settings.RepresentationOfNo; } if (showPercents) { twoByTwoPanel.ShowRowColumnPercents = true; } else { twoByTwoPanel.ShowRowColumnPercents = false; } if (string.IsNullOrEmpty(strataVar) && GadgetOptions.StrataVariableNames.Count == 0) { crosstabPanel.Margin = (Thickness)this.Resources["genericElementMargin"]; crosstabPanel.Children.Add(twoByTwoPanel); if (isGrouped && strataGroupPanel != null) { StrataGridListRow sRow = new StrataGridListRow(); sRow.StrataLabel = groupReference; sRow.OutcomeRateExposure = twoByTwoPanel.OutcomeRateExposure; sRow.OutcomeRateNoExposure = twoByTwoPanel.OutcomeRateNoExposure; sRow.RiskRatio = twoByTwoPanel.RiskRatio; sRow.RiskLower = twoByTwoPanel.RiskRatioLower; sRow.RiskUpper = twoByTwoPanel.RiskRatioUpper; sRow.OddsRatio = twoByTwoPanel.OddsRatio; sRow.OddsLower = twoByTwoPanel.OddsRatioLower; sRow.OddsUpper = twoByTwoPanel.OddsRatioUpper; strataGroupPanel.AddRow(sRow); strataGroupPanel.RowClicked += new StrataGridRowClickedHandler(strataGroupPanel_NoStrata_RowClicked); strataGroupPanel.ExpandAllClicked += new StrataGridExpandAllClickedHandler(strataGroupPanel_NoStrata_ExpandAllClicked); } groupPanel.Children.Add(crosstabPanel); //panelMain.Children.Add(crosstabPanel); if (!panelMain.Children.Contains(groupPanel)) { panelMain.Children.Add(groupPanel); } } else { GadgetStrataListPanel strataListPanel = new GadgetStrataListPanel(); bool found = false; foreach (UIElement element in groupPanel.Children) { if (element is GadgetStrataListPanel) { found = true; strataListPanel = (element as GadgetStrataListPanel); break; } } if (!found) { strataListPanel.RowClicked += new StrataGridRowClickedHandler(strataListPanel_RowClicked); strataListPanel.ExpandAllClicked += new StrataGridExpandAllClickedHandler(strataListPanel_ExpandAllClicked); strataListPanel.SnapsToDevicePixels = true; strataListPanels.Add(strataListPanel); groupPanel.Children.Add(strataListPanel); if (!isGrouped && strataSummaryOnly) { strataListPanel.Visibility = System.Windows.Visibility.Collapsed; } //panelMain.Children.Add(strataListPanel); } StrataGridListRow sRow = new StrataGridListRow(); sRow.StrataLabel = formattedValue; sRow.OutcomeRateExposure = twoByTwoPanel.OutcomeRateExposure; sRow.OutcomeRateNoExposure = twoByTwoPanel.OutcomeRateNoExposure; sRow.RiskRatio = twoByTwoPanel.RiskRatio; sRow.RiskLower = twoByTwoPanel.RiskRatioLower; sRow.RiskUpper = twoByTwoPanel.RiskRatioUpper; sRow.OddsRatio = twoByTwoPanel.OddsRatio; sRow.OddsLower = twoByTwoPanel.OddsRatioLower; sRow.OddsUpper = twoByTwoPanel.OddsRatioUpper; strataListPanel.AddRow(sRow); if (isGrouped && strataGroupPanel != null) { strataListPanel.ExpanderHeader = groupReference; sRow = new StrataGridListRow(); sRow.StrataLabel = groupReference; sRow.OutcomeRateExposure = null; sRow.OutcomeRateNoExposure = null; sRow.RiskRatio = null; sRow.RiskLower = null; sRow.RiskUpper = null; sRow.OddsRatio = null; sRow.OddsLower = null; sRow.OddsUpper = null; strataGroupPanel.AddRow(sRow); strataGroupPanel.RowClicked += new StrataGridRowClickedHandler(strataGroupPanel_RowClicked); strataGroupPanel.ExpandAllClicked += new StrataGridExpandAllClickedHandler(strataGroupPanel_ExpandAllClicked); } twoByTwoPanel.Tag = formattedValue; crosstabPanel.Margin = (Thickness)this.Resources["genericElementMargin"]; crosstabPanel.Children.Add(twoByTwoPanel); expander.Margin = (Thickness)this.Resources["expanderMargin"]; expander.IsExpanded = true; expander.Content = crosstabPanel; groupPanel.Children.Add(expander); //panelMain.Children.Add(expander); StrataExpanderList.Add(expander); if (groupList.Count == 0) { groupList.Add(groupPanel); } if (!panelMain.Children.Contains(groupPanel)) { panelMain.Children.Add(groupPanel); } } strata2x2GridList.Add(twoByTwoPanel); return; } else if ((columnCount != 3 || table.Rows.Count != 2) && (isRunningGrouped2x2 == true)) { return; } isRunningGrouped2x2 = false; Grid chiSquaregrid = new Grid(); chiSquaregrid.Tag = value; chiSquaregrid.HorizontalAlignment = HorizontalAlignment.Center; chiSquaregrid.Margin = new Thickness(0, 5, 0, 10); chiSquaregrid.Visibility = System.Windows.Visibility.Collapsed; chiSquaregrid.ColumnDefinitions.Add(new ColumnDefinition()); chiSquaregrid.ColumnDefinitions.Add(new ColumnDefinition()); chiSquaregrid.ColumnDefinitions.Add(new ColumnDefinition()); chiSquaregrid.RowDefinitions.Add(new RowDefinition()); chiSquaregrid.RowDefinitions.Add(new RowDefinition()); Grid grid = new Grid(); grid.Tag = value; grid.Style = this.Resources["genericOutputGrid"] as Style; grid.Visibility = System.Windows.Visibility.Collapsed; grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; for (int i = 0; i < columnCount; i++) { ColumnDefinition column = new ColumnDefinition(); column.Width = GridLength.Auto; grid.ColumnDefinitions.Add(column); } ColumnDefinition totalColumn = new ColumnDefinition(); totalColumn.Width = GridLength.Auto; grid.ColumnDefinitions.Add(totalColumn); ScrollViewer sv = new ScrollViewer(); sv.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; sv.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; sv.MaxHeight = System.Windows.SystemParameters.PrimaryScreenHeight - 320; sv.MaxWidth = System.Windows.SystemParameters.PrimaryScreenWidth - 300; sv.Margin = (Thickness)this.Resources["expanderMargin"]; Grid gridOuter = new Grid(); gridOuter.ColumnDefinitions.Add(new ColumnDefinition()); gridOuter.ColumnDefinitions.Add(new ColumnDefinition()); gridOuter.RowDefinitions.Add(new RowDefinition()); gridOuter.RowDefinitions.Add(new RowDefinition()); Grid.SetColumn(grid, 1); Grid.SetRow(grid, 1); gridOuter.Children.Add(grid); Canvas exposureCanvas = new Canvas(); Grid.SetColumn(exposureCanvas, 0); Grid.SetRow(exposureCanvas, 1); exposureCanvas.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; exposureCanvas.VerticalAlignment = System.Windows.VerticalAlignment.Center; exposureCanvas.Width = 25; Binding canvasHeightBinding = new Binding("Height"); canvasHeightBinding.Source = grid; exposureCanvas.SetBinding(Grid.HeightProperty, canvasHeightBinding); TextBlock tblock1 = new TextBlock(); tblock1.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; tblock1.VerticalAlignment = System.Windows.VerticalAlignment.Center; tblock1.Margin = new Thickness(0, 0, -5, 0); tblock1.FontWeight = FontWeights.Bold; tblock1.FontSize = tblock1.FontSize + 2; if (DashboardHelper.GetAllGroupsAsList().Contains(cbxExposureField.SelectedItem.ToString())) { tblock1.Text = value; } else { tblock1.Text = cbxExposureField.SelectedItem.ToString(); } Typeface typeFace = new Typeface(new FontFamily("Global User Interface"), tblock1.FontStyle, tblock1.FontWeight, tblock1.FontStretch); FormattedText ftxt = new FormattedText(tblock1.Text, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeFace, tblock1.FontSize, Brushes.Black); RotateTransform rotate = new RotateTransform(270); // This code works, but only if grid height is known at this point. //double actualCanvasHeight = exposureCanvas.Height; //double actualControlWidth = ftxt.Width;//tblockExposure.ActualWidth; //double x = Canvas.GetLeft(tblock1); //if (actualCanvasHeight > actualControlWidth) //{ // double diff = actualCanvasHeight - actualControlWidth; // double bottom = diff / 2; // Canvas.SetBottom(tblock1, bottom); //} tblock1.RenderTransform = rotate; exposureCanvas.Children.Add(tblock1); //Grid.SetColumn(tblock1, 0); //Grid.SetRow(tblock1, 1); //gridOuter.Children.Add(tblock1); gridOuter.Children.Add(exposureCanvas); TextBlock tblock2 = new TextBlock(); tblock2.Name = "tblockOutcomeGridHeader"; tblock2.FontWeight = FontWeights.Bold; tblock2.FontSize = tblock1.FontSize + 2; tblock2.Text = cbxOutcomeField.SelectedItem.ToString(); tblock2.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; tblock2.VerticalAlignment = System.Windows.VerticalAlignment.Center; Grid.SetColumn(tblock2, 1); Grid.SetRow(tblock2, 0); gridOuter.Children.Add(tblock2); sv.Content = gridOuter; TextBlock txtDisclaimerLabel = new TextBlock(); txtDisclaimerLabel.Text = string.Empty; txtDisclaimerLabel.Margin = new Thickness(2, 8, 2, 10); txtDisclaimerLabel.HorizontalAlignment = HorizontalAlignment.Center; txtDisclaimerLabel.Tag = value; gridDisclaimerList.Add(txtDisclaimerLabel); crosstabPanel.Children.Add(sv); crosstabPanel.Children.Add(chiSquaregrid); crosstabPanel.Children.Add(txtDisclaimerLabel); if (string.IsNullOrEmpty(strataVar) && GadgetOptions.StrataVariableNames.Count == 0) { panelMain.Children.Add(crosstabPanel); } else { crosstabPanel.Margin = (Thickness)this.Resources["genericElementMargin"]; expander.Margin = (Thickness)this.Resources["expanderMargin"]; expander.IsExpanded = true; expander.Content = crosstabPanel; panelMain.Children.Add(expander); } strataChiSquareGridList.Add(chiSquaregrid); StrataGridList.Add(grid); }
public void PathIsDot () { var target = new Canvas (); target.DataContext = "5"; target.SetBinding (Canvas.WidthProperty, new Binding (".")); Assert.AreEqual (5, target.Width, "#1"); }
//----------------------------------------------------------------------------// // Constructors // //----------------------------------------------------------------------------// //////////////////////////////////////////////////////////////////////////////// /// <summary> </summary> public GraphCanvas() { // Create brushes mSourceBrush = new SolidColorBrush (Color.FromArgb (255, 32, 132, 32)); mTargetBrush = new SolidColorBrush (Color.FromArgb (255, 132, 32, 32)); // Create selection containers mSelected = new LinkedList<Sensor>(); // Initialize lasso selection mLassoCanvas = new Canvas(); Children.Add (mLassoCanvas); mSelection = new LinkedList<Point>(); mLassoCanvas.Visibility = Visibility.Collapsed; Canvas.SetLeft (mLassoCanvas, 0); Canvas.SetTop (mLassoCanvas, 0); Canvas.SetZIndex (mLassoCanvas, 1); Binding wBinding = new Binding ("Width" ); wBinding.Source = this; Binding hBinding = new Binding ("Height"); hBinding.Source = this; mLassoCanvas.SetBinding (Canvas.WidthProperty, wBinding); mLassoCanvas.SetBinding (Canvas.HeightProperty, hBinding); mLassoBrush = new SolidColorBrush (Color.FromArgb (164, 255, 255, 255)); // Initialize path canvas mPathCanvas = new Canvas(); Children.Add (mPathCanvas); Canvas.SetLeft (mPathCanvas, 0); Canvas.SetTop (mPathCanvas, 0); Canvas.SetZIndex (mPathCanvas, 1); mPathCanvas.SetBinding (Canvas.WidthProperty, wBinding); mPathCanvas.SetBinding (Canvas.HeightProperty, hBinding); mPathBrush = new SolidColorBrush (Color.FromArgb (192, 255, 255, 255)); // Subscribe to events MouseUp += ActionMouseUp; MouseDown += ActionMouseDown; MouseMove += ActionMouseMove; }
public Gauge() { Canvas = new Canvas {ClipToBounds = true}; Content = Canvas; PieBack = new PieSlice(); Pie = new PieSlice(); TitleTextBlock = new TextBlock(); MeasureTextBlock = new TextBlock(); LeftLabel = new TextBlock(); RightLabel = new TextBlock(); Canvas.Children.Add(PieBack); Canvas.Children.Add(Pie); Canvas.Children.Add(TitleTextBlock); Canvas.Children.Add(MeasureTextBlock); Canvas.Children.Add(RightLabel); Canvas.Children.Add(LeftLabel); Panel.SetZIndex(PieBack, 0); Panel.SetZIndex(Pie, 1); Canvas.SetBinding(WidthProperty, new Binding {Path = new PropertyPath(WidthProperty), Source = this}); Canvas.SetBinding(HeightProperty, new Binding {Path = new PropertyPath(HeightProperty), Source = this}); PieBack.SetBinding(Shape.FillProperty, new Binding {Path = new PropertyPath(GaugeBackgroundProperty), Source = this}); PieBack.SetBinding(Shape.StrokeThicknessProperty, new Binding {Path = new PropertyPath(StrokeThicknessProperty), Source = this}); PieBack.SetBinding(Shape.StrokeProperty, new Binding {Path = new PropertyPath(StrokeProperty), Source = this}); Pie.SetBinding(Shape.StrokeThicknessProperty, new Binding { Path = new PropertyPath(StrokeThicknessProperty), Source = this }); Pie.Stroke = Brushes.Transparent; TitleTextBlock.SetBinding(TextBlock.TextProperty, new Binding { Path = new PropertyPath(TitleProperty), Source = this }); SetValue(GaugeBackgroundProperty, new SolidColorBrush(Color.FromRgb(21, 101, 191)) {Opacity = .1}); SetValue(StrokeThicknessProperty, 0d); SetValue(StrokeProperty, new SolidColorBrush(Color.FromRgb(222, 222, 222))); SetValue(ToColorProperty, Color.FromRgb(100, 180, 245)); SetValue(FromColorProperty, Color.FromRgb(21, 101, 191)); SetValue(MinHeightProperty, 50d); SetValue(MinWidthProperty, 80d); SetValue(AnimationsSpeedProperty, TimeSpan.FromMilliseconds(800)); MeasureTextBlock.FontWeight = FontWeights.Bold; IsNew = true; SizeChanged += (sender, args) => { IsChartInitialized = true; Update(); }; }
/// <summary> /// Initializes a new instance of the <see cref="GeoMap"/> class. /// </summary> public GeoMap() { Canvas = new Canvas(); Map = new Canvas(); Canvas.Children.Add(Map); Content = Canvas; Canvas.SetBinding(WidthProperty, new Binding { Path = new PropertyPath(ActualWidthProperty), Source = this }); Canvas.SetBinding(HeightProperty, new Binding { Path = new PropertyPath(ActualHeightProperty), Source = this }); Lands = new Dictionary<string, MapData>(); SetCurrentValue(DefaultLandFillProperty, new SolidColorBrush(Color.FromArgb(200,255,255,255))); SetCurrentValue(LandStrokeProperty, new SolidColorBrush(Color.FromArgb(30, 55,55, 55))); SetCurrentValue(LandStrokeThicknessProperty, 1.3d); SetCurrentValue(AnimationsSpeedProperty, TimeSpan.FromMilliseconds(500)); SetCurrentValue(BackgroundProperty, new SolidColorBrush(Color.FromArgb(150, 96, 125, 138))); SetCurrentValue(GradientStopCollectionProperty, new GradientStopCollection { new GradientStop(Color.FromArgb(100,2,119,188), 0d), new GradientStop(Color.FromRgb(2,119,188), 1d), }); SetCurrentValue(HeatMapProperty, new Dictionary<string, double>()); SetCurrentValue(GeoMapTooltipProperty, new DefaultGeoMapTooltip {Visibility = Visibility.Hidden}); Canvas.Children.Add(GeoMapTooltip); SizeChanged += (sender, e) => { Draw(); }; MouseWheel += (sender, e) => { if (!EnableZoomingAndPanning) return; e.Handled = true; var rt = Map.RenderTransform as ScaleTransform; var p = rt == null ? 1 : rt.ScaleX; p += e.Delta > 0 ? .05 : -.05; p = p < 1 ? 1 : p; var o = e.GetPosition(this); if (e.Delta > 0) Map.RenderTransformOrigin = new Point(o.X/ActualWidth,o.Y/ActualHeight); Map.RenderTransform = new ScaleTransform(p, p); }; MouseDown += (sender, e) => { if (!EnableZoomingAndPanning) return; DragOrigin = e.GetPosition(this); }; MouseUp += (sender, e) => { if (!EnableZoomingAndPanning) return; var end = e.GetPosition(this); var delta = new Point(DragOrigin.X - end.X, DragOrigin.Y - end.Y); var l = Canvas.GetLeft(Map) - delta.X; var t = Canvas.GetTop(Map) - delta.Y; if (DisableAnimations) { Canvas.SetLeft(Map, l); Canvas.SetTop(Map, t); } else { Map.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(l, AnimationsSpeed)); Map.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(t, AnimationsSpeed)); } }; }
public override void OnApplyTemplate() { base.OnApplyTemplate(); _dgTrendPens = GetTemplateChild("dgTrendPens") as DataGrid; if (_dgTrendPens != null) { UpdateDgPensColumnsVisibility(); } _gTrendPresenters = (Grid) GetTemplateChild("gTrendPresenters"); if (_gTrendPresenters != null) { _gTrendPresenters.MouseLeftButtonDown += GTrendPresentersMouseLeftButtonDown; _gTrendPresenters.MouseLeftButtonUp += GTrendPresentersMouseLeftButtonUp; _gTrendPresenters.MouseMove += GTrendPresentersMouseMove; } _gVerticalAxes = (Grid)GetTemplateChild("gVerticalAxes"); _cVerticalAxes = (Canvas)GetTemplateChild("cVerticalAxes"); if (_cVerticalAxes != null) { _cVerticalAxes.SizeChanged += CVerticalAxesSizeChanged; } _cHorizontalAxes = (Canvas)GetTemplateChild("cHorizontalAxes"); if (_cHorizontalAxes != null) { _cHorizontalAxes.SizeChanged += CHorizontalAxesSizeChanged; } _spHorisontalAxes = (StackPanel)GetTemplateChild("spHorisontalAxes"); #region Slider _slSlider = GetTemplateChild("slSlider") as Slider; if (_slSlider != null) { var sliderBinding = new Binding("CursorPosition") { Source = this, Mode = BindingMode.TwoWay }; _slSlider.SetBinding(RangeBase.ValueProperty, sliderBinding); } _cdSliderOffset = (ColumnDefinition)GetTemplateChild("cdSliderOffset"); _gSlider = (Grid)GetTemplateChild("gSlider"); if (_gSlider != null) _gSlider.SizeChanged += GSliderSizeChanged; _cSlider = (Canvas)GetTemplateChild("cSlider"); if (_cSlider != null) { var presentersVisibilityBinding = new Binding("ShowCursorPresenters") { Source = this, Converter = new BooleanToVisibilityConverter() }; _cSlider.SetBinding(VisibilityProperty, presentersVisibilityBinding); _cSlider.SizeChanged += CSliderSizeChanged; } _spSlider = (Panel)GetTemplateChild("spSlider"); UpdateSliderVisibility(); #endregion #region SetPeriod _popupPeriod = GetTemplateChild("popupPeriod") as Popup; _tspSetPeriod = GetTemplateChild("tspSetPeriod") as TimeSpanPicker; if (_popupPeriod != null && _tspSetPeriod != null) { _popupPeriod.Opened += PopupPeriodOpened; _tspSetPeriod.KeyUp += TspSetPeriodKeyUp; var bSetPeriod = GetTemplateChild("bSetPeriod") as Button; if (bSetPeriod != null) bSetPeriod.Click += BSetPeriodClick; } #endregion #region SetTime _popupTime = GetTemplateChild("popupTime") as Popup; _dtpSetTime = GetTemplateChild("dtpSetTime") as DateTimePicker; if (_popupTime != null && _dtpSetTime != null) { _popupTime.Opened += PopupTimeOpened; _dtpSetTime.KeyUp += DtpSetTimeKeyUp; var bSetTime = GetTemplateChild("bSetTime") as Button; if (bSetTime != null) { bSetTime.Click += BSetTimeClick; } } #endregion }