protected override PropertyManagerPageBitmapButtonControl CreateControl( IPropertyManagerPageBitmapButton swCtrl, IAttributeSet atts, SwPropertyManagerPageHandler handler, short height) { var bmpAtt = atts.Get <BitmapButtonAttribute>(); if (bmpAtt.StandardIcon.HasValue) { swCtrl.SetStandardBitmaps((int)bmpAtt.StandardIcon.Value); } else { var bmpWidth = bmpAtt.Width; var bmpHeight = bmpAtt.Height; var icon = AdjustIcon(IconsConverter.FromXImage(bmpAtt.Icon ?? Defaults.Icon), bmpWidth, bmpHeight); if (m_App.IsVersionNewerOrEqual(Enums.SwVersion_e.Sw2016)) { var icons = m_IconsConv.ConvertIcon(new BitmapButtonHighResIcon(icon, bmpWidth, bmpHeight)); var imgList = icons.Take(6).ToArray(); var maskImgList = icons.Skip(6).ToArray(); swCtrl.SetBitmapsByName3(imgList, maskImgList); } else { var icons = m_IconsConv.ConvertIcon(new BitmapButtonIcon(icon, bmpWidth, bmpHeight)); swCtrl.SetBitmapsByName2(icons[0], icons[1]); } } return(new PropertyManagerPageBitmapButtonControl(atts.Id, atts.Tag, swCtrl, handler)); }
protected override PropertyManagerPageGroupBase Create(PropertyManagerPagePage page, IAttributeSet atts) { const int OPTIONS_NOT_USED = 0; var icon = atts.BoundMemberInfo?.TryGetAttribute <IconAttribute>()?.Icon; if (icon == null) { icon = atts.BoundType?.TryGetAttribute <IconAttribute>()?.Icon; } string iconPath = ""; if (icon != null) { iconPath = m_IconsConv.ConvertIcon(new TabIcon(IconsConverter.FromXImage(icon))).First(); //NOTE: tab icon must be in 256 color bitmap, otherwise it is not displayed TryConvertIconTo8bit(iconPath); } var tab = page.Page.AddTab(atts.Id, atts.Name, iconPath, OPTIONS_NOT_USED) as IPropertyManagerPageTab; return(new PropertyManagerPageTabControl(atts.Id, atts.Tag, page.Handler, tab, page.App, page)); }
private void CreateIcons(CommandGroup cmdGroup, CommandGroupSpec cmdBar, IconsConverter iconsConv) { var mainIcon = cmdBar.Icon; if (mainIcon == null) { mainIcon = Defaults.Icon; } Image[] iconList = null; if (cmdBar.Commands != null) { iconList = cmdBar.Commands.Select(c => IconsConverter.FromXImage(c.Icon ?? Defaults.Icon)).ToArray(); } //NOTE: if commands are not used, main icon will fail if toolbar commands image list is not specified, so it is required to specify it explicitly if (CompatibilityUtils.SupportsHighResIcons(m_App.Sw, CompatibilityUtils.HighResIconsScope_e.CommandManager)) { var iconsList = iconsConv.ConvertIcon(new CommandGroupHighResIcon(IconsConverter.FromXImage(mainIcon))); cmdGroup.MainIconList = iconsList; if (iconList != null && iconList.Any()) { cmdGroup.IconList = iconsConv.ConvertIconsGroup( iconList.Select(i => new CommandGroupHighResIcon(i)).ToArray()); } else { cmdGroup.IconList = iconsList; } } else { var mainIconPath = iconsConv.ConvertIcon(new CommandGroupIcon(IconsConverter.FromXImage(mainIcon))); var smallIcon = mainIconPath[0]; var largeIcon = mainIconPath[1]; cmdGroup.SmallMainIcon = smallIcon; cmdGroup.LargeMainIcon = largeIcon; if (iconList != null && iconList.Any()) { var iconListPath = iconsConv.ConvertIconsGroup(iconList.Select(i => new CommandGroupIcon(i)).ToArray()); var smallIconList = iconListPath[0]; var largeIconList = iconListPath[1]; cmdGroup.SmallIconList = smallIconList; cmdGroup.LargeIconList = largeIconList; } else { cmdGroup.SmallIconList = smallIcon; cmdGroup.LargeIconList = largeIcon; } } }
protected override void SetSpecificValue(Image value) { if (value == null) { value = IconsConverter.FromXImage(Defaults.Icon); } var icons = m_IconsConv.ConvertIcon(new ControlIcon(value, m_Size)); SwSpecificControl.SetBitmapByName(icons[0], icons[1]); m_Image = value; }
private void TryCreateIcons() { var iconsConverter = new IconsConverter( MacroFeatureIconInfo.GetLocation(this.GetType()), false); System.Drawing.Image icon = null; this.GetType().TryGetAttribute <IconAttribute>(a => { icon = IconsConverter.FromXImage(a.Icon); }); if (icon == null) { icon = IconsConverter.FromXImage(Defaults.Icon); } //TODO: create different icons for highlighted and suppressed var regular = icon; var highlighted = icon; var suppressed = icon; //Creation of icons may fail if user doesn't have write permissions or icon is locked try { iconsConverter.ConvertIcon(new MacroFeatureIcon(icon, MacroFeatureIconInfo.RegularName)); iconsConverter.ConvertIcon(new MacroFeatureIcon(highlighted, MacroFeatureIconInfo.HighlightedName)); iconsConverter.ConvertIcon(new MacroFeatureIcon(suppressed, MacroFeatureIconInfo.SuppressedName)); iconsConverter.ConvertIcon(new MacroFeatureHighResIcon(icon, MacroFeatureIconInfo.RegularName)); iconsConverter.ConvertIcon(new MacroFeatureHighResIcon(highlighted, MacroFeatureIconInfo.HighlightedName)); iconsConverter.ConvertIcon(new MacroFeatureHighResIcon(suppressed, MacroFeatureIconInfo.SuppressedName)); } catch (Exception ex) { Logger.Log(ex); } }
protected override PropertyManagerPagePage Create(IAttributeSet atts) { int err = -1; swPropertyManagerPageOptions_e opts; TitleIcon titleIcon = null; IconAttribute commIconAtt; if (atts.BoundType.TryGetAttribute(out commIconAtt)) { if (commIconAtt.Icon != null) { titleIcon = new TitleIcon(IconsConverter.FromXImage(commIconAtt.Icon)); } } if (atts.Has <PageOptionsAttribute>()) { var optsAtt = atts.Get <PageOptionsAttribute>(); //TODO: implement conversion opts = (swPropertyManagerPageOptions_e)optsAtt.Options; } else { //TODO: implement conversion opts = (swPropertyManagerPageOptions_e)(PageOptions_e.OkayButton | PageOptions_e.CancelButton); } var helpLink = ""; var whatsNewLink = ""; if (atts.Has <HelpAttribute>()) { var helpAtt = atts.Get <HelpAttribute>(); if (!string.IsNullOrEmpty(helpAtt.WhatsNewLink)) { if (!opts.HasFlag(swPropertyManagerPageOptions_e.swPropertyManagerOptions_WhatsNew)) { opts |= swPropertyManagerPageOptions_e.swPropertyManagerOptions_WhatsNew; } } helpLink = helpAtt.HelpLink; whatsNewLink = helpAtt.WhatsNewLink; } var page = m_App.CreatePropertyManagerPage(atts.Name, (int)opts, m_Handler, ref err) as IPropertyManagerPage2; if (titleIcon != null) { var iconPath = m_IconsConv.ConvertIcon(titleIcon).First(); page.SetTitleBitmap2(iconPath); } if (atts.Has <MessageAttribute>()) { var msgAtt = atts.Get <MessageAttribute>(); page.SetMessage3(msgAtt.Text, (int)msgAtt.Visibility, (int)msgAtt.Expanded, msgAtt.Caption); } else if (!string.IsNullOrEmpty(atts.Description)) { page.SetMessage3(atts.Description, (int)swPropertyManagerPageMessageVisibility.swMessageBoxVisible, (int)swPropertyManagerPageMessageExpanded.swMessageBoxExpand, ""); } return(new PropertyManagerPagePage(page, m_Handler, m_App, helpLink, whatsNewLink)); }
private void AssignControlAttributes(TControlSw ctrl, ControlOptionsAttribute opts, IAttributeSet atts) { var swCtrl = ctrl as IPropertyManagerPageControl; if (opts.BackgroundColor != 0) { swCtrl.BackgroundColor = ConvertColor(opts.BackgroundColor); } if (opts.TextColor != 0) { swCtrl.TextColor = ConvertColor(opts.TextColor); } if (opts.Left != -1) { swCtrl.Left = opts.Left; } if (opts.Top != -1) { swCtrl.Top = opts.Top; } if (opts.Width != -1) { swCtrl.Width = opts.Width; } if (opts.ResizeOptions != 0) { swCtrl.OptionsForResize = (int)opts.ResizeOptions; } ControlIcon icon = null; var commonIcon = atts.BoundMemberInfo?.TryGetAttribute <IconAttribute>()?.Icon; if (commonIcon != null) { icon = new ControlIcon(IconsConverter.FromXImage(commonIcon)); } var hasIcon = false; if (atts.Has <StandardControlIconAttribute>()) { var attribution = atts.Get <StandardControlIconAttribute>(); if (attribution.Label != 0) { hasIcon = true; swCtrl.SetStandardPictureLabel((int)attribution.Label); } } if (icon != null) { hasIcon = true; var icons = m_IconConv.ConvertIcon(icon); var res = swCtrl.SetPictureLabelByName(icons[0], icons[1]); Debug.Assert(res); } if (!hasIcon) { var defIcon = GetDefaultBitmapLabel(atts); if (defIcon.HasValue) { swCtrl.SetStandardPictureLabel((int)defIcon.Value); } } }
public ISwTaskPane <TControl> CreateTaskPane <TControl>(TaskPaneSpec spec) { if (spec == null) { spec = new TaskPaneSpec(); } ITaskpaneView CreateTaskPaneView(IconsConverter iconConv, Image icon, string title) { if (icon == null) { if (spec.Icon != null) { icon = IconsConverter.FromXImage(spec.Icon); } } if (string.IsNullOrEmpty(title)) { if (spec != null) { title = spec.Title; } } if (Application.Sw.SupportsHighResIcons(CompatibilityUtils.HighResIconsScope_e.TaskPane)) { string[] taskPaneIconImages = null; if (icon != null) { taskPaneIconImages = iconConv.ConvertIcon(new TaskPaneHighResIcon(icon)); } return(Application.Sw.CreateTaskpaneView3(taskPaneIconImages, title)); } else { var taskPaneIconImage = ""; if (icon != null) { taskPaneIconImage = iconConv.ConvertIcon(new TaskPaneIcon(icon)).First(); } return(Application.Sw.CreateTaskpaneView2(taskPaneIconImage, title)); } } using (var iconConv = new IconsConverter()) { var taskPane = CustomControlHelper.HostControl <TControl, SwTaskPane <TControl> >( (c, h, t, i) => { var v = CreateTaskPaneView(iconConv, i, t); if (!v.DisplayWindowFromHandle(h.Handle.ToInt32())) { throw new NetControlHostException(h.Handle); } return(new SwTaskPane <TControl>(Application.Sw, v, c, spec)); }, (p, t, i) => { var v = CreateTaskPaneView(iconConv, i, t); var ctrl = (TControl)v.AddControl(p, ""); if (ctrl == null) { throw new ComControlHostException(p); } return(new SwTaskPane <TControl>(Application.Sw, v, ctrl, spec)); }); m_Disposables.Add(taskPane); return(taskPane); } }