Skip to content

Commit c0fdf7e

Browse files
V1.1.20.0 Updates
- Added Axis calibration wizard for RA, DEC, ALT, AZ to Mount Settings dialog. - Exposed Platesolve events from log watchers
1 parent 731e201 commit c0fdf7e

17 files changed

+1299
-186
lines changed

OATControl/Converters/IntToBoolConverter.cs

Lines changed: 101 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -5,107 +5,108 @@
55
namespace OATControl.Converters
66
{
77

8-
/// <summary>
9-
/// Data binding helper.
10-
/// Converts a binding from boolean to an integer value.
11-
/// Returns FalseValue when bound value is false and TrueValue when value is ture.
12-
/// </summary>
13-
public class IntToBoolConverter : MarkupExtension, IValueConverter
14-
{
15-
/// <summary>
16-
/// Gets or sets the integer value to return on the given boolean value.
17-
/// </summary>
18-
public int TrueValue { get; set; }
19-
public string Operator { get; set; } = "";
8+
/// <summary>
9+
/// Data binding helper.
10+
/// Converts a binding from boolean to an integer value.
11+
/// Returns FalseValue when bound value is false and TrueValue when value is ture.
12+
/// </summary>
13+
public class IntToBoolConverter : MarkupExtension, IValueConverter
14+
{
15+
/// <summary>
16+
/// Gets or sets the integer value to return on the given boolean value.
17+
/// </summary>
18+
public string Operator { get; set; } = "";
2019

21-
/// <summary>
22-
/// Converts a value.
23-
/// </summary>
24-
/// <param name="value">The value produced by the binding source.</param>
25-
/// <param name="targetType">The type of the binding target property.</param>
26-
/// <param name="parameter">The converter parameter to use.</param>
27-
/// <param name="culture">The culture to use in the converter.</param>
28-
/// <returns>
29-
/// A converted value. If the method returns null, the valid null value is used.
30-
/// </returns>
31-
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
32-
{
33-
if (Operator.Equals(">"))
34-
{
35-
return ((int)value > this.TrueValue);
36-
}
37-
if (Operator.Equals(">="))
38-
{
39-
return ((int)value >= this.TrueValue);
40-
}
41-
if (Operator.Equals("<"))
42-
{
43-
return ((int)value < this.TrueValue);
44-
}
45-
if (Operator.Equals("<="))
46-
{
47-
return ((int)value <= this.TrueValue);
48-
}
49-
if (Operator.Equals("=="))
50-
{
51-
return ((int)value == this.TrueValue);
52-
}
53-
if (Operator.Equals("!="))
54-
{
55-
return ((int)value != this.TrueValue);
56-
}
57-
return false;
58-
}
20+
/// <summary>
21+
/// Converts a value.
22+
/// </summary>
23+
/// <param name="value">The value produced by the binding source.</param>
24+
/// <param name="targetType">The type of the binding target property.</param>
25+
/// <param name="parameter">The converter parameter to use.</param>
26+
/// <param name="culture">The culture to use in the converter.</param>
27+
/// <returns>
28+
/// A converted value. If the method returns null, the valid null value is used.
29+
/// </returns>
30+
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
31+
{
32+
int.TryParse(parameter as string, out int paramValue);
33+
if (Operator.Equals(">"))
34+
{
35+
return ((int)value > paramValue);
36+
}
37+
if (Operator.Equals(">="))
38+
{
39+
return ((int)value >= paramValue);
40+
}
41+
if (Operator.Equals("<"))
42+
{
43+
return ((int)value < paramValue);
44+
}
45+
if (Operator.Equals("<="))
46+
{
47+
return ((int)value <= paramValue);
48+
}
49+
if (Operator.Equals("=="))
50+
{
51+
return ((int)value == paramValue);
52+
}
53+
if (Operator.Equals("!="))
54+
{
55+
return ((int)value != paramValue);
56+
}
57+
return false;
58+
}
5959

60-
/// <summary>
61-
/// Converts a value back. Not implemented
62-
/// </summary>
63-
/// <param name="value">The value that is produced by the binding target.</param>
64-
/// <param name="targetType">The type to convert to.</param>
65-
/// <param name="parameter">The converter parameter to use.</param>
66-
/// <param name="culture">The culture to use in the converter.</param>
67-
/// <returns>
68-
/// A converted value. If the method returns null, the valid null value is used.
69-
/// </returns>
70-
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
71-
{
72-
if (Operator.Equals(">"))
73-
{
74-
return this.TrueValue+1;
75-
}
76-
if (Operator.Equals(">="))
77-
{
78-
return this.TrueValue + 1;
79-
}
80-
if (Operator.Equals("<"))
81-
{
82-
return this.TrueValue - 1;
83-
}
84-
if (Operator.Equals("<="))
85-
{
86-
return this.TrueValue - 1;
87-
}
88-
if (Operator.Equals("=="))
89-
{
90-
return this.TrueValue ;
91-
}
92-
if (Operator.Equals("!="))
93-
{
94-
return this.TrueValue + 21;
95-
}
96-
return 0;
97-
}
60+
/// <summary>
61+
/// Converts a value back.
62+
/// </summary>
63+
/// <param name="value">The value that is produced by the binding target.</param>
64+
/// <param name="targetType">The type to convert to.</param>
65+
/// <param name="parameter">The converter parameter to use.</param>
66+
/// <param name="culture">The culture to use in the converter.</param>
67+
/// <returns>
68+
/// A converted value. If the method returns null, the valid null value is used.
69+
/// </returns>
70+
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
71+
{
72+
int.TryParse(parameter as string, out int paramValue);
73+
if (Operator.Equals(">"))
74+
{
75+
return paramValue + 1;
76+
}
77+
if (Operator.Equals(">="))
78+
{
79+
return paramValue + 1;
80+
}
81+
if (Operator.Equals("<"))
82+
{
83+
return paramValue - 1;
84+
}
85+
if (Operator.Equals("<="))
86+
{
87+
return paramValue - 1;
88+
}
89+
if (Operator.Equals("=="))
90+
{
91+
return paramValue;
92+
}
93+
if (Operator.Equals("!="))
94+
{
95+
return paramValue + 21;
96+
}
97+
return 0;
98+
}
9899

99-
/// <summary>
100-
/// When implemented in a derived class, returns an object that is provided as the value of the target property for this markup extension.
101-
/// </summary>
102-
/// <param name="serviceProvider">A service provider helper that can provide services for the markup extension.</param>
103-
/// <returns>
104-
/// The object value to set on the property where the extension is applied.
105-
/// </returns>
106-
public override object ProvideValue(IServiceProvider serviceProvider)
107-
{
108-
return this;
109-
}
110-
}
100+
/// <summary>
101+
/// When implemented in a derived class, returns an object that is provided as the value of the target property for this markup extension.
102+
/// </summary>
103+
/// <param name="serviceProvider">A service provider helper that can provide services for the markup extension.</param>
104+
/// <returns>
105+
/// The object value to set on the property where the extension is applied.
106+
/// </returns>
107+
public override object ProvideValue(IServiceProvider serviceProvider)
108+
{
109+
return this;
110+
}
111+
}
111112
}

OATControl/DayTime.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public virtual bool ChangeSecond(int newSecs)
252252
}
253253

254254
// Convert to a standard string (like 14:45:06)
255-
public override String ToString()
255+
public override string ToString()
256256
{
257257
int hours, mins, secs;
258258
GetTime(out hours, out mins, out secs);
@@ -263,5 +263,15 @@ public override String ToString()
263263

264264
return p;
265265
}
266+
267+
public virtual string ToUIString()
268+
{
269+
int hours, mins, secs;
270+
GetTime(out hours, out mins, out secs);
271+
272+
int absHours = Math.Abs(hours);
273+
string sign = _totalSeconds < 0 ? "-" : "";
274+
return $"{sign}{absHours:00}:{mins:00}:{secs:00}";
275+
}
266276
}
267277
}

OATControl/Declination.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ public override void CheckHours()
124124

125125
public override string ToString()
126126
{
127-
//string s = ToDisplayString('*', ':') + string.Format(" ({0:0.000})", TotalHours);
128127
int degrees, mins, secs;
129128
GetTime(out degrees, out mins, out secs);
130129

@@ -133,8 +132,16 @@ public override string ToString()
133132
string p = $"{sign}{absDegrees:00}*{mins:00}:{secs:00} ({TotalDegrees:0.0000})";
134133

135134
return p;
135+
}
136136

137-
//return s;
137+
public override string ToUIString()
138+
{
139+
int degrees, mins, secs;
140+
GetTime(out degrees, out mins, out secs);
141+
142+
int absDegrees = Math.Abs(degrees);
143+
string sign = _totalSeconds < 0 ? "-" : "";
144+
return $"{sign}{absDegrees:00}° {mins:00}' {secs:00}\"";
138145
}
139146

140147
public static new Declination ParseFromMeade(String s)

0 commit comments

Comments
 (0)