/// <summary> /// Used to set the tree node header with Icon + Title + SourceControlState Icon + ModifiedIndicator /// </summary> /// <param name="itemObj">The object which the tree node represent</param> /// <param name="itemObjTitleProperty">The object title/name field name to bind the node title to</param> /// <param name="itemIcon">The ImageMaker icon type to show as the node icon</param> /// <param name="itemSourceControlStateIcon">The ImageMaker icon type to show as the SourceControlState icon</param> /// <param name="addItemModifiedIndication">Define is to show Change/Modified/Dirty indication or not</param> /// <param name="objItemModifiedIndicationBoolPropertyName">The obj Bool field name which reflect if the obj is Dirty/Changed or not- to be used for binding</param> /// <returns></returns> public static StackPanel NewRepositoryItemTreeHeader(Object itemObj, string itemObjTitleProperty, eImageType itemIcon, eImageType itemSourceControlStateIcon, bool addItemModifiedIndication = false, string objItemModifiedIndicationBoolPropertyName = "") { StackPanel headerStack = new StackPanel(); headerStack.Orientation = Orientation.Horizontal; //Add icon if (itemIcon != eImageType.Null) { try { ImageMakerControl icon = new ImageMakerControl(); icon.ImageType = itemIcon; icon.Height = 16; icon.Width = 16; headerStack.Children.Add(icon); } catch (Exception e) { Reporter.ToLog(eLogLevel.ERROR, e.StackTrace); } } //Add source control icon if (itemSourceControlStateIcon != eImageType.Null) { try { ImageMakerControl sourceControlIcon = new ImageMakerControl(); sourceControlIcon.BindControl((RepositoryFolderBase)itemObj, nameof(RepositoryFolderBase.SourceControlStatus)); ((RepositoryFolderBase)itemObj).RefreshFolderSourceControlStatus(); sourceControlIcon.Height = 10; sourceControlIcon.Width = 10; headerStack.Children.Add(sourceControlIcon); } catch (Exception ex) { // TODO: write to log Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}"); } } //Add Item Title try { Label itemTitleLbl = new Label(); if (itemObj != null) { BindingLib.ControlsBinding.ObjFieldBinding(itemTitleLbl, Label.ContentProperty, itemObj, itemObjTitleProperty); } else { itemTitleLbl.Content = itemObjTitleProperty; } headerStack.Children.Add(itemTitleLbl); } catch { } //Add Modified icon if (addItemModifiedIndication == true) { try { ImageMakerControl modifiedIcon = new ImageMakerControl(); modifiedIcon.ImageType = eImageType.ItemModified; modifiedIcon.Height = 6; modifiedIcon.Width = 6; modifiedIcon.SetAsFontImageWithSize = 6; modifiedIcon.Foreground = Brushes.OrangeRed; modifiedIcon.VerticalAlignment = VerticalAlignment.Top; modifiedIcon.Margin = new Thickness(0, 10, 10, 0); modifiedIcon.ToolTip = "This item was modified"; if (string.IsNullOrEmpty(objItemModifiedIndicationBoolPropertyName) == false) { BindingLib.ControlsBinding.ObjFieldBinding(modifiedIcon, ImageMakerControl.VisibilityProperty, itemObj, objItemModifiedIndicationBoolPropertyName, BindingMode: BindingMode.OneWay, bindingConvertor: new System.Windows.Controls.BooleanToVisibilityConverter()); } headerStack.Children.Add(modifiedIcon); } catch { } } return(headerStack); }
/// <summary> /// The function creates the tree node item header /// </summary> /// <param name="repoItem">The repository item which the tree nodes represents</param> /// <param name="imageType">The image type which associated with the repository item- should be pulled from the repoItem</param> /// <param name="NameProperty">The field of the item which holds the item name or static name in case the repository item is null</param> /// <returns></returns> protected StackPanel NewTVItemHeaderStyle(RepositoryItemBase repoItem, eImageType imageType = eImageType.Null, string NameProperty = "") { //The new item style with Source control StackPanel stack = new StackPanel(); stack.Orientation = Orientation.Horizontal; if (WorkSpace.Instance.SourceControl != null) { // Source control image ImageMakerControl sourceControlImage = new ImageMakerControl(); sourceControlImage.BindControl(repoItem, nameof(RepositoryItemBase.SourceControlStatus)); sourceControlImage.Width = 8; sourceControlImage.Height = 8; stack.Children.Add(sourceControlImage); // Since it might take time to get the item status from SCM server // we run it on task so update will happen when status come back and we do not block the UI Task.Factory.StartNew(() => { repoItem.RefreshSourceControlStatus(); }); } // Add Item Image ImageMakerControl NodeImageType = new ImageMakerControl(); if (imageType == eImageType.Null) { NodeImageType.ImageType = repoItem.ItemImageType; } else { NodeImageType.ImageType = imageType; } NodeImageType.Width = 16; NodeImageType.Height = 16; stack.Children.Add(NodeImageType); // Add Item header text Label itemHeaderLabel = new Label(); string nameFieldProperty; if (string.IsNullOrEmpty(NameProperty)) { nameFieldProperty = repoItem.ItemNameField; } else { nameFieldProperty = NameProperty; } GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(itemHeaderLabel, Label.ContentProperty, repoItem, nameFieldProperty, BindingMode: System.Windows.Data.BindingMode.OneWay); stack.Children.Add(itemHeaderLabel); // add icon of dirty status ImageMakerControl dirtyStatusImage = new ImageMakerControl(); dirtyStatusImage.BindControl(repoItem, nameof(RepositoryItemBase.DirtyStatusImage)); dirtyStatusImage.Width = 6; dirtyStatusImage.Height = 6; dirtyStatusImage.VerticalAlignment = VerticalAlignment.Top; dirtyStatusImage.Margin = new Thickness(0, 10, 10, 0); stack.Children.Add(dirtyStatusImage); return(stack); }
public void ShowIcons(int from, int count) { // Arrange Grid grid = IconsGrid; if (grid.ColumnDefinitions.Count == 0) { for (int i = 0; i < 10; i++) { grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(80, GridUnitType.Star) }); } for (int i = 0; i < 5; i++) { grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(100, GridUnitType.Star) }); } } else { grid.Children.Clear(); } var icons = Enum.GetValues(typeof(eImageType)); int row = 0; int col = 0; int counter = 0; foreach (eImageType icon in icons) { counter++; if (counter < from) { continue; } if (counter >= from + count) { return; } StackPanel sp = new StackPanel(); sp.Orientation = Orientation.Vertical; ImageMakerControl IMK = new ImageMakerControl(); IMK.ImageType = icon; IMK.Width = 32; IMK.Height = 32; IMK.FontSize = 32; sp.Children.Add(IMK); mImageMakerControls.Add(IMK); Label l = new Label(); l.Content = icon.ToString(); sp.Children.Add(l); grid.Children.Add(sp); Grid.SetRow(sp, row); Grid.SetColumn(sp, col); col++; if (col == grid.ColumnDefinitions.Count) { col = 0; row++; } } }
// ------------------------------------------------------------ //Image Maker // ------------------------------------------------------------ public static void BindControl(this ImageMakerControl Label, Object obj, string Field) { GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(Label, ImageMakerControl.ImageTypeProperty, obj, Field, BindingMode.OneWay); }
private void SetItemExtraOperations() { this.Dispatcher.Invoke(() => { List <ListItemOperation> extraOperations = ListHelper.GetItemExtraOperationsList(Item); if (extraOperations != null && extraOperations.Count > 0) { xItemExtraOperationsMenu.Visibility = Visibility.Visible; foreach (ListItemOperation operation in extraOperations.Where(x => x.SupportedViews.Contains(ListHelper.PageViewMode)).ToList()) { MenuItem menuitem = new MenuItem(); menuitem.SetValue(AutomationProperties.AutomationIdProperty, operation.AutomationID); menuitem.Style = (Style)FindResource("$MenuItemStyle"); ImageMakerControl iconImage = new ImageMakerControl(); iconImage.ImageType = operation.ImageType; iconImage.SetAsFontImageWithSize = operation.ImageSize; iconImage.HorizontalAlignment = HorizontalAlignment.Left; menuitem.Icon = iconImage; menuitem.Header = operation.Header; menuitem.ToolTip = operation.ToolTip; if (operation.ImageForeground == null) { //iconImage.ImageForeground = (SolidColorBrush)FindResource("$BackgroundColor_DarkBlue"); } else { iconImage.ImageForeground = operation.ImageForeground; } if (operation.ImageBindingObject != null) { if (operation.ImageBindingConverter == null) { BindingHandler.ObjFieldBinding(iconImage, ImageMaker.ContentProperty, operation.ImageBindingObject, operation.ImageBindingFieldName, BindingMode.OneWay); } else { BindingHandler.ObjFieldBinding(iconImage, ImageMaker.ContentProperty, operation.ImageBindingObject, operation.ImageBindingFieldName, bindingConvertor: operation.ImageBindingConverter, BindingMode.OneWay); } } menuitem.Click += operation.OperationHandler; menuitem.Tag = Item; if (string.IsNullOrEmpty(operation.Group)) { ((MenuItem)(xItemExtraOperationsMenu.Items[0])).Items.Add(menuitem); } else { //need to add to Group bool addedToGroup = false; foreach (MenuItem item in ((MenuItem)(xItemExtraOperationsMenu.Items[0])).Items) { if (item.Header.ToString() == operation.Group) { //adding to existing group item.Items.Add(menuitem); addedToGroup = true; break; } } if (!addedToGroup) { //creating the group and adding MenuItem groupMenuitem = new MenuItem(); groupMenuitem.Style = (Style)FindResource("$MenuItemStyle"); ImageMakerControl groupIconImage = new ImageMakerControl(); groupIconImage.ImageType = operation.GroupImageType; groupIconImage.SetAsFontImageWithSize = operation.ImageSize; groupIconImage.HorizontalAlignment = HorizontalAlignment.Left; groupMenuitem.Icon = groupIconImage; groupMenuitem.Header = operation.Group; groupMenuitem.ToolTip = operation.Group; ((MenuItem)(xItemExtraOperationsMenu.Items[0])).Items.Add(groupMenuitem); groupMenuitem.Items.Add(menuitem); } } } } if (((MenuItem)(xItemExtraOperationsMenu.Items[0])).Items.Count == 0) { xItemExtraOperationsMenu.Visibility = Visibility.Collapsed; } }); }
private void xProfileImageDeleteBtn_Click(object sender, RoutedEventArgs e) { xProfileImageImgBrush.ImageSource = ImageMakerControl.GetImageSource(Amdocs.Ginger.Common.Enums.eImageType.User, width: 50); WorkSpace.Instance.UserProfile.ProfileImage = string.Empty; }
// ------------------------------------------------------------ //Image Maker // ------------------------------------------------------------ public static void BindControl(this ImageMakerControl Label, Object obj, string Field) { ControlsBinding.ObjFieldBinding(Label, ImageMakerControl.ImageTypeProperty, obj, Field, BindingMode.OneWay); }
/// <summary> /// The function creates the tree node item header /// </summary> /// <param name="repoItem">The repository item which the tree nodes represents</param> /// <param name="imageType">The image type which associated with the repository item- should be pulled from the repoItem</param> /// <param name="NameProperty">The field of the item which holds the item name or static name in case the repository item is null</param> /// <returns></returns> protected StackPanel NewTVItemHeaderStyle(RepositoryItemBase repoItem, eImageType imageType = eImageType.Null, string NameProperty = "") { //TODO: Move to biz flow page? repoItem.StartDirtyTracking(); //The new item style with Source control StackPanel stack = new StackPanel(); stack.Orientation = Orientation.Horizontal; if (WorkSpace.Instance.SourceControl != null) { // Source control image ImageMakerControl sourceControlImage = new ImageMakerControl(); sourceControlImage.BindControl(repoItem, nameof(RepositoryItemBase.SourceControlStatus)); repoItem.RefreshSourceControlStatus(); sourceControlImage.Width = 8; sourceControlImage.Height = 8; stack.Children.Add(sourceControlImage); } // Add Item Image ImageMakerControl NodeImageType = new ImageMakerControl(); if (imageType == eImageType.Null) { NodeImageType.ImageType = repoItem.ItemImageType; } else { NodeImageType.ImageType = imageType; } NodeImageType.Width = 16; NodeImageType.Height = 16; stack.Children.Add(NodeImageType); // Add Item header text Label itemHeaderLabel = new Label(); string nameFieldProperty; if (string.IsNullOrEmpty(NameProperty)) { nameFieldProperty = repoItem.ItemNameField; } else { nameFieldProperty = NameProperty; } BindingLib.ControlsBinding.ObjFieldBinding(itemHeaderLabel, Label.ContentProperty, repoItem, nameFieldProperty, BindingMode: System.Windows.Data.BindingMode.OneWay); stack.Children.Add(itemHeaderLabel); // add icon of dirty status ImageMakerControl dirtyStatusImage = new ImageMakerControl(); dirtyStatusImage.BindControl(repoItem, nameof(RepositoryItemBase.DirtyStatusImage)); dirtyStatusImage.Width = 6; dirtyStatusImage.Height = 6; dirtyStatusImage.VerticalAlignment = VerticalAlignment.Top; dirtyStatusImage.Margin = new Thickness(0, 10, 10, 0); stack.Children.Add(dirtyStatusImage); return(stack); }
public static StackPanel CreateItemHeader(string Header = null, eImageType imageType = eImageType.Null, Object obj = null, string ObjProperty = null, bool isDirty = false, string objItemModifiedIndicationBoolPropertyName = "") { StackPanel headerStack = new StackPanel(); headerStack.Orientation = Orientation.Horizontal; //Add icon if (imageType != eImageType.Null) { try { ImageMakerControl icon = new ImageMakerControl(); icon.ImageType = imageType; icon.Height = 16; icon.Width = 16; headerStack.Children.Add(icon); } catch (Exception e) { Reporter.ToLog(eLogLevel.ERROR, e.StackTrace); } } // Label Label lbl = new Label(); if (obj == null) { lbl.Content = Header; } else { // TODO: use lbl.BindControl // Can bind the obj property directly to label content - so auto update when changed BindTVItemHeader(lbl, Label.ContentProperty, obj, ObjProperty); } headerStack.Children.Add(lbl); if (isDirty) { try { ImageMakerControl modifiedIcon = new ImageMakerControl(); modifiedIcon.ImageType = eImageType.ItemModified; modifiedIcon.Height = 6; modifiedIcon.Width = 6; modifiedIcon.SetAsFontImageWithSize = 6; modifiedIcon.Foreground = Brushes.DarkOrange; modifiedIcon.VerticalAlignment = VerticalAlignment.Top; modifiedIcon.Margin = new Thickness(0, 10, 10, 0); modifiedIcon.ToolTip = "This item was modified"; if (string.IsNullOrEmpty(objItemModifiedIndicationBoolPropertyName) == false) { GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(modifiedIcon, ImageMakerControl.VisibilityProperty, obj, objItemModifiedIndicationBoolPropertyName, BindingMode: BindingMode.OneWay, bindingConvertor: new BooleanToVisibilityConverter()); } headerStack.Children.Add(modifiedIcon); } catch { } } return(headerStack); }
public void InitWindowLook() { try { //General if (mDriver.GetDevicePlatformType() == eDevicePlatformType.Android) { this.Icon = ImageMakerControl.GetImageSource(eImageType.AndroidOutline); } else { this.Icon = ImageMakerControl.GetImageSource(eImageType.IosOutline); } this.Title = string.Format("Ginger {0} Device View", mAgent.Name); this.Width = 320; this.Height = 650; xMessageLbl.Content = "Connecting to Device..."; //Configurations SetConfigurationsPanelView(false); //set refresh mode by what configured on driver mDeviceAutoScreenshotRefreshMode = mDriver.DeviceAutoScreenshotRefreshMode; switch (mDeviceAutoScreenshotRefreshMode) { case eAutoScreenshotRefreshMode.Live: xLiveRdBtn.IsChecked = true; break; case eAutoScreenshotRefreshMode.PostOperation: xPostOperationRdBtn.IsChecked = true; break; case eAutoScreenshotRefreshMode.Disabled: xDisabledRdBtn.IsChecked = true; break; } xConfigurationsFrame.Visibility = System.Windows.Visibility.Collapsed; xConfigurationsCol.Width = new GridLength(0); //Main tool bar xRefreshButton.ButtonStyle = FindResource("$ImageButtonStyle_WhiteSmoke") as Style; xPinBtn.ButtonStyle = FindResource("$ImageButtonStyle_WhiteSmoke") as Style; xConfigurationsBtn.ButtonStyle = FindResource("$ImageButtonStyle_WhiteSmoke") as Style; xSwipeBtn.ButtonStyle = FindResource("$ImageButtonStyle_WhiteSmoke") as Style; xPortraiteBtn.ButtonStyle = FindResource("$ImageButtonStyle_WhiteSmoke") as Style; xLandscapeBtn.ButtonStyle = FindResource("$ImageButtonStyle_WhiteSmoke") as Style; xPinBtn_Click(null, null); //Loading Pnl xDeviceScreenshotCanvas.Visibility = Visibility.Collapsed; xMessagePnl.Visibility = Visibility.Visible; if (mDriver.GetDevicePlatformType() == eDevicePlatformType.Android) { xMessageImage.ImageType = eImageType.AndroidWhite; } else { xMessageImage.ImageType = eImageType.IosWhite; } //Device buttons panel xHomeBtn.ButtonStyle = FindResource("$ImageButtonStyle_WhiteSmoke") as Style; xMenuBtn.ButtonStyle = FindResource("$ImageButtonStyle_WhiteSmoke") as Style; xBackButton.ButtonStyle = FindResource("$ImageButtonStyle_WhiteSmoke") as Style; switch (mDriver.GetDevicePlatformType()) { case eDevicePlatformType.Android: break; case eDevicePlatformType.iOS: //only middle button xBackButton.Visibility = Visibility.Collapsed; xMenuBtn.Visibility = Visibility.Collapsed; break; } //fliping the back icon to fit look on mobile xBackButton.xButtonImage.RenderTransformOrigin = new Point(0.5, 0.5); ScaleTransform flipTrans = new ScaleTransform(); flipTrans.ScaleX = -1; xBackButton.xButtonImage.RenderTransform = flipTrans; } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Error occurred while designing the Mobile window initial look", ex); } }