예제 #1
0
        public override object GetObject(string name, CultureInfo culture)
        {
            if(name == null) throw new ArgumentNullException("name");

            if(this.GetObjectPre != null)
            {
                CrmEventArgs e = new CrmEventArgs(name, culture, null);
                this.GetObjectPre(this, e);
                if(e.Object != null) return e.Object;
            }

            object oOvr;
            if(m_dOverrides.TryGetValue(name, out oOvr)) return oOvr;

            object o = m_rm.GetObject(name, culture);
            if(o == null) { Debug.Assert(false); return null; }

            try
            {
                Image img = (o as Image);
                if(img != null)
                {
                    Debug.Assert(!(o is Icon));

                    Image imgScaled = DpiUtil.ScaleImage(img, false);
                    if(imgScaled != null)
                    {
                        m_dOverrides[name] = imgScaled;
                        return imgScaled;
                    }
                    else { Debug.Assert(false); }
                }
            }
            catch(Exception) { Debug.Assert(false); }

            return o;
        }
예제 #2
0
        public override object GetObject(string name, CultureInfo culture)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (this.GetObjectPre != null)
            {
                CrmEventArgs e = new CrmEventArgs(name, culture, null);
                this.GetObjectPre(this, e);
                if (e.Object != null)
                {
                    return(e.Object);
                }
            }

            object oOvr;

            if (m_dOverrides.TryGetValue(name, out oOvr))
            {
                return(oOvr);
            }

            object o = m_rm.GetObject(name, culture);

            if (o == null)
            {
                Debug.Assert(false); return(null);
            }

            try
            {
                Image img = (o as Image);
                if (img != null)
                {
                    Debug.Assert(!(o is Icon));

                    Image imgOvr = m_iaAppHighRes.GetForObject(name);
                    if (imgOvr != null)
                    {
                        int wOvr  = imgOvr.Width;
                        int hOvr  = imgOvr.Height;
                        int wBase = img.Width;
                        int hBase = img.Height;
                        int wReq  = DpiUtil.ScaleIntX(wBase);
                        int hReq  = DpiUtil.ScaleIntY(hBase);

                        if ((wBase > wOvr) || (hBase > hOvr))
                        {
                            Debug.Assert(false);                             // Base has higher resolution
                            imgOvr = img;
                            wOvr   = wBase;
                            hOvr   = hBase;
                        }

                        if ((wReq != wOvr) || (hReq != hOvr))
                        {
                            imgOvr = GfxUtil.ScaleImage(imgOvr, wReq, hReq,
                                                        ScaleTransformFlags.UIIcon);
                        }
                    }
                    else
                    {
                        imgOvr = DpiUtil.ScaleImage(img, false);
                    }

                    m_dOverrides[name] = imgOvr;
                    return(imgOvr);
                }
            }
            catch (Exception) { Debug.Assert(false); }

            return(o);
        }
예제 #3
0
		public override object GetObject(string name, CultureInfo culture)
		{
			if(name == null) throw new ArgumentNullException("name");

			if(this.GetObjectPre != null)
			{
				CrmEventArgs e = new CrmEventArgs(name, culture, null);
				this.GetObjectPre(this, e);
				if(e.Object != null) return e.Object;
			}

			object oOvr;
			if(m_dOverrides.TryGetValue(name, out oOvr)) return oOvr;

			object o = m_rm.GetObject(name, culture);
			if(o == null) { Debug.Assert(false); return null; }

			try
			{
				Image img = (o as Image);
				if(img != null)
				{
					Debug.Assert(!(o is Icon));

					Image imgOvr = m_iaAppHighRes.GetForObject(name);
					if(imgOvr != null)
					{
						int wOvr = imgOvr.Width;
						int hOvr = imgOvr.Height;
						int wBase = img.Width;
						int hBase = img.Height;
						int wReq = DpiUtil.ScaleIntX(wBase);
						int hReq = DpiUtil.ScaleIntY(hBase);

						if((wBase > wOvr) || (hBase > hOvr))
						{
							Debug.Assert(false); // Base has higher resolution
							imgOvr = img;
							wOvr = wBase;
							hOvr = hBase;
						}

						if((wReq != wOvr) || (hReq != hOvr))
							imgOvr = GfxUtil.ScaleImage(imgOvr, wReq, hReq,
								ScaleTransformFlags.UIIcon);
					}
					else imgOvr = DpiUtil.ScaleImage(img, false);

					m_dOverrides[name] = imgOvr;
					return imgOvr;
				}
			}
			catch(Exception) { Debug.Assert(false); }

			return o;
		}