Exemple #1
0
        public void EnableRelativeScaling(bool bEnable, bool bScaleToVisible, double dfPctMargin = 0.0)
        {
            List <int> rgRemoveIdx = new List <int>();

            m_bScaleToVisibleWhenRelative = bScaleToVisible;

            for (int i = 0; i < TargetLines.Count; i++)
            {
                if (TargetLines[i].LineType == ConfigurationTargetLine.LINE_TYPE.MIN ||
                    TargetLines[i].LineType == ConfigurationTargetLine.LINE_TYPE.MAX)
                {
                    rgRemoveIdx.Add(i);
                }
            }

            for (int i = rgRemoveIdx.Count - 1; i >= 0; i--)
            {
                TargetLines.RemoveAt(rgRemoveIdx[i]);
            }

            if (bEnable)
            {
                TargetLines.Add(new ConfigurationTargetLine(0, Color.Transparent, ConfigurationTargetLine.LINE_TYPE.MIN));
                TargetLines.Add(new ConfigurationTargetLine(1, Color.Transparent, ConfigurationTargetLine.LINE_TYPE.MAX));
                YAxis.InitialMaximum = -double.MaxValue;
                YAxis.InitialMinimum = double.MaxValue;
                SetMarginPercent(dfPctMargin);
            }
            else
            {
                YAxis.InitialMaximum = -double.MaxValue;
                YAxis.InitialMinimum = double.MaxValue;
            }
        }
        private bool MakePropertyLine(string currentLine, string searchToken, string defaultValue)
        {
            string padding = "      ";

            currentLine = currentLine.Replace(@"?", "questionmark");
            searchToken = searchToken.Replace(@"?", "questionmark");

            if (currentLine.Contains("public " + searchToken + " "))
            {
                Regex regex = new Regex(@"(?<=\bpublic " + searchToken + @" )(\w+)");
                Match match = regex.Match(currentLine);

                if (match.Success)
                {
                    PropertyRecord.Add(match.Value);

                    var neLine = padding + @"public Property<" + searchToken + "> " + match.Value +
                                 " { get; set; } = new Property<" + searchToken +
                                 ">(){" + defaultValue + "};";

                    neLine      = neLine.Replace("questionmark", @"?");
                    searchToken = searchToken.Replace("questionmark", @"?");


                    TargetLines.Add(neLine);

                    //this.ID = Property<int>.Make(test.ID);
                    var makeLine = padding + @"this." + match.Value + " = Property<" + searchToken + ">.Make(test." + match.Value + ");";

                    MakeLines.Add(makeLine);

                    //ConvertToDtoLines

                    var convertLine = padding + "returnVal." + match.Value + " = " + match.Value + ".Value;";

                    ConvertToDtoLines.Add(convertLine);


                    var cloneLines = padding + "" + match.Value + " = this." + match.Value + ";";


                    CloneLines.Add(cloneLines);


                    var resetLine = padding + "" + match.Value + ".Revert();";

                    ResetLines.Add(resetLine);

                    return(true);
                }
            }



            return(false);
        }
        private bool MakeListLine(string currentLine, string searchType)
        {
            string padding = "      ";

            currentLine = currentLine.Replace(@"?", "questionmark");
            searchType  = searchType.Replace(@"?", "questionmark");

            if (currentLine.Contains("public " + searchType + " "))
            {
                Regex regex = new Regex(@"(?<=\bpublic " + searchType + @" )(\w+)");
                Match match = regex.Match(currentLine);

                if (match.Success)
                {
                    PropertyRecord.Add(match.Value);

                    var neLine = padding + @"public " + searchType + " " + match.Value +
                                 " { get => _current." + match.Value +
                                 "; set { _current." + match.Value + " = value; OnPropertyChanged(); } }";

                    neLine     = neLine.Replace("questionmark", @"?");
                    searchType = searchType.Replace("questionmark", @"?");


                    TargetLines.Add(neLine);

                    //public bool Completed { get => _current.Completed; set { _current.Completed = value; OnPropertyChanged(); } }

                    MakeLines.Add(padding + @"_original." + match.Value + " = test." + match.Value + ";");
                    MakeLines.Add(padding + @"_current." + match.Value + " = test." + match.Value + ";");


                    var convertLine = padding + "returnVal." + match.Value + " = this." + match.Value + ";";

                    ConvertToDtoLines.Add(convertLine);

                    var cloneLines = padding + "" + match.Value + " = this." + match.Value + ";";

                    var resetLine = padding + "" + match.Value + ".Revert();";

                    CloneLines.Add(cloneLines);

                    return(true);
                }
            }



            return(false);
        }
        public void CreateDtoClass()
        {
            var padding = "      ";

            SourceAsLines.AddRange(Source.Split(
                                       new[] { Environment.NewLine },
                                       StringSplitOptions.None
                                       ));



            foreach (var l in SourceAsLines)
            {
                bool result = false;

                MakeNames(l, "");



                if (MakeDtoLine(l, "string"))
                {
                    result = true;
                }

                if (MakeDtoLine(l, "double"))
                {
                    result = true;
                }

                if (MakeDtoLine(l, @"double?"))
                {
                    result = true;
                }

                if (MakeDtoLine(l, "int"))
                {
                    result = true;
                }

                if (MakeDtoLine(l, @"int?"))
                {
                    result = true;
                }

                if (MakeDtoLine(l, "DateTime"))
                {
                    result = true;
                }

                if (MakeDtoLine(l, @"DateTime?"))
                {
                    result = true;
                }

                if (MakeDtoLine(l, "bool"))
                {
                    result = true;
                }

                if (MakeDtoLine(l, @"bool?"))
                {
                    result = true;
                }

                if (MakeDtoLine(l, @"ComboBoxValue"))
                {
                    result = true;
                }

                if (MakeDtoLine(l, @"CATPlotObj"))
                {
                    result = true;
                }

                if (MakeDtoLine(l, @"CATPlotObjBool"))
                {
                    result = true;
                }

                if (l.Contains("public class"))
                {
                    TargetLines.Add("public class " + OldName + " : BaseDto, IRecord ");
                }
                else
                {
                    if (l.Trim() != "}")
                    {
                        if (l.Trim() != "{")
                        {
                            TargetLines.Add(padding + l.TrimStart());
                        }
                        else
                        {
                            TargetLines.Add(l.TrimStart());
                        }
                    }
                }
            }

            TargetLines.AddRange(CreateCloneMethod(this.CloneLines, OldName));

            TargetLines.Add("}");
        }
        public void CreateEditClass()
        {
            SourceAsLines.AddRange(Source.Split(
                                       new[] { Environment.NewLine },
                                       StringSplitOptions.None
                                       ));

            var constructorCreated = false;

            foreach (var l in SourceAsLines)
            {
                bool result = false;

                MakeNames(l, "Edit");


                if (!constructorCreated)
                {
                    constructorCreated = MakeConstructor(OldName, NewName);
                    continue;
                }


                if (l.Replace(" ", "") == "{")
                {
                    // TargetLines.Add("{");
                    result = true;
                }

                if (l.Replace(" ", "") == "}")
                {
                    result = true;
                }

                if (MakePropertyLine(l, "string", @"Value = string.Empty, Original = string.Empty"))
                {
                    result = true;
                }

                if (MakePropertyLine(l, "double", @"Value = 0.0, Original = 0.0"))
                {
                    result = true;
                }

                if (MakePropertyLine(l, @"double?", @"Value = 0.0, Original = 0.0"))
                {
                    result = true;
                }

                if (MakePropertyLine(l, "int", @"Value = 0, Original = 0"))
                {
                    result = true;
                }

                if (MakePropertyLine(l, @"int?", @"Value = 0, Original = 0"))
                {
                    result = true;
                }

                if (MakePropertyLine(l, "DateTime", @"Value = DateTime.Today,Original = DateTime.Today"))
                {
                    result = true;
                }

                if (MakePropertyLine(l, @"DateTime?", @"Value = DateTime.Today,Original = DateTime.Today"))
                {
                    result = true;
                }

                if (MakePropertyLine(l, "bool", @"Value = false, Original = false"))
                {
                    result = true;
                }

                if (MakePropertyLine(l, @"bool?", @"Value = false, Original = false"))
                {
                    result = true;
                }

                if (MakePropertyLine(l, @"ComboBoxValue", @"Value = null, Original = null"))
                {
                    result = true;
                }

                if (MakePropertyLine(l, @"CATPlotObj", @"Value = null, Original = null"))
                {
                    result = true;
                }

                if (MakePropertyLine(l, @"CATPlotObjBool", @"Value = null, Original = null"))
                {
                    result = true;
                }

                if (!result)
                {
                    TargetLines.Add(l);
                }
            }

            TargetLines.Add("");
            TargetLines.Add("");

            TargetLines.Add("public int RecordId => Id.Value;");

            TargetLines.Add("");
            TargetLines.Add("");


            TargetLines.AddRange(CreateConvertToDto(ConvertToDtoLines, OldName, "Edit"));

            TargetLines.Add("");
            TargetLines.Add("");


            TargetLines.AddRange(CreateMakeFromExistingMethod(MakeLines, NewName));


            TargetLines.Add("");
            TargetLines.Add("");


            TargetLines.AddRange(CreateMakeMethod(MakeLines, OldName, true));


            TargetLines.Add("");
            TargetLines.Add("");


            TargetLines.AddRange(CreateEditResetChangesMethod(ResetLines, OldName));

            TargetLines.Add("");
            TargetLines.Add("");


            TargetLines.AddRange(CreateEditMakeCollectionMethod());

            TargetLines.Add("}//endofclass");
        }