Ejemplo n.º 1
0
        public bool AddSoftRunCount()
        {
            curRegInfoStruct.AlreadyUseCount++;
            int index = RegInfo.LastIndexOf("#");

            try
            {
                string TempRegInfo = RegInfo.Substring(0, index + 1);
                TempRegInfo += curRegInfoStruct.AlreadyUseCount.ToString();
                TempRegInfo  = MyMethod.GetEecryptStr(TempRegInfo);
                MyMethod.DelFile(RegFilePath);
                MyMethod.StrToFile(RegFilePath, TempRegInfo);
            }
            catch (Exception E)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
    void OnTriggerStay2D(Collider2D col) //When a dice enters a cell (and the mouse is not held anymore)
    {
        if (!collided && !Input.GetKey(KeyCode.Mouse0))
        {
            if (col.tag == "Right")
            {
                val = new MyMethod(col.GetComponent <MoveRightFn>().MoveRight);
            }
            else if (col.tag == "Left")
            {
                val = new MyMethod(col.GetComponent <MoveRightFn>().MoveLeft);
            }

            //Debug.Log(val);
            //this.val();
            collided        = true;
            collidingObject = col.gameObject;
            collidingObject.transform.position = transform.position;
            source.PlayOneShot(moveDice, 1);
            theGrid.GetComponent <calcCols>().Execute();
        }
    }
Ejemplo n.º 3
0
        public static void DataGridViewCut(DataGridView dgv, DataGridViewCellEventHandler dgv_CellValueChanged)
        {
            if (dgv_CellValueChanged != null)
            {
                dgv.CellValueChanged -= dgv_CellValueChanged;
            }
            MyMethod.CopyFromDataGridView(dgv);
            foreach (DataGridViewCell item in dgv.SelectedCells)
            {
                if (dgv.Columns[item.ColumnIndex].ReadOnly)
                {
                    continue;
                }

                item.Value = DBNull.Value;
            }
            //再绑定单元格值改变事件
            if (dgv_CellValueChanged != null)
            {
                dgv.CellValueChanged += dgv_CellValueChanged;
            }
        }
Ejemplo n.º 4
0
        public string sendCommand(string command, int timeOut)
        {
            cacheData.Clear();
            string result = "";

            try
            {
                LogHelper.WriteLog4("发送命令:" + command, LogType.Info);
                MyMethod.SendBytesData(serialPort, MyMethod.string16tobytes(command));
                Thread.Sleep(timeOut);
                if (cacheData.Count > 0)
                {
                    result = MyMethod.bytestostr(cacheData.ToArray());
                }
                LogHelper.WriteLog4("接收:" + result, LogType.Info);
            }
            catch (Exception e)
            {
                LogHelper.WriteLog4(e.ToString(), LogType.Error);
            }
            return(result);
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            double x1, y1, x2, y2;

            Console.WriteLine("Узнать расстояние между точками \n");

            Console.WriteLine("Введите координаты 1-й точки: (используйте \',\' для дробных значений)");
            Console.Write("x = ");
            x1 = double.Parse(Console.ReadLine());
            Console.Write("y = ");
            y1 = double.Parse(Console.ReadLine());
            Console.WriteLine();

            Console.WriteLine("Введите координаты 2-й точки:");
            Console.Write("x = ");
            x2 = double.Parse(Console.ReadLine());
            Console.Write("y = ");
            y2 = double.Parse(Console.ReadLine());
            Console.WriteLine();

            // Способ А
            double r = Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2));

            Console.WriteLine("Расстояние между точками = " + "{0:0.00}", r);

            //Cпособ Б
            double dist = Distance(x1, y1, x2, y2);

            Console.WriteLine("Расстояние между точками = " + "{0:0.00}", dist);
            MyMethod.Pause();

            //Метод
            double Distance(double x1, double y1, double x2, double y2)
            {
                return(Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2)));
            }
        }
Ejemplo n.º 6
0
        private MyMethod GetMethod(MethodInfo methodSymbol, Assembly definingAssembly, ISymbol parent)
        {
            var method = new MyMethod(methodSymbol.Name)
            {
                Parent = parent,
            };

            method.ReturnType = GetType(methodSymbol.ReturnType, definingAssembly, method);
            method.Modifiers  = GetModifiers(methodSymbol);

            foreach (var parameterSymbol in methodSymbol.GetParameters())
            {
                var parameter = GetParameter(parameterSymbol, definingAssembly, method);
                method.Parameters.Add(parameter);
            }

            foreach (var attributeData in methodSymbol.GetCustomAttributesData())
            {
                var attribute = GetAttribute(attributeData, method);
                method.Attributes.Add(attribute);
            }

            return(method);
        }
Ejemplo n.º 7
0
        //获取用户最新的注册信息
        private string GetNewRegStrInfo()
        {
            string RegInfo = "";

            string CPUID = MyMethod.GetCPUID();

            string HddID = MyMethod.GetHddID();

            string strSql = "select * from 注册码管理 where CPU编号='" + CPUID + "' and 硬盘编号='" + HddID + "'";

            DataSet curSet = new DataSet();

            try
            {
                curSet = opWeb.GetDataSet(strSql);
                if (!string.IsNullOrEmpty(opWeb.ErrMsg))
                {
                    return("");
                }
                if (curSet.Tables[0].Rows.Count == 0)
                {
                    //用户信息没有提交注册,自动注册上
                    return("");
                }
                else
                {
                    RegInfo = curSet.Tables[0].Rows[0]["注册码"].ToString();
                }
            }
            catch (Exception E)
            {
                ErrMsg  = E.Message;
                RegInfo = "";
            }
            return(RegInfo);
        }
Ejemplo n.º 8
0
        private void Init()
        {
            RegFilePath = Application.StartupPath + "\\AppRun.dll";
            if (!MyMethod.CheckFileExists(RegFilePath))
            {
                curRegInfoStruct.str_Err           = "配置文件丢失!";
                curRegInfoStruct.curRegCheckResult = RegCheckResult.RegFileLose;
                //curResult = RegCheckResult.RegFileLose;
                return;
            }

            RegFilePath = @"C:\Users\cmp\Desktop\AppRun.dll";
            string FileStr = MyMethod.FileToStr(RegFilePath);

            if (string.IsNullOrEmpty(FileStr))
            {
                curRegInfoStruct.str_Err           = "配置意外被修改!";
                curRegInfoStruct.curRegCheckResult = RegCheckResult.PareseFileErr;
                //curResult = RegCheckResult.PareseFileErr;
                return;
            }
            RegInfo = MyMethod.GetDecryptStr(FileStr.Trim());
            if (string.IsNullOrEmpty(RegInfo))
            {
                curRegInfoStruct.str_Err           = "配置意外被修改!";
                curRegInfoStruct.curRegCheckResult = RegCheckResult.PareseFileErr;
                //curResult = RegCheckResult.PareseFileErr;
                return;
            }

            string Spec = "#";

            string[] RegList = RegInfo.Split(Spec.ToCharArray());
            if (RegList.Length < 8)
            {
                curRegInfoStruct.str_Err           = "配置被非法修改!";
                curRegInfoStruct.curRegCheckResult = RegCheckResult.RegFileBeCracked;
                // curResult = RegCheckResult.RegFileBeCracked;
                return;
            }
            string VerInfo = RegList[0];

            switch (VerInfo.ToLower().Trim())
            {
            case "v1.0":
                PareseRegStrV1(RegInfo);
                break;

            default:
                PareseRegStrV0(RegInfo);
                break;
            }
            //if(curRegInfoStruct.curRegCheckResult == RegCheckResult.Lock)
            //{
            //    //如果是锁定状态,直接返回
            //    return;
            //}

            if (curRegInfoStruct.curRegCheckResult != RegCheckResult.TrialVer)
            {
                //检测硬件信息是否匹配
                if (!JugeHardWareInfo())
                {
                    return;
                }
            }

            if (curRegInfoStruct.curRegCheckResult == RegCheckResult.UnlimitedVer)
            {
                //硬件已经匹配,如果是正式版,就可以直接返回了
                return;
            }

            if (curRegInfoStruct.curRegCheckResult == RegCheckResult.Lock)
            {
                //如果是锁定状态,也可以直接返回了
                return;
            }

            //判断软件日期是否已超期
            if (!JugeDateLimite())
            {
                return;
            }

            //判断使用次数是否超限
            if (!JugeUserCountLimite())
            {
                return;
            }
            //自增访问次数
            AddSoftRunCount();
        }
Ejemplo n.º 9
0
        void back_CheckReg_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //获取当前系统版本
            FileVersionInfo myFileVersion = FileVersionInfo.GetVersionInfo(System.Windows.Forms.Application.ExecutablePath);
            string          version       = myFileVersion.FileVersion;

            switch (curRegInfoStruct.curRegCheckResult)
            {
            case RegCheckResult.UnlimitedVer:
                //正式版本无任何限制
                if (!string.IsNullOrEmpty(curRegInfoStruct.RegUnit))
                {
                    //this.Text = this.Text + "(正式版" + version + "-" + curRegInfoStruct.RegUnit + ")";
                    //barStaticItem_AppInfo.Caption = "当前版本:" + version;
                    HitInfo = "授权类型:正式版。\n注册单位:" + curRegInfoStruct.RegUnit;
                }
                VerInfo = "当前版本:" + version;
                break;

            case RegCheckResult.TrialVer:
                if (!string.IsNullOrEmpty(curRegInfoStruct.RegUnit))
                {
                    //this.Text = this.Text + "(试用版" + version + "-" + curRegInfoStruct.RegUnit + ")";
                    //barStaticItem_AppInfo.Caption = "当前版本:T " + version;
                    HitInfo = "授权类型:试用版。\n注册单位:" + curRegInfoStruct.RegUnit;
                }
                VerInfo = "当前版本:T " + version;
                if (curRegInfoStruct.TrialRemainingDays <= 3)
                {
                    MyMethod.ShowMessage(parentForm, "您的软件还可使用" + curRegInfoStruct.TrialRemainingDays.ToString() + "天,为保障您正常使用,请联系软件供应商。" + TelPhoneInfo);
                }
                break;

            case RegCheckResult.Overdue:
                MyMethod.ShowMessage(parentForm, "很抱歉,您的软件已超过试用期限,如您想继续使用,请联系软件供应商。" + TelPhoneInfo);
                NeedLockSystem = true;
                break;

            case RegCheckResult.Mismatch:
                MyMethod.ShowMessage(parentForm, "很抱歉,您的电脑不具备运行系统的权限,如您想试用系统,请联系软件供应商。" + TelPhoneInfo);
                NeedLockSystem = true;
                break;

            case RegCheckResult.PareseFileErr:
                MyMethod.ShowMessage(parentForm, "很抱歉,软件检测到严重异常,系统文件被破坏,软件将关闭,请联系软件供应商。" + TelPhoneInfo);
                NeedLockSystem = true;
                break;

            case RegCheckResult.RegFileLose:
                //MyMethod.ShowMessage(parentForm, "您所使用的软件尚未授权,请联系软件供应商。" + TelPhoneInfo);
                NeedLockSystem = true;
                break;

            case RegCheckResult.RegFileBeCracked:
                MyMethod.ShowMessage(parentForm, "系统文件被意外修改,软件出现不应有的异常,无法继续使用,请联系软件供应商。" + TelPhoneInfo);
                NeedLockSystem = true;
                break;

            case RegCheckResult.Error:
                MyMethod.ShowMessage(parentForm, "软件出现不应有的异常,无法继续使用,请联系软件供应商。\n" + curRegInfoStruct.str_Err + TelPhoneInfo);
                NeedLockSystem = true;
                break;

            case RegCheckResult.Lock:
                MyMethod.ShowMessage(parentForm, "软件应用出现严重异常,请确认授权合法,请联系软件供应商。\n" + curRegInfoStruct.str_Err + TelPhoneInfo);
                NeedLockSystem = true;
                break;

            default:
                MyMethod.ShowMessage(parentForm, "出现不可预知的异常,软件将关闭,请联系软件供应商。" + TelPhoneInfo);
                NeedLockSystem = true;
                break;
            }
            if (RegCheckOver != null)
            {
                RegCheckOverEventArgs newArges = new RegCheckOverEventArgs();
                newArges.NeedLockSystem   = NeedLockSystem;
                newArges.curRegInfoStruct = curRegInfoStruct;
                newArges.HitInfo          = HitInfo;
                newArges.VerInfo          = VerInfo;
                RegCheckOver(this, newArges);
            }
        }
Ejemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            MyMethod my = method;

            IAsyncResult asyncResult = my.BeginInvoke(MethodCompleted, my);
        }
Ejemplo n.º 11
0
 private void tsm3Paste_Click(object sender, EventArgs e)
 {
     MyMethod.PasterToDataGridView(treeHeadDataGridView1, true);
     //treeHeadDataGridView1.Text = "单元开发数据共:" + curTable.Rows.Count.ToString() + " 条";
     tsbSave.Enabled = true;
 }
Ejemplo n.º 12
0
 public static void Main()
 {
     string   myChoice;
     MyMethod mm = new MyMethod();
 }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            // 解决控制台中文乱码
            //Console.OutputEncoding = Encoding.GetEncoding(936);

            // 常量
            //const double PI = 3.14159;
            const string Const_Str = "Welcome to the C# Wrold.";

            Console.WriteLine(Const_Str);
            //Console.WriteLine(PI);

            // Array.cs
            //MyArray ar = new MyArray();
            var ar = new MyArray();

            ar.Run();

            //ReferenceTypes Rer = new ReferenceTypes();
            //Rer.DynamicType();

            // Enum.cs
            MyEnum e = new MyEnum();

            e.Run();

            // Interface.cs
            MyInterface Inter = new MyInterface();

            Inter.Run();

            // Method.cs
            MyMethod Met = new MyMethod();

            Met.Run();

            // Operators.cs
            MyOperators OP = new MyOperators();

            OP.Run();

            // RegularExpression.cs 正则表达式
            MyRegularExpression RE = new MyRegularExpression();

            RE.Run();

            // StringTest.cs
            MyString str = new MyString();

            str.Run();

            // StrucTest.cs
            MyStruc st = new MyStruc();

            st.Run();

            // VariAblesConst.cs
            InputCustomers i = new InputCustomers();

            i.InputCustomer("Please input Int:");

            // NameSpace.cs
            MyNameSpace NS = new MyNameSpace();

            NS.Run();

            // DataTypes.cs
            MyDataType DT = new MyDataType();

            DT.Run();

            // MultipleInherit.cs
            InheritClass02 Inh02 = new InheritClass02();

            Inh02.Run();

            // RectangleText RT = new RectangleText(10, 20);

            // Polymorphism.cs
            MyPolymorphism PP = new MyPolymorphism();

            PP.Run();

            // FilesTest.cs
            MyFiles file = new MyFiles();

            file.Run();

            // DirectoryTest.cs
            MyDirectory Dir = new MyDirectory();

            Dir.Run();

            // AttributeTest.cs
            MyAttributes AB = new MyAttributes();

            AB.Run();

            // PropertyTest.cs
            MyProperty pp = new MyProperty();

            pp.Run();

            // IndexerTest.cs
            var id = new MyIndexer(5);

            id.Run();

            // DelegateTest.cs
            var DL = new MyDelegate();

            DL.Run();

            //
            MyEvent ee = new MyEvent();

            ee.Run();

            // CollectionTest.cs
            MyCollection cc = new MyCollection();

            cc.Run();

            #region 预处理指令
            // #define 定义一个符号,这个符号会作为一个表达式传递给 #if 指令,这个判断会得到 ture 的 结果。
            //#if (PI)
            //            Console.WriteLine("PI is defined");
            //#else
            //            Console.WriteLine("PI is not defined");
            //#endif

            //#if (DEBUG && !VC_V10)
            //            Console.WriteLine("DEBUG is defined");
            //#elif (!DEBUG && VC_V10)
            //            Console.WriteLine("VC_V10 is defined");
            //#elif (DEBUG && VC_V10)
            //            Console.WriteLine("DEBUG and VC_V10 are defined");
            //#else
            //           Console.WriteLine("DEBUG and VC_V10 are not defined");
            //#endif
            #endregion

            // RandomNumber.cs
            MyRandom rd = new MyRandom();
            rd.Run();

            //
            MyTest tt = new MyTest();
            tt.Test();

            Console.ReadKey();
        }
Ejemplo n.º 14
0
        public RedundantDeclaration()
        {
            MyEvent += new EventHandler((a, b) => { }); // Noncompliant {{Remove the explicit delegate creation; it is redundant.}}
//                     ^^^^^^^^^^^^^^^^
            MyEvent += (a, b) => { };

            (new EventHandler((a, b) => { }))(1, null);

            MyEvent2 = new MyMethod((i, j) => { }); // Noncompliant
            MyEvent2 = new MyMethod(                // Noncompliant
                delegate(int i, int j) { });        // Noncompliant {{Remove the parameter list; it is redundant.}}
//                       ^^^^^^^^^^^^^^

            MyEvent2 = delegate(int i, int j) { Console.WriteLine(); };  //Noncompliant
            MyEvent  = delegate { Console.WriteLine("fdsfs"); };

            var l = new List <int>()
            {
            };                           // Noncompliant {{Remove the initializer; it is redundant.}}

//                                  ^^^
            l = new List <int>();
            var o = new object()
            {
            };                        // Noncompliant

//                               ^^^
            o = new object { };

            var ints = new int[] { 1, 2, 3 }; // Noncompliant {{Remove the array type; it is redundant.}}

//                         ^^^
            ints = new[] { 1, 2, 3 };
            ints = new int[3] {
                1, 2, 3
            };                             // Noncompliant {{Remove the array size specification; it is redundant.}}
//                         ^

            var ddd = new double[] { 1, 2, 3.0 }; // Compliant the element types are not the same as the specified one

            var xxx = new int[, ] {
                { 1, 1, 1 }, { 2, 2, 2 }, { 3, 3, 3 }
            };
            var yyy = new int[3   // Noncompliant, we report two issues on this to keep the comma unfaded
                              , 3 // Noncompliant
                      ] {
                { 1, 1, 1 }, { 2, 2, 2 }, { 3, 3, 3 }
            };

            // see https://github.com/SonarSource/sonar-csharp/issues/1840
            var multiDimIntArray = new int[][] // Compliant - type specifier is mandatory here
            {
                new int[] { 1 } // Noncompliant
            };
            var zzz = new int[][] { new[] { 1, 2, 3 }, new int[0], new int[0] };
            var www = new int[][][] { new[] { new[] { 0 } } };

            int?xx = ((new int?(5)));  // Noncompliant {{Remove the explicit nullable type creation; it is redundant.}}

//                      ^^^^^^^^
            xx = new Nullable <int>(5); // Noncompliant
            var rr = new int?(5);

            NullableTest1(new int?(5));
            NullableTest1 <int>(new int?(5));          // Noncompliant
            NullableTest2(new int?(5));                // Noncompliant

            Func <int, int?> f = new Func <int, int?>( // Noncompliant
                i => new int?(i));                     // Noncompliant

            f = i =>
            {
                return(new int?(i)); // Noncompliant
            };

            Delegate d  = new Action(() => { });
            Delegate d2 = new Func <double>(() => { return(1); });

            NullableTest2(f(5));

            var f2 = new Func <int, int?>(i => i);

            Func <int, int> f1 = (int i) => 1; //Noncompliant {{Remove the type specification; it is redundant.}}
//                               ^^^
            Func <int, int> f3           = (i) => 1;
            var             transformer  = Funcify((string x) => new { Original = x, Normalized = x.ToLower() });
            var             transformer2 = Funcify2((string x) => new { Original = x, Normalized = x.ToLower() }); // Noncompliant

            RefDelegateMethod((ref int i) => { });
        }
Ejemplo n.º 15
0
        public void BeginCheck()
        {
            string AppRegFilePath = Application.StartupPath + "\\AppRun.dll";

            #region  //测试版先不连接地址院的校验服务器


            //if(!MyMethod.CheckFileExists(AppRegFilePath))
            //{
            //    //第一次运行,由于没有注册文件,所以先到服务器上拉取一下,比较慢,出进度条
            //    curProgress = new ProgressForm("正在为第一次运行做准备……");
            //    curProgress.Show(parentForm);
            //    //parentForm.Enabled = false;
            //}


            ////先连接服务器,调用更新文件
            //DownLoadRegFile opUpdateRegFile = new DownLoadRegFile();
            //opUpdateRegFile.BeginOp();

            //if (curProgress != null)
            //{
            //    curProgress.Close();
            //    //parentForm.Enabled = true;
            //}

            #endregion

            //如果没有注册文件,要检测是否是第一次安装
            if (!MyMethod.CheckFileExists(AppRegFilePath))
            {   //获取数据库中的标识
                if (GetAccessRegInfo(opDB))
                {
                    //如果第一次安装,密码存储应为null
                    if (dt_AcessReg.Rows.Count > 0)
                    {
                        string TempValue = dt_AcessReg.Rows[0]["psw"].ToString();
                        if (string.IsNullOrEmpty(TempValue))
                        {
                            //确认为第一次安装,启动相关模块
                            RegForm form = new RegForm(opDB);
                            ////默认一个月
                            ////form.text_RegDW.Text = "培训专用";
                            ////form.date_UseDataLimite.Value = "2015-11-10".ConvertDate("yyyy-MM-dd");
                            ////form.btn_Reg_Click(null, null);
                            ////手工注册使用
                            form.TopMost = true;
                            form.ShowDialog(parentForm);
                            form.Dispose();
                            string tempValue = DateTime.Now.ToString("yyyy-MM-dd");
                            dt_AcessReg.Rows[0]["psw"] = MyMethod.GetEecryptStr(tempValue);
                            SaveAccessRegInfo();
                        }
                    }
                }
            }

            BackgroundWorker back_CheckReg = new BackgroundWorker();
            back_CheckReg.WorkerSupportsCancellation = true;
            back_CheckReg.DoWork             += back_CheckReg_DoWork;
            back_CheckReg.RunWorkerCompleted += back_CheckReg_RunWorkerCompleted;
            back_CheckReg.RunWorkerAsync();
        }
Ejemplo n.º 16
0
    //创建类方法
    //MyClassList

    private static void ProductMethodClass_Now(string subClassName, string gate, List <string> strList, string IclassName)
    {
        string className = "NetHelper_";

        if (IclassName == "Request_")
        {
            var arr = gate.Split('.');
            className = className + arr[1];
        }
        else if (IclassName == "Response_")
        {
            if (gate.Contains('.'))
            {
                return;
            }
            else
            {
                className = className + gate;
            }
        }
        MyClass mc = new MyClass(className);
        //var file = path + "/RouteClass" + mc.Name + ".cs";
        var dir_Test = "D:/TestClass/";

        if (Directory.Exists(dir_Test) == false)
        {
            Directory.CreateDirectory(dir_Test);
        }
        var file = "D:/TestClass/" + mc.Name + ".cs";

        if (!File.Exists(file))
        {
            mc.AddNameSpace("System");
            mc.AddNameSpace("MyJson");
            mc.AddNameSpace("System.Linq");
        }
        //用来添加方法体
        MyMethod m        = null;
        MyMethod m_Remove = null;

        if (IclassName == "Request_")
        {
            m = CreateMethod_Client(IclassName, gate, strList);
        }
        else
        {
            m        = CreateMethod_Server(subClassName, gate, strList, false);
            m_Remove = CreateMethod_Server(subClassName, gate, strList, true);
        }
        mc.AddMethod(m);
        if (m_Remove != null)
        {
            mc.AddMethod(m_Remove);
        }

        var    code   = mc.ToString();
        string result = "";

        if (File.Exists(file))
        {
            //File.Delete(file);
            //将当前类插入到最后一个“}”之前
            var str = File.ReadAllText(file).ToString();
            code = m.ToString();
            if (str.Contains(code))
            {
                result = str;
            }
            else
            {
                result = str.Insert(str.LastIndexOf('}'), code);
            }
        }
        else
        {
            mc.AddMethod(m);
            result = code;
        }
        var dir = Path.GetDirectoryName(path + "/NetHelper/");

        if (Directory.Exists(dir) == false)
        {
            Directory.CreateDirectory(dir);
        }

        //File.WriteAllText(path + "/NetHelper/" + mc.Name + ".cs", result);
        File.WriteAllText("D:/TestClass/" + mc.Name + ".cs", result);
    }
Ejemplo n.º 17
0
        private static void Main(string[] args)
        {
            //if HttpListener is not supported by the Framework
            if (!HttpListener.IsSupported)
            {
                Console.WriteLine("A more recent Windows version is required to use the HttpListener class.");
                return;
            }

            // Create a listener.
            HttpListener listener = new HttpListener();

            // Add the prefixes.
            if (args.Length != 0)
            {
                foreach (string s in args)
                {
                    listener.Prefixes.Add(s);
                    // don't forget to authorize access to the TCP/IP addresses localhost:xxxx and localhost:yyyy
                    // with netsh http add urlacl url=http://localhost:xxxx/ user="******"
                    // and netsh http add urlacl url=http://localhost:yyyy/ user="******"
                    // user="******" is language dependent, use user=Everyone in english
                }
            }
            else
            {
                Console.WriteLine("Syntax error: the call must contain at least one web server url as argument");
            }
            listener.Start();

            // get args
            foreach (string s in args)
            {
                Console.WriteLine("Listening for connections on " + s);
            }

            // Trap Ctrl-C on console to exit
            Console.CancelKeyPress += delegate {
                // call methods to close socket and exit
                listener.Stop();
                listener.Close();
                Environment.Exit(0);
            };


            while (true)
            {
                // Note: The GetContext method blocks while waiting for a request.
                HttpListenerContext context = listener.GetContext();
                HttpListenerRequest request = context.Request;

                string documentContents;
                using (Stream receiveStream = request.InputStream)
                {
                    using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
                    {
                        documentContents = readStream.ReadToEnd();
                    }
                }

                // get url
                Console.WriteLine($"Received request for {request.Url}");


                /*
                 * //get url protocol
                 * Console.WriteLine("url protocol: "+request.Url.Scheme);
                 * //get user in url
                 * Console.WriteLine("user in url: " + request.Url.UserInfo);
                 * //get host in url
                 * Console.WriteLine("host in url: " + request.Url.Host);
                 * //get port in url
                 * Console.WriteLine("port in url: " + request.Url.Port);
                 * //get path in url
                 * Console.WriteLine("path in url: "+request.Url.LocalPath);
                 *
                 * // parse path in url
                 * foreach (string str in request.Url.Segments)
                 * {
                 *  Console.WriteLine(str);
                 * }
                 * //get params un url. After ? and between &
                 * Console.WriteLine(request.Url.Query);
                 * //parse params in url
                 * Console.WriteLine("param1 = " + HttpUtility.ParseQueryString(request.Url.Query).Get("param1"));
                 * Console.WriteLine("param2 = " + HttpUtility.ParseQueryString(request.Url.Query).Get("param2"));
                 * Console.WriteLine("param3 = " + HttpUtility.ParseQueryString(request.Url.Query).Get("param3"));
                 * Console.WriteLine("param4 = " + HttpUtility.ParseQueryString(request.Url.Query).Get("param4"));
                 *
                 * Console.WriteLine(documentContents);
                 */

                HttpListenerResponse response = context.Response;

                string   responseString;
                string[] path = request.Url.Segments;
                if (path[path.Length - 1].Equals("helloworld"))
                {
                    string name1 = HttpUtility.ParseQueryString(request.Url.Query).Get("param1");
                    string name2 = HttpUtility.ParseQueryString(request.Url.Query).Get("param2");
                    responseString = MyMethod.Hello(name1, name2);
                }
                else
                {
                    responseString = "<HTML><BODY> Hello world!</BODY></HTML>";
                }

                byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
                // Get a response stream and write the response to it.
                response.ContentLength64 = buffer.Length;
                System.IO.Stream output = response.OutputStream;
                output.Write(buffer, 0, buffer.Length);
                // You must close the output stream.
                output.Close();
            }
            // Httplistener neither stop ... But Ctrl-C do that ...
            // listener.Stop();
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 点击开始按钮时触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lbl_kaishi_Click(object sender, EventArgs e)
        {
            //修改程序状态为执行,刷新状态信息
            lbl_zhuangtai.Text   = "正在进行数据解析……";
            lbl_kaishi.Enabled   = false;
            lbl_kaishi.BackColor = Color.Gray;
            statue = 1;

            //获得文件夹下所有的文件名
            for (int i = folderIndex; i < dgv_task.Rows.Count; i++)
            {
                folderIndex = i;//时刻记录当前程序执行到的文件夹位置
                string   folder = dgv_task.Rows[i].Cells[1].Value.ToString();
                string[] files  = Directory.GetFiles(folder);
                for (int k = fileIndex; k < files.Length; k++)
                {
                    //计算百分率
                    double _processRate = 100 * Convert.ToDouble(k + 1) / Convert.ToDouble(files.Length);
                    dgv_task.Rows[i].Cells[3].Value = $"{_processRate.ToString("00.00")}%";
                    Application.DoEvents();

                    //如果用户终止了或者暂停了程序,就跳出循环
                    if (statue == 0 || statue == 2)
                    {
                        return;
                    }
                    fileIndex = k;//时刻记录当前程序执行到的文件位置
                    string file = files[k];
                    #region  1、文件名格式标准化

                    /*1、开始文件名格式标准化*/
                    string path         = Path.GetDirectoryName(file);
                    string fileOriginal = Path.GetFileNameWithoutExtension(file);
                    string extension    = Path.GetExtension(file);
                    string filename     = string.Empty;//用于存放改后的文件名
                    //判断“文件名标准化”格式,如果不是“无”,则进行文件名格式标准化

                    if (!SystemInfo._userInfo._wjmbzh.Equals("无"))
                    {
                        //拆分出路径和文件名
                        ///拆分后的文件名集合,对list进行处理,如果是\d星,那么要和前一项合并
                        List <string> list = Regex.Split(fileOriginal, @"\.").ToList();
                        for (int j = 0; j < list.Count; j++)
                        {
                            if (Regex.IsMatch(list[j], @"\d星"))
                            {
                                list[j] = $"{list[j - 1] }.{list[j]}";
                                list.RemoveAt(j - 1);
                                break;
                            }
                        }
                        //获得文件名标准格式下的所有rule名称
                        FormatInfo fi = new FormatInfo(SystemInfo._userInfo._wjmbzh);
                        fi.GetFormatInfo();
                        List <string> rules = Regex.Split(fi._formatSet, @"\|").ToList();
                        //对每一个rule循环,获得设置root
                        foreach (string rule in rules)
                        {
                            RuleInfo myri = new RuleInfo(rule, "文件名标准化");
                            myri.GetRuleInfo();
                            WjmRuleRoot myroot = ((WjmRuleRoot)myri._root);
                            //判断位置,得到操作目标,对每种可能的目标进行判断操作
                            if (myroot.position[0].Equals("整个文件名"))
                            {
                                //对操作目标进行操作
                                if (!myroot.delete.Trim().Equals(string.Empty))
                                {
                                    filename = Regex.Replace(fileOriginal, myroot.delete.Trim(), "");
                                }
                                else if (!myroot.replace0.Trim().Equals(string.Empty))
                                {
                                    filename = Regex.Replace(fileOriginal, myroot.replace0.Trim(), myroot.replace);
                                }
                            }
                            else if (myroot.position[0].Equals("文件名前"))
                            {
                                //新增内容
                                if (!myroot.newText.Trim().Equals(string.Empty))
                                {
                                    filename = $"{myroot.newText}{fileOriginal}";
                                }
                            }
                            else if (myroot.position[0].Equals("文件名后"))
                            {
                                //新增内容
                                if (!myroot.newText.Trim().Equals(string.Empty))
                                {
                                    filename = $"{fileOriginal}{myroot.newText}";
                                }
                            }
                            else if (Regex.IsMatch(myroot.position[0], @"文件名第\d项前"))
                            {
                                //获得数字,然后获得目标文本
                                int    index  = Convert.ToInt32(Regex.Match(myroot.position[0], @"\d").Value);
                                string target = list[index - 1];
                                //新增内容
                                if (!myroot.newText.Trim().Equals(string.Empty))
                                {
                                    target = $"{myroot.newText.Trim()}{target}";
                                }
                                list[index - 1] = target;
                                filename        = string.Join(".", list);
                            }
                            else if (Regex.IsMatch(myroot.position[0], @"文件名第\d项后"))
                            {
                                //获得数字,然后获得目标文本
                                int    index  = Convert.ToInt32(Regex.Match(myroot.position[0], @"\d").Value);
                                string target = list[index - 1];
                                //新增内容
                                if (!myroot.newText.Trim().Equals(string.Empty))
                                {
                                    target = $"{target}{myroot.newText.Trim()}";
                                }
                                list[index - 1] = target;
                                filename        = string.Join(".", list);
                            }
                            //给文件改名
                            File.Move($"{file}", $"{path}\\{filename}{extension}");
                        }
                    }
                    else//如果不进行文件名标准化,那么新得文件名和原先一样
                    {
                        filename = fileOriginal;
                    }
                    string currentFilename = $"{path}\\{filename}{extension}";

                    #endregion



                    #region 2、文档格式标准化
                    //判断“文档格式标准化”格式,如果用户不是选择了“无”,则执行文件格式标准化
                    if (!SystemInfo._userInfo._wjbzh.Equals("无"))
                    {
                        //获得标准化规则
                        FormatInfo _format = new FormatInfo(SystemInfo._userInfo._wjbzh);
                        _format.GetFormatInfo();
                        string   _rule     = Regex.Split(_format._formatSet, @"\|")[0];
                        RuleInfo _ruleInfo = new RuleInfo(_rule, "格式标准化");
                        _ruleInfo.GetRuleInfo();
                        BzhRuleRoot _root = _ruleInfo._root as BzhRuleRoot;
                        //调整文档格式,包括大标题,副标题,正文,一级标题,二级标题,三级标题,页边距,
                        MyMethod.UpdateFormat2(currentFilename, _root);

                        //文本标注,暂时 放一放
                    }


                    #endregion

                    #region 3、查重清洗
                    //判断用户选择的查重清洗格式,如果不等于,则进行查重清洗
                    if (!SystemInfo._userInfo._ccqx.Equals("无"))
                    {
                    }

                    #endregion
                    #region 4、基础解析
                    //判断用户选择的基础解析格式,如果不等于无,则进行基础解析
                    JJDocument _jjDoc = new JJDocument(currentFilename);

                    if (!SystemInfo._userInfo._jcjx.Equals("无"))
                    {
                        var listbase = _jjDoc.GetBaseAnalysis();
                        _jjDoc.SaveList2Excel(listbase);
                    }


                    #endregion

                    #region 5、内容解析
                    //判断用户选择的内容解析格式,如果不等于无,则进行内容解析
                    if (!SystemInfo._userInfo._nrjx.Equals("无"))
                    {
                        var listneirong = _jjDoc.GetNeirongAnalysis();
                        _jjDoc.SaveList2Excel(listneirong);
                    }

                    #endregion
                    #region 6、大数据版
                    //判断用户选择的大数据版,如果不等于无,则进行大数据版
                    if (!SystemInfo._userInfo._dsjb.Equals("无"))
                    {
                    }
                    #endregion
                }
            }
            //执行完成提示,完成并将系统状态还原为0
            statue             = 0;
            lbl_kaishi.Enabled = true;

            lbl_kaishi.ForeColor = Color.White;
            lbl_kaishi.BackColor = Color.MediumSeaGreen;
            lbl_zhuangtai.Text   = "已就绪,请点击\"开始\"执行解析";
            MessageBox.Show("本次数据处理已完成!");
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 点击保存按钮时触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lbl_baocun_Click(object sender, EventArgs e)
        {
            //构造一个biaoqianinfo实例,保存在数据库中内容标签表
            TagRoot _bqRoot = new TagRoot()
            {
                shuoming    = tb_shuoming.Text,
                zhengze     = tb_zhengze.Text,
                shunshu     = Convert.ToInt32(tb_shunshu.Text),
                daoshu      = Convert.ToInt32(tb_daoshu.Text),
                gudingzhi   = tb_gudingzhi.Text,
                jushouzhi   = tb_jushouzhi.Text,
                juzhongzhi  = tb_juzhongzhi.Text,
                juweizhi    = tb_juweizhi.Text,
                weizhiqian0 = tb_weizhiqian0.Text,
                weizhiqian1 = tb_weizhiqian1.Text,
                weizhihou0  = tb_weizhihou0.Text,
                weizhihou1  = tb_weizhihou1.Text,
                zhengzetiqu = tb_zhengzetiqu.Text,
            };

            foreach (Control c in panel_neirong.Controls)
            {
                if (c is CheckBox && (c as CheckBox).Checked == true)
                {
                    _bqRoot.list_leibie.Add(c.Text);
                }
            }
            foreach (Control c in flp_weizhi.Controls)
            {
                if (c is CheckBox && (c as CheckBox).Checked == true)
                {
                    _bqRoot.list_position.Add(c.Text);
                }
            }
            foreach (Control c in flp_pipeidu.Controls)
            {
                if (c is CheckBox && (c as CheckBox).Checked == true)
                {
                    _bqRoot.list_pipei.Add(c.Text);
                }
            }

            foreach (Control c in flp_jiedian.Controls)
            {
                if (c is CheckBox && (c as CheckBox).Checked == true)
                {
                    _bqRoot.list_neirong.Add(c.Text);
                }
            }
            foreach (Control c in flp_yupian.Controls)
            {
                if (c is CheckBox && (c as CheckBox).Checked == true)
                {
                    _bqRoot.list_yupian.Add(c.Text);
                }
            }
            string _bqSetJson = JsonConvert.SerializeObject(_bqRoot);

            //如果是新建一个标签,那么父标签是有实例传进来的,而自身的tagInfo没有
            //如果是编辑标签,那么父标签是没有实例的,而自身的tagInfo有值
            if (_parentInfo != null)
            {
                _tagInfo = new TagInfo()
                {
                };
                _tagInfo._kuming    = _parentInfo._kuming;
                _tagInfo._mingcheng = tb_mingcheng.Text;
                _tagInfo._jibie     = _parentInfo._jibie + 1;
                //_tagInfo._fubiaoqianming = _parentInfo._mingcheng;
                _tagInfo._biaoqianSet       = _bqSetJson;
                _tagInfo._chuangjianren     = SystemInfo._userInfo._shiming;
                _tagInfo._chuangjianshijian = DateTime.Now.ToString("yyyy-MM-dd");
                _tagInfo._parent            = _parentInfo;
                //保存biaoqianinfo
                SaveBiaoqianInfo();
                MessageBox.Show($"内容标签 {_tagInfo._mingcheng} 已添加成功!");
                MyMethod._updateTag();
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                _tagInfo._biaoqianSet = _bqSetJson;
                //保存biaoqianinfo
                SaveBiaoqianInfo();
                MessageBox.Show($"内容标签 {_tagInfo._mingcheng} 已设置成功!");
                MyMethod._updateTag();
                this.DialogResult = DialogResult.OK;
            }
        }
Ejemplo n.º 20
0
        private void Load_Card()
        {
            this.FormBorderStyle = FormBorderStyle.None;
            this.Size            = new Size(327, 93);
            Rectangle rect = Screen.GetWorkingArea(this);     //获取显示器的分辨率

            this.Location     = new Point(rect.Width / 2 - this.Width / 2, rect.Height / 2 - this.Height / 2);
            lblState.Location = new Point(0, 0);
            #region 卡片信息处理
            string CARD_IFFO = Myhelp.getHtml("http://appimg2.qq.com/card/mk/card_info_v3.js");                                                           //有网时
            string CARD_MINI = Myhelp.postHtml("http://card.show.qq.com/cgi-bin/card_mini_get?g_tk=" + Mydata.Gtk, "uin=" + Mydata.Iuin, Mydata.Cookies); //已收集的套卡

            Regex           regStr = new Regex("id=\"(.*)\" num=\"(.*)\"", RegexOptions.IgnoreCase);                                                      //已收集套卡信息的正则
            MatchCollection mats   = regStr.Matches(CARD_MINI);


            regStr = new Regex(@"(\d{2,4}),'(.*|[\(].*[\)])',(\d),(\d{10}),.*\[(.*)\],(.),.*\d{10},(\d{1,10}),", RegexOptions.IgnoreCase); //套卡信息的正则
            MatchCollection mat = regStr.Matches(CARD_IFFO);
            for (int i = 0; i < mat.Count; i++)
            {
                int      id      = Convert.ToInt32(mat[i].Groups[1].ToString()); //--------------------
                string   name    = mat[i].Groups[2].ToString();
                int      diff    = Convert.ToInt32(mat[i].Groups[3].ToString());
                int      time    = Convert.ToInt32(mat[i].Groups[4].ToString()); //  各种的数据
                string   cards   = mat[i].Groups[5].ToString();
                int      type    = Convert.ToInt32(mat[i].Groups[6].ToString());
                int      offtime = Convert.ToInt32(mat[i].Groups[7].ToString());//----------------------
                MyMethod mmd     = delegate()
                {
                    #region 加载套卡 必须优化,代码乱的要死
                    bool xxx = false;
                    switch (type)
                    {
                    case 0:
                    case 2:
                        #region
                        xxx = false;
                        for (int x = 0; x < mats.Count; x++)
                        {
                            if (id == Convert.ToInt32(mats[x].Groups[1].ToString()))
                            {
                                xxx = true;
                                break;
                            }
                        }
                        if (xxx)
                        {
                            tvFX.Nodes[diff.ToString()].Nodes.Insert(0, name).Tag = id;       //添加子节点的同时添加它的数据(ID)
                            tvFX.Nodes[diff.ToString()].Nodes[0].BackColor        = Color.FromArgb(128, 255, 128);
                        }
                        else
                        {
                            tvFX.Nodes[diff.ToString()].Nodes.Insert(0, name).Tag = id;       //添加子节点的同时添加它的数据(ID)
                        }

                        #endregion
                        break;

                    case 1:
                    case 5:
                        #region
                        xxx = false;
                        for (int x = 0; x < mats.Count; x++)
                        {
                            if (id == Convert.ToInt32(mats[x].Groups[1].ToString()))
                            {
                                xxx = true;
                                break;
                            }
                        }
                        if (xxx)
                        {
                            tvXJ.Nodes[diff.ToString()].Nodes.Insert(0, name).Tag = id;       //添加子节点的同时添加它的数据(ID)
                            tvXJ.Nodes[diff.ToString()].Nodes[0].BackColor        = Color.FromArgb(128, 255, 128);
                        }
                        else
                        {
                            tvXJ.Nodes[diff.ToString()].Nodes.Insert(0, name).Tag = id;       //添加子节点的同时添加它的数据(ID)
                        }

                        #endregion
                        break;

                    case 9:
                        #region
                        xxx = false;
                        for (int x = 0; x < mats.Count; x++)
                        {
                            if (id == Convert.ToInt32(mats[x].Groups[1].ToString()))
                            {
                                xxx = true;
                                break;
                            }
                        }
                        if (xxx)
                        {
                            tvSK.Nodes[diff.ToString()].Nodes.Insert(0, name).Tag = id;       //添加子节点的同时添加它的数据(ID)
                            tvSK.Nodes[diff.ToString()].Nodes[0].BackColor        = Color.FromArgb(128, 255, 128);
                        }
                        else
                        {
                            tvSK.Nodes[diff.ToString()].Nodes.Insert(0, name).Tag = id;       //添加子节点的同时添加它的数据(ID)
                        }

                        #endregion
                        break;

                    default:
                        break;
                    }
                    #endregion
                };
                Invoke(mmd);
                _themeDic.Add(id, new ThemeTemplet(id, name, diff, time, cards, type, offtime)); //将信息存入该字典中
                //ds.Tables["Theme"].Rows.Add(new object[] { id, name });
            }
            regStr = new Regex(@"\[(.*),(.*),'(.*)',(\d{2,4}),", RegexOptions.IgnoreCase);//卡片信息的正则
            mat    = regStr.Matches(CARD_IFFO);
            for (int i = 0; i < mat.Count; i++)
            {
                int    id      = Convert.ToInt32(mat[i].Groups[1].ToString());
                int    themeid = Convert.ToInt32(mat[i].Groups[2].ToString());
                string name    = mat[i].Groups[3].ToString();
                int    price   = Convert.ToInt32(mat[i].Groups[4].ToString());
                _cardDic.Add(id, new CardTemplet(id, themeid, name, price));
            }


            tssState.BackColor = Color.FromArgb(128, 255, 128);
            tssState.Text      = "卡片信息加载完毕!!!";
            lblState.Visible   = false;
            #endregion
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.Size            = new Size(440, 408);
            cbTop.Left           = 366;
            this.Location        = new Point(rect.Width / 2 - this.Width / 2, rect.Height / 2 - this.Height / 2);
            lblHide.Enabled      = true;
            btnTst.Enabled       = true;
            Console.Beep();
            Debug.WriteLine(groupBox1.Location.Y);
        }//获取和载入卡片
Ejemplo n.º 21
0
 public float EaseCalculate(MyMethod ease_type, float from, float to, float linear_progress)
 {
     return(GetEaseProgress(ease_type, linear_progress, from, to - from));
 }
Ejemplo n.º 22
0
        private void UpdateRegInfoToServer(RegInfoStruct curRegInfoStruct)
        {
            string strSql = "select * from 注册码管理 where CPU编号='" + curRegInfoStruct.CPUID + "' and 硬盘编号='" + curRegInfoStruct.HDDID + "'";

            DataSet curSet = new DataSet();

            try
            {
                curSet = opWeb.GetDataSet(strSql);
                if (!string.IsNullOrEmpty(opWeb.ErrMsg))
                {
                    return;
                }
                if (curSet.Tables[0].Rows.Count > 0)
                {
                    return;
                }

                DataRow newRow = curSet.Tables[0].NewRow();
                newRow["编号"]    = MyMethod.GetGUID();
                newRow["所属单位"]  = curRegInfoStruct.RegUnit;
                newRow["注册人姓名"] = curRegInfoStruct.RegUser;
                newRow["注册时间"]  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                if (curRegInfoStruct.curRegCheckResult == RegCheckResult.UnlimitedVer)
                {
                    newRow["授权类型"] = 1;
                }
                else
                {
                    newRow["授权类型"] = 0;
                }
                newRow["使用截止时间"]  = curRegInfoStruct.TrialLimiteTime;
                newRow["软件可运行次数"] = curRegInfoStruct.TrialLimiteCount;
                if (curRegInfoStruct.LimiteDataUpdateFromServer)
                {
                    newRow["数据获取限制"] = 1;
                }
                else
                {
                    newRow["数据获取限制"] = 0;
                }

                if (!string.IsNullOrEmpty(curRegInfoStruct.CYCID))
                {
                    newRow["采油厂标识"] = curRegInfoStruct.CYCID;
                }
                newRow["注册码"] = MyMethod.FileToStr(Application.StartupPath + "\\AppRun.dll");
                if (curRegInfoStruct.curBindType == RegBindHDType.CPU)
                {
                    newRow["绑定硬件"] = 0;
                }
                else
                {
                    newRow["绑定硬件"] = 1;
                }
                newRow["版本"]    = curRegInfoStruct.CurAppVer;
                newRow["CPU编号"] = curRegInfoStruct.CPUID;
                newRow["硬盘编号"]  = curRegInfoStruct.HDDID;
                newRow["用户IP"]  = curRegInfoStruct.CurIP;
                newRow["记录来源"]  = "自动补充";

                curSet.Tables[0].Rows.Add(newRow);
                if (!opWeb.UpdateDataSet(curSet, strSql))
                {
                    string ErrMsg = opWeb.ErrMsg;
                }
            }
            catch (Exception E)
            {
                ErrMsg = E.Message;
            }
        }
Ejemplo n.º 23
0
    float GetEaseProgress(MyMethod ease_type, float linear_progress, float from, float by)
    {
        switch (ease_type)
        {
        case MyMethod.Linear:
            return(from + linear_progress * by);

        case MyMethod.BackEaseIn:
            return(BackEaseIn(linear_progress, from, by, 1));

        case MyMethod.BackEaseInOut:
            return(BackEaseInOut(linear_progress, from, by, 1));

        case MyMethod.BackEaseOut:
            return(BackEaseOut(linear_progress, from, by, 1));

        case MyMethod.BackEaseOutIn:
            return(BackEaseOutIn(linear_progress, from, by, 1));

        case MyMethod.BounceEaseIn:
            return(BounceEaseIn(linear_progress, from, by, 1));

        case MyMethod.BounceEaseInOut:
            return(BounceEaseInOut(linear_progress, from, by, 1));

        case MyMethod.BounceEaseOut:
            return(BounceEaseOut(linear_progress, from, by, 1));

        case MyMethod.BounceEaseOutIn:
            return(BounceEaseOutIn(linear_progress, from, by, 1));

        case MyMethod.CircEaseIn:
            return(CircEaseIn(linear_progress, from, by, 1));

        case MyMethod.CircEaseInOut:
            return(CircEaseInOut(linear_progress, from, by, 1));

        case MyMethod.CircEaseOut:
            return(CircEaseOut(linear_progress, from, by, 1));

        case MyMethod.CircEaseOutIn:
            return(CircEaseOutIn(linear_progress, from, by, 1));

        case MyMethod.CubicEaseIn:
            return(CubicEaseIn(linear_progress, from, by, 1));

        case MyMethod.CubicEaseInOut:
            return(CubicEaseInOut(linear_progress, from, by, 1));

        case MyMethod.CubicEaseOut:
            return(CubicEaseOut(linear_progress, from, by, 1));

        case MyMethod.CubicEaseOutIn:
            return(CubicEaseOutIn(linear_progress, from, by, 1));

        case MyMethod.ElasticEaseIn:
            return(ElasticEaseIn(linear_progress, from, by, 1));

        case MyMethod.ElasticEaseInOut:
            return(ElasticEaseInOut(linear_progress, from, by, 1));

        case MyMethod.ElasticEaseOut:
            return(ElasticEaseOut(linear_progress, from, by, 1));

        case MyMethod.ElasticEaseOutIn:
            return(ElasticEaseOutIn(linear_progress, from, by, 1));

        case MyMethod.ExpoEaseIn:
            return(ExpoEaseIn(linear_progress, from, by, 1));

        case MyMethod.ExpoEaseInOut:
            return(ExpoEaseInOut(linear_progress, from, by, 1));

        case MyMethod.ExpoEaseOut:
            return(ExpoEaseOut(linear_progress, from, by, 1));

        case MyMethod.ExpoEaseOutIn:
            return(ExpoEaseOutIn(linear_progress, from, by, 1));

        case MyMethod.QuadEaseIn:
            return(QuadEaseIn(linear_progress, from, by, 1));

        case MyMethod.QuadEaseInOut:
            return(QuadEaseInOut(linear_progress, from, by, 1));

        case MyMethod.QuadEaseOut:
            return(QuadEaseOut(linear_progress, from, by, 1));

        case MyMethod.QuadEaseOutIn:
            return(QuadEaseOutIn(linear_progress, from, by, 1));

        case MyMethod.QuartEaseIn:
            return(QuartEaseIn(linear_progress, from, by, 1));

        case MyMethod.QuartEaseInOut:
            return(QuartEaseInOut(linear_progress, from, by, 1));

        case MyMethod.QuartEaseOut:
            return(QuartEaseOut(linear_progress, from, by, 1));

        case MyMethod.QuartEaseOutIn:
            return(QuartEaseOutIn(linear_progress, from, by, 1));

        case MyMethod.QuintEaseIn:
            return(QuintEaseIn(linear_progress, from, by, 1));

        case MyMethod.QuintEaseInOut:
            return(QuintEaseInOut(linear_progress, from, by, 1));

        case MyMethod.QuintEaseOut:
            return(QuintEaseOut(linear_progress, from, by, 1));

        case MyMethod.QuintEaseOutIn:
            return(QuintEaseOutIn(linear_progress, from, by, 1));

        case MyMethod.SineEaseIn:
            return(SineEaseIn(linear_progress, from, by, 1));

        case MyMethod.SineEaseInOut:
            return(SineEaseInOut(linear_progress, from, by, 1));

        case MyMethod.SineEaseOut:
            return(SineEaseOut(linear_progress, from, by, 1));

        case MyMethod.SineEaseOutIn:
            return(SineEaseOutIn(linear_progress, from, by, 1));

        default:
            return(linear_progress);
        }
    }
Ejemplo n.º 24
0
        public static void CreateContrlCS(List <RegistViewItem> itemList, string goName)
        {
            MyClass mc = new MyClass("Contrl_" + goName + ":AViewContrlBase");

            mc.AddNameSpace(new string[2] {
                "BDFramework.UI", "UnityEngine"
            });
            mc.SetSelfNameSpace("Code.Game.Windows.MCX"); MyMethod construct = new MyMethod();
            construct.OverwriteContent(@"//[Note]
        public [method name](DataDrive_Service data) : base(data)
        {
            
        } ");
            construct.SetMethSign(null, "Contrl_" + goName, null);
            mc.AddMethod(construct);
            foreach (RegistViewItem item in itemList)
            {
                if (string.IsNullOrEmpty(item.BindDataName))
                {
                    continue;
                }
                Type     t = GetUIType(item.gameObject);
                MyMethod bindData = new MyMethod();
                string   methodName = ""; string methodParams = "";
                if (t.Equals(typeof(UnityEngine.UI.Button)))
                {
                    methodName   = "OnClick_" + item.name;
                    methodParams = "";
                }
                else if (t.Equals(typeof(UnityEngine.UI.Slider)))
                {
                    methodName   = "OnValueChange_" + item.name;
                    methodParams = "float value";
                }
                else if (t.Equals(typeof(UnityEngine.UI.Scrollbar)))
                {
                    methodName   = "OnValueChange_" + item.name;
                    methodParams = "float value";
                }
                else
                {
                    methodName   = "On_" + item.name;
                    methodParams = "";
                }
                bindData.OverwriteContent(@"//[Note]
                private [return type] [method name] ([params])
                {
                   [method content]
                }
                ");
                bindData.SetMethSign(null, methodName, methodParams);
                bindData.SetMethodContent(string.Format("Debug.Log(\"use {0}\");", item.name));
                mc.AddMethod(bindData);
            }


            string path = Application.dataPath + createPath;

            if (!Directory.Exists(path))
            {
                Debug.LogError(string.Format("文件夹不存在!路径:{0}", path));
                return;
            }
            path = path + "Contrl_" + goName + ".cs";
            File.WriteAllText(path, mc.ToString());
            Debug.Log(string.Format("生成成功!路径:{0}", path));
        }
Ejemplo n.º 25
0
 private void tsm3Copy_Click(object sender, EventArgs e)
 {
     MyMethod.CopyFromDataGridView(treeHeadDataGridView1);
 }
        public RedundantDeclaration()
        {
            MyEvent += new EventHandler((a, b) => { }); // Fixed
            MyEvent += (a, b) => { };

            (new EventHandler((a, b) => { }))(1, null);

            MyEvent2 = new MyMethod((i, j) => { });                     // Fixed
            MyEvent2 = new MyMethod(                                    // Fixed
                delegate(int i, int j) { });                            // Fixed

            MyEvent2 = delegate(int i, int j) { Console.WriteLine(); }; //Fixed
            MyEvent  = delegate { Console.WriteLine("fdsfs"); };

            var l = new List <int>()
            {
            };                           // Fixed

            l = new List <int>();
            var o = new object()
            {
            };                        // Fixed

            o = new object { };

            var ints = new int[] { 1, 2, 3 }; // Fixed

            ints = new[] { 1, 2, 3 };
            ints = new int[3] {
                1, 2, 3
            };                                    // Fixed

            var ddd = new double[] { 1, 2, 3.0 }; // Compliant the element types are not the same as the specified one

            var xxx = new int[, ] {
                { 1, 1, 1 }, { 2, 2, 2 }, { 3, 3, 3 }
            };
            var yyy = new int[3   // Fixed
                              , 3 // Fixed
                      ] {
                { 1, 1, 1 }, { 2, 2, 2 }, { 3, 3, 3 }
            };

            // see https://github.com/SonarSource/sonar-csharp/issues/1840
            var multiDimIntArray = new int[][] // Compliant - type specifier is mandatory here
            {
                new int[] { 1 } // Fixed
            };
            var zzz = new int[][] { new[] { 1, 2, 3 }, new int[0], new int[0] };
            var www = new int[][][] { new[] { new[] { 0 } } };

            int?xx = ((5)); // Fixed

            xx = 5;         // Fixed
            var rr = new int?(5);

            NullableTest1(new int?(5));
            NullableTest1 <int>(5);                    // Fixed
            NullableTest2(5);                          // Fixed

            Func <int, int?> f = new Func <int, int?>( // Fixed
                i => i);                               // Fixed

            f = i =>
            {
                return(i); // Fixed
            };

            Delegate d = new Action(() => { });
            Delegate d = new Func <double>(() => { return(1); });

            NullableTest2(f(5));

            var f2 = new Func <int, int?>(i => i);

            Func <int, int> f1           = (int i) => 1; //Fixed
            Func <int, int> f3           = (i) => 1;
            var             transformer  = Funcify((string x) => new { Original = x, Normalized = x.ToLower() });
            var             transformer2 = Funcify2((string x) => new { Original = x, Normalized = x.ToLower() }); // Fixed

            RefDelegateMethod((ref int i) => { });
        }
Ejemplo n.º 27
0
 public void CheckException2()
 {
     Assert.IsInstanceOfType(MyMethod.SumMinArrayElements1(new int[] { }), typeof(Exception));
 }