Files
PowerToys/src/modules/fancyzones/editor/FancyZonesEditor/RowColInfo.cs

47 lines
1.1 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FancyZonesEditor
{
public class RowColInfo
{
public RowColInfo(int percent)
{
Percent = percent;
}
public RowColInfo(int index, int count)
{
Percent = (c_multiplier / count) + ((index == 0) ? (c_multiplier % count) : 0);
}
private const int c_multiplier = 10000;
public double SetExtent(double start, double totalExtent)
{
Start = start;
Extent = totalExtent * Percent / c_multiplier;
End = Start + Extent;
return Extent;
}
public RowColInfo[] Split(double offset)
{
RowColInfo[] info = new RowColInfo[2];
int newPercent = (int)(Percent * offset / Extent);
info[0] = new RowColInfo(newPercent);
info[1] = new RowColInfo(Percent - newPercent);
return info;
}
public int Percent;
public double Extent;
public double Start;
public double End;
}
}