static void BrushHandler(Player player, CommandReader cmd) { string brushName = cmd.Next(); if (brushName == null) { player.Message(player.Brush.Description); } else { IBrushFactory brushFactory = GetBrushFactory(brushName); if (brushFactory == null) { player.Message("Unrecognized brush \"{0}\"", brushName); } else { IBrush newBrush = brushFactory.MakeBrush(player, cmd); if (newBrush != null) { player.Brush = newBrush; player.Message("Brush set to {0}", player.Brush.Description); } } } }
public HierarchicalDataContext AnalyzeKnowledge(IBrushFactory brushFactory, IAliasMapping aliasMapping) { LoadHistory(); LoadMetrics(); LoadContributions(false); var localFileToContribution = AliasTransformContribution(_contributions, aliasMapping); var summary = _history.GetArtifactSummary(GetDisplayFilter(), aliasMapping); var fileToMainDeveloper = localFileToContribution.ToDictionary(pair => pair.Key, pair => pair.Value.GetMainDeveloper()); // Assign a color to each developer var mainDevelopers = fileToMainDeveloper.Select(pair => pair.Value.Developer).Distinct().ToList(); var legend = new LegendBitmap(mainDevelopers, brushFactory); legend.CreateLegendBitmap(Path.Combine(_outputPath, "knowledge_color.bmp")); // Build the knowledge data var builder = new KnowledgeBuilder(); var hierarchicalData = builder.Build(summary, _metrics, fileToMainDeveloper); var dataContext = new HierarchicalDataContext(hierarchicalData, brushFactory); dataContext.AreaSemantic = Strings.LinesOfCode; dataContext.WeightSemantic = Strings.NotAvailable; return(dataContext); }
static void BrushHandler([NotNull] Player player, [NotNull] CommandReader cmd) { string brushName = cmd.Next(); if (brushName == null) { player.Message("Brush: {0}", player.BrushDescription); } else { IBrushFactory brushFactory = GetBrushFactory(brushName); if (brushFactory == null) { player.Message("Unrecognized brush \"{0}\"", brushName); } else { player.BrushSet(brushFactory); if (cmd.HasNext) { player.ConfigureBrush(cmd); } player.Message("Brush set to {0}", player.BrushDescription); } } }
protected override void CreateChildElements() { base.CreateChildElements(); this.DrawBorder = false; this.DrawText = false; this.BackColor = this.BackColor2 = Color.Black; this.brushFactory = (IBrushFactory) new LinearGaugeBrushFactory(); }
/// <summary> /// Creates a new object. /// </summary> public ImageServer() { _ImageFile = Factory.ResolveSingleton <IImageFile>(); _BrushFactory = Factory.ResolveSingleton <IBrushFactory>(); _ImageServerConfiguration = Factory.ResolveSingleton <IImageServerConfiguration>(); _SharedConfiguration = Factory.ResolveSingleton <ISharedConfiguration>(); _Graphics = Factory.ResolveSingleton <IWebSiteGraphics>(); _AircraftPictureManager = Factory.ResolveSingleton <IAircraftPictureManager>(); _AutoConfigPictureFolderCache = Factory.ResolveSingleton <IAutoConfigPictureFolderCache>(); }
public IBrushInstance MakeInstance([NotNull] Player player, [NotNull] Command cmd, [NotNull] DrawOperation op) { if (player == null) { throw new ArgumentNullException("player"); } if (cmd == null) { throw new ArgumentNullException("cmd"); } if (op == null) { throw new ArgumentNullException("op"); } if (cmd.HasNext) { Block block = cmd.NextBlock(player); if (block == Block.Undefined) { return(null); } string brushName = cmd.Next(); if (brushName == null || !CommandManager.IsValidCommandName(brushName)) { player.Message("ReplaceBrush usage: &H/Brush rb <Block> <BrushName>"); return(null); } IBrushFactory brushFactory = BrushManager.GetBrushFactory(brushName); if (brushFactory == null) { player.Message("Unrecognized brush \"{0}\"", brushName); return(null); } IBrush replacement = brushFactory.MakeBrush(player, cmd); if (replacement == null) { return(null); } Block = block; Replacement = replacement; } ReplacementInstance = Replacement.MakeInstance(player, cmd, op); if (ReplacementInstance == null) { return(null); } return(new ReplaceBrushBrush(this)); }
protected override void CreateChildElements() { base.CreateChildElements(); this.DrawFill = false; this.DrawText = false; this.brushFactory = (IBrushFactory) new Telerik.WinControls.UI.Gauges.BrushFactory(); this.BackColor = Color.FromArgb(111, 185, 71); this.BackColor2 = Color.FromArgb(142, 205, 101); this.GradientPercentage = 0.07f; this.GradientPercentage2 = 0.15f; this.NumberOfColors = 2; }
public IBrush MakeBrush([NotNull] Player player, [NotNull] Command cmd) { if (player == null) { throw new ArgumentNullException("player"); } if (cmd == null) { throw new ArgumentNullException("cmd"); } if (!cmd.HasNext) { player.Message("ReplaceBrush usage: &H/Brush rb <Block> <BrushName>"); return(null); } Block block = cmd.NextBlock(player); if (block == Block.Undefined) { return(null); } string brushName = cmd.Next(); if (brushName == null || !CommandManager.IsValidCommandName(brushName)) { player.Message("ReplaceBrush usage: &H/Brush rb <Block> <BrushName>"); return(null); } IBrushFactory brushFactory = BrushManager.GetBrushFactory(brushName); if (brushFactory == null) { player.Message("Unrecognized brush \"{0}\"", brushName); return(null); } IBrush newBrush = brushFactory.MakeBrush(player, cmd); if (newBrush == null) { return(null); } return(new ReplaceBrushBrush(block, newBrush)); }
public string AnalyzeWorkOnSingleFile(string fileName, IBrushFactory brushFactory, IAliasMapping aliasMapping) { var workByDeveloper = _sourceProvider.CalculateDeveloperWork(fileName); var workByAlias = AliasTransformWork(aliasMapping, workByDeveloper); var bitmap = new FractionBitmap(); var fi = new FileInfo(fileName); var path = Path.Combine(_outputPath, fi.Name) + ".bmp"; // TODO atr bitmap? bitmap.Create(path, workByAlias, brushFactory, true); return(path); }
/// <summary> /// Same as knowledge but uses a different color scheme /// </summary> public HierarchicalDataContext AnalyzeKnowledgeLoss(string developer, IBrushFactory brushFactory, IAliasMapping aliasMapping) { LoadContributions(false); var localFileToContribution = AliasTransformContribution(_contributions, aliasMapping); developer = aliasMapping.GetAlias(developer); var summary = _history.GetArtifactSummary(_extendedDisplayFilter, aliasMapping); var fileToMainDeveloper = localFileToContribution.ToDictionary(pair => pair.Key, pair => pair.Value.GetMainDeveloper()); // Build the knowledge data var builder = new KnowledgeBuilder(developer); var hierarchicalData = builder.Build(summary, _metrics, fileToMainDeveloper); var dataContext = new HierarchicalDataContext(hierarchicalData, brushFactory); dataContext.AreaSemantic = Strings.LinesOfCode; dataContext.WeightSemantic = Strings.NotAvailable; return(dataContext); }
public static void RegisterBrush([NotNull] IBrushFactory factory) { if (factory == null) { throw new ArgumentNullException("factory"); } string helpString = String.Format("&S{0} brush: {1}", factory.Name, factory.Help); string lowerName = factory.Name.ToLower(); BrushFactories.Add(lowerName, factory); if (factory.Aliases != null) { helpString += " Aliases: &H" + factory.Aliases.JoinToString(); foreach (string alias in factory.Aliases) { BrushAliases.Add(alias.ToLower(), factory); } } CdBrush.HelpSections.Add(lowerName, helpString); CdBrush.Help += factory.Name + " "; }
/// <summary> /// Creates a new object. /// </summary> public WebSiteGraphics() { _ImageFile = Factory.ResolveSingleton <IImageFile>(); _PenFactory = Factory.ResolveSingleton <IPenFactory>(); _BrushFactory = Factory.ResolveSingleton <IBrushFactory>(); _FontFactory = Factory.ResolveSingleton <IFontFactory>(); _SplashFillBrush = _BrushFactory.CreateBrush(255, 255, 255, 255, useCache: true); _SplashFontFamily = _FontFactory.GetFontFamilyOrFallback( _SplashFontStyle, "Tahoma", "Microsoft Sans Serif", "MS Reference Sans Serif", "Roboto", "Droid Sans", "MS Sans Serif", "Verdana", "Helvetica", "Sans Serif", "Sans" ); }
public HierarchicalDataContext(IHierarchicalData data, IBrushFactory brushFactory) { Data = data; BrushFactory = brushFactory; }
public CirclePackingRenderer(IBrushFactory brushFactory) { _brushFactory = brushFactory; }
public SquarifiedTreeMapRenderer(IBrushFactory brushFactory) { _brushFactory = brushFactory; }
public LegendBitmap(List <string> names, IBrushFactory brushFactory) { _names = names; _brushFactory = brushFactory; }
public UriBrushFactory(Uri uri, IBrushFactory fallback) { _uri = uri; _fallback = fallback; }
public Stop(IBrushFactory colour, Percent offset, float opacity) { Colour = colour; Offset = offset; Opacity = opacity; }
public void Create(string filename, Dictionary <string, uint> workByDevelopers, IBrushFactory brushFactory, bool legend) { double allWork = workByDevelopers.Values.Sum(w => w); // For the fractal const int width = 200; const int height = 200; var remainingWidth = width; var remainingHeight = height; // Reserve plenty of space. Trimmed later. var bitmap = new System.Drawing.Bitmap(2000, 2000); var graphics = Graphics.FromImage(bitmap); var sorted = workByDevelopers.ToList().OrderByDescending(pair => pair.Value).ToList(); var oneUnitOfWork = width * height / allWork; var x = 0; var y = 0; var vertical = true; var index = 0; foreach (var developersWork in sorted) { var brush = ToDrawingBrush(brushFactory.GetBrush(developersWork.Key)); if (legend) { var legendY = index * 30; var legendX = 250; graphics.DrawString(developersWork.Key, new Font(FontFamily.GenericSansSerif, 12), Brushes.Black, legendX + 25, legendY); graphics.FillRectangle(brush, legendX, legendY, 20, 20); } var workArea = developersWork.Value; var pixelArea = oneUnitOfWork * workArea; if (index == sorted.Count - 1) { // Due to rounding there is always some pixels left. Give the last // developer the remaining space. pixelArea = remainingWidth * remainingHeight; } if (vertical) { var widthOfWork = (int)Math.Round(pixelArea / remainingHeight); graphics.FillRectangle(brush, x, y, widthOfWork, remainingHeight); graphics.DrawRectangle(Pens.Black, x, y, widthOfWork, remainingHeight); x += widthOfWork; remainingWidth -= widthOfWork; } else { var heightOfWork = (int)Math.Round(pixelArea / remainingWidth); graphics.FillRectangle(brush, x, y, remainingWidth, heightOfWork); graphics.DrawRectangle(Pens.Black, x, y, remainingWidth, heightOfWork); y += heightOfWork; remainingHeight -= heightOfWork; } // Toggle next orientation vertical = !vertical; index++; } graphics.DrawRectangle(Pens.Black, 0, 0, width - 1, height - 1); BitmapManipulation.TrimBitmap(bitmap).Save(filename); }