-
Notifications
You must be signed in to change notification settings - Fork 7
/
RasiStrengthsControl.cs
344 lines (297 loc) · 10.4 KB
/
RasiStrengthsControl.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
/******
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.Windows.Forms;
namespace mhora
{
public class RasiStrengthsControl : Form
{
private System.Windows.Forms.ListView mList;
private System.Windows.Forms.ComboBox cbStrength;
private System.ComponentModel.IContainer components = null;
private UserOptions options = null;
private System.Windows.Forms.ComboBox cbRasi1;
private System.Windows.Forms.ComboBox cbRasi2;
private System.Windows.Forms.ContextMenu cMenu;
private System.Windows.Forms.MenuItem menuOptions;
private System.Windows.Forms.Label lVarga;
private Horoscope h = null;
class UserOptions: ICloneable
{
Division m_dtype;
[PGNotVisible]
public Division Division
{
get { return m_dtype; }
set { m_dtype = value; }
}
[PGDisplayName("Varga")]
public Basics.DivisionType UIDivision
{
get { return m_dtype.MultipleDivisions[0].Varga; }
set { this.m_dtype = new Division(value); }
}
public UserOptions()
{
m_dtype = new Division(Basics.DivisionType.Rasi);
}
public object Clone ()
{
UserOptions uo = new UserOptions();
uo.Division = this.Division;
return uo;
}
public object SetOptions (object _uo)
{
UserOptions uo = (UserOptions)_uo;
this.Division = uo.Division;
return this.Clone();
}
}
public RasiStrengthsControl(Horoscope _h)
{
// This call is required by the Windows Form Designer.
InitializeComponent();
if (false == MhoraGlobalOptions.Instance.RasiStrengthsFormSize.IsEmpty)
this.Size = MhoraGlobalOptions.Instance.RasiStrengthsFormSize;
h = _h;
h.Changed += new EvtChanged(this.OnRecalculate);
this.options = new UserOptions();
InitializeComboBoxes();
}
public void OnRecalculate (object _h)
{
h = (Horoscope)_h;
this.Compute();
}
/// <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 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()
{
this.cbStrength = new System.Windows.Forms.ComboBox();
this.cbRasi1 = new System.Windows.Forms.ComboBox();
this.cbRasi2 = new System.Windows.Forms.ComboBox();
this.mList = new System.Windows.Forms.ListView();
this.cMenu = new System.Windows.Forms.ContextMenu();
this.menuOptions = new System.Windows.Forms.MenuItem();
this.lVarga = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// cbStrength
//
this.cbStrength.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cbStrength.Location = new System.Drawing.Point(8, 8);
this.cbStrength.Name = "cbStrength";
this.cbStrength.Size = new System.Drawing.Size(128, 21);
this.cbStrength.TabIndex = 0;
this.cbStrength.Text = "cbStrength";
this.cbStrength.SelectedIndexChanged += new System.EventHandler(this.cbStrength_SelectedIndexChanged);
//
// cbRasi1
//
this.cbRasi1.Location = new System.Drawing.Point(8, 40);
this.cbRasi1.Name = "cbRasi1";
this.cbRasi1.Size = new System.Drawing.Size(104, 21);
this.cbRasi1.TabIndex = 1;
this.cbRasi1.Text = "cbRasi1";
this.cbRasi1.SelectedIndexChanged += new System.EventHandler(this.cbGraha1_SelectedIndexChanged);
//
// cbRasi2
//
this.cbRasi2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.cbRasi2.Location = new System.Drawing.Point(144, 40);
this.cbRasi2.Name = "cbRasi2";
this.cbRasi2.Size = new System.Drawing.Size(112, 21);
this.cbRasi2.TabIndex = 2;
this.cbRasi2.Text = "cbRasi2";
this.cbRasi2.SelectedIndexChanged += new System.EventHandler(this.cbGraha2_SelectedIndexChanged);
//
// mList
//
this.mList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.mList.FullRowSelect = true;
this.mList.Location = new System.Drawing.Point(16, 72);
this.mList.Name = "mList";
this.mList.Size = new System.Drawing.Size(240, 176);
this.mList.TabIndex = 3;
this.mList.View = System.Windows.Forms.View.Details;
this.mList.SelectedIndexChanged += new System.EventHandler(this.mList_SelectedIndexChanged);
//
// cMenu
//
this.cMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuOptions});
//
// menuOptions
//
this.menuOptions.Index = 0;
this.menuOptions.Text = "Options";
this.menuOptions.Click += new System.EventHandler(this.menuOptions_Click);
//
// lVarga
//
this.lVarga.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lVarga.Location = new System.Drawing.Point(144, 8);
this.lVarga.Name = "lVarga";
this.lVarga.Size = new System.Drawing.Size(104, 23);
this.lVarga.TabIndex = 4;
this.lVarga.Text = "label1";
this.lVarga.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// RasiStrengthsControl
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(264, 262);
this.ContextMenu = this.cMenu;
this.Controls.Add(this.lVarga);
this.Controls.Add(this.mList);
this.Controls.Add(this.cbRasi2);
this.Controls.Add(this.cbRasi1);
this.Controls.Add(this.cbStrength);
this.Name = "RasiStrengthsControl";
this.Text = "Rasi Strengths Reckoner";
this.Resize += new System.EventHandler(this.RasiStrengthsControl_Resize);
this.Load += new System.EventHandler(this.GrahaStrengthsControl_Load);
this.ResumeLayout(false);
}
#endregion
private void mList_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private ArrayList GetRules ()
{
switch (this.cbStrength.SelectedIndex)
{
case 0:
return FindStronger.RulesNarayanaDasaRasi(h);
case 1:
return FindStronger.RulesNaisargikaDasaRasi(h);
case 2:
return FindStronger.RulesMoolaDasaRasi(h);
case 3:
return FindStronger.RulesKarakaKendradiGrahaDasaRasi(h);
case 4:
return FindStronger.RulesNavamsaDasaRasi(h);
case 5:
return FindStronger.RulesJaiminiFirstRasi(h);
case 6:
return FindStronger.RulesJaiminiSecondRasi(h);
default:
return FindStronger.RulesNarayanaDasaRasi(h);
}
}
private void InitializeComboBoxes()
{
for (int i = (int)ZodiacHouse.Name.Ari; i <= (int)ZodiacHouse.Name.Pis; i++)
{
string s = String.Format("{0}", ((ZodiacHouse.Name)i).ToString());
this.cbRasi1.Items.Add(s);
this.cbRasi2.Items.Add(s);
}
this.cbRasi1.SelectedIndex=0;
this.cbRasi2.SelectedIndex=6;
this.cbStrength.Items.Add ("Narayana Dasa");
this.cbStrength.Items.Add ("Naisargika Dasa");
this.cbStrength.Items.Add ("Moola Dasa");
this.cbStrength.Items.Add ("Karaka Kendradi Graha Dasa");
this.cbStrength.Items.Add ("Navamsa Dasa");
this.cbStrength.Items.Add ("Jaimini's 1st Source of Strength");
this.cbStrength.Items.Add ("Jaimini's 2nd Source of Strength");
this.cbStrength.SelectedIndex=0;
this.lVarga.Text = options.Division.ToString();
}
private void Compute()
{
this.mList.BeginUpdate();
this.mList.Clear();
this.mList.BackColor = Color.AliceBlue;
this.mList.Columns.Add ("Body", -1, System.Windows.Forms.HorizontalAlignment.Left);
this.mList.Columns.Add ("Winner", -1, System.Windows.Forms.HorizontalAlignment.Left);
int winner=0;
if (this.cbRasi1.SelectedIndex < 0) this.cbRasi1.SelectedIndex = 0;
if (this.cbRasi2.SelectedIndex < 0) this.cbRasi2.SelectedIndex = 0;
ZodiacHouse.Name z1 = (ZodiacHouse.Name)this.cbRasi1.SelectedIndex+1;
ZodiacHouse.Name z2 = (ZodiacHouse.Name)this.cbRasi2.SelectedIndex+1;
ArrayList al = this.GetRules();
for (int i=0; i<al.Count; i++)
{
ArrayList rule = new ArrayList();
rule.Add (al[i]);
FindStronger fs = new FindStronger(h, options.Division, rule);
ZodiacHouse.Name zw = fs.StrongerRasi(z1, z2, false, ref winner);
ListViewItem li = new ListViewItem();
li.Text = string.Format("{0}", EnumDescConverter.GetEnumDescription((System.Enum)al[i]));
if (winner == 0)
li.SubItems.Add (string.Format("{0}", zw));
this.mList.Items.Add(li);
}
this.mList.Columns[0].Width = -1;
this.mList.Columns[1].Width = -2;
this.mList.EndUpdate();
}
private void GrahaStrengthsControl_Load(object sender, System.EventArgs e)
{
}
private void cbStrength_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.Compute();
}
private void cbGraha1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.Compute();
}
private void cbGraha2_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.Compute();
}
public object SetOptions (object o)
{
object o2 = options.SetOptions(o);
this.lVarga.Text = options.Division.ToString();
return o2;
}
private void menuOptions_Click(object sender, System.EventArgs e)
{
new MhoraOptions(this.options, new ApplyOptions(this.SetOptions)).ShowDialog();
}
private void RasiStrengthsControl_Resize(object sender, System.EventArgs e)
{
MhoraGlobalOptions.Instance.RasiStrengthsFormSize = this.Size;
}
}
}