本文整理汇总了C#中INuGenServiceProvider.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# INuGenServiceProvider.GetService方法的具体用法?C# INuGenServiceProvider.GetService怎么用?C# INuGenServiceProvider.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INuGenServiceProvider
的用法示例。
在下文中一共展示了INuGenServiceProvider.GetService方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateSampleTree
/// <summary>
/// </summary>
/// <param name="serviceProvider"><para>Requires:</para>
/// <para><see cref="ISampleFolder"/></para></param>
/// <param name="treeView"></param>
/// <param name="folderImageIndex"></param>
/// <param name="expandedFolderImageIndex"></param>
/// <param name="sampleImageIndex"></param>
/// <exception cref="ArgumentNullException">
/// <para><paramref name="serviceProvider"/> is <see langword="null"/>.</para>
/// -or-
/// <para><paramref name="treeView"/> is <see langword="null"/>.</para>
/// </exception>
public void PopulateSampleTree(
INuGenServiceProvider serviceProvider
, NuGenTreeView treeView
, int folderImageIndex
, int expandedFolderImageIndex
, int sampleImageIndex
)
{
if (serviceProvider == null)
{
throw new ArgumentNullException("serviceProvider");
}
if (treeView == null)
{
throw new ArgumentNullException("treeView");
}
ISampleFolderDescriptor sampleFolder = serviceProvider.GetService<ISampleFolderDescriptor>();
Debug.Assert(sampleFolder != null, "sampleFolder != null");
DirectoryInfo sampleDirInfo = new DirectoryInfo(sampleFolder.Path);
Debug.Write("Scanning \"");
Debug.Write(sampleDirInfo.FullName);
Debug.WriteLine("\" folder...");
if (!sampleDirInfo.Exists)
{
Trace.Write("Sample directory does not exist.");
return;
}
DirectoryInfo[] samples = sampleDirInfo.GetDirectories();
Debug.WriteLine("Getting the list of sub-directories...");
Debug.WriteLineIf(samples != null, "samples.Length = " + samples.Length.ToString());
if (samples != null)
{
Debug.WriteLine("Looping through the sub-directories...");
foreach (DirectoryInfo dirInfo in samples)
{
NuGenTreeNode treeNode = new NuGenTreeNode(dirInfo.Name, folderImageIndex, expandedFolderImageIndex);
treeView.Nodes.Add(treeNode);
Debug.Write("Examining \"");
Debug.Write(dirInfo.FullName);
Debug.WriteLine("\" sub-directory...");
this.BuildSampleTreeNode(sampleFolder, dirInfo, treeNode, folderImageIndex, expandedFolderImageIndex, sampleImageIndex);
}
}
}
示例2: NuGenContextMenuStrip
/// <summary>
/// Initializes a new instance of the <see cref="NuGenContextMenuStrip"/> class.
/// </summary>
/// <param name="serviceProvider">
/// <para>Requires:</para>
/// <para><see cref="INuGenToolStripRenderer"/></para>
/// </param>
/// <exception cref="ArgumentNullException">
/// <para><paramref name="serviceProvider"/> is <see langword="null"/>.</para>
/// </exception>
/// <exception cref="NuGenServiceNotFoundException"/>
public NuGenContextMenuStrip(INuGenServiceProvider serviceProvider)
{
if (serviceProvider == null)
{
throw new ArgumentNullException("serviceProvider");
}
INuGenToolStripRenderer toolStripRenderer = serviceProvider.GetService<INuGenToolStripRenderer>();
if (toolStripRenderer == null)
{
throw new NuGenServiceNotFoundException<INuGenToolStripRenderer>();
}
this.Renderer = toolStripRenderer.GetToolStripRenderer();
}
示例3: DrawBackground
/// <summary>
/// </summary>
/// <param name="serviceProvider">
/// <para>Requires:</para>
/// <para><see cref="INuGenSmoothColorManager"/></para>
/// </param>
/// <param name="paintParams"></param>
/// <exception cref="ArgumentNullException">
/// <para><paramref name="serviceProvider"/> is <see langword="null"/>.</para>
/// -or-
/// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
/// </exception>
/// <exception cref="NuGenServiceNotFoundException"/>
public static void DrawBackground(INuGenServiceProvider serviceProvider, NuGenPaintParams paintParams)
{
if (serviceProvider == null)
{
throw new ArgumentNullException("serviceProvider");
}
if (paintParams == null)
{
throw new ArgumentNullException("paintParams");
}
Graphics g = paintParams.Graphics;
Rectangle bounds = paintParams.Bounds;
NuGenControlState state = paintParams.State;
RectangleF ellipseBounds = new RectangleF(
bounds.Left - bounds.Width * 0.2f
, bounds.Top + bounds.Height * 0.6f
, bounds.Width * 2
, bounds.Height
);
if (ellipseBounds.Width > 0 && ellipseBounds.Height > 0)
{
INuGenSmoothColorManager colorManager = serviceProvider.GetService<INuGenSmoothColorManager>();
if (colorManager == null)
{
throw new NuGenServiceNotFoundException<INuGenSmoothColorManager>();
}
Color beginColor = Color.FromArgb(60, colorManager.GetBorderColor(state));
Color endColor = Color.FromArgb(10, colorManager.GetBackgroundGradientEnd(state));
using (Brush brush = new LinearGradientBrush(ellipseBounds, beginColor, endColor, 0.0f))
{
g.SetClip(bounds, CombineMode.Replace);
g.FillEllipse(brush, ellipseBounds);
}
}
}
示例4: MainForm
/// <summary>
/// Initializes a new instance of the <see cref="MainForm"/> class.
/// </summary>
/// <exception cref="ArgumentNullException">
/// <para>
/// <paramref name="serviceProvider"/> is <see langword="null"/>.
/// </para>
/// </exception>
public MainForm(INuGenServiceProvider serviceProvider)
{
if (serviceProvider == null)
{
throw new ArgumentNullException("serviceProvider");
}
_serviceProvider = serviceProvider;
_splashStarter = _serviceProvider.GetService<SplashStarter>();
Debug.Assert(_splashStarter != null, "_splashStarter != null");
_splashStarter.ShowSplashScreen();
InitializeComponent();
ForceActiveTitleBar = true;
SetStyle(ControlStyles.Opaque, true);
_canvasSizeToolStrip.ApplySettings += _canvasSizeToolStrip_ApplySettings;
_canvasSizeToolStrip.CancelSettings += _canvasSizeToolStrip_CancelSettings;
_insertFileDialog.Filter = Resources.Text_InsertFileDialog_Filter;
_insertFileDialog.FilterIndex = 3;
_insertFileDialog.Title = Resources.Text_InsertFileDialog;
_openFileDialog.Filter = Resources.Text_OpenFileDialog_Filter;
_openFileDialog.Title = Resources.Text_OpenFileDialog;
_saveFileDialog.Filter = Resources.Text_SaveFileDialog_Filter;
_saveFileDialog.Title = Resources.Text_SaveFileDialog;
SetCanvasDependableButtonsVisibility(false);
}