forked from sureshdr/mhora
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MhoraControlContainer.cs
471 lines (442 loc) · 14.5 KB
/
MhoraControlContainer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
/******
Copyright (C) 2005 Ajit Krishnan (http://www.mudgala.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******/
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Diagnostics;
namespace mhora
{
/// <summary>
/// Summary description for MhoraControlContainer.
/// </summary>
public class MhoraControlContainer : System.Windows.Forms.UserControl
{
private MhoraControl mControl;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public BaseUserOptions options;
public Horoscope h;
public class BaseUserOptions: ICloneable
{
public enum ViewType : int
{
DivisionalChart, Ashtakavarga,
KeyInfo, BasicCalculations, Balas,
TransitSearch, NavamsaCircle,
VaraChakra, KutaMatching,
ChakraSarvatobhadra81,
Panchanga,
DasaAshtottari, DasaVimsottari, DasaMudda,
DasaShodashottari,DasaDwadashottari,
DasaPanchottari, DasaShatabdika,
DasaTithiAshtottari,
DasaYogaVimsottari,
DasaKaranaChaturashitiSama,
DasaTithiPraveshAshtottariCompressedFixed,
DasaTithiPraveshAshtottariCompressedSolar,
DasaTithiPraveshAshtottariCompressedTithi,
DasaYogaPraveshVimsottariCompressedYoga,
DasaChaturashitiSama, DasaDwisaptatiSama,
DasaShatTrimshaSama,
DasaDrig, DasaNarayana, DasaNarayanaSama,
DasaShoola, DasaNiryaanaShoola,
DasaSu, DasaKalachakra,
DasaTajaka,
DasaTithiPravesh, DasaYogaPravesh, DasaNakshatraPravesh,
DasaKaranaPravesh,
DasaTattwa,
NaisargikaRasiDasa,
NaisargikaGrahaDasa,
DasaSudarshanaChakra,
DasaSudarshanaChakraCompressed,
DasaYogini,
DasaNavamsa,
DasaMandooka,
DasaChara, DasaTrikona,
DasaLagnaKendradiRasi, DasaMoola,
DasaKarakaKendradiGraha
}
private ViewType _view;
public object Clone ()
{
BaseUserOptions uo = new BaseUserOptions();
uo._view = _view;
return uo;
}
public ViewType View
{
get { return _view; }
set
{
_view = value;
}
}
public BaseUserOptions ()
{
_view = ViewType.DivisionalChart;
}
}
public void SetView (BaseUserOptions.ViewType view)
{
MhoraControl mc=null;;
switch (view)
{
case BaseUserOptions.ViewType.DivisionalChart:
mc = new DivisionalChart(h);
break;
case BaseUserOptions.ViewType.Ashtakavarga:
mc = new AshtakavargaControl(h);
break;
case BaseUserOptions.ViewType.ChakraSarvatobhadra81:
mc = new Sarvatobhadra81Control (h);
break;
case BaseUserOptions.ViewType.NavamsaCircle:
mc = new NavamsaControl(h);
break;
case BaseUserOptions.ViewType.VaraChakra:
mc = new VaraChakra(h);
break;
case BaseUserOptions.ViewType.Panchanga:
mc = new PanchangaControl(h);
break;
case BaseUserOptions.ViewType.KutaMatching:
{
Horoscope h2 = h;
foreach (Form f in ((MhoraContainer)MhoraGlobalOptions.mainControl).MdiChildren)
{
if (f is MhoraChild)
{
MhoraChild mch = (MhoraChild)f;
if (h == h2 && mch.getHoroscope() != h2)
{
h2 = mch.getHoroscope();
break;
}
}
}
mc = new KutaMatchingControl(h, h);
}
break;
case BaseUserOptions.ViewType.DasaVimsottari:
mc = new DasaControl (h, new VimsottariDasa(h));
break;
case BaseUserOptions.ViewType.DasaYogini:
mc = new DasaControl (h, new YoginiDasa(h));
break;
case BaseUserOptions.ViewType.DasaShodashottari:
mc = new DasaControl(h, new ShodashottariDasa(h));
break;
case BaseUserOptions.ViewType.DasaAshtottari:
mc = new DasaControl(h, new AshtottariDasa(h));
break;
case BaseUserOptions.ViewType.DasaTithiAshtottari:
mc = new DasaControl(h, new TithiAshtottariDasa(h));
break;
case BaseUserOptions.ViewType.DasaKaranaChaturashitiSama:
mc = new DasaControl(h, new KaranaChaturashitiSamaDasa(h));
break;
case BaseUserOptions.ViewType.DasaYogaVimsottari:
mc = new DasaControl(h, new YogaVimsottariDasa(h));
break;
case BaseUserOptions.ViewType.DasaLagnaKendradiRasi:
mc = new DasaControl(h, new LagnaKendradiRasiDasa(h));
break;
case BaseUserOptions.ViewType.DasaKarakaKendradiGraha:
mc = new DasaControl(h, new KarakaKendradiGrahaDasa(h));
break;
case BaseUserOptions.ViewType.DasaKalachakra:
mc = new DasaControl(h, new KalachakraDasa(h));
break;
case BaseUserOptions.ViewType.DasaMoola:
mc = new DasaControl(h, new MoolaDasa(h));
break;
case BaseUserOptions.ViewType.DasaNavamsa:
mc = new DasaControl(h, new NavamsaDasa(h));
break;
case BaseUserOptions.ViewType.DasaMandooka:
mc = new DasaControl(h, new MandookaDasa(h));
break;
case BaseUserOptions.ViewType.DasaChara:
mc = new DasaControl(h, new CharaDasa(h));
break;
case BaseUserOptions.ViewType.DasaTrikona:
mc = new DasaControl(h, new TrikonaDasa(h));
break;
case BaseUserOptions.ViewType.DasaSu:
mc = new DasaControl(h, new SuDasa(h));
break;
case BaseUserOptions.ViewType.DasaSudarshanaChakra:
mc = new DasaControl(h, new SudarshanaChakraDasa(h));
break;
case BaseUserOptions.ViewType.DasaMudda:
{
DasaControl dc = new DasaControl(h, new VimsottariDasa(h));
dc.DasaOptions.YearType = ToDate.DateType.SolarYear;
dc.DasaOptions.YearLength = 360;
dc.DasaOptions.Compression = 1;
dc.Reset();
mc = dc;
}
break;
case BaseUserOptions.ViewType.DasaSudarshanaChakraCompressed:
{
DasaControl dc = new DasaControl(h, new SudarshanaChakraDasa(h));
dc.DasaOptions.YearType = ToDate.DateType.SolarYear;
dc.DasaOptions.YearLength = 360;
dc.DasaOptions.Compression = 1;
dc.Reset();
mc = dc;
}
break;
case BaseUserOptions.ViewType.DasaYogaPraveshVimsottariCompressedYoga:
{
DasaControl dc = new DasaControl(h, new YogaVimsottariDasa(h));
dc.compressToYogaPraveshaYearYoga();
mc = dc;
}
break;
case BaseUserOptions.ViewType.DasaTithiPraveshAshtottariCompressedTithi:
{
DasaControl dc = new DasaControl(h, new TithiAshtottariDasa(h));
dc.DasaOptions.YearType = ToDate.DateType.TithiYear;
ToDate td_pravesh = new ToDate(h.baseUT, ToDate.DateType.TithiPraveshYear, 360.0, 0, h);
ToDate td_tithi = new ToDate(h.baseUT, ToDate.DateType.TithiYear, 360.0, 0, h);
sweph.obtainLock(h);
if (td_tithi.AddYears(1).toUniversalTime() + 15.0 < td_pravesh.AddYears(1).toUniversalTime())
dc.DasaOptions.YearLength = 390;
sweph.releaseLock(h);
dc.DasaOptions.Compression = 1;
TithiAshtottariDasa.UserOptions tuo = (TithiAshtottariDasa.UserOptions)dc.DasaSpecificOptions;
tuo.UseTithiRemainder = true;
dc.DasaSpecificOptions = tuo;
dc.Reset();
mc = dc;
}
break;
case BaseUserOptions.ViewType.DasaTithiPraveshAshtottariCompressedFixed:
{
DasaControl dc = new DasaControl(h, new TithiAshtottariDasa(h));
ToDate td_pravesh = new ToDate(h.baseUT, ToDate.DateType.TithiPraveshYear, 360.0, 0, h);
sweph.obtainLock(h);
dc.DasaOptions.YearType = ToDate.DateType.FixedYear;
dc.DasaOptions.YearLength = td_pravesh.AddYears(1).toUniversalTime() -
td_pravesh.AddYears(0).toUniversalTime();
sweph.releaseLock(h);
TithiAshtottariDasa.UserOptions tuo = (TithiAshtottariDasa.UserOptions)dc.DasaSpecificOptions;
tuo.UseTithiRemainder = true;
dc.DasaSpecificOptions = tuo;
dc.DasaOptions.Compression = 1;
dc.Reset();
mc = dc;
}
break;
case BaseUserOptions.ViewType.DasaTithiPraveshAshtottariCompressedSolar:
{
DasaControl dc = new DasaControl(h, new TithiAshtottariDasa(h));
ToDate td_pravesh = new ToDate(h.baseUT, ToDate.DateType.TithiPraveshYear, 360.0, 0, h);
sweph.obtainLock(h);
double ut_start = td_pravesh.AddYears(0).toUniversalTime();
double ut_end = td_pravesh.AddYears(1).toUniversalTime();
BodyPosition sp_start = Basics.CalculateSingleBodyPosition(
ut_start, sweph.BodyNameToSweph(Body.Name.Sun), Body.Name.Sun, BodyType.Name.Graha, this.h);
BodyPosition sp_end = Basics.CalculateSingleBodyPosition(
ut_end, sweph.BodyNameToSweph(Body.Name.Sun), Body.Name.Sun, BodyType.Name.Graha, this.h);
Longitude lDiff = sp_end.longitude.sub(sp_start.longitude);
double diff = lDiff.value;
if (diff < 120.0) diff += 360.0;
dc.DasaOptions.YearType = ToDate.DateType.SolarYear;
dc.DasaOptions.YearLength = diff;
sweph.releaseLock(h);
TithiAshtottariDasa.UserOptions tuo = (TithiAshtottariDasa.UserOptions)dc.DasaSpecificOptions;
tuo.UseTithiRemainder = true;
dc.DasaSpecificOptions = tuo;
//dc.DasaOptions.YearType = ToDate.DateType.FixedYear;
//dc.DasaOptions.YearLength = td_pravesh.AddYears(1).toUniversalTime() -
// td_pravesh.AddYears(0).toUniversalTime();
dc.DasaOptions.Compression = 1;
dc.Reset();
mc = dc;
}
break;
case BaseUserOptions.ViewType.DasaDwadashottari:
mc = new DasaControl(h, new DwadashottariDasa(h));
break;
case BaseUserOptions.ViewType.DasaPanchottari:
mc = new DasaControl(h, new PanchottariDasa(h));
break;
case BaseUserOptions.ViewType.DasaShatabdika:
mc = new DasaControl(h, new ShatabdikaDasa(h));
break;
case BaseUserOptions.ViewType.DasaChaturashitiSama:
mc = new DasaControl(h, new ChaturashitiSamaDasa(h));
break;
case BaseUserOptions.ViewType.DasaDwisaptatiSama:
mc = new DasaControl(h, new DwisaptatiSamaDasa(h));
break;
case BaseUserOptions.ViewType.DasaShatTrimshaSama:
mc = new DasaControl(h, new ShatTrimshaSamaDasa(h));
break;
case BaseUserOptions.ViewType.BasicCalculations:
mc = new BasicCalculationsControl(h);
break;
case BaseUserOptions.ViewType.KeyInfo:
mc = new KeyInfoControl(h);
break;
case BaseUserOptions.ViewType.Balas:
mc = new BalasControl(h);
break;
case BaseUserOptions.ViewType.TransitSearch:
mc = new TransitSearch(h);
break;
case BaseUserOptions.ViewType.NaisargikaRasiDasa:
mc = new DasaControl(h, new NaisargikaRasiDasa(h));
break;
case BaseUserOptions.ViewType.NaisargikaGrahaDasa:
mc = new DasaControl(h, new NaisargikaGrahaDasa(h));
break;
case BaseUserOptions.ViewType.DasaNarayana:
mc = new DasaControl(h, new NarayanaDasa(h));
break;
case BaseUserOptions.ViewType.DasaNarayanaSama:
mc = new DasaControl(h, new NarayanaSamaDasa(h));
break;
case BaseUserOptions.ViewType.DasaShoola:
mc = new DasaControl(h, new ShoolaDasa(h));
break;
case BaseUserOptions.ViewType.DasaNiryaanaShoola:
mc = new DasaControl(h, new NirayaanaShoolaDasa(h));
break;
case BaseUserOptions.ViewType.DasaDrig:
mc = new DasaControl(h, new DrigDasa(h));
break;
case BaseUserOptions.ViewType.DasaTajaka:
mc = new DasaControl(h, new TajakaDasa(h));
break;
case BaseUserOptions.ViewType.DasaTithiPravesh:
{
DasaControl dc = new DasaControl(h, new TithiPraveshDasa (h));
dc.DasaOptions.YearType = ToDate.DateType.TithiPraveshYear;
dc.LinkToHoroscope = false;
dc.Reset();
mc = dc;
}
break;
case BaseUserOptions.ViewType.DasaYogaPravesh:
{
DasaControl dc = new DasaControl(h, new YogaPraveshDasa(h));
dc.DasaOptions.YearType = ToDate.DateType.YogaPraveshYear;
dc.LinkToHoroscope = false;
dc.Reset();
mc = dc;
}
break;
case BaseUserOptions.ViewType.DasaNakshatraPravesh:
{
DasaControl dc = new DasaControl(h, new NakshatraPraveshDasa(h));
dc.DasaOptions.YearType = ToDate.DateType.NakshatraPraveshYear;
dc.LinkToHoroscope = false;
dc.Reset();
mc = dc;
}
break;
case BaseUserOptions.ViewType.DasaKaranaPravesh:
{
DasaControl dc = new DasaControl(h, new KaranaPraveshDasa(h));
dc.DasaOptions.YearType = ToDate.DateType.KaranaPraveshYear;
dc.LinkToHoroscope = false;
dc.Reset();
mc = dc;
}
break;
case BaseUserOptions.ViewType.DasaTattwa:
mc = new DasaControl (h, new TattwaDasa(h));
break;
default:
Debug.Assert (false, "Unknown View Internal error");
break;
}
mc.Dock = DockStyle.Fill;
if (null != this.Control)
this.Control.Dispose();
this.Control = mc;
return;
}
public void SetBaseOptions (Object o)
{
BaseUserOptions uo = (BaseUserOptions)o;
options.View = uo.View;
SetView (uo.View);
}
public MhoraControl Control
{
get { return mControl; }
set {
if (mControl != null)
this.Controls.Remove (mControl);
mControl = value;
mControl.Dock = DockStyle.Fill;
this.Controls.Add (mControl);
mControl.Parent = this;
}
}
public MhoraControlContainer(MhoraControl _mControl)
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitForm call
Control = _mControl;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// MhoraControlContainer
//
this.Name = "MhoraControlContainer";
this.Load += new System.EventHandler(this.MhoraControlContainer_Load);
}
#endregion
private void mControl_Load(object sender, System.EventArgs e)
{
}
private void MhoraControlContainer_Load(object sender, System.EventArgs e)
{
options = new BaseUserOptions();
}
}
}