Skip to content

Commit

Permalink
Experimental development (12) (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serg-Norseman committed Oct 8, 2023
1 parent d4a51d9 commit 140c46e
Show file tree
Hide file tree
Showing 9 changed files with 42,491 additions and 5,238 deletions.
31 changes: 29 additions & 2 deletions projects/GKCore/GKCore/Charts/ChartRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,42 @@ public static IColor GetColor(int argb)

public abstract void SetTarget(object target);

/// <summary>
/// A separate implementation only for those cases when different classes
/// at the UI and diagram rendering levels are responsible for the image.
/// </summary>
public virtual IImage LoadImage(string fileName)
{
return AppHost.GfxProvider.LoadImage(fileName);
}

/// <summary>
/// A separate implementation only for those cases when different classes
/// at the UI and diagram rendering levels are responsible for the image.
/// </summary>
public virtual IImage LoadResourceImage(Type baseType, string resName)
{
return AppHost.GfxProvider.LoadResourceImage(baseType, resName);
}

/// <summary>
/// A separate implementation only for those cases when different classes
/// at the UI and diagram rendering levels are responsible for the image.
/// </summary>
public virtual IImage LoadResourceImage(string resName, bool makeTransp = false)
{
return AppHost.GfxProvider.LoadResourceImage(resName, makeTransp);
}

public void DrawImage(IImage image, float x, float y, string imName)
{
if (image == null) return;

DrawImage(image, x, y, image.Width, image.Height, imName);
}

public abstract void DrawImage(IImage image, float x, float y,
float width, float height, string imName);
public abstract void DrawImage(IImage image, float destX, float destY,
float destWidth, float destHeight, string imName);
public abstract void DrawImage(IImage image, ExtRect destinationRect,
ExtRect sourceRect);

Expand Down
22 changes: 12 additions & 10 deletions projects/GKCore/GKCore/Charts/TreeChartModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,31 +288,34 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}

private static IImage PrepareImage(string name, bool makeTransp)
private static IImage PrepareImage(ChartRenderer renderer, string name, bool makeTransp)
{
if (string.IsNullOrEmpty(name))
return null;

try {
return AppHost.GfxProvider.LoadResourceImage("Resources." + name, makeTransp);
return renderer.LoadResourceImage("Resources." + name, makeTransp);
} catch (Exception ex) {
Logger.WriteError("TreeChartModel.PrepareImage()", ex);
return null;
}
}

private void InitSigns()
private void InitSigns(ChartRenderer renderer)
{
if (fSignsPic != null)
return;

try {
int uRefsNum = GKData.SpecialUserRefs.Length;
fSignsPic = new IImage[uRefsNum];
for (int i = 0; i < uRefsNum; i++) {
fSignsPic[i] = PrepareImage(GKData.SpecialUserRefs[i].ResName, false);
fSignsPic[i] = PrepareImage(renderer, GKData.SpecialUserRefs[i].ResName, false);
}

fExpPic = PrepareImage("btn_expand.gif", true);
fPersExpPic = PrepareImage("btn_expand2.gif", true);
fInfoPic = PrepareImage("btn_info.gif", true);
fExpPic = PrepareImage(renderer, "btn_expand.gif", true);
fPersExpPic = PrepareImage(renderer, "btn_expand2.gif", true);
fInfoPic = PrepareImage(renderer, "btn_info.gif", true);
} catch (Exception ex) {
Logger.WriteError("TreeChartModel.InitSigns()", ex);
}
Expand Down Expand Up @@ -1571,7 +1574,7 @@ public override void SetRenderer(ChartRenderer renderer)
{
base.SetRenderer(renderer);

InitSigns();
InitSigns(renderer);
InitGraphics();
}

Expand Down Expand Up @@ -1728,8 +1731,7 @@ private void DrawPerson(TreeChartPerson person, ChartDrawMode drawMode)
ExtRect brt = prt;
if (person.Portrait != null) {
ExtRect portRt = person.PortraitArea.GetOffset(prt.Left, prt.Top);
fRenderer.DrawImage(person.Portrait, portRt.Left, portRt.Top,
portRt.GetWidth(), portRt.GetHeight(), person.Rec.XRef);
fRenderer.DrawImage(person.Portrait, portRt.Left, portRt.Top, portRt.GetWidth(), portRt.GetHeight(), person.Rec.XRef);

prt.Left += person.PortraitWidth;
}
Expand Down
5 changes: 2 additions & 3 deletions projects/GKCore/GKCore/Charts/TreeChartPerson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public void BuildBy(GDMIndividualRecord iRec)

if (fPortrait == null && options.DefaultPortraits) {
string resImage = GKData.SexData[(int)fSex].DefPortraitImage;
fPortrait = AppHost.GfxProvider.LoadResourceImage(resImage, false);
fPortrait = fModel.Renderer.LoadResourceImage(resImage, false);
}
} catch (MediaFileNotFoundException) {
if (!fModel.HasMediaFail) {
Expand Down Expand Up @@ -547,8 +547,7 @@ public void CalcBounds(int lines, ChartRenderer renderer)
}
}

int pad2side = (fModel.NodePadding * 2);

int pad2side = fModel.NodePadding * 2;
fWidth = pad2side + maxwid;
fHeight = pad2side + height;

Expand Down
Loading

0 comments on commit 140c46e

Please sign in to comment.