当前位置: 首页>>代码示例>>C#>>正文


C# MainForm.Add方法代码示例

本文整理汇总了C#中MainForm.Add方法的典型用法代码示例。如果您正苦于以下问题:C# MainForm.Add方法的具体用法?C# MainForm.Add怎么用?C# MainForm.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MainForm的用法示例。


在下文中一共展示了MainForm.Add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessDecoder

        protected override bool ProcessDecoder(MainForm form, IWICBitmapDecoder decoder, DataEntry[] de, object tag)
        {
            IWICBitmapDecoderInfo info = decoder.GetDecoderInfo();
            try
            {
                Guid clsid;
                info.GetCLSID(out clsid);
                if (clsid != Parent.Clsid)
                {
                    form.Add(this, Resources.IncorrectDecoderPickedUp, de, new DataEntry(Resources.Expected, Parent.Clsid), new DataEntry(Resources.Actual, clsid));
                }
                else
                {
                    Tag t = (Tag)tag;
                    if (!t.SupportsMultiframe && decoder.GetFrameCount() > 1)
                    {
                        form.Add(this, Resources.DecoderDoesNotMultiframe, de, new DataEntry(Resources.FrameCount, decoder.GetFrameCount()));
                    }
                }
            }
            finally
            {
                info.ReleaseComObject();
            }

            return true;
        }
开发者ID:eakova,项目名称:resizer,代码行数:27,代码来源:BitmapDecoderInfoRule.cs

示例2: RunInternal

 void RunInternal(MainForm form)
 {
     form.SetStatus(string.Format(CultureInfo.CurrentUICulture, Resources.Running, FullPath));
     try
     {
         RunOverride(form, null);
     }
     catch (Exception e)
     {
         form.Add(this, e.TargetSite.ToString(Resources._0_Failed), new DataEntry(e));
     }
 }
开发者ID:eakova,项目名称:resizer,代码行数:12,代码来源:RuleBase.cs

示例3: ProcessFrameDecode

        protected override bool ProcessFrameDecode(MainForm form, IWICBitmapFrameDecode frame, DataEntry[] de, object tag)
        {
            Guid pixelFormat;
            frame.GetPixelFormat(out pixelFormat);

            Tag t = (Tag)tag;
            if (Array.IndexOf(t.PixelFormats, pixelFormat) < 0)
            {
                form.Add(this, Resources.DecoderUnsuportedPixelFormat, de, new DataEntry(Resources.PixelFormat, pixelFormat), new DataEntry(Resources.SupportedPixelFormats, t.PixelFormats));
            }

            return true;
        }
开发者ID:eakova,项目名称:resizer,代码行数:13,代码来源:BitmapDecoderInfoRule.cs

示例4: ProcessDecoder

        protected override bool ProcessDecoder(MainForm form, IWICBitmapDecoder decoder, DataEntry[] de, object tag)
        {
            CheckCopyPalette(form, de, decoder.CopyPalette);

            CheckGetColorContexts(form, de, decoder.GetColorContexts);

            if (decoder.GetFrameCount() == 0)
            {
                form.Add(this, Resources.FileNoFrames, de);
            }

            CheckGetBitmapSource(form, de, decoder.GetPreview, WinCodecError.WINCODEC_ERR_UNSUPPORTEDOPERATION);
            CheckGetBitmapSource(form, de, decoder.GetThumbnail, WinCodecError.WINCODEC_ERR_CODECNOTHUMBNAIL);

            return true;
        }
开发者ID:eakova,项目名称:resizer,代码行数:16,代码来源:BitmapDecoderRule.cs

示例5: ProcessFrameDecode

        protected override bool ProcessFrameDecode(MainForm form, IWICBitmapFrameDecode frame, DataEntry[] de, object tag)
        {
            CheckGetColorContexts(form, de, frame.GetColorContexts);

            CheckGetBitmapSource(form, de, frame.GetThumbnail, WinCodecError.WINCODEC_ERR_CODECNOTHUMBNAIL);

            uint width;
            uint height;
            frame.GetSize(out width, out height);

            Guid pixelFormat;
            frame.GetPixelFormat(out pixelFormat);

            uint stride = (PixelFormatInfoRule.GetBitPerPixel(pixelFormat) * width + 7) / 8;
            byte[] buffer = new byte[stride * height];
            WICRect rect = new WICRect();
            rect.Height = (int)Math.Min(height, int.MaxValue);
            rect.Width = (int)Math.Min(width, int.MaxValue);
            try
            {
                frame.CopyPixels(rect, stride, stride * height, buffer);
                try
                {
                    frame.CopyPixels(null, stride, stride * height, buffer);
                }
                catch (Exception e)
                {
                    form.Add(this, e.TargetSite.ToString(Resources._0_Failed, "NULL"), de, new DataEntry(e));
                }
            }
            catch
            {
            }

            return true;
        }
开发者ID:eakova,项目名称:resizer,代码行数:36,代码来源:BitmapDecoderRule.cs

示例6: Check

 protected override void Check(MainForm form, string ext, RegistryKey rk, DataEntry[] de)
 {
     using (RegistryKey r = OpenSubKey(form, Registry.LocalMachine, PropertyHandler, de))
     {
         string value = CheckStringValue(form, r, null, de);
         if (value != null)
         {
             if (value == PhotoMetadataHandler)
             {
                 using (RegistryKey r2 = OpenSubKey(form, Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\PhotoPropertyHandler\ContainerAssociations", de))
                 {
                     foreach (Guid g in Parent.ContainerFormats)
                     {
                         if (0 <= Array.FindIndex(r2.GetValueNames(), delegate(string obj) { return string.Compare(obj, g.ToString("B"), CultureInfo.InvariantCulture, CompareOptions.IgnoreCase) == 0; }))
                         {
                             CheckValue(form, r2, g.ToString("B"), PhotoMetadataHandlerContainerFormats, de);
                         }
                     }
                 }
             }
             else
             {
                 Guid? clsid = null;
                 try
                 {
                     clsid = new Guid(value);
                 }
                 catch (ArgumentException)
                 {
                     form.Add(this, Resources.InvalidGUIDRegistryValue, new DataEntry(Resources.Key, r.ToString()), new DataEntry(Resources.Value, Resources.RegistryValue_default));
                 }
                 if (clsid.HasValue)
                 {
                     Type t = Type.GetTypeFromCLSID(clsid.Value, false);
                     if (t == null)
                     {
                         object ps = null;
                         try
                         {
                             ps = Activator.CreateInstance(t);
                         }
                         catch (Exception e)
                         {
                             form.Add(this, string.Format(CultureInfo.CurrentUICulture, Resources._0_Failed, "CoCreateInstance(...)"), new DataEntry(e), new DataEntry(Resources.CLSID, clsid));
                         }
                         finally
                         {
                             ps.ReleaseComObject();
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:eakova,项目名称:resizer,代码行数:55,代码来源:PropertyStoreIntegrationRule.cs

示例7: RunOverride

        protected override void RunOverride(MainForm form, object tag)
        {
            IWICImagingFactory factory = (IWICImagingFactory)new WICImagingFactory();
            IWICBitmapDecoderInfo info = (IWICBitmapDecoderInfo)factory.CreateComponentInfo(Parent.Clsid);
            Guid cf;
            info.GetContainerFormat(out cf);
            IWICBitmapDecoder decoder = null;
            try
            {
                decoder = info.CreateInstance();
                Guid containerFormat;
                try
                {
                    decoder.GetContainerFormat(out containerFormat);
                    if (containerFormat != cf)
                    {
                        form.Add(this, Resources.ContainerFormatsDoNotMatch, new DataEntry(Resources.Actual, cf), new DataEntry(Resources.Expected, containerFormat));
                    }
                }
                catch (Exception e)
                {
                    form.Add(this, e.TargetSite.ToString(Resources._0_Failed), new DataEntry(e));
                }

                ComponentInfoHelper.CheckEquals<IWICBitmapDecoderInfo>(form, decoder.GetDecoderInfo, this, Extensions.CompareInfos);
            }
            finally
            {
                factory.ReleaseComObject();
                info.ReleaseComObject();
                decoder.ReleaseComObject();
            }

            base.RunOverride(form, tag);
        }
开发者ID:eakova,项目名称:resizer,代码行数:35,代码来源:BitmapDecoderRule.cs

示例8: QueryCapabilitiesError

 protected override void QueryCapabilitiesError(MainForm form, string text, params DataEntry[] de)
 {
     form.Add(this, text, de);
 }
开发者ID:eakova,项目名称:resizer,代码行数:4,代码来源:BitmapDecoderRule.cs

示例9: CheckGetColorContexts

        void CheckGetColorContexts(MainForm form, DataEntry[] de, Func<uint, IWICColorContext[], uint> method)
        {
            IWICColorContext[] contexts = null;
            IWICImagingFactory factory = new WICImagingFactory() as IWICImagingFactory;
            try
            {
                try
                {
                    contexts = new IWICColorContext[method(0, null)];
                }
                catch (Exception e)
                {
                    form.CheckHRESULT(this, WinCodecError.WINCODEC_ERR_UNSUPPORTEDOPERATION, e, "0, NULL", de);

                    return;
                }
                if (contexts.Length > 0)
                {
                    for (int i = 0; i < contexts.Length; i++)
                    {
                        contexts[i] = factory.CreateColorContext();
                    }
                    try
                    {
                        method((uint)contexts.Length, contexts);

                        int index = 0;
                        foreach (IWICColorContext c in contexts)
                        {
                            if (c == null)
                            {
                                form.Add(this, method.ToString(Resources._0_NULLItem), de, new DataEntry(Resources.Index, index));
                            }
                            index++;
                        }
                    }
                    catch (Exception e)
                    {
                        form.Add(this, method.ToString(Resources._0_Failed), de, new DataEntry(e));
                    }
                }
            }
            finally
            {
                contexts.ReleaseComObject();
                factory.ReleaseComObject();
            }
        }
开发者ID:eakova,项目名称:resizer,代码行数:48,代码来源:BitmapDecoderRule.cs

示例10: CheckCopyPalette

        void CheckCopyPalette(MainForm form, DataEntry[] de, Action<IWICPalette> method)
        {
            IWICImagingFactory factory = (IWICImagingFactory)new WICImagingFactory();
            IWICPalette palette = factory.CreatePalette();

            try
            {
                method(palette);
                try
                {
                    if (palette.GetColorCount() == 0)
                    {
                        form.Add(this, method.ToString(Resources._0_ZeroColorPalette), de);
                    }
                }
                catch (Exception e)
                {
                    form.Add(this, method.ToString(Resources._0_IncorrectStatePalette), de, new DataEntry(e));
                }
            }
            catch (Exception e)
            {
                form.CheckHRESULT(this, WinCodecError.WINCODEC_ERR_PALETTEUNAVAILABLE, e, de);
            }
            finally
            {
                palette.ReleaseComObject();
                factory.ReleaseComObject();
            }
        }
开发者ID:eakova,项目名称:resizer,代码行数:30,代码来源:BitmapDecoderRule.cs

示例11: CheckRegistry

 private void CheckRegistry(MainForm form, string key, IWowRegistryChecked parent)
 {
     using (RegistryKey x64 = Registry.ClassesRoot.OpenSubKey(key))
     {
         string wowKey = string.Format(CultureInfo.InvariantCulture, "Wow6432Node\\{0}", key);
         using (RegistryKey wow = Registry.ClassesRoot.OpenSubKey(wowKey))
         {
             if (x64 == null || wow == null)
             {
                 if (x64 != wow)
                 {
                     form.Add(this, Resources.MissingRegistryKey, new DataEntry(Resources.Key, string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", Registry.ClassesRoot, wow == null ? wowKey : key)));
                 }
             }
             else
             {
                 foreach (string s in new HashSet<string>(x64.GetValueNames().Union(wow.GetValueNames()), StringComparer.OrdinalIgnoreCase))
                 {
                     RegistryValueKind kind = RegistryValueKind.Unknown;
                     RegistryValueKind kindWow = RegistryValueKind.Unknown;
                     try
                     {
                         kind = x64.GetValueKind(s);
                         kindWow = wow.GetValueKind(s);
                     }
                     catch (IOException)
                     {
                         form.Add(this, Resources.MissingRegistryValue, new DataEntry(Resources.Key, (kind == RegistryValueKind.Unknown ? x64 : wow).ToString()), new DataEntry(Resources.Value, s));
                     }
                     if (kind != RegistryValueKind.Unknown && kindWow != RegistryValueKind.Unknown)
                     {
                         if (kind != kindWow)
                         {
                             form.Add(this, Resources.InconsistentRegistryValueType, new DataEntry(Resources.Key, x64.ToString()), new DataEntry(Resources.WowKey, wow.ToString()), new DataEntry(Resources.Value, s), new DataEntry(Resources.X86, kindWow), new DataEntry(Resources.Amd64, kind));
                         }
                         else
                         {
                             object value = x64.GetValue(s, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                             object valueWow = wow.GetValue(s, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                             if (!object.Equals(value, valueWow))
                             {
                                 string[] strings = value as string[];
                                 if (strings == null || !strings.ItemsEqual(valueWow as string[]))
                                 {
                                     byte[] bytes = value as byte[];
                                     if (bytes == null || !bytes.ItemsEqual(valueWow as byte[]))
                                     {
                                         form.Add(this, Resources.InconsistentRegistryValue, new DataEntry(Resources.Key, x64.ToString()), new DataEntry(Resources.WowKey, wow.ToString()), new DataEntry(Resources.Value, string.IsNullOrEmpty(s) ? Resources.RegistryValue_default : value), new DataEntry(Resources.X86, value), new DataEntry(Resources.Amd64, valueWow));
                                     }
                                 }
                             }
                         }
                     }
                 }
                 foreach (string s in new HashSet<string>(x64.GetSubKeyNames().Union(wow.GetSubKeyNames()), StringComparer.OrdinalIgnoreCase))
                 {
                     CheckRegistry(form, string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", key, s), parent);
                 }
             }
         }
     }
 }
开发者ID:eakova,项目名称:resizer,代码行数:62,代码来源:WowRule.cs

示例12: Check

        protected override void Check(MainForm form, string ext, RegistryKey rk, DataEntry[] de)
        {
            bool openWith = false;
            bool imagePreview = false;

            string progid = CheckStringValue(form, rk, null, de);
            if (!string.IsNullOrEmpty(progid))
            {
                using (RegistryKey r = OpenSubKey(form, rk, "OpenWithProgids", de))
                {
                    if (r != null)
                    {
                        if (Array.IndexOf(r.GetValueNames(), progid) < 0)
                        {
                            form.Add(this, Resources.MissingRegistryValue, de, new DataEntry(Resources.Value, progid), new DataEntry(Resources.Key, rk.ToString()));
                        }
                    }
                }
                using (RegistryKey r = OpenSubKey(form, rk, string.Format(CultureInfo.InvariantCulture, "OpenWithList\\{0}", PhotoViewerDll), de, ref openWith))
                {
                }
                using (RegistryKey r = OpenSubKey(form, rk, "ShellExt\\ContextMenuHandlers\\ShellImagePreview", de, ref imagePreview))
                {
                    CheckValue(form, r, null, new string[] { PhotoGalleryGuid }, de);
                }

                using (RegistryKey r = OpenSubKey(form, Registry.ClassesRoot, progid, new DataEntry[0]))
                {
                    CheckStringValue(form, r, null, de);

                    using (RegistryKey r1 = OpenSubKey(form, r, "DefaultIcon", new DataEntry[0]))
                    {
                        string iconPath = CheckStringValue(form, r1, null, de);
                        if (!string.IsNullOrEmpty(iconPath))
                        {
                            using (TempFileCollection t = new TempFileCollection())
                            {
                                string file = t.AddExtension(ext);
                                File.WriteAllBytes(file, new byte[0]);
                                try
                                {
                                    Icon.ExtractAssociatedIcon(file).Dispose();
                                }
                                catch (Exception e)
                                {
                                    form.Add(this, Resources.CannotExtractIcon, de, new DataEntry(Resources.Key, r1.ToString()), new DataEntry(Resources.Value, Resources.RegistryValue_default), new DataEntry(Resources.Actual, iconPath), new DataEntry(e));
                                }
                            }
                        }
                    }

                    using (RegistryKey r1 = OpenSubKey(form, r, "shell\\open\\command", new DataEntry[0]))
                    {
                        CheckValue(form, r1, null, new string[] { string.Format(CultureInfo.InvariantCulture, "%SystemRoot%\\System32\\rundll32.exe \"{0}\", ImageView_Fullscreen %1", PhotoGalleryPath) }, de);
                    }
                    using (RegistryKey r1 = OpenSubKey(form, r, "shell\\open", new DataEntry[0]))
                    {
                        CheckValue(form, r1, "MuiVerb", new string[] { string.Format(CultureInfo.InvariantCulture, "@{0},-3043", PhotoGalleryPath) }, de);
                    }
                    using (RegistryKey r1 = OpenSubKey(form, r, "shell\\open\\DropTarget", new DataEntry[0]))
                    {
                        CheckValue(form, r1, "Clsid", new string[] { PhotoGalleryGuid }, de);
                    }
                    using (RegistryKey r1 = OpenSubKey(form, r, "shell\\printto\\command", new DataEntry[0]))
                    {
                        CheckValue(form, r1, null, new string[] { "%SystemRoot%\\System32\\rundll32.exe \"%SystemRoot%\\System32\\shimgvw.dll\", ImageView_PrintTo /pt \"%1\" \"%2\" \"%3\" \"%4\"" }, de);
                    }
                }
            }

            using (RegistryKey r = OpenSubKey(form, Registry.ClassesRoot, string.Format(CultureInfo.InvariantCulture, "SystemFileAssociations\\{0}", ext), new DataEntry[0]))
            {
                using (RegistryKey r1 = OpenSubKey(form, r, string.Format(CultureInfo.InvariantCulture, "OpenWithList\\{0}", PhotoViewerDll), de, ref openWith))
                {
                }
                using (RegistryKey r2 = OpenSubKey(form, r, "ShellEx\\ContextMenuHandlers\\ShellImagePreview", de, ref imagePreview))
                {
                    CheckValue(form, r2, null, new string[] { PhotoGalleryGuid }, de);
                }
            }

            if (!openWith)
            {
                form.Add(this, Resources.MissingRegistryKey, de, new DataEntry(Resources.Key, new string[]
                {
                    string.Format(CultureInfo.InvariantCulture, "{2}\\{0}\\OpenWithList\\{1}", ext, PhotoViewerDll, Registry.ClassesRoot),
                    string.Format(CultureInfo.InvariantCulture, "{2}\\SystemFileAssociations\\{0}\\OpenWithList\\{1}", ext, PhotoViewerDll, Registry.ClassesRoot)
                }));
            }
            if (!imagePreview)
            {
                form.Add(this, Resources.MissingRegistryKey, de, new DataEntry(Resources.Key, new string[]
                {
                    string.Format(CultureInfo.InvariantCulture, "{2}\\{0}\\ShellEx\\ContextMenuHandlers\\ShellImagePreview", ext, PhotoViewerDll, Registry.ClassesRoot),
                    string.Format(CultureInfo.InvariantCulture, "{2}\\SystemFileAssociations\\{0}\\ShellEx\\ContextMenuHandlers\\ShellImagePreview", ext, PhotoViewerDll, Registry.ClassesRoot)
                }));
            }
        }
开发者ID:eakova,项目名称:resizer,代码行数:98,代码来源:PhotoGalleryIntegrationRule.cs

示例13: ProcessEncoder

        protected override bool ProcessEncoder(MainForm form, IWICBitmapEncoder encoder, object tag)
        {
            IWICImagingFactory factory = (IWICImagingFactory)new WICImagingFactory();
            IWICBitmap bitmap = factory.CreateBitmap(1, 1, Consts.GUID_WICPixelFormat128bpp7ChannelsAlpha, WICBitmapCreateCacheOption.WICBitmapCacheOnLoad);
            IWICBitmapFrameEncode frame = null;
            try
            {
                try
                {
                    encoder.CreateNewFrame(out frame, null);
                }
                catch (Exception e)
                {
                    form.Add(this, e.TargetSite.ToString(Resources._0_Failed), new DataEntry(e));
                }

                if (frame != null)
                {
                    try
                    {
                        frame.Initialize(null);
                    }
                    catch (Exception e)
                    {
                        form.Add(this, e.TargetSite.ToString(Resources._0_Failed, "NULL"), new DataEntry(e));
                        frame.ReleaseComObject();
                        frame = null;
                    }
                }
                if (frame != null)
                {
                    try
                    {
                        frame.WriteSource(bitmap, null);
                    }
                    catch (Exception e)
                    {
                        form.Add(this, e.TargetSite.ToString(Resources._0_Failed, "..., NULL"), new DataEntry(e));
                        frame.ReleaseComObject();
                        frame = null;
                    }
                }

                if (frame != null)
                {
                    try
                    {
                        frame.Commit();
                        encoder.Commit();
                    }
                    catch (Exception e)
                    {
                        form.Add(this, e.TargetSite.ToString(Resources._0_Failed), new DataEntry(e));
                    }
                }
            }
            finally
            {
                frame.ReleaseComObject();
                bitmap.ReleaseComObject();
                factory.ReleaseComObject();
            }

            return base.ProcessEncoder(form, encoder, tag);
        }
开发者ID:eakova,项目名称:resizer,代码行数:65,代码来源:BitmapFrameEncodeRule.cs

示例14: Check

        void Check(MainForm form, IWICBitmapDecoderInfo info, Tag tag)
        {
            ComponentInfoHelper.CheckNotReserverdGuid(form, info.GetContainerFormat, this);

            tag.PixelFormats = PixelFormatInfoRule.CheckPixelFormats(form, this, info.GetPixelFormats);

            ComponentInfoHelper.CheckVersion(form, info.GetColorManagementVersion, this);
            ComponentInfoHelper.CheckCommaSeparatedString(form, info.GetMimeTypes, ComponentInfoHelper.MimeMask, this);

            tag.Extensions = ComponentInfoHelper.CheckCommaSeparatedString(form, info.GetFileExtensions, ComponentInfoHelper.ExtensionMask, this);

            if (!info.DoesSupportMultiframe() && info.DoesSupportAnimation())
            {
                form.Add(this, Resources.DecoderAnimationIfMultiframe);
            }
            tag.SupportsMultiframe = info.DoesSupportMultiframe();

            uint count;
            uint size = info.GetPatterns(0, IntPtr.Zero, out count);
            if (size != 0)
            {
                IntPtr p = Marshal.AllocCoTaskMem((int)size);
                try
                {
                    info.GetPatterns(size, p, out count);

                    WICBitmapPattern[] patterns = PropVariantMarshaler.ToArrayOf<WICBitmapPattern>(p, (int)count);
                    int index = 0;
                    HashSet<int> dups = new HashSet<int>();
                    foreach (WICBitmapPattern pattern in patterns)
                    {
                        index++;
                        if (pattern.Length == 0)
                        {
                            form.Add(this, Resources.PatternZeroLength, new DataEntry(Resources.PatternIndex, index));
                        }
                        else if (index < patterns.Length)
                        {
                            if (Array.FindIndex(patterns, index, delegate(WICBitmapPattern obj) { return obj.EndOfStream == pattern.EndOfStream && obj.Position == pattern.Position && GetNormalizedMask(obj).ItemsEqual(GetNormalizedMask(pattern)); }) >= 0)
                            {
                                dups.Add(index);
                            }
                        }
                    }
                    if (dups.Count > 0)
                    {
                        form.Add(this, Resources.PatternDuplicated, new DataEntry(Resources.PatternIndices, dups.ToArray()));
                    }
                }
                finally
                {
                    Marshal.FreeCoTaskMem(p);
                }
            }

            if (count == 0 || size == 0)
            {
                form.Add(this, Resources.PatternNo);
            }
        }
开发者ID:eakova,项目名称:resizer,代码行数:60,代码来源:BitmapDecoderInfoRule.cs


注:本文中的MainForm.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。