Пример #1
0
        void Initialize()
        {
            // initialize variables
            totalItemsCreatedCount = 0;
            contentLayout          = GoogleDesktopDisplayContentItemLayout.GDD_CONTENT_ITEM_LAYOUT_EMAIL;
            totalItemsCreatedCount = 0;
            showImages             = true;
            isDirty = false;

            // Load our icons
            contentIcon1 = ImageConverter.ImageToIpicture(new Icon(
                                                              Assembly.GetExecutingAssembly().GetManifestResourceStream(
                                                                  "GoogleDesktopDisplayCSharpSample.ico1.ico")).ToBitmap());
            contentIcon2 = ImageConverter.ImageToIpicture(new Icon(
                                                              Assembly.GetExecutingAssembly().GetManifestResourceStream(
                                                                  "GoogleDesktopDisplayCSharpSample.ico2.ico")).ToBitmap());

            Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                "GoogleDesktopDisplayCSharpSample.plugin.ico");
            Bitmap smallImage = new Icon(stream, 16, 16).ToBitmap();

            stream.Seek(0, System.IO.SeekOrigin.Begin);
            Bitmap largeImage = new Icon(stream, 32, 32).ToBitmap();

            // Set plugin information
            IGoogleDesktopDisplayPluginHelper helper = (IGoogleDesktopDisplayPluginHelper)this;

            helper.about_text = aboutStr;
            helper.SetIcons(ImageConverter.ImageToIpicture(smallImage),
                            ImageConverter.ImageToIpicture(largeImage));
            UpdateTitle();
        }
Пример #2
0
        public Int32 AddBitmap(Int32 iWidth, Int32 iHeight, stdole.IPicture pip, Int32 crMask)
        {
            object[] paramsArray = Invoker.ValidateParamsArray(iWidth, iHeight, pip, crMask);
            object   returnItem  = Invoker.MethodReturn(this, "AddBitmap", paramsArray);

            return(NetRuntimeSystem.Convert.ToInt32(returnItem));
        }
Пример #3
0
        private static object GetTabPicture(Bitmap img)
        {
            Color transparent = Color.FromArgb(0, 254, 0, 254);

            if (Common.chDTE.Version == "8.0")
            {
                for (int x = 0; x < img.Width; x++)
                {
                    for (int y = 0; y < img.Height; y++)
                    {
                        if (img.GetPixel(x, y) == Color.FromArgb(192, 192, 192))
                        {
                            img.SetPixel(x, y, transparent);
                        }
                    }
                }
            }
            else
            {
                img.MakeTransparent(Color.FromArgb(192, 192, 192));
            }

            stdole.IPicture ret = Support.ImageToIPicture(img) as stdole.IPicture;
            return(ret);
        }
Пример #4
0
        /// <summary>Gets a  for a given OLE IPicture object.</summary>
        /// <returns>A <see cref="T:System.Drawing.Image" />.</returns>
        /// <param name="pict">An OLE IPicture object.</param>
        // ReSharper disable InconsistentNaming
        public static Image IPictureToImage(object pict)
        // ReSharper restore InconsistentNaming
        {
            if (pict == null)
            {
                return(null);
            }
            IntPtr zero = IntPtr.Zero;

            // ReSharper disable SuggestUseVarKeywordEvident
#if NET_CORE_APP
            Interop.Ole32.IPicture picture = (Interop.Ole32.IPicture)pict;
#else
            stdole.IPicture picture = (stdole.IPicture)pict;
#endif
            // ReSharper restore SuggestUseVarKeywordEvident
            int type = picture.Type;
            if (type == 1)
            {
                try
                {
                    zero = new IntPtr(picture.hPal);
                }
                catch (COMException expr_2C)
                {
                    ProjectData.SetProjectError(expr_2C);
                    ProjectData.ClearProjectError();
                }
            }

            IntPtr handle = new IntPtr(picture.Handle);
            return(GetImageFromParams(handle, type, zero, picture.Width, picture.Height));
        }
Пример #5
0
        private static void SaveMasterPicture(string picture_filename, Master master)
        {
            stdole.IPicture master_picture_pic = (stdole.IPicture)master.Picture;
            IntPtr          metafile_handle    = (IntPtr)master_picture_pic.Handle;

            using (var metafile = new System.Drawing.Imaging.Metafile(metafile_handle, true))
            {
                metafile.Save(picture_filename);
            }
            FormGetMasterImages.DeleteEnhMetaFile(metafile_handle);
        }
Пример #6
0
        private static void SaveMasterIcon(string icon_filename, Master master)
        {
            stdole.IPicture master_icon_pic = (stdole.IPicture)master.Icon;
            IntPtr          icon_handle     = (IntPtr)master_icon_pic.Handle;

            using (var icon = System.Drawing.Icon.FromHandle(icon_handle).ToBitmap())
            {
                icon.Save(icon_filename);
            }
            FormGetMasterImages.DestroyIcon(icon_handle);
        }
Пример #7
0
        /// -----------------------------------------------------------------------------------
        /// <summary>Member RenderPicture</summary>
        /// <param name='_pic'>_pic</param>
        /// <param name='x'>x</param>
        /// <param name='y'>y</param>
        /// <param name='cx'>cx</param>
        /// <param name='cy'>cy</param>
        /// <param name='xSrc'>xSrc</param>
        /// <param name='ySrc'>ySrc</param>
        /// <param name='cxSrc'>cxSrc</param>
        /// <param name='cySrc'>cySrc</param>
        /// <param name='_rcWBounds'>_rcWBounds</param>
        /// -----------------------------------------------------------------------------------
        public void RenderPicture(stdole.IPicture _pic, int x, int y, int cx, int cy,
                                  int xSrc, int ySrc, int cxSrc, int cySrc, ref Rect _rcWBounds)
        {
            Debug.Assert(m_bitmapGraphics != null);
            IntPtr hdc = m_bitmapGraphics.GetHdc();
            IntPtr ptr = Marshal.AllocCoTaskMem(Marshal.SizeOf(_rcWBounds));

            Marshal.StructureToPtr(_rcWBounds, ptr, true);

            _pic.Render(hdc.ToInt32(), x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, ptr);

            Marshal.FreeCoTaskMem(ptr);
            m_bitmapGraphics.ReleaseHdc(hdc);
        }
Пример #8
0
        //添加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;

            ISymbologyStyleClass pSymbolClass = psymbologyStyleClass;

            pSymbolClass.AddItem(styleGalleryItem, 0);
            pSymbolClass.SelectItem(0);
            Image image = null;

            if (symbol is IMarker3DSymbol)
            {
                IMarker3DSymbol mar3dsym = symbol as IMarker3DSymbol;
                stdole.IPicture pic      = mar3dsym.Thumbnail;
                image = Image.FromHbitmap(new System.IntPtr(pic.Handle));
            }
            else
            {
                stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(styleGalleryItem, 140, 15);
                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);
            Symbollist.Add(symbol);
        }
Пример #9
0
 public static Image GetImage(stdole.IPicture iPicture)
 {
     return(ConvertIconToImage(Convert(iPicture)));
 }
Пример #10
0
 public virtual Int32 AddBitmap(Int32 iWidth, Int32 iHeight, stdole.IPicture pip, Int32 crMask)
 {
     return(InvokerService.InvokeInternal.ExecuteInt32MethodGet(this, "AddBitmap", iWidth, iHeight, pip, crMask));
 }
Пример #11
0
        /// <summary>
        /// Create content items and add to the display
        /// </summary>
        /// <param name="refreshOnly">true if the item counter should not be
        /// incremented, false if it should be incremented
        /// </param>
        void ChangeItems(bool refreshOnly)
        {
            // add content to display.
            int maxItems = (firstTime) ? 1 : 1;

            firstTime = false;

            IGoogleDesktopDisplayPluginHelper pluginHelper =
                (IGoogleDesktopDisplayPluginHelper)this;

            // Here we show absolute time for items in email layout
            GoogleDesktopDisplayContentItemFlags itemFlags =
                GoogleDesktopDisplayContentItemFlags.GDD_CONTENT_ITEM_FLAG_NONE;

            if (contentLayout ==
                GoogleDesktopDisplayContentItemLayout.GDD_CONTENT_ITEM_LAYOUT_EMAIL)
            {
                itemFlags =
                    GoogleDesktopDisplayContentItemFlags.GDD_CONTENT_ITEM_FLAG_TIME_ABSOLUTE;
            }

            for (int j = 0, i = itemStart + itemRotate; j < maxItems; ++j, ++i)
            {
                // create a new item
                SamplePluginContentItem curItem = new SamplePluginContentItem();
                IGoogleDesktopDisplayContentItemHelper itemHelper =
                    (IGoogleDesktopDisplayContentItemHelper)curItem;

                // the strings to display, different format for odd and even numbered items
                String heading = "Line " + i + " line " + i + " line " + i;
                String source  = "Google";
                String snippet =
                    "Google doodles with the idea to create noodles to sell on Froogle.";

                stdole.IPicture image = null;
                if (showImages)
                {
                    // use different images for odd and even numbered items
                    bool oddNumberedItem = ((i % 2) == 1);
                    image = (oddNumberedItem) ? contentIcon1 : contentIcon2;
                }

                DateTime timeCreated = DateTime.UtcNow;

                // Show the item in the sidebar and optionally in the notifier window
                // if the sidebar was auto-hidden.
                GoogleDesktopContentItemDisplayOptions options =
                    GoogleDesktopContentItemDisplayOptions.GDD_ITEM_DISPLAY_IN_SIDEBAR |
                    GoogleDesktopContentItemDisplayOptions.GDD_ITEM_DISPLAY_AS_NOTIFICATION_IF_SIDEBAR_HIDDEN;
                pluginHelper.AddContentItem(curItem, options);

                // do the actual setting of properties
                itemHelper.heading      = heading;
                itemHelper.tooltip      = heading;
                itemHelper.source       = source;
                itemHelper.time_created = timeCreated;
                itemHelper.snippet      = snippet;
                itemHelper.flags        = itemFlags;
                itemHelper.image        = image;
                itemHelper.layout       = contentLayout;
            }

            if (!refreshOnly)
            {
                // increment item counter since we are asked to add new content
                itemRotate              = (itemRotate + maxItems) % itemRotateMax;
                totalItemsCreatedCount += maxItems;
            }

            // if we are in minimized mode, update the title with latest info.
            // displaySite will be null until plugin is fully initialized.
            if (displaySite != null && displaySite.display_state ==
                GoogleDesktopDisplayTileDisplayState.GDD_TILE_DISPLAY_STATE_MINIMIZED)
            {
                UpdateTitle();
            }
        }
Пример #12
0
 public static object Convert(stdole.IPicture pic)
 {
     return(Convert(pic, pic.Type, () => pic.Handle, () => pic.hPal));
 }
Пример #13
0
 public static System.Drawing.Image GetImage(stdole.IPicture iPicture)
 {
     return(IconToolsAxHost.GetImageFromIPicture(iPicture));
 }
Пример #14
0
			public SandboxVc(CachePair caches, InterlinLineChoices choices, bool fIconsForAnalysisChoices, SandboxBase sandbox)
			{
				m_caches = caches;
				m_choices = choices;
				m_sandbox = sandbox;
				m_fIconsForAnalysisChoices = fIconsForAnalysisChoices;
				m_wsAnalysis = caches.MainCache.LangProject.DefaultAnalysisWritingSystem;
				m_wsUi = caches.MainCache.LanguageWritingSystemFactoryAccessor.UserWs;
				m_tssMissingMorphs = m_tsf.MakeString(ITextStrings.ksStars, m_sandbox.RawWordformWs);
				m_tssEmptyAnalysis = m_tsf.MakeString("", m_wsAnalysis);
				m_tssEmptyVern = m_tsf.MakeString("", m_sandbox.RawWordformWs);
				m_tssMissingEntry = m_tssMissingMorphs;
				// It's tempting to re-use m_tssMissingMorphs, but the analysis and vernacular default
				// fonts may have different sizes, requiring differnt line heights to align things well.
				m_tssMissingMorphGloss = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis);
				m_tssMissingMorphPos = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis);
				m_tssMissingWordPos = m_tssMissingMorphPos;
				m_PulldownArrowPic = (stdole.IPicture)OLECvt.ToOLE_IPictureDisp(ResourceHelper.InterlinPopupArrow);
				m_dxmpArrowPicWidth = ConvertPictureWidthToMillipoints(m_PulldownArrowPic);
				IWritingSystem wsObj = caches.MainCache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(m_sandbox.RawWordformWs);
				if (wsObj != null)
					m_fRtl = wsObj.RightToLeft;

			}
Пример #15
0
			/// <summary>
			/// Executes in two distinct scenarios.
			///
			/// 1. If disposing is true, the method has been called directly
			/// or indirectly by a user's code via the Dispose method.
			/// Both managed and unmanaged resources can be disposed.
			///
			/// 2. If disposing is false, the method has been called by the
			/// runtime from inside the finalizer and you should not reference (access)
			/// other managed objects, as they already have been garbage collected.
			/// Only unmanaged resources can be disposed.
			/// </summary>
			/// <param name="disposing"></param>
			/// <remarks>
			/// If any exceptions are thrown, that is fine.
			/// If the method is being done in a finalizer, it will be ignored.
			/// If it is thrown by client code calling Dispose,
			/// it needs to be handled by fixing the bug.
			///
			/// If subclasses override this method, they should call the base implementation.
			/// </remarks>
			protected override void Dispose(bool disposing)
			{
				//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
				// Must not be run more than once.
				if (IsDisposed)
					return;

				if (disposing)
				{
					// Dispose managed resources here.
				}

				// Dispose unmanaged resources here, whether disposing is true or false.
				m_sandbox = null; // Client gave it to us, so has to deal with it.
				m_caches = null; // Client gave it to us, so has to deal with it.
				Marshal.ReleaseComObject(m_PulldownArrowPic);
				m_PulldownArrowPic = null;
				Marshal.ReleaseComObject(m_tsf);
				m_tsf = null;
				m_tssMissingEntry = null; // Same as m_tssMissingMorphs, so just null it.
				m_tssMissingWordPos = null; // Same as m_tssMissingMorphPos, so just null it.
				Marshal.ReleaseComObject(m_tssMissingMorphs);
				m_tssMissingMorphs = null;
				Marshal.ReleaseComObject(m_tssEmptyAnalysis);
				m_tssEmptyAnalysis = null;
				Marshal.ReleaseComObject(m_tssEmptyVern);
				m_tssEmptyVern = null;
				Marshal.ReleaseComObject(m_tssMissingMorphGloss);
				m_tssMissingMorphGloss = null;
				Marshal.ReleaseComObject(m_tssMissingMorphPos);
				m_tssMissingMorphPos = null;

				base.Dispose(disposing);
			}
Пример #16
0
		/// <summary>
		/// Setup the check-mark column, if desired.
		/// </summary>
		protected virtual void SetupSelectColumn()
		{
			XmlAttribute xa = m_xnSpec.Attributes["selectColumn"];
			m_fShowSelected = xa != null && xa.Value == "true";
			if (m_fShowSelected)
			{
				// Only need these if showing the selected column.
				m_UncheckedCheckPic = (stdole.IPicture)
					OLECvt.ToOLE_IPictureDisp(ResourceHelper.UncheckedCheckBox);
				m_CheckedCheckPic =
					(stdole.IPicture)OLECvt.ToOLE_IPictureDisp(ResourceHelper.CheckedCheckBox);
				m_DisabledCheckPic =
					(stdole.IPicture)OLECvt.ToOLE_IPictureDisp(ResourceHelper.DisabledCheckBox);
				// We want a width in millipoints (72000/inch). Value we have is in 100/mm.
				// There are 25.4 mm/inch.
				m_dxmpCheckWidth = m_UncheckedCheckPic.Width * 72000 / 2540;
			}
			// By default, we currently set check boxes
			XmlAttribute xaDefaultCheckedAll = m_xnSpec.Attributes["defaultChecked"];
			m_fDefaultChecked = xaDefaultCheckedAll == null || xaDefaultCheckedAll.Value == "true";
		}
Пример #17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Executes in two distinct scenarios.
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
				if (m_columns != null)
					m_columns.Clear();
				if (m_possibleColumns != null)
					m_possibleColumns.Clear();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_columns = null;
			m_possibleColumns = null;
			m_xbv = null;
			m_sortItemProvider = null;
			if (m_UncheckedCheckPic != null)
			{
				Marshal.ReleaseComObject(m_UncheckedCheckPic);
				m_UncheckedCheckPic = null;
			}
			if (m_CheckedCheckPic != null)
			{
				Marshal.ReleaseComObject(m_CheckedCheckPic);
				m_CheckedCheckPic = null;
			}
			if (m_DisabledCheckPic != null)
			{
				Marshal.ReleaseComObject(m_DisabledCheckPic);
				m_DisabledCheckPic = null;
			}
			if (m_PreviewArrowPic != null)
			{
				Marshal.ReleaseComObject(m_PreviewArrowPic);
				m_PreviewArrowPic = null;
			}
			if (m_PreviewRTLArrowPic != null)
			{
				Marshal.ReleaseComObject(m_PreviewRTLArrowPic);
				m_PreviewRTLArrowPic = null;
			}

			base.Dispose (disposing);
		}
Пример #18
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the TeNotesVc class
		/// </summary>
		/// <param name="cache"></param>
		/// ------------------------------------------------------------------------------------
		public TeNotesVc(FdoCache cache) : base(TeStVc.LayoutViewTarget.targetDraft, -1)
		{
			m_wsDefault = cache.DefaultAnalWs;
			m_cache = cache;
			m_scr = cache.LangProject.TranslatedScriptureOA;
			m_scrBooks = new DBMultilingScrBooks((Scripture)m_scr);

			Image img = ResourceHelper.MinusBox;
			m_picMinus = (stdole.IPicture)OLECvt.ToOLE_IPictureDisp(img);
			//m_pixelHeights[m_picMinus] = img.Height;
			m_picPlus = (stdole.IPicture)OLECvt.ToOLE_IPictureDisp(ResourceHelper.PlusBox);
			m_picChooser = GetChooserImage();

			//using (Form frm = new Form())
			//using (Graphics g = frm.CreateGraphics())
			//    m_dpiY = (int)g.DpiY;

			m_quoteLabel = MakeLabelFromStringID("kstidQuoteLabel");
			m_detailsLabel = MakeLabelFromStringID("kstidDetailsLabel");
			m_discussionLabel = MakeLabelFromStringID("kstidDiscussionLabel");
			m_messageLabel = MakeLabelFromStringID("kstidMessageLabel");
			m_suggestionLabel = MakeLabelFromStringID("kstidSuggestionLabel");
			m_resolutionLabel = MakeLabelFromStringID("kstidResolutionLabel");
			m_authorLabel = MakeLabelFromStringID("kstidAuthorLabel");
			m_createdLabel = MakeLabelFromStringID("kstidCreatedLabel");
			m_modifiedLabel = MakeLabelFromStringID("kstidModifiedLabel");
			m_resolvedLabel = MakeLabelFromStringID("kstidResolvedLabel");
			m_responseLabel = MakeLabelFromStringID("kstidResponseLabel");
			ITsStrFactory strFactory = TsStrFactoryClass.Create();
			m_tssEmpty = strFactory.MakeString(string.Empty, m_scr.Cache.DefaultUserWs);
		}
Пример #19
0
 public static System.Drawing.Image IPictureToImage(stdole.IPicture picture)
 {
     return(GetPictureFromIPicture(picture));
 }
Пример #20
0
 public Int32 AddBitmap(Int32 iWidth, Int32 iHeight, stdole.IPicture pip, Int32 crMask)
 {
     return(Factory.ExecuteInt32MethodGet(this, "AddBitmap", iWidth, iHeight, pip, crMask));
 }
Пример #21
0
        void Initialize()
        {
            // initialize variables
              totalItemsCreatedCount = 0;
              contentLayout = GoogleDesktopDisplayContentItemLayout.GDD_CONTENT_ITEM_LAYOUT_EMAIL;
              totalItemsCreatedCount = 0;
              showImages = true;
              isDirty = false;

              // Load our icons
              contentIcon1 = ImageConverter.ImageToIpicture(new Icon(
            Assembly.GetExecutingAssembly().GetManifestResourceStream(
            "GoogleDesktopDisplayCSharpSample.ico1.ico")).ToBitmap());
              contentIcon2 = ImageConverter.ImageToIpicture(new Icon(
            Assembly.GetExecutingAssembly().GetManifestResourceStream(
            "GoogleDesktopDisplayCSharpSample.ico2.ico")).ToBitmap());

              Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
            "GoogleDesktopDisplayCSharpSample.plugin.ico");
              Bitmap smallImage = new Icon(stream, 16, 16).ToBitmap();
              stream.Seek(0, System.IO.SeekOrigin.Begin);
              Bitmap largeImage = new Icon(stream, 32, 32).ToBitmap();

              // Set plugin information
              IGoogleDesktopDisplayPluginHelper helper =  (IGoogleDesktopDisplayPluginHelper)this;
              helper.about_text = aboutStr;
              helper.SetIcons(ImageConverter.ImageToIpicture(smallImage),
            ImageConverter.ImageToIpicture(largeImage));
              UpdateTitle();
        }