private void InitialColorRamp(esriSymbologyStyleClass styleClass) { if (m_pRasterRenderer is IRasterStretchColorRampRenderer) { //得到当前栅格拉伸渲染样式 IRasterStretchColorRampRenderer rasterStrecthcRenderer = m_pRasterRenderer as IRasterStretchColorRampRenderer; //从文件打开渲染库 string sInstall = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle"; axSymbologyControl1.LoadStyleFile(sInstall); axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps; pSymbolClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps); IStyleGalleryItem pStyleGalleryItem = new ServerStyleGalleryItem(); pStyleGalleryItem.Item = rasterStrecthcRenderer.ColorRamp; pSymbolClass.AddItem(pStyleGalleryItem, 0); //将渲染库中所有渲染方式添加到列表中 for (int i = 0; i < pSymbolClass.ItemCount; i++) { stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(pSymbolClass.GetItem(i), cmbColorRamp.Width, cmbColorRamp.Height); Image image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle)); cmbColorRamp.Items.Add(image); } if (pSymbolClass.ItemCount > 0) { pSymbolClass.SelectItem(0); } if (cmbColorRamp.Items.Count > 0) { cmbColorRamp.SelectedIndex = 0; } } }
void CreateButtonDefinition() { System.Reflection.Assembly currentAssembly = System.Reflection.Assembly .GetExecutingAssembly(); System.IO.Stream centerPtRectangleButtonPath = currentAssembly .GetManifestResourceStream ("QubeItTools.Resources.Horizontal Mid-Point Rectangle.ico"); int largeIconSize = 32; int standardIconSize = 16; Icon HzMidPtRectangleIcon = new Icon(centerPtRectangleButtonPath); Icon largeHzMidPtRectangleIcon = new Icon(HzMidPtRectangleIcon, largeIconSize, largeIconSize); Icon standardHzMidPtRectangleIcon = new Icon(HzMidPtRectangleIcon, standardIconSize, standardIconSize); stdole.IPictureDisp largeIconPictureDisp = (stdole.IPictureDisp)Support.IconToIPicture(largeHzMidPtRectangleIcon); stdole.IPictureDisp standardIconPictureDisp = (stdole.IPictureDisp)Support.IconToIPicture(standardHzMidPtRectangleIcon); ButtonDefinition = invApplication.CommandManager.ControlDefinitions. AddButtonDefinition("H.M.P.R.", ClientButtonInternalName, CommandTypesEnum.kShapeEditCmdType, StandardAddInServer.AddInServerId, "Create Horizontal Mid Point Rectangle", "Creates a rectangle that is constrained to the mid-point of one of the horizontal lines.", standardIconPictureDisp, largeIconPictureDisp, ButtonDisplayEnum.kDisplayTextInLearningMode); ButtonDefinition.Enabled = true; buttonPressed = ButtonDefinition.Pressed; CommandIsRunning = false; }
/* * public addInButtonDefinition(string Name, string ToolTip, Icon large_Ico, CommandTypesEnum cmd_Type) * { * * assemble(var_es._ClientId, Name, "id_" + Name, ToolTip, "", null, large_Ico, cmd_Type, ButtonDisplayEnum.kDisplayTextInLearningMode); * * } * */ #endregion private void assemble(string ClientId, string Name, string internalName, string Tooltip, string Description, Icon small_Ico, Icon large_Ico, CommandTypesEnum cmd_type, ButtonDisplayEnum btn_type) { if (String.IsNullOrEmpty(ClientId)) { ClientId = var_es._ClientId; } stdole.IPictureDisp common = null; if (small_Ico != null) { common = ImgTypeConv.Ico_to_Picture(small_Ico); } stdole.IPictureDisp large = null; if (large_Ico != null) { large = ImgTypeConv.Ico_to_Picture(large_Ico); } Button = var_es.InventorApp.CommandManager.ControlDefinitions.AddButtonDefinition(Name, internalName, cmd_type, ClientId, Description, Tooltip, common, large, btn_type); Button.Enabled = true; Button.OnExecute += BTN_OnExecute; }
public stdole.IPictureDisp GenerateSignatureLineImage( Office.SignatureLineImage siglnimg, Office.SignatureSetup psigsetup, Office.SignatureInfo psiginfo, object XmlDsigStream) { stdole.IPictureDisp picture = null; Bitmap b = new Bitmap(200, 50); if (siglnimg == Office.SignatureLineImage.siglnimgUnsigned) { Graphics g = Graphics.FromImage(b); g.DrawRectangle(new Pen(Color.Red, 2), 0, 0, 200, 50); g.FillRectangle(new SolidBrush(Color.Thistle), 2, 2, 196, 46); g.DrawString(String.Format("{0} ({1})", psigsetup.SuggestedSigner, DateTime.Now.ToShortDateString()), new Font("Courier", 12), new SolidBrush(Color.MidnightBlue), new PointF(30, 16)); } picture = PictureConverter.ImageToPictureDisp( Image.FromHbitmap(b.GetHbitmap())); return(picture); }
protected override void CreateControl() { CommandManager commandMgr = Application.CommandManager; //Create IPictureDisp from Icon resources stdole.IPictureDisp standardIconPict = (StandardIcon != null ? PictureDispConverter.ToIPictureDisp(StandardIcon) : null); stdole.IPictureDisp largeIconPict = (LargeIcon != null ? PictureDispConverter.ToIPictureDisp(LargeIcon) : null); _controlDef = commandMgr.ControlDefinitions.AddButtonDefinition( DisplayName, InternalName, Classification, ClientId, Description, ToolTipText, standardIconPict, largeIconPict, ButtonDisplay); ControlDefinition = _controlDef as ControlDefinition; _controlDef.OnExecute += new ButtonDefinitionSink_OnExecuteEventHandler(Handle_ButtonDefinition_OnExecute); _controlDef.OnHelp += new ButtonDefinitionSink_OnHelpEventHandler(Handle_ButtonDefinition_OnHelp); }
/// <summary> /// This function sets the Picture and Mask for Office Buttons /// it can be used in for all Office Applications not only for Outlook. /// Created in VS2005 with VSTO Tools, but works also with VS2003 without VSTO. /// </summary> /// <example> /// ButtonHelper buttonHelper = new ButtonHelper(); /// buttonHelper.SetButtonPicture( ref _button, "X4UButton" ); /// </example> /// this sample applies the embedded Bitmap /// "X4UButtonPicture.bmp" /// and the Bitmap /// "X4UButtonMask.bmp" /// to the button given by reference. /// <param name="button">the office button by reference</param> /// <param name="pictureName">the name of the embedded Picture</param> public void SetButtonPicture(ref OfficeCore.CommandBarButton button, string pictureName) { try { // define the ButtonPicture and MASK as IPictureDisp stdole.IPictureDisp buttonFace = null; stdole.IPictureDisp buttonMask = null; // get the current assembly Assembly assembly = Assembly.GetExecutingAssembly(); // load the embedded Bitmaps from assembly // the bitmaps should be 2 32 x 32 Bitmaps // described in MSDN article: http://support.microsoft.com/kb/286460/en-us Stream pictureStream = assembly.GetManifestResourceStream("X4UTools.Images." + pictureName + ".bmp"); Stream maskStream = assembly.GetManifestResourceStream("X4UTools.Images.Mask.bmp"); // Convert the Resourcestream to an Image and // convert the Images to stdole.IPictureDisp buttonFace = ImageToIPictureDisp(Image.FromStream(pictureStream)); buttonMask = ImageToIPictureDisp(Image.FromStream(maskStream)); // apply the Face and Mask to the Button. // here is a BUG when setting this Picture in an Outlook MailItem Inspector // set the Picture before mask... button.Picture = buttonFace; button.Mask = buttonMask; } catch (System.Exception ex) { Trace.WriteLine(ex.Message); } }
GetCustomImage(Office.IRibbonControl control) { stdole.IPictureDisp pictureDisp = null; switch (control.Id) { case "settingsButtonNew": case "settingsButtonRead": pictureDisp = ImageConverter.Convert(Properties.Resources.database_gear); break; case "aboutButtonNew": case "aboutButtonRead": pictureDisp = ImageConverter.Convert(Properties.Resources.Logo); break; case "attachPublicKeyButton": pictureDisp = ImageConverter.Convert(Properties.Resources.attach); break; default: if ((control.Id == EncryptButton.Id) || (control.Id == DecryptButton.Id)) { pictureDisp = ImageConverter.Convert(Properties.Resources.lock_edit); } if ((control.Id == SignButton.Id) || (control.Id == VerifyButton.Id)) { pictureDisp = ImageConverter.Convert(Properties.Resources.link_edit); } break; } return(pictureDisp); }
/// <summary> /// The helper method for constructors to call to avoid duplicate code. /// </summary> public void Create( string displayName, string internalName, string description, string tooltip, string clientId, Icon standardIcon, Icon largeIcon, CommandTypesEnum commandType, ButtonDisplayEnum buttonDisplayType) { if (string.IsNullOrEmpty(clientId)) { clientId = AddinGlobal.ClassId; } stdole.IPictureDisp standardIconIPictureDisp = null; stdole.IPictureDisp largeIconIPictureDisp = null; if (standardIcon != null) { standardIconIPictureDisp = Support.IconToIPicture(standardIcon) as stdole.IPictureDisp; largeIconIPictureDisp = (stdole.IPictureDisp)Support.IconToIPicture(largeIcon); } mButtonDef = AddinGlobal.InventorApp.CommandManager.ControlDefinitions.AddButtonDefinition( displayName, internalName, commandType, clientId, description, tooltip, standardIconIPictureDisp, largeIconIPictureDisp, buttonDisplayType); mButtonDef.Enabled = true; mButtonDef.OnExecute += ButtonDefinition_OnExecute; DisplayText = true; AddinGlobal.ButtonList.Add(this); }
void CreateButtonDefinition() { System.Reflection.Assembly currentAssembly = System.Reflection.Assembly .GetExecutingAssembly(); System.IO.Stream centerPtRectangleButtonPath = currentAssembly .GetManifestResourceStream ("QubeItTools.Resources.DiagonalCenterPointRectangle.ico"); Icon DiagonalCenterPointRectangleIcon = new Icon(centerPtRectangleButtonPath); Icon largeDiagonalCenterPointRectangleIcon = new Icon(DiagonalCenterPointRectangleIcon, largeIconSize, largeIconSize); Icon standardDiagonalCenterPointRectangleIcon = new Icon(DiagonalCenterPointRectangleIcon, standardIconSize, standardIconSize); stdole.IPictureDisp largeIconPictureDisp = (stdole.IPictureDisp)Support.IconToIPicture(largeDiagonalCenterPointRectangleIcon); stdole.IPictureDisp standardIconPictureDisp = (stdole.IPictureDisp)Support.IconToIPicture(standardDiagonalCenterPointRectangleIcon); ButtonDefinition = invApplication.CommandManager.ControlDefinitions. AddButtonDefinition("D.C.P.R.", ClientButtonInternalName, CommandTypesEnum.kShapeEditCmdType, StandardAddInServer.AddInServerId, "Create Diagonal Center Point Rectangle", "Creates a Diagonal Center Point Rectangle around the origin of where the " + "user picks using a diagonal line.", standardIconPictureDisp, largeIconPictureDisp, ButtonDisplayEnum.kDisplayTextInLearningMode); ButtonDefinition.Enabled = true; buttonPressed = ButtonDefinition.Pressed; CommandIsRunning = false; }
public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime) { // This method is called by Inventor when it loads the addin. // The AddInSiteObject provides access to the Inventor Application object. // The FirstTime flag indicates if the addin is loaded for the first time. // Initialize AddIn members. m_inventorApplication = addInSiteObject.Application; // TODO: Add ApplicationAddInServer.Activate implementation. // e.g. event initialization, command creation etc. // Connect to the user-interface events to handle a ribbon reset. { m_uiEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents; m_uiEvents.OnResetRibbonInterface += m_uiEvents_OnResetRibbonInterface; stdole.IPictureDisp largeIcon = PictureDispConverter.ToIPictureDisp(InvAddIn.Resource1.Large); stdole.IPictureDisp smallIcon = PictureDispConverter.ToIPictureDisp(InvAddIn.Resource1.Small); Inventor.ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions; m_sampleButton1 = controlDefs.AddButtonDefinition("License check", "Entitlement API", CommandTypesEnum.kShapeEditCmdType, AddInClientID(), "Entitlement api", "Entitlement api", smallIcon, largeIcon); m_sampleButton1.OnExecute += m_sampleButton1_OnExecute; // Add to the user interface, if it's the first time. if (firstTime) { AddToUserInterface(); } } }
public McMasterButton(StandardAddInServer s) { _stAddIn = s; mv = new MainWindowViewModel(); Stream myStream = System.Reflection.Assembly. GetExecutingAssembly().GetManifestResourceStream( "McMasterAddin.Resources.mcmaster.ico"); stdole.IPictureDisp largeImage = PictureDispConverter.ToIPictureDisp(new Icon(myStream)); //Button definition m_buttonDefinition = _stAddIn.m_invApp.CommandManager. ControlDefinitions.AddButtonDefinition("Browse", "BrowseButton", CommandTypesEnum.kQueryOnlyCmdType, StandardAddInServer.m_ClientIDstr, "Browse McMaster-Carr Inventory", "Use this to find " + "hardware and other products available on McMaster.com", largeImage, largeImage, ButtonDisplayEnum.kAlwaysDisplayText); m_button_Definition_OnExecute_Delegate = new ButtonDefinitionSink_OnExecuteEventHandler( m_button_OnExecute); m_buttonDefinition.OnExecute += m_button_Definition_OnExecute_Delegate; m_buttonDefinition.Enabled = true; }
public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime) { // This method is called by Inventor when it loads the addin. // The AddInSiteObject provides access to the Inventor Application object. // The FirstTime flag indicates if the addin is loaded for the first time. // Initialize AddIn members. _inventorApplication = addInSiteObject.Application; ControlDefinitions controlDefs = _inventorApplication.CommandManager.ControlDefinitions; IPictureDisp smallPicture2 = AxHostConverter.ImageToPictureDisp(Resources.CreateMasterM.ToBitmap()); IPictureDisp largePicture2 = AxHostConverter.ImageToPictureDisp(Resources.CreateMasterM.ToBitmap()); _dockableWindow = controlDefs.AddButtonDefinition("Dockable Window", "DockableWindow:Show", CommandTypesEnum.kNonShapeEditCmdType, "{" + ClientId + "}", null, null, smallPicture2, largePicture2); _dockableWindow.OnExecute += m_dockableWindow_OnExecute; // Get the initial ribbon. Ribbon ribbon = _inventorApplication.UserInterfaceManager.Ribbons["ZeroDoc"]; // Get "Extras" tab. RibbonTab extrasTab = ribbon.RibbonTabs["id_TabTools"]; const string chatPanelInternalName = "DockableWindow:ChatPanel"; RibbonPanel panel = extrasTab.RibbonPanels.OfType <RibbonPanel>().SingleOrDefault(rp => rp.InternalName == chatPanelInternalName); if (panel == null) { panel = extrasTab.RibbonPanels.Add("Chat", chatPanelInternalName, "{" + ClientId + "}"); } panel.CommandControls.AddButton(_dockableWindow, true); }
//添加GLISTBOX项 private void addListBoxItem(ISymbol symbol) { IStyleGallery styleGallery; IStyleGalleryItem styleGalleryItem; IStyleGalleryStorage styleGalleryStorge; styleGalleryItem = new ServerStyleGalleryItemClass(); styleGalleryItem.Name = this.txtSymbolName.Text; styleGalleryItem.Category = "default"; object objSymbol = symbol; styleGalleryItem.Item = objSymbol; styleGallery = new ServerStyleGalleryClass(); styleGalleryStorge = styleGallery as IStyleGalleryStorage; styleGalleryStorge.TargetFile = fileName; //IStyleGalleryClass styleGalleryClass = styleGallery.get_Class(CurrentStyleGalleryClassIndex); ISymbologyStyleClass pSymbolClass = psymbologyStyleClass; pSymbolClass.AddItem(styleGalleryItem, 0); pSymbolClass.SelectItem(0); stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(styleGalleryItem, 140, 20); Image image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle)); GridPanel panel = supergrid.PrimaryGrid; GridRow row = new GridRow(image); panel.Rows.Add(row); psymbologyStyleClass.RemoveItem(0); imagelist.Add(image); }
public stdole.IPictureDisp GetCustomImage(Office.IRibbonControl control) { StringBuilder sbTrace = new StringBuilder(); stdole.IPictureDisp pictureDisp = null; try { sbTrace.AppendLine("Start"); Logger.SaveLoggerTrace(sbTrace); switch (control.Id) { case "textButton": //Image image = Image.FromFile(Environment.CurrentDirectory+ "\\Image\\legal-numbering.bmp"); pictureDisp = ImageConverter.Convert(Properties.Resources.legalnumbering); break; case "SmartToStraightButton": //Image image2 = Image.FromFile(Environment.CurrentDirectory + "\\Image\\smart-to-straight-quotes.bmp"); pictureDisp = ImageConverter.Convert(Properties.Resources.smarttostraightquotes); break; case "StraightToSmartButton": //Image image3 = Image.FromFile(Environment.CurrentDirectory + "\\Image\\straight-to-smart-quotes.bmp"); pictureDisp = ImageConverter.Convert(Properties.Resources.straighttosmartquotes); break; case "SmartToStraightButton2": // Image image4 = Image.FromFile(Environment.CurrentDirectory + "\\Image\\smart-to-straight-apostrophes.bmp"); pictureDisp = ImageConverter.Convert(Properties.Resources.smarttostraightapostrophes); break; case "SmartToStraightButton23": // Image image5 = Image.FromFile(Environment.CurrentDirectory + "\\Image\\straight-to-smart-apostrophes.bmp"); pictureDisp = ImageConverter.Convert(Properties.Resources.straighttosmartapostrophes); break; case "btnBlankDoc": // Image image6 = Image.FromFile(Environment.CurrentDirectory + "\\Image\\new-blank-document.bmp"); pictureDisp = ImageConverter.Convert(Properties.Resources.newblankdocument); break; } return(pictureDisp); } catch (Exception ex) { sbTrace.Clear(); sbTrace.AppendLine("Exception" + ex); Logger.SaveLoggerTrace(sbTrace); Logger.LogWriter(ex.StackTrace); return(pictureDisp); } finally { sbTrace.Clear(); sbTrace.AppendLine("End"); Logger.SaveLoggerTrace(sbTrace); } }
private void PreviewImage() { stdole.IPictureDisp picture = this.axSymbologyControl.GetStyleClass(this.axSymbologyControl.StyleClass).PreviewItem(pStyleGalleryItem, this.ptbPreview.Width, this.ptbPreview.Height); System.Drawing.Image image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); this.ptbPreview.Image = image; }
private void PreviewImage() { ISymbologyStyleClass symbologyStyleClass = axSymbologyControl.GetStyleClass(axSymbologyControl.StyleClass); stdole.IPictureDisp picture = symbologyStyleClass.PreviewItem(m_styleGalleryItem, SymbolPictureBox.Width, SymbolPictureBox.Height); System.Drawing.Image image = Image.FromHbitmap(new IntPtr(picture.Handle)); SymbolPictureBox.Image = image; }
//problem with the api public void PictureBoxTestMethod(Part part) { stdole.IPictureDisp thumbNail = part.PartDocument.Thumbnail; Image image = IconTools.GetImage(thumbNail); //PictureBoxTest.Image = image; }
public TempWriter(Inventor.Application currentApplication, stdole.IPictureDisp thumbnail) { //The path to the temp directory where temp folders will be saved path = "C:\\Users\\" + System.Environment.UserName + "\\AppData\\Roaming\\Autodesk\\Synthesis\\"; //the active document currentDocument = (AssemblyDocument)currentApplication.ActiveDocument; this.currentApplication = currentApplication; thumbnailDisp = thumbnail; }
// 预览 将 pStyleGalleryItem 反映到 picture 上 private void PreviewPicture() { ISymbologyStyleClass pSymbologyStyle = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass); stdole.IPictureDisp picture = pSymbologyStyle.PreviewItem(pStyleGalleryItem, pictureBox1.Width, pictureBox1.Height); //建立实例 Image image = Image.FromHbitmap(new IntPtr(picture.Handle)); //转成 C# 支持的 Image 实例 pictureBox1.Image = image; }
/// <summary> /// Gets the Icon Image /// </summary> /// <param name="menuIcon"> Icon object to be displayed as image.</param> /// <returns> /// stdole.IPictureDisp type object. /// </returns> internal static stdole.IPictureDisp GetImage(Icon menuIcon) { stdole.IPictureDisp tempImage = null; ImageList imageList = new ImageList(); imageList.Images.Add(menuIcon); tempImage = ConvertImage.Convert(imageList.Images[0]); return(tempImage); }
//选择样式后返回图片 public Image GetImageByGiveSymbolAfterSelectItem(int width, int height) { ISymbologyStyleClass symbologyStyleClass = axSymbologyControl.GetStyleClass(axSymbologyControl.StyleClass); //Preview an image of the symbol stdole.IPictureDisp picture = symbologyStyleClass.PreviewItem(pStyleGalleryItem, width, width); System.Drawing.Image image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); return(image); }
private void PreviewImage() { //Get and set the style class ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass); //Preview an image of the symbol stdole.IPictureDisp picture = symbologyStyleClass.PreviewItem(m_styleGalleryItem, pictureBox1.Width, pictureBox1.Height); System.Drawing.Image image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); pictureBox1.Image = image; }
private void ShowPreviewImage() { //Get and set the style class ISymbologyStyleClass symbologyStyleClass = this._axSymCtrl.GetStyleClass(_axSymCtrl.StyleClass); //Preview an image of the symbol stdole.IPictureDisp picture = symbologyStyleClass.PreviewItem(this._styleGalleryItem, (int)PreviewImage.Width, (int)PreviewImage.Height); System.Drawing.Bitmap bitmap = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); PreviewImage.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); }
/// <summary> /// Views the symble. /// </summary> private void ViewSymble() { if (this._styleGalleryItem != null) { ISymbologyStyleClass styleClass = this.axSymbologyControl1.GetStyleClass(this.axSymbologyControl1.StyleClass); stdole.IPictureDisp pictureDisp = styleClass.PreviewItem(this._styleGalleryItem, this.pictureEdit.Width, this.pictureEdit.Height); Image image = Image.FromHbitmap(new IntPtr(pictureDisp.Handle)); this.pictureEdit.Image = image; } }
private void FrmSymboloTin_Load(object sender, EventArgs e) { string sInstall = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle"; axSymbologyControl1.LoadStyleFile(sInstall); axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps; pSymbolClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps); /* ********************************* * 生成色度带 * *********************************/ for (int i = 0; i < pSymbolClass.get_ItemCount(pSymbolClass.StyleCategory); i++) { stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(pSymbolClass.GetItem(i), cmbcolor.Width, cmbcolor.Height); Image image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle)); cmbcolor.Items.Add(image); } if (cmbcolor.Items.Count > 0) { cmbcolor.SelectedIndex = 0; } /* ********************************* * 初始化gridview及颜色控件 * *********************************/ if (pTLayer.GetRenderer(0).GetType().Name == "TinFaceRendererClass" || pTLayer.GetRenderer(0).Name == "Faces") { treeshow.SelectedIndex = 1; ITinSingleSymbolRenderer pTinrenderer = pTLayer.GetRenderer(0) as ITinSingleSymbolRenderer; ISimpleFillSymbol psymbol = new SimpleFillSymbolClass(); psymbol = pTinrenderer.Symbol as ISimpleFillSymbol; btncolor.SelectedColor = ClsGDBDataCommon.IColorToColor(psymbol.Color); istrue = true; } else if (pTLayer.GetRenderer(0).Name == "Elevation" || pTLayer.GetRenderer(0).Name == "Edge types") { treeshow.SelectedIndex = 0; btncolor.SelectedColor = System.Drawing.Color.Green; for (int j = 0; j < pTLayer.RendererCount; j++) { if (pTLayer.GetRenderer(j).Name == "Elevation") { ptinColorRampRenderer = pTLayer.GetRenderer(j) as ITinColorRampRenderer; break; } } cmbclasses.SelectedIndex = ptinColorRampRenderer.BreakCount - 1; initialupdatagrid(); } }
private System.Drawing.Image Symbol2Picture(object pSymbol, int width, int height) { if (pSymbol == null || width < 1 || height < 1) { return(null); } if (pSymbol is IMarkerSymbol) { axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassMarkerSymbols; } else if (pSymbol is ILineSymbol) { axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassLineSymbols; } else if (pSymbol is IFillSymbol) { axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassFillSymbols; } else if (pSymbol is ITextSymbol) { axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassTextSymbols; } else if (pSymbol is INorthArrow) { axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassNorthArrows; } else if (pSymbol is IScaleBar) { axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassScaleBars; } else if (pSymbol is IScaleText) { axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassScaleTexts; } ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass); symbologyStyleClass.RemoveAll(); IStyleGalleryItem pStyleItem = new ServerStyleGalleryItemClass(); pStyleItem.Name = "tempSymbol"; pStyleItem.Item = pSymbol; //symbologyStyleClass.AddItem(pStyleItem, 0); stdole.IPictureDisp picture = symbologyStyleClass.PreviewItem(pStyleItem, width, height); if (pSymbol is IScaleBar) { picture = symbologyStyleClass.PreviewItem(pStyleItem, width * 2, height); } else if (pSymbol is IScaleText) { picture = symbologyStyleClass.PreviewItem(pStyleItem, width * 2, height); } System.Drawing.Image image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle)); return(image); }
public static System.Drawing.Image ConvertIPictureDispToImage(stdole.IPictureDisp IPict) { try { return(GetPictureFromIPictureDisp(IPict)); } catch (Exception ex) { return(null); } }
public static IPicture Wrap(stdole.IPictureDisp obj, bool mustRelease = true) { if (obj == null) { return(null); } PictureWrapper wrapped = new PictureWrapper(obj); wrapped.MustRelease = mustRelease; return(wrapped); }
//预览 private void PreviewImage() { //Get and set the style class ISymbologyStyleClass symbologyStyleClass = axSymbologyControl.GetStyleClass(axSymbologyControl.StyleClass); //Preview an image of the symbol stdole.IPictureDisp pPicpture = symbologyStyleClass.PreviewItem(pStyleGalleryItem, ImagePreview.Width, ImagePreview.Height); System.Drawing.Image pImage = System.Drawing.Image.FromHbitmap(new System.IntPtr(pPicpture.Handle)); ImagePreview.Image = pImage; }
/// <summary> /// 在图片框中预览选择的样式 /// </summary> private void PreviewImage() { if (pStyleGalleryItem != null) { stdole.IPictureDisp picture = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass). PreviewItem(pStyleGalleryItem, ptbPreview.Width, ptbPreview.Height); ptbPreview.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Stretch; IntPtr intPtr = new IntPtr(picture.Handle); ptbPreview.Image = Image.FromHbitmap(intPtr); picture = null; } }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { // Initialize variables. m_Application = this.Application; m_Explorers = m_Application.Explorers; m_Inspectors = m_Application.Inspectors; m_Windows = new List<OutlookExplorer>(); m_InspectorWindows = new List<OutlookInspector>(); // Wire up event handlers to handle multiple Explorer windows. m_Explorers.NewExplorer += new Outlook.ExplorersEvents_NewExplorerEventHandler(m_Explorers_NewExplorer); // Wire up event handler to handle multiple Inspector windows. m_Inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(m_Inspectors_NewInspector); // Add the ActiveExplorer to m_Windows. Outlook.Explorer expl = m_Application.ActiveExplorer() as Outlook.Explorer; OutlookExplorer window = new OutlookExplorer(expl); m_Windows.Add(window); // Hook up event handlers for window. window.Close += new EventHandler(WrappedWindow_Close); window.InvalidateControl += new EventHandler<OutlookExplorer.InvalidateEventArgs>(WrappedWindow_InvalidateControl); // Get IPictureDisp for CurrentUser on startup. try { Outlook.AddressEntry addrEntry = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry; if (addrEntry.Type == "EX") { Outlook.ExchangeUser exchUser = addrEntry.GetExchangeUser() as Outlook.ExchangeUser; m_pictdisp = exchUser.GetPicture() as stdole.IPictureDisp; } } catch (Exception ex) { // Write exception to debug window. Debug.WriteLine(ex.Message); } }
private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { // Shutdown code here // Unhook event handlers m_Explorers.NewExplorer -= new Outlook.ExplorersEvents_NewExplorerEventHandler(m_Explorers_NewExplorer); m_Inspectors.NewInspector -= new Outlook.InspectorsEvents_NewInspectorEventHandler(m_Inspectors_NewInspector); // Dereference objects m_pictdisp = null; m_Explorers = null; m_Inspectors = null; m_Windows.Clear(); m_Windows = null; m_InspectorWindows.Clear(); m_InspectorWindows = null; m_Ribbon = null; m_Application = null; }