-
Notifications
You must be signed in to change notification settings - Fork 0
/
Globals.cs
112 lines (91 loc) · 2.89 KB
/
Globals.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
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using ExcelDna.Integration;
using ExcelDna.IntelliSense;
using Application = Microsoft.Office.Interop.Excel.Application;
namespace Campagna
{
internal class AddIn : IExcelAddIn
{
public void AutoOpen()
{
// Versions before v1.1.0 required only a call to Register() in the AutoOpen().
// The name was changed (and made obsolete) to highlight the pair of function calls now required.
IntelliSenseServer.Install();
}
public void AutoClose()
{
IntelliSenseServer.Uninstall();
}
}
internal class Slice : IComparable<Slice>
{
public int Index { get; set; }
public double Data { get; set; }
public Slice(int index, double data)
{
this.Index = index;
this.Data = data;
}
// Default comparer for Slice type.
public int CompareTo(Slice compareSlice)
{
// A null value means that this object is greater.
if (compareSlice == null)
return 1;
else
return this.Data.CompareTo(compareSlice.Data);
}
public override int GetHashCode()
{
return Index;
}
}
internal class SliceList: List<Slice>
{
}
internal class SliceDictionary: Dictionary<string, SliceList>
{
public SliceList GetSliceList(string cellName)
{
if (this.TryGetValue(cellName, out SliceList sliceList))
{
return sliceList;
}
else
{
throw new ArgumentNullException();
}
}
}
internal class ParentWnd : IWin32Window
{
public IntPtr Handle
{
get
{
// get current excel window through Excel DNA
return (IntPtr)(ExcelDnaUtil.Application as Application).Hwnd;
}
}
}
internal class Globals
{
// These dictate which formulas are identified as input or output functions
public static string _outputRegexPattern = "CampagnaOutput";
public static string _inputRegexPattern = "CampagnaInput";
// These deal with simulations
public static readonly int _dataSteps = 100;
public static int _numberIterations;
public static int _currentIteration;
public static bool _isSimulating = false;
public static DateTime _start;
// These deal with the random number generator
public static int _randomSeed;
public static Random _rand = new Random();
// set up Dictionary for storage of the data
public static SliceDictionary _sliceData = new SliceDictionary();
public static SliceDictionary _randomNumbers = new SliceDictionary();
}
}