当前位置: 首页>>代码示例>>C#>>正文


C# Form1.Invoke方法代码示例

本文整理汇总了C#中Form1.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# Form1.Invoke方法的具体用法?C# Form1.Invoke怎么用?C# Form1.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Form1的用法示例。


在下文中一共展示了Form1.Invoke方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());
            Form1 tf = new Form1();

            Thread ct = new Thread(
                           new ThreadStart(
                           delegate ()
                           {
                               while (true)
                               {
                                   string command = Console.ReadLine();
                                   switch (command)
                                   {
                                       case "close":
                                           tf.Invoke(new MethodInvoker(
                                               delegate ()
                                               {
                                                   tf.Close();
                                               }));
                                           break;
                                       case "max":
                                           tf.Invoke(new MethodInvoker(
                                               delegate ()
                                               {
                                                   tf.WindowState = FormWindowState.Maximized;
                                               }));
                                           break;
                                       case "min":
                                           tf.Invoke(new MethodInvoker(
                                               delegate ()
                                               {
                                                   tf.WindowState = FormWindowState.Minimized;
                                               }));
                                           break;
                                       case "res":
                                           tf.Invoke(new MethodInvoker(
                                               delegate ()
                                               {
                                                   tf.WindowState = FormWindowState.Normal;
                                               }));
                                           break;
                                   }

                               }
                           }));
            ct.Start();
            tf.Show();
            tf.Activate();
            Application.Run(tf);
            Environment.Exit(0);
        }
开发者ID:kenmarst,项目名称:SerialPort,代码行数:54,代码来源:Program.cs

示例2: Connect

        //----------------------------------------------------------------------------------
        public bool Connect(Form1 form, string hostname, int port)
        {
            try
            {
                _form = form;

                _tcpClient = new TcpClient();
                _tcpClient.Connect(hostname, port);

                _stream = _tcpClient.GetStream();
                _writer = new BinaryWriter(_stream, Encoding.UTF8);
                _reader = new BinaryReader(_stream, Encoding.UTF8);

                _thread = new Thread(new ThreadStart(ProcessServerResponse));
                _thread.Start();

                NicknamePacket nickNamePacket = new NicknamePacket("Bill");
                Send(nickNamePacket);
            }
            catch (Exception e)
            {
                _form.Invoke(new RecieveMessageDelegate(_form.AppendText), new object[] { "Exception: " + e.Message });
                return false;
            }

            return true;
        }
开发者ID:ashpemb,项目名称:ConcurrentNetworks,代码行数:28,代码来源:Connection.cs

示例3: Update

        public void Update(Form1 invoker)
        {
            if (panelOpen && steps < outVal)
            {
                invoker.Invoke((MethodInvoker)delegate
                {
                    if (steps > 32)
                    {
                        snagButt.Parent = header;
                        snagButt.BringToFront();
                        snagButt.Location = openPoint;
                    }

                    int add = 1 + (1 * (int)(count / 10));      //Opening speed varies on time the animation has played so it isn't so boring

                    if (steps + add > outVal)
                    {
                        add = outVal - steps;
                        count = 0;
                    }
                    steps += add;
                    add *= dir;
                    controling.Location = new Point(controling.Location.X + add, 0);
                    count++;
                });
            }else if (!panelOpen && steps > 0)
            {
                invoker.Invoke((MethodInvoker)delegate
                {
                    if (steps < 32)
                    {
                        snagButt.Parent = invoker;
                        snagButt.Location = closePoint;
                    }

                    int add = 1 + (1 * (int)(count / 10));      //Opening speed varies on time the animation has played so it isn't so boring

                    if (steps - add < 0)
                    {
                        add = 0 - steps;
                        count = 0;
                    }
                    steps -= add;
                    add *= dir * -1;
                    controling.Location = new Point(controling.Location.X + add, 0);
                    count++;
                });
            }
        }
开发者ID:DevinPower,项目名称:anotherTicketSystem,代码行数:49,代码来源:PanelSlide.cs

示例4: oldUpdate

        public void oldUpdate(Form1 invoker, int count)
        {
            if (panelOpen)
            {
                if (controling.Location.X < outVal)
                {
                    invoker.Invoke((MethodInvoker)delegate
                    {
                        if (controling.Location.X >= -118)      //When we're far enough along, move the button too.
                        {
                            snagButt.Parent = header;
                            snagButt.BringToFront();
                            snagButt.Location = new Point(140, 0);
                        }
                        int add = 1 + (1 * (int)(count / 10));      //Opening speed varies on time the animation has played so it isn't so boring
                        controling.Location = new Point(controling.Location.X + add, 0);
                        count++;
                    });
                }
                else
                {
                    invoker.Invoke((MethodInvoker)delegate
                    {
                        controling.Location = new Point(outVal, 0);      //Make sure it doesn't overshoot
                    });
                }
            }
            else
            {
                if (controling.Location.X > inVal)
                {
                    invoker.Invoke((MethodInvoker)delegate
                    {
                        if (controling.Location.X <= -140)
                        {
                            snagButt.Parent = invoker;
                            snagButt.Location = new Point(0, 24);
                        }
                        int add = 1 + (1 * (int)(count / 10));
                        controling.Location = new Point(controling.Location.X - add, 0);
                        count++;
                    });
                }
                else
                {
                    invoker.Invoke((MethodInvoker)delegate
                    {
                        controling.Location = new Point(inVal, 0);
                    });
                }
            }

        }
开发者ID:DevinPower,项目名称:anotherTicketSystem,代码行数:53,代码来源:PanelSlide.cs

示例5: GenerateQuery

        private void GenerateQuery(Form1 form)
        {
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();

            int count = 0;
            bool containsUsername = true, addedUsername = false, Write = false;

            string query;

            if (!form.checkBox1.Checked && form.textBox2.Text != "Username field name")
            {
                containsUsername = false;
                form.checkBox1.Enabled = false;
                columns.Insert(0, form.textBox2.Text);
            }

            if (form.checkBox3.Checked)
            {
                query = "INSERT IGNORE INTO `" + form.textBox1.Text + "` (";
            }
            else
            {
                query = "INSERT INTO `" + form.textBox1.Text + "` (";
            }

            //Add all the columns into a single string
            for (int i = 0; i < columns.Count; i++)
            {
                query += "`" + columns[i] + "`" + ",";
            }

            //Remove extra trailing comma (,)
            query = query.Remove(query.Length - 1);

            query += ") VALUES ";

            //Create a new string to store the values
            string Finalquery = query + "(";

            StreamWriter file = new StreamWriter(outputDir.ToString());

            file.Write("/*\t\t*********************************************\r\n");
            file.Write("\t\t*											*\r\n");
            file.Write("\t\t*			Generated by Ini->Sql			*\r\n");
            file.Write("\t\t*			Created by GtakillerIV			*\r\n");
            file.Write("\t\t*											*\r\n");
            file.Write("\t\t**********************************************\r\n*/\r\n");

            int dataLine = 0;
            List<string> data = new List<string>();
            string Line = null;
            float perc = 0.0f;

            int accsDone = 0;
            int s;
            float f;
            #region loop through .ini file and generate query
            foreach (var fi in dir.GetFiles("*.ini"))
            {
                if (thread1.CancellationPending)
                {
                    stoppedThread = true;
                    break;
                }

                if (fi.Length == 0)// Is the .ini file empty?
                {
                    form.Invoke((MethodInvoker)delegate{
                        form.listBox2.Items.Add("Skipping " + fi.Name + " due to it being empty.");
                    });
                    count++;
                    accsDone++;
                    continue;
                }
                //Console.WriteLine("File: " + fi.Name);
                var lines = File.ReadLines(fi.FullName);

                foreach (var line in lines)
                {
                    if (Regex.Match(line, @"^[\w]").Success)
                    {
                        if (containsSpaces)
                        {
                            Line = line.Remove(0, line.IndexOf("=") + 2);
                        }
                        else
                        {
                            Line = line.Remove(0, line.IndexOf("=") + 1);
                        }
                        Line = Line.Trim();
                        Line = Line.Replace("\"", string.Empty);

                        // Ignore .ini comments

                        if (Line.Contains(";")) Line = Line.Remove(Line.IndexOf(";"));
                        else if (Line.Contains("#")) Line = Line.Remove(Line.IndexOf("#"));

                        Line = Line.Replace("\u0001", "");//Get rid of SOH

//.........这里部分代码省略.........
开发者ID:GtakillerIV,项目名称:IniToSql,代码行数:101,代码来源:Parser.cs

示例6: RunForm2

 public void RunForm2(Form1 Info, string msg)
 {
     if (Info.InvokeRequired)
     {
         form2Delegate DDD = new form2Delegate(RunForm2);
         Info.Invoke(DDD, new object[] { Info, msg });
     }
     else
     {
         Form2 f2 = new Form2(msg);
         f2.ShowDialog(this);
     }
 }
开发者ID:Cagyo,项目名称:domain-checker,代码行数:13,代码来源:Form1.cs

示例7: RunForm3

 private void RunForm3(Form1 Info, int k, int n)
 {
     if (Info.InvokeRequired)
     {
         form3Delegate DDD = new form3Delegate(RunForm3);
         Info.Invoke(DDD, new object[] { Info, k, n });
     }
     else
     {
         Form3 f3 = new Form3("Импортировано " + k.ToString() + " из " + n + " записей");
         f3.ShowDialog(this);
     }
 }
开发者ID:Cagyo,项目名称:domain-checker,代码行数:13,代码来源:Form1.cs

示例8: farthestInsertion

        public static void farthestInsertion(List<Edge> edgelist, List<node> nodelist, node startnode, Form1 f)
        {
            Thread thisThread = Thread.CurrentThread;
            int count = nodelist.Count();
            Edge greatestEdge = edgelist[0];
            List<node> markednodes = new List<node>();
            List<Edge> Route = new List<Edge>();
            f.route = Route;
            List<node> nodelistcopy = new List<node>(nodelist);
            f.secondThread = thisThread;
            f.marked = markednodes;

            markednodes.Add(startnode);
            nodelist.Remove(startnode);

            for (int i = 0; i < edgelist.Count(); i++)
            {
                if (edgelist[i].FromNode == startnode)
                {
                    greatestEdge = edgelist[i];
                    break;
                }
            }
            for (int i = 0; i < edgelist.Count(); i++)
            {
                if (edgelist[i].FromNode == startnode)
                {
                    if (edgelist[i].distance > greatestEdge.distance)
                        greatestEdge = edgelist[i];
                }
            }

            Route.Add(greatestEdge);
            Route.Add(new Edge(greatestEdge.ToNode, greatestEdge.FromNode));

            markednodes.Add(greatestEdge.ToNode);
            nodelist.Remove(greatestEdge.ToNode);

            f.Invoke(f.addPanelDelegate);

            Edge NodetoEdgeStart;
            Edge NodetoEdgeEnd;
            Edge NodetoEdge2Start;
            Edge NodetoEdge2End;

            foreach (node item in nodelist)
            {
                NodetoEdgeStart = edgelist.Find(i => ((i.ToNode == item) && (i.FromNode == startnode)));
                float CrossProduct = Math.Abs((greatestEdge.xdif * NodetoEdgeStart.ydif) - (greatestEdge.ydif * NodetoEdgeStart.xdif));
                item.ClosestEdgeDist = CrossProduct / greatestEdge.distance;
                item.ClosestEdge = greatestEdge;
            }
            node closestnode = nodelist[0];

            foreach (node item in nodelist)
            {
                if (item.ClosestEdgeDist < closestnode.ClosestEdgeDist)
                {
                    closestnode = item;
                }
            }
            markednodes.Add(closestnode);
            nodelist.Remove(closestnode);

            Route.Remove(Route[0]);

            Route.Insert(0, new Edge(closestnode, greatestEdge.ToNode));
            Route.Insert(0, new Edge(greatestEdge.FromNode, closestnode));

            f.Invoke(f.refresherDelegate);

            while (Route.Count() < count)
            {
                closestnode = nodelist[0];
                List<node> nodelistcopy2 = new List<node>(nodelist);
                Edge edge2;

                foreach (node item in nodelistcopy2)
                {
                    foreach (Edge edge in Route)
                    {
                        NodetoEdgeStart = edgelist.Find(i => ((i.ToNode == item) && (i.FromNode == edge.FromNode)));
                        NodetoEdgeEnd = edgelist.Find(i => ((i.ToNode == edge.ToNode) && (i.FromNode == item)));
                        float CrossProduct = Math.Abs((edge.xdif * NodetoEdgeStart.ydif) - (edge.ydif * NodetoEdgeStart.xdif));
                        float D = CrossProduct / edge.distance;
                        float Dotproduct = edge.xdif * NodetoEdgeStart.xdif + edge.ydif * NodetoEdgeStart.ydif;
                        float t = Dotproduct / (edge.distance * edge.distance);
                        edge2 = Route.Find(i => (i.ToNode == edge.FromNode));
                        NodetoEdge2Start = edgelist.Find(i => ((i.ToNode == item) && (i.FromNode == edge2.FromNode)));
                        NodetoEdge2End = edgelist.Find(i => ((i.ToNode == edge2.ToNode) && (i.FromNode == item)));
                        float D2 = NodetoEdge2Start.distance + NodetoEdge2End.distance + edge.distance;
                        float D1 = NodetoEdgeStart.distance + NodetoEdgeEnd.distance + edge2.distance;

                        if ((t > 0) && (t < 1))
                        {
                            if (!Route.Contains(item.ClosestEdge))
                            {
                                item.ClosestEdgeDist = D;
                                item.ClosestEdge = edge;
                            }
//.........这里部分代码省略.........
开发者ID:billwalden,项目名称:TravelingSalesman,代码行数:101,代码来源:Driver.cs


注:本文中的Form1.Invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。