/// <summary>
		/// Checks to see if an IFrequency type meets frequency conditions.
		/// </summary>
		/// <returns><c>true</c>, if frequency conditions was meetsed, <c>false</c> otherwise.</returns>
		/// <param name="frequentObject">Frequent object.</param>
		
		static public bool MeetsFrequencyConditions(IFrequency frequentObject, int occurances) {

			string frequency = "";

			// Check for null references before getting the correct frequency 
			if(frequentObject.Frequency != null) {frequency = frequentObject.Frequency.ToUpper();}

			// Return true if this action should occur everytime - most common
			if (frequency == "" || frequency == AlwaysFrequency) {
				return true;
			}
			
			// Return true if this action should only play once and the action sequence has not occured
			else if (frequency == OnceFrequency && occurances == 1)
			{
				return true;
			}
			
			// Return true if frequency is after first and this sequence has occured once
			else if (frequency == AfterFirstFrequency && occurances > 1) {
				return true;
			}

			return false;
		
		}
 public RecurringTransaction(ITransaction baseTransaction, IFrequency frequency, DateTime startDate, DateTime?endDate)
 {
     BaseTransaction = baseTransaction;
     Frequency       = frequency;
     StartDate       = startDate;
     EndDate         = endDate;
 }
        public static DataGridView ConverToDataGridView(this IFrequency source, bool pairChar = false)
        {
            var nameCel1 = "Letters";
            var nameCel2 = "FreqLetters";
            var result   = new DataGridView();

            result.Dock = DockStyle.Fill;
            result.Columns.Add(nameCel1, "Letters");
            result.Columns.Add(nameCel2, "Frequency letters");

            Dictionary <string, double> src;

            if (pairChar)
            {
                src = source.GetPairLetterFreq();
            }
            else
            {
                src = source.GetLetterFreq();
            }

            foreach (var let in src.OrderBy(p => p.Key))
            {
                int i = result.Rows.Add();
                result.Rows[i].Cells[0].Value = let.Key;
                result.Rows[i].Cells[1].Value = Math.Round(let.Value, 4);
            }


            result.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            result.RowHeadersVisible   = false;


            return(result);
        }
Exemple #4
0
        private void ViewCalcFrequenceLetter(object sender, FrequencyEventArgs e)
        {
            IFrequency freq = securityManager.CalcFreq(e.SourceText);

            view.SetFrequencyChart(freq.ConverToChart(), FrequencyTypeTask.Letter);
            view.SetFrequencyDataGrid(freq.ConverToDataGridView(), FrequencyTypeTask.Letter);
            view.SetFrequencyChart(freq.ConverToChart(true), FrequencyTypeTask.PairLetter);
            view.SetFrequencyDataGrid(freq.ConverToDataGridView(true), FrequencyTypeTask.PairLetter);
        }
        public static Chart ConverToChart(this IFrequency source, bool pairChar = false)
        {
            var result = new Chart();

            result.ChartAreas.Add(new ChartArea());
            result.Series.Add(new Series());

            result.Series[0].ChartType = SeriesChartType.Column;

            //result.ChartAreas[0].AxisX = new Axis();
            result.ChartAreas[0].AxisX.Minimum                 = 0;
            result.ChartAreas[0].AxisX.Interval                = 1;
            result.ChartAreas[0].AxisX.IsLabelAutoFit          = false;
            result.ChartAreas[0].AxisX.LabelAutoFitMinFontSize = 9;
            result.ChartAreas[0].AxisX.TextOrientation         = TextOrientation.Horizontal;
            result.ChartAreas[0].AxisX.LabelAutoFitStyle       = LabelAutoFitStyles.DecreaseFont;

            Dictionary <string, double> src;

            if (pairChar)
            {
                src = source.GetPairLetterFreq();
            }
            else
            {
                src = source.GetLetterFreq();
            }

            int numb = 0;

            foreach (var let in src.OrderBy(p => p.Key))
            {
                result.Series[0].Points.AddXY(++numb, let.Value);
                result.ChartAreas[0].AxisX.CustomLabels.Add(numb - 2, numb + 2, let.Key);
            }

            result.ChartAreas[0].CursorX.IsUserEnabled              = true;
            result.ChartAreas[0].CursorX.IsUserSelectionEnabled     = true;
            result.ChartAreas[0].AxisX.ScaleView.Zoomable           = true;
            result.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;

            return(result);
        }