From b788e4c0e08c30574a19e56bdd285e833514d32d Mon Sep 17 00:00:00 2001 From: TSK Date: Thu, 25 Jun 2020 12:08:06 +0200 Subject: [PATCH 01/12] humanizerfix --- .../Soloplan.WhatsON.GUI.Common.csproj | 5 ++++- src/Soloplan.WhatsON.GUI/Soloplan.WhatsON.GUI.csproj | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Soloplan.WhatsON.GUI.Common/Soloplan.WhatsON.GUI.Common.csproj b/src/Soloplan.WhatsON.GUI.Common/Soloplan.WhatsON.GUI.Common.csproj index a894912..5e62a3e 100644 --- a/src/Soloplan.WhatsON.GUI.Common/Soloplan.WhatsON.GUI.Common.csproj +++ b/src/Soloplan.WhatsON.GUI.Common/Soloplan.WhatsON.GUI.Common.csproj @@ -105,8 +105,11 @@ 2.2.0 + + 2.8.26 + - 2.7.9 + 2.8.26 3.0.1 diff --git a/src/Soloplan.WhatsON.GUI/Soloplan.WhatsON.GUI.csproj b/src/Soloplan.WhatsON.GUI/Soloplan.WhatsON.GUI.csproj index ea70ec6..ee571ec 100644 --- a/src/Soloplan.WhatsON.GUI/Soloplan.WhatsON.GUI.csproj +++ b/src/Soloplan.WhatsON.GUI/Soloplan.WhatsON.GUI.csproj @@ -271,8 +271,11 @@ 1.5.0.6 + + 2.8.26 + - 2.7.9 + 2.8.26 1.2.2 From 71464abc208762ab285af4d1f8e026783d7afa80 Mon Sep 17 00:00:00 2001 From: TSK Date: Fri, 26 Jun 2020 08:40:26 +0200 Subject: [PATCH 02/12] multi deletions fix --- .../ConnectorTreeViewModel.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorTreeViewModel.cs b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorTreeViewModel.cs index e228c27..0225ce6 100644 --- a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorTreeViewModel.cs +++ b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorTreeViewModel.cs @@ -653,6 +653,33 @@ private void DeleteSelectedConnectors() } } + /// + /// Performs a deletion of a connector. + /// + private void DeleteConnector(ConnectorViewModel connectorViewModel) + { + bool madeChanges = false; + foreach (var connectorGroup in this.connectorGroups.ToList()) + { + foreach (var connector in connectorGroup.ConnectorViewModels.ToList()) + { + if (connectorViewModel.Identifier == connector.Identifier) + { + connectorGroup.ConnectorViewModels.Remove(connectorViewModel); + madeChanges = true; + } + } + } + + this.ClearEmptyGroups(); + + if (madeChanges) + { + this.OnConfigurationChanged(this, EventArgs.Empty); + this.FireOneGroupChanged(); + } + } + public async void DeleteGroup(object sender, DeleteTreeItemEventArgs e) { if (e.DeleteItem is ConnectorViewModel clickedConnector) @@ -670,6 +697,12 @@ public async void DeleteGroup(object sender, DeleteTreeItemEventArgs e) var canceled = await e.CheckCanceled(); if (!canceled) { + if (selectedConnectors.Count == 0) + { + this.DeleteConnector(clickedConnector); + return; + } + this.DeleteSelectedConnectors(); } From 06847ec88bb9cddaa3fc9e2757540ccce45e2830 Mon Sep 17 00:00:00 2001 From: TSK Date: Fri, 26 Jun 2020 11:09:51 +0200 Subject: [PATCH 03/12] undo optimization --- .../ConnectorTreeView/ConnectorsTreeView.xaml | 6 ++-- .../ConnectorsTreeView.xaml.cs | 33 ------------------- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml index e7e0b23..0c44c64 100644 --- a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml +++ b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml @@ -200,10 +200,8 @@ HorizontalContentAlignment="Stretch" dd:DragDrop.DropHandler="{Binding}" dd:DragDrop.IsDragSource="True" - dd:DragDrop.IsDropTarget="True" - VirtualizingPanel.IsVirtualizing="True" - ScrollViewer.ScrollChanged="OnScroll"> - + dd:DragDrop.IsDropTarget="True"> + diff --git a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs index 4d1a496..7a4c575 100644 --- a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs +++ b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs @@ -871,38 +871,5 @@ private void OnKeyDown(object sender, KeyEventArgs e) } } } - - /// - /// Handles scrolling event. Becuse of item virtualization it is necessary to refresh displayed item styles in code behind, because virtual items are null pointers when not seen. - /// - /// Sender object. - /// Args. - private void OnScroll(object sender, ScrollChangedEventArgs e) - { - if (this.model == null) - { - return; - } - - if (this.model.ConnectorGroups == null) - { - return; - } - - foreach (var group in this.model.ConnectorGroups) - { - foreach (var item in group.ConnectorViewModels) - { - if (this.IsConnectorSelected(item)) - { - this.SetConnectorStyle(item); - } - else if (!this.IsConnectorSelected(item)) - { - this.ResetConnectorStyle(item); - } - } - } - } } } From 74d725dc0d9a461ddffcb8e1a7210e0d82148ec9 Mon Sep 17 00:00:00 2001 From: TSK Date: Fri, 26 Jun 2020 11:26:10 +0200 Subject: [PATCH 04/12] master update --- .../ConnectorsTreeView.xaml.cs | 219 +++++++++++++++--- 1 file changed, 192 insertions(+), 27 deletions(-) diff --git a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs index 7a4c575..4fb3bb0 100644 --- a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs +++ b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs @@ -19,13 +19,17 @@ namespace Soloplan.WhatsON.GUI.Common.ConnectorTreeView using System.Windows.Input; using System.Windows.Markup; using System.Windows.Media; + using System.Windows.Media.Animation; using GongSolutions.Wpf.DragDrop; + using Humanizer; using Humanizer.Localisation; using MaterialDesignThemes.Wpf; using Soloplan.WhatsON.Composition; using Soloplan.WhatsON.Configuration; using Soloplan.WhatsON.GUI.Common.VisualConfig; using Soloplan.WhatsON.Model; + using Windows.Networking.Sockets; + using Windows.UI.Notifications; /// /// Interaction logic for ConnectorsTreeView.xaml. @@ -34,7 +38,7 @@ public partial class ConnectorsTreeView : UserControl, IDisposable { private ConnectorTreeViewModel model; - private Collection selectedConnectors=new Collection(); + private Collection selectedConnectors = new Collection(); /// /// Backing field for . @@ -128,6 +132,27 @@ public void ApplyTreeListSettings(TreeListSettings treeListSettings) this.model.ApplyGroupExpansionState(treeListSettings.GroupExpansions); } + /// + /// Gets the ConnectorViewModel based on given identifier. + /// + /// Connector's identifier. + /// ConnectorViewModel. + public ConnectorViewModel GetConnectorWithIdentifier(string identifier) + { + foreach (var group in this.model.ConnectorGroups) + { + foreach (var connector in group.ConnectorViewModels) + { + if (connector.Identifier.ToString() == identifier) + { + return connector; + } + } + } + + return null; + } + /// /// Focuses the node connected with . /// @@ -147,7 +172,35 @@ public void FocusItem(Connector connector) { groupViewModel.IsNodeExpanded = true; treeViewItem.IsSelected = true; - treeViewItem.BringIntoView(new Rect(100, 100, 100, 100)); + var scrollViewer = this.mainTreeView.Template.FindName("ScrollViewer", this.mainTreeView) as ScrollViewer; + } + } + } + } + } + + /// + /// Focuses the node connected with . + /// + /// Connector which should be focused. + public void FocusItem(ConnectorViewModel connector) + { + foreach (var groupViewModel in this.model.ConnectorGroups) + { + foreach (var connectorViewModel in groupViewModel.ConnectorViewModels) + { + if (connectorViewModel.Connector.Configuration.Identifier == connector.Identifier) + { + TreeViewItem groupViewItem = (TreeViewItem)this.mainTreeView.ItemContainerGenerator.ContainerFromItem(groupViewModel); + var treeViewItem = (TreeViewItem)groupViewItem?.ItemContainerGenerator.ContainerFromItem(connectorViewModel) + ?? (TreeViewItem)this.mainTreeView.ItemContainerGenerator.ContainerFromItem(connectorViewModel); + if (treeViewItem != null) + { + groupViewModel.IsNodeExpanded = true; + this.SetConnectorStyle(connector); + var offset = treeViewItem.TransformToAncestor(this.mainTreeView).Transform(new Point(0.0, 0.0)); + this.mainScrollViewer.ScrollToVerticalOffset(offset.Y - (this.RenderSize.Height / 2) + (treeViewItem.RenderSize.Height / 2)); + this.BeginBlinkAnimation(ref treeViewItem); } } } @@ -224,7 +277,7 @@ private CustomCommand CreateDeleteFocusedObjectCommand() } var args = new DeleteTreeItemEventArgs(this.selectedConnectors[0]); - this.model.DeleteGroup(s,args); + this.model.DeleteGroup(s, args); }; return command; @@ -331,8 +384,25 @@ private void ResetStyle(ref TreeViewItem treeViewItem) { var style = this.FindResource("MaterialDesignBackground"); treeViewItem.Foreground = this.InvertColor(style.ToString()); + + treeViewItem.BeginAnimation(TreeViewItem.OpacityProperty, null); + treeViewItem.IsSelected = false; } + private void BeginBlinkAnimation(ref TreeViewItem treeViewItem) + { + DoubleAnimation animation = new DoubleAnimation(); + animation.From = treeViewItem.Opacity; + animation.To = 0.5; + animation.Duration = new Duration(TimeSpan.FromSeconds(0.5)); + animation.AutoReverse = true; + animation.RepeatBehavior = new RepeatBehavior(TimeSpan.FromSeconds(3.0d)); + treeViewItem.BeginAnimation(TreeViewItem.OpacityProperty, animation); + + } + + + /// /// Sets style for a tree view item. /// @@ -573,6 +643,22 @@ private bool IsConnectorSelected(ConnectorViewModel connector) return isAlreadyAdded; } + public ConnectorGroupViewModel FindConnectorGroup(ConnectorViewModel connectorViewModel) + { + foreach (var group in this.model.ConnectorGroups) + { + foreach (var connector in group.ConnectorViewModels) + { + if (connector.Identifier == connectorViewModel.Identifier) + { + return group; + } + } + } + + return null; + } + /// /// Checks if all connectors are selected. /// @@ -626,6 +712,27 @@ private void OnGroupClicked(ConnectorGroupViewModel group) } } + /// + /// Gets the connector group/ + /// + /// Connector to get froup of + /// Group + private ConnectorGroupViewModel GetConnectorGroup(ConnectorViewModel connector) + { + foreach (ConnectorGroupViewModel groupViewModel in this.model.ConnectorGroups) + { + foreach (ConnectorViewModel connectorViewModel in groupViewModel.ConnectorViewModels) + { + if (connector.Identifier == connectorViewModel.Identifier) + { + return groupViewModel; + } + } + } + + return null; + } + /// /// Defines behaviour when an item in tree is clicked with Ctrl. /// @@ -640,22 +747,19 @@ private void ControlLeftMouseDownHandler(object sender, MouseButtonEventArgs e) } var connector = new ConnectorViewModel(); - try + if (item.Header is ConnectorViewModel) { connector = (ConnectorViewModel)item.Header; this.OnCtrlProjectClicked(connector); } - catch + else { var group = new ConnectorGroupViewModel(); - try + if(item.Header is ConnectorGroupViewModel) { group = (ConnectorGroupViewModel)item.Header; this.OnGroupClicked(group); } - catch (Exception ex) - { - } } this.model.UpdateSelectedConnectors(this.selectedConnectors); @@ -675,14 +779,11 @@ private void ShiftLeftMouseDownHandler(object sender, MouseButtonEventArgs e) } var connector = new ConnectorViewModel(); - try + if (item.Header is ConnectorViewModel) { connector = (ConnectorViewModel)item.Header; this.OnShiftProjectClicked(connector); } - catch - { - } } /// @@ -692,7 +793,7 @@ private void OnTreeItemLeftMouseDown(object sender, MouseButtonEventArgs e) { if (Keyboard.IsKeyDown(Key.LeftCtrl)) { - this.ControlLeftMouseDownHandler(sender,e); + this.ControlLeftMouseDownHandler(sender, e); } else if (Keyboard.IsKeyDown(Key.LeftShift)) { @@ -744,20 +845,21 @@ private void ManageContextMenuAvailability() private void ControlLeftMouseUpHandler(object sender, MouseButtonEventArgs e) { TreeViewItem item = (TreeViewItem)sender; - try + + var connector = new ConnectorViewModel(); + if (item == null) { - var connector = new ConnectorViewModel(); - if (item == null) - { - return; - } + return; + } + if (item.Header is ConnectorViewModel) + { connector = (ConnectorViewModel)item.Header; this.DeselectAllConnectors(); this.connectorItemEventFired = true; this.OnCtrlProjectClicked(connector); } - catch + else { if (this.connectorItemEventFired) { @@ -766,18 +868,14 @@ private void ControlLeftMouseUpHandler(object sender, MouseButtonEventArgs e) else { var group = new ConnectorGroupViewModel(); - try + if (item.Header is ConnectorGroupViewModel) { group = (ConnectorGroupViewModel)item.Header; this.DeselectAllConnectors(); this.OnGroupClicked(group); } - catch (Exception ex) - { - } } } - this.model.UpdateSelectedConnectors(this.selectedConnectors); } @@ -790,7 +888,7 @@ private void OnTreeItemLeftMouseUp(object sender, MouseButtonEventArgs e) { if (Keyboard.IsKeyUp(Key.LeftCtrl) && Keyboard.IsKeyUp(Key.LeftShift)) { - this.ControlLeftMouseUpHandler(sender,e); + this.ControlLeftMouseUpHandler(sender, e); } this.ManageContextMenuAvailability(); @@ -871,5 +969,72 @@ private void OnKeyDown(object sender, KeyEventArgs e) } } } + + /// + /// Defines behavoiour when RMB is used. + /// + /// sender item. + /// event args. + private void OnTreeItemRightMouseDown(object sender, MouseButtonEventArgs e) + { + TreeViewItem item = (TreeViewItem)sender; + try + { + var connector = new ConnectorViewModel(); + if (item == null) + { + return; + } + + connector = (ConnectorViewModel)item.Header; + foreach (var selectedItem in this.selectedConnectors) + { + if (selectedItem.Identifier == connector.Identifier) + { + return; + } + } + } + catch + { + return; + } + + this.DeselectAllConnectors(); + this.model.UpdateSelectedConnectors(this.selectedConnectors); + } + + /// + /// Handles scrolling event. Becuse of item virtualization it is necessary to refresh displayed item styles in code behind, because virtual items are null pointers when not seen. + /// + /// Sender object. + /// Args. + private void OnScroll(object sender, ScrollChangedEventArgs e) + { + if (this.model == null) + { + return; + } + + if (this.model.ConnectorGroups == null) + { + return; + } + + foreach (var group in this.model.ConnectorGroups) + { + foreach (var item in group.ConnectorViewModels) + { + if (this.IsConnectorSelected(item)) + { + this.SetConnectorStyle(item); + } + else if (!this.IsConnectorSelected(item)) + { + this.ResetConnectorStyle(item); + } + } + } + } } } From 7df7fc5e028dfc4518aef4dfbcd5d67426ed6c07 Mon Sep 17 00:00:00 2001 From: TSK Date: Fri, 26 Jun 2020 11:26:18 +0200 Subject: [PATCH 05/12] master update --- .../ConnectorsTreeView.xaml.cs | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs index 4fb3bb0..651ba09 100644 --- a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs +++ b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs @@ -28,8 +28,6 @@ namespace Soloplan.WhatsON.GUI.Common.ConnectorTreeView using Soloplan.WhatsON.Configuration; using Soloplan.WhatsON.GUI.Common.VisualConfig; using Soloplan.WhatsON.Model; - using Windows.Networking.Sockets; - using Windows.UI.Notifications; /// /// Interaction logic for ConnectorsTreeView.xaml. @@ -172,7 +170,6 @@ public void FocusItem(Connector connector) { groupViewModel.IsNodeExpanded = true; treeViewItem.IsSelected = true; - var scrollViewer = this.mainTreeView.Template.FindName("ScrollViewer", this.mainTreeView) as ScrollViewer; } } } @@ -198,9 +195,6 @@ public void FocusItem(ConnectorViewModel connector) { groupViewModel.IsNodeExpanded = true; this.SetConnectorStyle(connector); - var offset = treeViewItem.TransformToAncestor(this.mainTreeView).Transform(new Point(0.0, 0.0)); - this.mainScrollViewer.ScrollToVerticalOffset(offset.Y - (this.RenderSize.Height / 2) + (treeViewItem.RenderSize.Height / 2)); - this.BeginBlinkAnimation(ref treeViewItem); } } } @@ -970,40 +964,6 @@ private void OnKeyDown(object sender, KeyEventArgs e) } } - /// - /// Defines behavoiour when RMB is used. - /// - /// sender item. - /// event args. - private void OnTreeItemRightMouseDown(object sender, MouseButtonEventArgs e) - { - TreeViewItem item = (TreeViewItem)sender; - try - { - var connector = new ConnectorViewModel(); - if (item == null) - { - return; - } - - connector = (ConnectorViewModel)item.Header; - foreach (var selectedItem in this.selectedConnectors) - { - if (selectedItem.Identifier == connector.Identifier) - { - return; - } - } - } - catch - { - return; - } - - this.DeselectAllConnectors(); - this.model.UpdateSelectedConnectors(this.selectedConnectors); - } - /// /// Handles scrolling event. Becuse of item virtualization it is necessary to refresh displayed item styles in code behind, because virtual items are null pointers when not seen. /// From 7e1d7080a65ba831d714a91ec6fa8b5af418ffb0 Mon Sep 17 00:00:00 2001 From: TSK Date: Wed, 1 Jul 2020 14:14:26 +0200 Subject: [PATCH 06/12] Empty tooltips visibility solved. --- .../CruiseControlProjectDataTemplate.xaml | 25 +++++++----- .../CruiseControlProjectViewModel.cs | 16 ++++++++ .../BuildServer/CulpritsControl.xaml | 2 +- .../ConnectorTreeView/ConnectorViewModel.cs | 9 +++++ .../MainStatusToVisibilityConverter.cs | 38 +++++++++++++++++++ .../Soloplan.WhatsON.GUI.Common.csproj | 1 + .../WizardProjectToVisibilityConverter.cs | 38 +++++++++++++++++++ .../Configuration/Wizard/ProjectViewModel.cs | 9 +++++ .../Wizard/ProjectsTreeView.xaml | 22 ++++++----- .../Soloplan.WhatsON.GUI.csproj | 1 + .../JenkinsProjectDataTemplate.xaml | 32 ++++++++++------ .../JenkinsProjectViewModel.cs | 14 +++++++ 12 files changed, 175 insertions(+), 32 deletions(-) create mode 100644 src/Soloplan.WhatsON.GUI.Common/Converters/MainStatusToVisibilityConverter.cs create mode 100644 src/Soloplan.WhatsON.GUI/Configuration/Wizard/Converters/WizardProjectToVisibilityConverter.cs diff --git a/src/Soloplan.WhatsON.CruiseControl.GUI/CruiseControlProjectDataTemplate.xaml b/src/Soloplan.WhatsON.CruiseControl.GUI/CruiseControlProjectDataTemplate.xaml index cc34f75..f1bb09d 100644 --- a/src/Soloplan.WhatsON.CruiseControl.GUI/CruiseControlProjectDataTemplate.xaml +++ b/src/Soloplan.WhatsON.CruiseControl.GUI/CruiseControlProjectDataTemplate.xaml @@ -7,15 +7,23 @@ - - - - - + + + + + + - - + + + + + + + + + @@ -39,9 +47,6 @@ FontWeight="Normal" Text="{Binding CurrentStatus.FinishTime, Converter={StaticResource TimeToApproximateTimeConverter}}" Visibility="{Binding CurrentStatus.FinishTime, Converter={StaticResource NullOrDefaultVisibilityConverter}}" /> - - - \ No newline at end of file diff --git a/src/Soloplan.WhatsON.CruiseControl.GUI/CruiseControlProjectViewModel.cs b/src/Soloplan.WhatsON.CruiseControl.GUI/CruiseControlProjectViewModel.cs index c9a0b85..03c5800 100644 --- a/src/Soloplan.WhatsON.CruiseControl.GUI/CruiseControlProjectViewModel.cs +++ b/src/Soloplan.WhatsON.CruiseControl.GUI/CruiseControlProjectViewModel.cs @@ -8,8 +8,10 @@ namespace Soloplan.WhatsON.CruiseControl.GUI { using System; + using System.Windows.Navigation; using Soloplan.WhatsON.GUI.Common.BuildServer; using Soloplan.WhatsON.GUI.Common.ConnectorTreeView; + using Soloplan.WhatsON.Model; public class CruiseControlProjectViewModel : ConnectorViewModel { @@ -23,5 +25,19 @@ protected override BuildStatusViewModel GetStatusViewModel() { return new CruiseControlStatusViewModel(this); } + + /// + /// Implements function that decides if a tooltip should be visible. + /// + /// True when should be visible, false when should not be visible. + public override bool IsTooltipVisible() + { + if (this.CurrentStatus is CruiseControlStatusViewModel status) + { + return (status.Culprits.Count == 0 && status.State != ObservationState.Running) ? false : true; + } + + return true; + } } } \ No newline at end of file diff --git a/src/Soloplan.WhatsON.GUI.Common/BuildServer/CulpritsControl.xaml b/src/Soloplan.WhatsON.GUI.Common/BuildServer/CulpritsControl.xaml index 576f40b..cf7d0b0 100644 --- a/src/Soloplan.WhatsON.GUI.Common/BuildServer/CulpritsControl.xaml +++ b/src/Soloplan.WhatsON.GUI.Common/BuildServer/CulpritsControl.xaml @@ -14,7 +14,6 @@ - @@ -26,5 +25,6 @@ + diff --git a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorViewModel.cs b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorViewModel.cs index c094770..a15d007 100644 --- a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorViewModel.cs +++ b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorViewModel.cs @@ -179,6 +179,15 @@ public virtual void Update(Connector changedConnector) })); } + /// + /// Implements function that decides if a tooltip should be visible. + /// + /// Base returns always true. + public virtual bool IsTooltipVisible() + { + return true; + } + protected virtual BuildStatusViewModel GetStatusViewModel() { return new BuildStatusViewModel(this); diff --git a/src/Soloplan.WhatsON.GUI.Common/Converters/MainStatusToVisibilityConverter.cs b/src/Soloplan.WhatsON.GUI.Common/Converters/MainStatusToVisibilityConverter.cs new file mode 100644 index 0000000..ddaf8d7 --- /dev/null +++ b/src/Soloplan.WhatsON.GUI.Common/Converters/MainStatusToVisibilityConverter.cs @@ -0,0 +1,38 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) Soloplan GmbH. All rights reserved. +// Licensed under the MIT License. See License-file in the project root for license information. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace Soloplan.WhatsON.GUI.Common.Converters +{ + using Soloplan.WhatsON.GUI.Common.ConnectorTreeView; + using Soloplan.WhatsON.Model; + using System; + using System.Globalization; + using System.Windows; + using System.Windows.Data; + using System.Windows.Navigation; + + /// + /// Converter for projects DataTemplates. Determines visibility of a project tooltips. Uses StatusViewmodel method to find out if tooltip should be visible or not. + /// + public class MainStatusToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is StatusViewModel status) + { + return status.Parent.IsTooltipVisible() ? Visibility.Visible : Visibility.Hidden; + } + + return Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/Soloplan.WhatsON.GUI.Common/Soloplan.WhatsON.GUI.Common.csproj b/src/Soloplan.WhatsON.GUI.Common/Soloplan.WhatsON.GUI.Common.csproj index 5e62a3e..053d644 100644 --- a/src/Soloplan.WhatsON.GUI.Common/Soloplan.WhatsON.GUI.Common.csproj +++ b/src/Soloplan.WhatsON.GUI.Common/Soloplan.WhatsON.GUI.Common.csproj @@ -72,6 +72,7 @@ ProgressBarTooltipControl.xaml + diff --git a/src/Soloplan.WhatsON.GUI/Configuration/Wizard/Converters/WizardProjectToVisibilityConverter.cs b/src/Soloplan.WhatsON.GUI/Configuration/Wizard/Converters/WizardProjectToVisibilityConverter.cs new file mode 100644 index 0000000..29d82ea --- /dev/null +++ b/src/Soloplan.WhatsON.GUI/Configuration/Wizard/Converters/WizardProjectToVisibilityConverter.cs @@ -0,0 +1,38 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) Soloplan GmbH. All rights reserved. +// Licensed under the MIT License. See License-file in the project root for license information. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace Soloplan.WhatsON.GUI.Configuration.Wizard +{ + using Soloplan.WhatsON.GUI.Common.ConnectorTreeView; + using Soloplan.WhatsON.Model; + using System; + using System.Globalization; + using System.Windows; + using System.Windows.Data; + using System.Windows.Navigation; + + /// + /// Converter for wizard project tooltips. Uses method from ProjectViewModel to determine visibility. + /// + public class WizardProjectToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is Soloplan.WhatsON.GUI.Configuration.Wizard.ProjectViewModel project) + { + return project.IsTooltipVisible() ? Visibility.Visible : Visibility.Hidden; + } + + return Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/Soloplan.WhatsON.GUI/Configuration/Wizard/ProjectViewModel.cs b/src/Soloplan.WhatsON.GUI/Configuration/Wizard/ProjectViewModel.cs index 180561e..0ee51fd 100644 --- a/src/Soloplan.WhatsON.GUI/Configuration/Wizard/ProjectViewModel.cs +++ b/src/Soloplan.WhatsON.GUI/Configuration/Wizard/ProjectViewModel.cs @@ -213,5 +213,14 @@ private void UpdateParentGroupsCheckedState() currentParent = currentParent.Parent; } } + + /// + /// Decides if a tooltip should be visible. + /// + /// True when should be visible, false when should not be visible. + public bool IsTooltipVisible() + { + return (this.Description == string.Empty || this.Description == null) ? false : true; + } } } \ No newline at end of file diff --git a/src/Soloplan.WhatsON.GUI/Configuration/Wizard/ProjectsTreeView.xaml b/src/Soloplan.WhatsON.GUI/Configuration/Wizard/ProjectsTreeView.xaml index c3d354f..3c7aa7c 100644 --- a/src/Soloplan.WhatsON.GUI/Configuration/Wizard/ProjectsTreeView.xaml +++ b/src/Soloplan.WhatsON.GUI/Configuration/Wizard/ProjectsTreeView.xaml @@ -6,6 +6,7 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:wpf="clr-namespace:TheArtOfDev.HtmlRenderer.WPF;assembly=HtmlRenderer.WPF" + xmlns:converters="clr-namespace:Soloplan.WhatsON.GUI.Configuration.Wizard" d:DesignHeight="450" d:DesignWidth="800" Background="{DynamicResource MaterialDesignPaper}" @@ -15,20 +16,21 @@ - - + - - - - - - - - + + + + + + + + + + + WizardWindow.xaml diff --git a/src/Soloplan.WhatsON.Jenkins.GUI/JenkinsProjectDataTemplate.xaml b/src/Soloplan.WhatsON.Jenkins.GUI/JenkinsProjectDataTemplate.xaml index 1ba720e..4bab0a8 100644 --- a/src/Soloplan.WhatsON.Jenkins.GUI/JenkinsProjectDataTemplate.xaml +++ b/src/Soloplan.WhatsON.Jenkins.GUI/JenkinsProjectDataTemplate.xaml @@ -10,14 +10,15 @@ + + @@ -28,7 +29,7 @@ - + @@ -37,16 +38,28 @@ + + + + + + + + + + - - + + + + + + - + - - - - + \ No newline at end of file diff --git a/src/Soloplan.WhatsON.Jenkins.GUI/JenkinsProjectViewModel.cs b/src/Soloplan.WhatsON.Jenkins.GUI/JenkinsProjectViewModel.cs index da8a2b7..82f9be8 100644 --- a/src/Soloplan.WhatsON.Jenkins.GUI/JenkinsProjectViewModel.cs +++ b/src/Soloplan.WhatsON.Jenkins.GUI/JenkinsProjectViewModel.cs @@ -20,6 +20,20 @@ public JenkinsProjectViewModel(Connector connector) this.Url = JenkinsApi.UrlHelper.ProjectUrl(connector); } + /// + /// Implements function that decides if a tooltip should be visible. + /// + /// Base returns always true. + public override bool IsTooltipVisible() + { + if (this.CurrentStatus is JenkinsStatusViewModel status) + { + return (status.Culprits.Count == 0 && status.CommittedToThisBuild.Count == 0 && status.State != ObservationState.Running) ? false : true; + } + + return true; + } + protected override BuildStatusViewModel GetStatusViewModel() { return new JenkinsStatusViewModel(this); From 0102b5d5b0d9015709fde5205e220c12d055a0a0 Mon Sep 17 00:00:00 2001 From: TSK Date: Wed, 1 Jul 2020 14:18:16 +0200 Subject: [PATCH 07/12] cleanup --- .../ConnectorsTreeView.xaml.cs | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs index 651ba09..da182a0 100644 --- a/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs +++ b/src/Soloplan.WhatsON.GUI.Common/ConnectorTreeView/ConnectorsTreeView.xaml.cs @@ -706,27 +706,6 @@ private void OnGroupClicked(ConnectorGroupViewModel group) } } - /// - /// Gets the connector group/ - /// - /// Connector to get froup of - /// Group - private ConnectorGroupViewModel GetConnectorGroup(ConnectorViewModel connector) - { - foreach (ConnectorGroupViewModel groupViewModel in this.model.ConnectorGroups) - { - foreach (ConnectorViewModel connectorViewModel in groupViewModel.ConnectorViewModels) - { - if (connector.Identifier == connectorViewModel.Identifier) - { - return groupViewModel; - } - } - } - - return null; - } - /// /// Defines behaviour when an item in tree is clicked with Ctrl. /// From faab377ca566e0393dcbb6e3e12c9cc5d61156c2 Mon Sep 17 00:00:00 2001 From: TSK Date: Wed, 1 Jul 2020 14:48:25 +0200 Subject: [PATCH 08/12] Bottom margin of build progress in tooltips fixed. --- .../CCProgressBarTooltipControl.xaml | 1 + .../BuildServer/ProgressBarControl .xaml | 48 ++++++++++++++ .../BuildServer/ProgressBarControl .xaml.cs | 66 +++++++++++++++++++ .../ProgressBarTooltipControl.xaml | 4 +- .../ProgressBarTooltipControl.xaml.cs | 14 ++-- .../Soloplan.WhatsON.GUI.Common.csproj | 7 ++ .../JenkinsProjectDataTemplate.xaml | 8 +-- 7 files changed, 136 insertions(+), 12 deletions(-) create mode 100644 src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarControl .xaml create mode 100644 src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarControl .xaml.cs diff --git a/src/Soloplan.WhatsON.CruiseControl.GUI/CCProgressBarTooltipControl.xaml b/src/Soloplan.WhatsON.CruiseControl.GUI/CCProgressBarTooltipControl.xaml index cb86bec..e74553e 100644 --- a/src/Soloplan.WhatsON.CruiseControl.GUI/CCProgressBarTooltipControl.xaml +++ b/src/Soloplan.WhatsON.CruiseControl.GUI/CCProgressBarTooltipControl.xaml @@ -25,6 +25,7 @@ + diff --git a/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarControl .xaml b/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarControl .xaml new file mode 100644 index 0000000..dae7021 --- /dev/null +++ b/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarControl .xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarControl .xaml.cs b/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarControl .xaml.cs new file mode 100644 index 0000000..6ac130c --- /dev/null +++ b/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarControl .xaml.cs @@ -0,0 +1,66 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) Soloplan GmbH. All rights reserved. +// Licensed under the MIT License. See License-file in the project root for license information. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace Soloplan.WhatsON.GUI.Common.BuildServer +{ + using System.Windows; + using System.Windows.Controls; + + /// + /// Control for project build progress. + /// + public partial class ProgressBarControl : UserControl + { + /// + /// Dependency property for . + /// + public static readonly DependencyProperty ControlOrientationProperty = DependencyProperty.Register(nameof(ControlOrientation), typeof(Orientation), typeof(ProgressBarControl), new PropertyMetadata(Orientation.Vertical)); + + public static readonly DependencyProperty CompactDisplayProperty = DependencyProperty.Register(nameof(CompactDisplay), typeof(bool), typeof(ProgressBarControl), new PropertyMetadata(false, new PropertyChangedCallback(OnCurrentReadingChanged))); + + public ProgressBarControl() + { + this.InitializeComponent(); + } + + private static void OnCurrentReadingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is ProgressBarTooltipControl control) + { + control.UpdateTexts(); + } + } + + public Orientation ControlOrientation + { + get => (Orientation)this.GetValue(ControlOrientationProperty); + set => this.SetValue(ControlOrientationProperty, value); + } + + public bool CompactDisplay + { + get => (bool)this.GetValue(CompactDisplayProperty); + set => this.SetValue(CompactDisplayProperty, value); + } + + public void UpdateTexts() + { + if (this.CompactDisplay) + { + this.CompletionText.Text = string.Empty; + this.EstimatedRemainingText.Text = " ETA"; + this.PercentSignText.Text = "%/"; + } + else + { + this.CompletionText.Text = "Completion: "; + this.EstimatedRemainingText.Text = " estimated remaining"; + this.PercentSignText.Text = "% "; + } + } + } +} diff --git a/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarTooltipControl.xaml b/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarTooltipControl.xaml index 2a1b490..baeba27 100644 --- a/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarTooltipControl.xaml +++ b/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarTooltipControl.xaml @@ -29,6 +29,7 @@ + @@ -42,7 +43,8 @@ - + + diff --git a/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarTooltipControl.xaml.cs b/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarTooltipControl.xaml.cs index 8a7f6ce..9eb84a1 100644 --- a/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarTooltipControl.xaml.cs +++ b/src/Soloplan.WhatsON.GUI.Common/BuildServer/ProgressBarTooltipControl.xaml.cs @@ -11,16 +11,16 @@ namespace Soloplan.WhatsON.GUI.Common.BuildServer using System.Windows.Controls; /// - /// Interaction logic for ProgressInformationControl.xaml. + /// Control for project tooltips. /// public partial class ProgressBarTooltipControl : UserControl { /// /// Dependency property for . /// - public static readonly DependencyProperty ControlOrientationProperty = DependencyProperty.Register(nameof(ControlOrientation), typeof(Orientation), typeof(ProgressBarTooltipControl), new PropertyMetadata(Orientation.Vertical)); + public static readonly DependencyProperty ControlOrientationTooltipProperty = DependencyProperty.Register(nameof(ControlOrientation), typeof(Orientation), typeof(ProgressBarTooltipControl), new PropertyMetadata(Orientation.Vertical)); - public static readonly DependencyProperty CompactDisplayProperty = DependencyProperty.Register(nameof(CompactDisplay), typeof(bool), typeof(ProgressBarTooltipControl), new PropertyMetadata(false, new PropertyChangedCallback(OnCurrentReadingChanged))); + public static readonly DependencyProperty CompactDisplayTooltipProperty = DependencyProperty.Register(nameof(CompactDisplay), typeof(bool), typeof(ProgressBarTooltipControl), new PropertyMetadata(false, new PropertyChangedCallback(OnCurrentReadingChanged))); public ProgressBarTooltipControl() { @@ -37,14 +37,14 @@ private static void OnCurrentReadingChanged(DependencyObject d, DependencyProper public Orientation ControlOrientation { - get => (Orientation)this.GetValue(ControlOrientationProperty); - set => this.SetValue(ControlOrientationProperty, value); + get => (Orientation)this.GetValue(ControlOrientationTooltipProperty); + set => this.SetValue(ControlOrientationTooltipProperty, value); } public bool CompactDisplay { - get => (bool)this.GetValue(CompactDisplayProperty); - set => this.SetValue(CompactDisplayProperty, value); + get => (bool)this.GetValue(CompactDisplayTooltipProperty); + set => this.SetValue(CompactDisplayTooltipProperty, value); } public void UpdateTexts() diff --git a/src/Soloplan.WhatsON.GUI.Common/Soloplan.WhatsON.GUI.Common.csproj b/src/Soloplan.WhatsON.GUI.Common/Soloplan.WhatsON.GUI.Common.csproj index 053d644..50bf22f 100644 --- a/src/Soloplan.WhatsON.GUI.Common/Soloplan.WhatsON.GUI.Common.csproj +++ b/src/Soloplan.WhatsON.GUI.Common/Soloplan.WhatsON.GUI.Common.csproj @@ -49,6 +49,9 @@ BuildNumberControl.xaml + + ProgressBarControl .xaml + @@ -157,6 +160,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + Designer MSBuild:Compile diff --git a/src/Soloplan.WhatsON.Jenkins.GUI/JenkinsProjectDataTemplate.xaml b/src/Soloplan.WhatsON.Jenkins.GUI/JenkinsProjectDataTemplate.xaml index 4bab0a8..ef992ca 100644 --- a/src/Soloplan.WhatsON.Jenkins.GUI/JenkinsProjectDataTemplate.xaml +++ b/src/Soloplan.WhatsON.Jenkins.GUI/JenkinsProjectDataTemplate.xaml @@ -77,16 +77,16 @@ - - +