Example #1
0
        /// <summary>
        /// This method adds saved functions to the current lists.
        /// </summary>
        /// <param name="c"> The container file. </param>
        public void AddSavedFunctionsToList(ContainerFileForSerealization c)
        {
            while (this.PolyFunctions.Count != 0)
            {
                this.PolyFunctions.RemoveAt(0);
            }

            while (this.TrigFunctions.Count != 0)
            {
                this.TrigFunctions.RemoveAt(0);
            }

            foreach (var item in c.TrigFunctions)
            {
                var vm = new TrigFunctionVM(item, this.removeCommand);
                vm.GetPolyline(this.SmallestXValueGrid, this.BigestXValueGrid, this.SmallestYValueGrid, this.BigestYValueGrid);
                vm.OnTrigFunctionChanged += this.DrawNewPolyLineForTrigFunction;
                this.TrigFunctions.Add(vm);
            }

            foreach (var item in c.PolyFunctions)
            {
                var polyFunction = new PolyFunction(item.ParameterList);
                var vm           = new PolyFunctionVM(polyFunction, this.removeCommandPoly);
                vm.GetPolyline(this.SmallestXValueGrid, this.BigestXValueGrid, this.SmallestYValueGrid, this.BigestYValueGrid);
                vm.OnPolyFunctionChanged += this.DrawNewPolyLineForPolyFunction;
                this.PolyFunctions.Add(vm);
            }
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PolyFunctionVMContainer"/> class.
 /// </summary>
 /// <param name="polyFunction"> The <see cref="PolyFunctionVM"/>. </param>
 public PolyFunctionVMContainer(PolyFunctionVM polyFunction)
 {
     this.Opacity         = polyFunction.Opacity;
     this.StrokeThickness = polyFunction.StrokeThickness;
     this.FunctionColor   = polyFunction.FunctionColor;
     this.PolyFunction    = polyFunction.Model;
 }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FunctionListVM"/> class.
        /// </summary>
        /// <param name="functionalListVMContainer"> The container file of the saved <see cref="FunctionListVM"/>. </param>
        /// <param name="smallestXValue"> The smallest value on x axis. </param>
        /// <param name="biggestXValue"> The biggest value on x axis. </param>
        /// <param name="smallestYValue"> The smallest value on y axis. </param>
        /// <param name="biggestYvalue"> The biggest value on y axis. </param>
        public FunctionListVM(FunctionalListVMContainer functionalListVMContainer, double smallestXValue, double biggestXValue, double smallestYValue, double biggestYvalue)
        {
            this.TrigFunctions = new ObservableCollection <TrigFunctionVM>();
            this.PolyFunctions = new ObservableCollection <PolyFunctionVM>();
            this.removeCommand = new Command(obj =>
            {
                var functionVM = obj as TrigFunctionVM;

                if (functionVM != null)
                {
                    this.TrigFunctions.Remove(functionVM);
                    this.CalculateBiggestYANDSmallestY();
                }
            });
            this.removeCommandPoly = new Command(obj =>
            {
                var functionVM = obj as PolyFunctionVM;

                if (functionVM != null)
                {
                    this.PolyFunctions.Remove(functionVM);
                    this.CalculateBiggestYANDSmallestY();
                }
            });

            foreach (var item in functionalListVMContainer.PolyFunctionVMContainers)
            {
                var temp = new PolyFunctionVM(item, this.removeCommandPoly);
                temp.OnPolyFunctionChanged += this.DrawNewPolyLineForPolyFunction;
                this.PolyFunctions.Add(temp);
            }

            foreach (var item in functionalListVMContainer.TrigFunctionVMContainers)
            {
                var temp = new TrigFunctionVM(item, this.removeCommand);
                temp.OnTrigFunctionChanged += this.DrawNewPolyLineForTrigFunction;
                this.TrigFunctions.Add(temp);
            }

            this.smallestxValue          = smallestXValue;
            this.bigestxValue            = biggestXValue;
            this.smallestyValue          = smallestYValue;
            this.bigestyValue            = biggestYvalue;
            this.DegreeOfPolyFunction    = 2;
            this.saveFileDialogue        = new SaveFileDialog();
            this.openFileDialog1         = new OpenFileDialog();
            this.saveFileDialogue.Filter = "dat files (*.dat)|*.dat";
            this.openFileDialog1.Filter  = "dat files (*.dat)|*.dat";
            this.DrawNewPolyLines();
        }