//protected override bool AreAxisValuesValid(out string errorMessage) //{ // //throw new NotImplementedException(); // // TODO // errorMessage = ""; // return true; //} internal override void GenerateAxisEntries() { DateTime tickDateAndTime = MinimumValue; DateTime previousDate = MinimumValue.Date.AddDays(-1); string label; AxisEntry <DateTime> tick; int tickCounter = 0; while (tickDateAndTime <= MaximumValue) { ++tickCounter; // If the date has changed, then display the date; otherwise just the time. if (previousDate != tickDateAndTime.Date) { label = FormatLabelString(tickDateAndTime, true); previousDate = tickDateAndTime.Date; } else { label = FormatLabelString(tickDateAndTime, false); } tick = new AxisEntry <DateTime>(tickDateAndTime, null, label); if ((tickDateAndTime - MinimumValue).TotalMinutes % MajorIncrement == 0) { tick.IsMajorTick = true; } AddEntry(tick); tickDateAndTime = tickDateAndTime.AddMinutes(MinorIncrement); } }
public static void AddAxis(IConvertible control_scheme, IConvertible control, string im_name, string control_name = "") { AxisEntry entry = new AxisEntry(() => Input.GetAxis(im_name)); I.GetOrAddEntryList(control_scheme, control).Add(entry); if (control_name != "") { I.SetControlName(control_scheme, control, control_name); } }
public override int GetAxisPosition(string keyValue) { int rValue; AxisEntry <string> xValues = AxisEntries.Where(s => s.Label.Text == keyValue).Single(); rValue = (AxisXY == Axis.X) ? xValues.Position.X : xValues.Position.Y; return(rValue); }
public static void AddAxis(IConvertible control_scheme, IConvertible control, Func <bool> neg, Func <bool> pos, string control_name = "") { AxisEntry entry = new AxisEntry( () => (neg() ? -1 : 0) + (pos() ? 1 : 0)); I.GetOrAddEntryList(control_scheme, control).Add(entry); if (control_name != "") { I.SetControlName(control_scheme, control, control_name); } }
public static void AddAxis(IConvertible control_scheme, IConvertible control, KeyCode neg, KeyCode pos, string control_name = "") { AxisEntry entry = new AxisEntry( () => (Input.GetKey(neg) ? -1 : 0) + (Input.GetKey(pos) ? 1 : 0)); I.GetOrAddEntryList(control_scheme, control).Add(entry); if (control_name != "") { I.SetControlName(control_scheme, control, control_name); } }
public static int GetAxisOnceCS(IConvertible control_scheme, IConvertible control, bool repeat = false) { List <Entry> entries = I.TryGetEntryList(control_scheme, control); if (entries == null) { return(0); } float f = 0; foreach (Entry e in entries) { AxisEntry ae = e as AxisEntry; if (ae != null) { f += ae.GetAxisOnce(repeat); } } return(f < 0 ? -1 : f > 0 ? 1 : 0); }
public static float GetAxisCS(IConvertible control_scheme, IConvertible control) { List <Entry> entries = I.TryGetEntryList(control_scheme, control); if (entries == null) { return(0); } float answer = 0; foreach (Entry e in entries) { AxisEntry ae = e as AxisEntry; if (ae != null) { answer += ae.GetAxis(); } } return(Mathf.Clamp(answer, -1, 1)); }
internal override void GenerateAxisEntries() { int minValue = (int)MinimumValue; int maxValue = (int)MaximumValue; int tickValue = maxValue; AxisEntry <int> tick; int majorTickCounter = 0; while (tickValue >= minValue) { ++majorTickCounter; tick = new AxisEntry <int>(tickValue, null, FormatLabelString(tickValue)); if (tickValue % MajorIncrement == 0) { tick.IsMajorTick = true; } AddEntry(tick); tickValue -= MinorIncrement; } }
/// <summary> /// Checks to see if the axis values are valid. /// </summary> /// <param name="errorMessage"></param> /// <returns></returns> //protected override bool AreAxisValuesValid(out string errorMessage) //{ // bool rValue = true; // errorMessage = null; // if (MajorIncrement <= 0) errorMessage = $"Major Increment must be > 0 for DATE_SCALE. It is set to {MajorIncrement}"; // if (MinorIncrement < 0) errorMessage = $"Minor Increment must be >= 0 for DATE_SCALE. It is set to {MinorIncrement}"; // if (MajorIncrement < MinorIncrement) errorMessage = $"Major Increment must be > Minor Increment for DATE_SCALE. Major increment is {MajorIncrement}, Minor increment is {MinorIncrement}"; // if (errorMessage != null) // rValue = false; // return rValue; //} /// <summary> /// Generate the axis values, between the minimum and maximum values, designating which ticks will be major or minor. /// </summary> internal override void GenerateAxisEntries() { DateTime maxDate = ((DateTime)MaximumValue).Date; DateTime minDate = ((DateTime)MinimumValue).Date; DateTime tickDate = minDate; AxisEntry <DateTime> tick; int tickCounter = 0; while (tickDate <= maxDate) { ++tickCounter; tick = new AxisEntry <DateTime>(tickDate, null, FormatLabelString(tickDate, false)); if (tickCounter % MajorIncrement == 0) { tick.IsMajorTick = true; } AddEntry(tick); tickDate = tickDate.AddDays(1); } }
/// <summary> /// Return the position along an Axis for a key value. /// For example: /// if the value you're searching for is 12 and 12 is an AxisEntry then it will return that x/y value for that Point. /// if the AxisEntries are 10 and 15, then the value will be 2/5ths between 10 and 15. /// </summary> /// <param name="keyValue"></param> /// <returns></returns> public override int GetAxisPosition(int keyValue) { int rValue = -1; // First, get the AxisEntry for those above/below the specific value. AxisEntry <int> belowAxisEntry = null; AxisEntry <int> equalAxisEntry = null; AxisEntry <int> aboveAxisEntry = null; if (AxisXY == Axis.Y) { // This code will work for DESCENDING scale only foreach (AxisEntry <int> e in AxisEntries) { if (e.KeyValue > keyValue) { aboveAxisEntry = e; } if ((e.KeyValue < keyValue) && (belowAxisEntry == null)) { belowAxisEntry = e; } if (e.KeyValue == keyValue) { equalAxisEntry = e; } } // Second, (if required) calculate how far along it is between ticks if (equalAxisEntry == null) { double abovePos; double belowPos; double pixelGapBetween; double PixelsPerValue; int difference; switch (AxisXY) { case Axis.X: abovePos = aboveAxisEntry.Position.X; belowPos = belowAxisEntry.Position.X; pixelGapBetween = (abovePos > belowPos) ? abovePos - belowPos : belowPos - abovePos; PixelsPerValue = pixelGapBetween / (double)((aboveAxisEntry.KeyValue > belowAxisEntry.KeyValue) ? aboveAxisEntry.KeyValue - belowAxisEntry.KeyValue : aboveAxisEntry.KeyValue - belowAxisEntry.KeyValue); difference = keyValue - belowAxisEntry.KeyValue; rValue = (int)(belowPos + (difference * PixelsPerValue)); break; case Axis.Y: abovePos = aboveAxisEntry.Position.Y; belowPos = belowAxisEntry.Position.Y; pixelGapBetween = (abovePos > belowPos) ? abovePos - belowPos : belowPos - abovePos; PixelsPerValue = pixelGapBetween / (double)((aboveAxisEntry.KeyValue > belowAxisEntry.KeyValue) ? aboveAxisEntry.KeyValue - belowAxisEntry.KeyValue : aboveAxisEntry.KeyValue - belowAxisEntry.KeyValue); difference = keyValue - belowAxisEntry.KeyValue; rValue = (int)(belowPos - (difference * PixelsPerValue)); break; } } else { rValue = (AxisXY == Axis.X) ? equalAxisEntry.Position.X : equalAxisEntry.Position.Y; } } return(rValue); }
public override int GetAxisPosition(DateTime keyValue) { int rValue = -1; // First, get the AxisEntry for those above/below the specific value. AxisEntry <DateTime> belowAxisEntry = null; AxisEntry <DateTime> equalAxisEntry = null; AxisEntry <DateTime> aboveAxisEntry = null; foreach (AxisEntry <DateTime> e in AxisEntries) { if (e.KeyValue < keyValue) { belowAxisEntry = e; } if (e.KeyValue == keyValue) { equalAxisEntry = e; } if ((e.KeyValue > keyValue) && (aboveAxisEntry == null)) { aboveAxisEntry = e; } } // Second, (if required) calculate how far along it is between ticks if (equalAxisEntry == null) { throw new NotImplementedException("This section not implemented."); /*double abovePos; * double belowPos; * double pixelGapBetween; * double PixelsPerValue; * int difference; * * switch (AxisXY) * { * case Axis.X: // 12 * abovePos = aboveAxisEntry.Position.X; // 15 * belowPos = belowAxisEntry.Position.X; // 10 * pixelGapBetween = abovePos - belowPos; // 20px * PixelsPerValue = pixelGapBetween / (double)(aboveAxisEntry.KeyValue - belowAxisEntry.KeyValue); * difference = keyValue - belowAxisEntry.KeyValue; * rValue = (int)(belowPos + (difference * PixelsPerValue)); * break; * case Axis.Y: * abovePos = aboveAxisEntry.Position.Y; // 15 * belowPos = belowAxisEntry.Position.Y; // 10 * pixelGapBetween = abovePos - belowPos; // 20px * PixelsPerValue = pixelGapBetween / (double)(aboveAxisEntry.KeyValue - belowAxisEntry.KeyValue); * difference = keyValue - belowAxisEntry.KeyValue; * rValue = (int)(belowPos - (difference * PixelsPerValue)); * break; * }*/ } else { rValue = (AxisXY == Axis.X) ? equalAxisEntry.Position.X : equalAxisEntry.Position.Y; } return(rValue); }
public AxisRegion(AxisEntry <TDataType> start, AxisEntry <TDataType> end) { Start = start; End = end; }