private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            AnimateStop();
            btnAnimate.Enabled = false;

            TreeNode sn = treeView1.SelectedNode;

            // if group of functions are associated with this node
            if (sn != null && sn.Tag != null)
            {
                FunctionsCollection fc = c1Chart1.ChartGroups[0].ChartData.FunctionsList;

                // clear previous functions and listview
                fc.Clear();
                listView1.Items.Clear();

                FunctionsGroup fg = (FunctionsGroup)sn.Tag;
                fg.Load(statusBar1);

                // fill listview
                for (int i = 0; i < fg.FunctionList.Length; i++)
                {
                    FunctionBase f   = fg.FunctionList[i];
                    ListViewItem lvi = new ListViewItem(f.Label);
                    lvi.Checked   = true;
                    lvi.ForeColor = f.LineStyle.Color;
                    lvi.Tag       = f;
                    listView1.Items.Add(lvi);
                    fc.Add(f);
                }

                fg.ApplyOptions(c1Chart1);
            }
        }
示例#2
0
    public static void Main(string[] args)
    {
        LinkedList <int> numbers = FunctionsCollection.ReadIntLinkedListUptoEmptyLine();

        numbers = RemoveOddOccuringNumbers(numbers);
        Console.WriteLine("The sequence without the members that occur odd number of times is:");
        FunctionsCollection.PrintIntLinkedList(numbers);
    }
示例#3
0
    public static void Main(string[] args)
    {
        LinkedList <int> numbers = FunctionsCollection.ReadIntLinkedListUptoEmptyLine();

        numbers = RemoveNegativeMembers(numbers);
        Console.WriteLine("The sequence without its negative members is:");
        FunctionsCollection.PrintIntLinkedList(numbers);
    }
示例#4
0
    public static void Main(string[] args)
    {
        List <int> numbers = FunctionsCollection.ReadIntListInRangeUptoEmptyLine();

        numbers.Sort();

        Console.WriteLine("The sorted list is:");
        FunctionsCollection.PrintIntList(numbers);
    }
 public FunctionsCollection()
 {
     ReadData("directory_func.dat", directoryFunctionality);
     ReadData("network_func.dat", networkFunctionality);
     ReadData("zip_func.dat", zipFunctionality);
     ReadData("day_func.dat", dateTimeFunctionality);
     ReadData("process_func.dat", processFunctionality);
     Instance = this;
 }
    public static void Main(string[] args)
    {
        Console.WriteLine("Please enter the numbers count (N):");
        int numbersCount = FunctionsCollection.ReadIntInRange(1);

        Stack <int> numbersStack = ReadIntStack(numbersCount);

        Console.WriteLine("The reversed numbers collection is:");
        PrintIntStack(numbersCount, numbersStack);
    }
示例#7
0
    public Execute()
    {
        FunctionsCollection f = new FunctionsCollection();

        dayTimeFunc   = new DayTimeFunc();
        directoryFunc = new DirectoryFunc();
        networkFunc   = new NetworkFunc();
        zipFunc       = new ZipFunc();
        processFunc   = new ProcessExecute();
    }
示例#8
0
    public static void Main(string[] args)
    {
        List <int> numbers            = FunctionsCollection.ReadIntListInRangeUptoEmptyLine();
        List <int> longestSubsequence = GetLongestSubsequence(numbers);

        Console.WriteLine("The longest subsequence in the list is:");
        FunctionsCollection.PrintIntList(longestSubsequence);

        // For more test see the test class ListMethodsTest.cs
    }
示例#9
0
    public static void Main(string[] args)
    {
        Console.WriteLine("Please enter the first number in the sequence (N):");
        int startNumber = FunctionsCollection.ReadIntInRange();

        List <int> newSequence = GenerateSequence(startNumber, 50);

        Console.WriteLine("The result sequence with 50 members is:");
        FunctionsCollection.PrintIntList(newSequence);
    }
    private static Stack <int> ReadIntStack(int numbersCount)
    {
        Stack <int> numbersStack = new Stack <int>();

        for (int i = 0; i < numbersCount; i++)
        {
            Console.WriteLine("Enter the next number:");
            int currentNumber = FunctionsCollection.ReadIntInRange();
            numbersStack.Push(currentNumber);
        }

        return(numbersStack);
    }
示例#11
0
    public static void Main(string[] args)
    {
        Console.WriteLine("Please enter the first number in the sequence (N):");
        int startNumber = FunctionsCollection.ReadIntInRange();

        Console.WriteLine("Please enter the searched number in the sequence (M > N):");
        int searchedNumber = FunctionsCollection.ReadIntInRange(startNumber + 1);

        List <int> shortestSequence = GenerateShortestSequence(startNumber, searchedNumber);

        Console.WriteLine("The result shortest sequence from {0} to {1} is:", startNumber, searchedNumber);
        FunctionsCollection.PrintIntList(shortestSequence);
    }
示例#12
0
    public static void Main(string[] args)
    {
        Console.WriteLine("We expect positive numbers!");
        List <int> numberCollection = FunctionsCollection.ReadIntListInRangeUptoEmptyLine(1, int.MaxValue);

        long sumNumbers = CalcIntCollectionSum(numberCollection);

        Console.WriteLine("The collection sum is: {0}", sumNumbers);

        double averageNumbers = CalcIntCollectionAverage(numberCollection);

        Console.WriteLine("The collection average is: {0}", averageNumbers);
    }
示例#13
0
    public static void Main(string[] args)
    {
        int[] numbers = FunctionsCollection.ReadIntListInRangeUptoEmptyLine().ToArray();
        Dictionary <int, int> numbersCount = FunctionsCollection.GetNumbersCount(numbers);

        int?majorant = FindMajorant(numbersCount, numbers.Length);

        if (majorant == null)
        {
            Console.WriteLine("There is no majorant of that sequence!");
        }
        else
        {
            Console.WriteLine("The majorant is: {0}", majorant);
        }
    }
示例#14
0
    // Tests
    public static void Main(string[] args)
    {
        ADTStack <int> testStack = new ADTStack <int>(2);

        Debug.Assert(testStack.Count == 0, "The stack count is not 0!");

        Console.WriteLine("Fill the stack with integers.");
        Console.WriteLine("Please enter more then 2 values to force it to resize.");
        Console.WriteLine(new string('-', 30));

        List <int> userData = FunctionsCollection.ReadIntListInRangeUptoEmptyLine();

        for (int i = 0; i < userData.Count; i++)
        {
            testStack.Push(userData[i]);
        }

        Debug.Assert(testStack.Count == userData.Count, "The stack count is not equal to the number of values entered!");
        Console.WriteLine(new string('-', 30));
        Console.WriteLine("The stack count is: {0}", testStack.Count);

        Console.WriteLine(new string('-', 30));
        try
        {
            Console.WriteLine("Read last element by Peek(): {0}", testStack.Peek());
        }
        catch (InvalidOperationException)
        {
            Console.WriteLine("The stack is empty so Peek() throws an InvalidOperationException!");
        }

        Console.WriteLine(new string('-', 30));
        Console.WriteLine("Read the stack by using Pop():");

        for (int i = testStack.Count - 1; i >= 0; i--)
        {
            Console.WriteLine("{0} : {1}", i, testStack.Pop());
        }

        Debug.Assert(testStack.Count == 0, "The stack count is not 0!");
        Console.WriteLine(new string('-', 30));
        Console.WriteLine("The stack count is: {0}", testStack.Count);
    }
示例#15
0
    private static LinkedList <int> RemoveOddOccuringNumbers(LinkedList <int> numbers)
    {
        Dictionary <int, int> occurances = FunctionsCollection.GetNumbersCount(numbers);

        LinkedListNode <int> node = numbers.First;

        while (node != null)
        {
            LinkedListNode <int> next = node.Next;
            if (occurances[node.Value] % 2 != 0)
            {
                numbers.Remove(node);
            }

            node = next;
        }

        return(numbers);
    }
示例#16
0
    public static void Main(string[] args)
    {
        Console.WriteLine("We expect numbers in the range [0 .. 1000]");
        int[] numbers = FunctionsCollection.ReadIntListInRangeUptoEmptyLine(0, 1000).ToArray();
        Dictionary <int, int> numbersCount = FunctionsCollection.GetNumbersCount(numbers);

        Console.WriteLine("The number occurances count is:");
        foreach (KeyValuePair <int, int> numberCount in numbersCount)
        {
            if (numberCount.Value == 1)
            {
                Console.WriteLine("{0} -> {1} time", numberCount.Key, numberCount.Value);
            }
            else
            {
                Console.WriteLine("{0} -> {1} times", numberCount.Key, numberCount.Value);
            }
        }
    }
示例#17
0
    public static void Main(string[] args)
    {
        ADTQueue <int> testQueue = new ADTQueue <int>();

        Debug.Assert(testQueue.Count == 0, "The queue count is not 0!");

        Console.WriteLine("Fill the queue with integers!");
        Console.WriteLine(new string('-', 30));

        List <int> userData = FunctionsCollection.ReadIntListInRangeUptoEmptyLine();

        for (int i = 0; i < userData.Count; i++)
        {
            testQueue.Enqueue(userData[i]);
        }

        Debug.Assert(testQueue.Count == userData.Count, "The queue count is not equal to the number of values entered!");
        Console.WriteLine(new string('-', 30));
        Console.WriteLine("The queue count is: {0}", testQueue.Count);

        Console.WriteLine(new string('-', 30));
        try
        {
            Console.WriteLine("Read first item by Peak(): {0}", testQueue.Peek());
        }
        catch (InvalidOperationException)
        {
            Console.WriteLine("The queue is empty so Peek() throws an InvalidOperationException!");
        }

        Console.WriteLine(new string('-', 30));
        Console.WriteLine("Read the queue by using Dequeue():");
        for (int i = testQueue.Count - 1; i >= 0; i--)
        {
            Console.WriteLine("{0} : {1}", i, testQueue.Dequeue());
        }

        Debug.Assert(testQueue.Count == 0, "The queue count is not 0!");
        Console.WriteLine(new string('-', 30));
        Console.WriteLine("The queue count is: {0}", testQueue.Count);
    }