コード例 #1
0
 private void btnRemoveCarStream_Click(object sender, EventArgs e)
 {
     mouseMode             = WhatToDo.RemoveCarStream;
     RemoveCarStreamToggle = true;
     this.cl.ActiveGrid.GetAllCarStreamStartPoints();
     this.Refresh();
 }
コード例 #2
0
 public YourMessageHandler(IBus bus, WhatToDo whatToDo, ManualResetEvent messageHandledGood, Action <string> callback)
 {
     _bus                = bus;
     _callback           = callback;
     _whatToDo           = whatToDo;
     _messageHandledGood = messageHandledGood;
 }
コード例 #3
0
    protected virtual void ChasePlayer()
    {
        navMeshAgent.SetDestination(target.transform.position);
        WhatToDo whatToDo = strategy.GetNextAction(targetMask, target.HitTargetPoint, projectileSpawnPoint.position,
                                                   navMeshAgent.remainingDistance, attack.Range, attack.Couldown <= 0f);

        bool hasToLookAtTarget = false;

        switch (whatToDo)
        {
        case WhatToDo.BASIC_ATTACK:
            PerformAttack();
            break;

        case WhatToDo.MOVE_BASIC:
            navMeshAgent.stoppingDistance = attack.Range - 0.5f;
            break;

        case WhatToDo.FACE_TARGET:
            hasToLookAtTarget = true;
            break;

        default:        // move closer
            navMeshAgent.stoppingDistance = 0.5f;
            break;
        }

        // if the enemy is performing a non frozen attack or if he doesn't need to move to attack the player
        if (hasToLookAtTarget || (isFrozen && !isRotationFrozen && isAttacking))
        {
            transform.LookAt(target.transform);
        }
    }
コード例 #4
0
 public static Task <ClimbingContext2> InitExistingDatabase(string connectionString, String applicationAdminUser, String applicationAdminPassword,
                                                            WhatToDo whatToDo, ProgressNotifier notifier = null, CancellationToken?token = null)
 {
     return(BaseContext.InitContextOnExistingDBAsync(connectionString, whatToDo,
                                                     cnString => new ClimbingContext2(cnString),
                                                     cnString => new ClimbingContext2(cnString, false, false, null, null),
                                                     applicationAdminUser, applicationAdminPassword, notifier, token ?? CancellationToken.None)
            .ContinueWith(tsk => (ClimbingContext2)tsk.Result, token ?? CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Current));
 }
コード例 #5
0
 private void WhatToDo_ItemCheck(object sender, ItemCheckEventArgs e)
 {
     for (int i = 0; i < WhatToDo.Items.Count; ++i)
     {
         if (i != e.Index)
         {
             WhatToDo.SetItemChecked(i, false);
         }
     }
 }
コード例 #6
0
        public Form1()
        {
            InitializeComponent();
            WhatToDo.SetItemChecked(0, true);
            #region Adding to Form

            this.Controls.Add(Class_Screen);
            #endregion
            setup();
        }
コード例 #7
0
 private void btnAddEditPedestrian_Click(object sender, EventArgs e)
 {
     foreach (Button btn in this.gpGrid.Controls.OfType <Button>())
     {
         btn.Enabled = false;
     }
     this.cl.ActiveGrid.SetPossiblePedestrianStreams();
     mouseMode = WhatToDo.AddEditPedestrianStreamStart;
     this.Refresh();
 }
コード例 #8
0
        private void TitleNextBtn_Click(object sender, EventArgs e)
        {
            int i = WhatToDo.CheckedItems.Count;

            for (i = 0; i < WhatToDo.Items.Count; i++)
            {
                if (WhatToDo.GetItemChecked(i))
                {
                    changePage(i + 1);
                }
            }
        }
コード例 #9
0
 public static Task InitDatabaseAsync(String serverName, String databaseName,
                                      String sqlServerUser, String sqlServerPassword,
                                      String applicationAdminUser, String applicationAdminPassword,
                                      WhatToDo whatToDo, ProgressNotifier notifier = null, CancellationToken?token = null)
 {
     return(BaseContext.InitDatabaseAsync(serverName, databaseName, PROJECT_NAME,
                                          sqlServerUser, sqlServerPassword, applicationAdminUser, applicationAdminPassword,
                                          whatToDo,
                                          cnString => new ClimbingContext2(cnString),
                                          cnString => new ClimbingContext2(cnString, false, false, null, null),
                                          notifier, token ?? CancellationToken.None));
 }
コード例 #10
0
        public MainForm()
        {
            this.InitializeComponent();
            PossibleEndPoints = new List <Point>();
            SelectedEndPoint  = new Point(0, 0);
            this.selectedPedestrianStartPoint = new Point(0, 0);
            EditCarStreamToggle = false;
            this.toolStrip1.AllowItemReorder = true;
            //SET FORM STYLES FOR AVOIDING FLICKERING ISSUES
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
            this.st   = new Stopwatch();
            mouseMode = WhatToDo.None;
            //EVENTS
            this.MouseDown     += this.GridMouseDown_Down;
            this.DoubleBuffered = true;
            this.UpdateStyles();

            //INITIALIZE OF FIRST GRID
            this.tabButton1            = new ToolStripButton();
            this.tabButton1.Text       = "Unnamed Grid1";
            this.tabButton1.Name       = this.tabButton1.Text;
            this.tabButton1.Font       = new Font("Roboto", 10);
            this.tabButton1.ForeColor  = Color.Blue;
            this.tabButton1.Click     += this.CommonChangeTab_Click;
            this.tabButton1.MouseDown += this.CommonCloseTab_Click;
            this.toolStrip1.Items.Add(this.tabButton1);

            #region DESIGN

            //DESIGN
            this.Location                          = new Point(0, 0);
            this.gpTools.ForeColor                 = Color.FromArgb(77, 188, 233);
            this.gpGrid.ForeColor                  = Color.FromArgb(77, 188, 233);
            this.label1.ForeColor                  = Color.FromArgb(77, 188, 233);
            this.label2.ForeColor                  = Color.FromArgb(77, 188, 233);
            this.btnAddSimple.BackColor            = Color.FromArgb(95, 90, 92);
            this.btnAddComplex.BackColor           = Color.FromArgb(95, 90, 92);
            this.btnRemoveCrossing.BackColor       = Color.FromArgb(95, 90, 92);
            this.btnAddEditStream.BackColor        = Color.FromArgb(95, 90, 92);
            this.btnRemoveCarStream.BackColor      = Color.FromArgb(95, 90, 92);
            this.btnRemoveAllCarStreams.BackColor  = Color.FromArgb(95, 90, 92);
            this.btnAddEditPedestrian.BackColor    = Color.FromArgb(95, 90, 92);
            this.btnRemovePedestrian.BackColor     = Color.FromArgb(95, 90, 92);
            this.btnRemoveAllPedestrians.BackColor = Color.FromArgb(95, 90, 92);
            this.btnClearGrid.BackColor            = Color.FromArgb(162, 18, 47);
            this.btnClearGrid.ForeColor            = Color.FromArgb(77, 188, 233);

            #endregion
        }
コード例 #11
0
        //funktioniert das hinzufügen? wird überprüft mit einem OkObjectResult
        public void TestMethod()
        {
            WhatToDo needed = new WhatToDo();

            needed.DeleteOneItem(99);

            Person         person = new Person(99, "prenametest", "surnametest", "*****@*****.**");
            OkObjectResult result = (OkObjectResult)needed.CreatePerson(person);
            OkObjectResult issame = new OkObjectResult("Person with PersonID 99 and Name prenametest surnametest was created!");

            Console.WriteLine(result.GetType());
            Console.WriteLine(issame.GetType());

            Assert.AreEqual(result.GetType(), issame.GetType());
        }
コード例 #12
0
        private void btnAddEditStream_Click(object sender, EventArgs e)
        {
            foreach (Crossing crozz in this.cl.ActiveGrid.ListOfCrossings)
            {
                this.cl.ActiveGrid.MakeNeighbours(crozz);
            }
            this.cl.ActiveGrid.SetAllStartPoints();
            this.cl.ActiveGrid.AllRoads.Clear();
            EditCarStreamToggle = true;
            //
            //FormNewStream.Show();

            mouseMode = WhatToDo.AddEditCarStream;
            this.Invalidate();
        }
コード例 #13
0
    public static void MyMethod(WhatToDo what)
    {
        switch (what)
        {
        case WhatToDo.Something:
            Struct1 param1 = new Struct1();
            MygenericMethod(param1);
            break;

        case WhatToDo.SomethingElse:
            Struct2 param2 = new Struct2();
            MygenericMethod(param2);
            break;
        }
    }
        public void DoesNotReceiveSameFailedMessageOverAndOver()
        {
            var events   = new ConcurrentQueue <string>();
            var whatToDo = new WhatToDo();

            var messageHandledGood = new ManualResetEvent(false);

            _activator.Register((bus, context) => new YourMessageHandler(bus, whatToDo, messageHandledGood, text =>
            {
                events.Enqueue(text);
                Console.WriteLine(text);
            }));

            _activator.Bus.SendLocal(new YourMessage()).Wait();

            messageHandledGood.WaitOrDie(TimeSpan.FromSeconds(6));
        }
コード例 #15
0
        protected override void SetInitializer(WhatToDo whatToDo)
        {
            switch (whatToDo)
            {
            case WhatToDo.CreateOrUpdate:
                Database.SetInitializer <ClimbingContext2>(new MigrateDatabaseToLatestVersion <ClimbingContext2, ClimbingContextMigration2>(true));
                return;

            case WhatToDo.LeaveAsIs:
                Database.SetInitializer <ClimbingContext2>(new NullDatabaseInitializer <ClimbingContext2>());
                return;

            default:
                Database.SetInitializer <ClimbingContext2>(new DropCreateDatabaseAlways <ClimbingContext2>());
                return;
            }
        }
コード例 #16
0
ファイル: FacebookHandler.cs プロジェクト: wattson-coder/TD
 /// <summary>
 /// Share a link on Facebook
 /// </summary>
 public void ShareLink()
 {
     if (FB.IsLoggedIn)
     {
         FB.ShareLink(
             new Uri("https://play.google.com/store/apps/details?id=com.vinh.tap"),
             "Pet Up Up!!!",
             "I'm playing this great game!",
             callback: ShareCallback
             );
     }
     else
     {
         FacebookHandler.Instance.FBLogin();
         TO_DO = WhatToDo.Share;
     }
 }
コード例 #17
0
        public void ConnectionEstablished()
        {
            WhatToDo needed = new WhatToDo();

            try
            {
                using (SqlConnection connection = new SqlConnection(needed.GetSqlConnectionString().ConnectionString))
                {
                    connection.Open();
                    //Gegenteil von Assert.Fail
                    return;
                }
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
コード例 #18
0
 private void btnAddComplex_Click(object sender, EventArgs e)
 {
     mouseMode = WhatToDo.ComplexCrossing;
 }
コード例 #19
0
ファイル: cmc.cs プロジェクト: andyhebear/Csharp-Parser
        static void Main(string[] args)
        {
            WhatToDo            whatToDo = WhatToDo.OnlyParse;
            List <String>       files    = new List <String>();
            List <Parser.Error> errors   = new List <Parser.Error>();
            String skipToFile            = null;
            bool   useMono   = false;
            bool   showUsage = false;

            for (int i = 0; i < args.Length; i++)
            {
                String arg = args[i];
                if (arg == "-O")
                {
                    whatToDo = WhatToDo.PrintToScreen;
                }
                else if (arg == "-F")
                {
                    whatToDo = WhatToDo.WriteToFiles;
                }
                else if (arg == "-C")
                {
                    whatToDo = WhatToDo.Compile;
                }
                else if (arg == "--skipto")
                {
                    if (i + 1 >= args.Length)
                    {
                        Console.WriteLine("--skipto option is missing the file argument!");
                        return;
                    }
                    skipToFile = args[++i];
                }
                else if (arg == "--mono")
                {
                    useMono = true;
                }
                else if (arg == "--help")
                {
                    showUsage = true;
                    break;
                }
                else if (File.Exists(arg))
                {
                    files.Add(arg);
                }
                else if (Directory.Exists(arg))
                {
                    files.AddRange(Directory.GetFiles(arg, "*.cs", SearchOption.AllDirectories));
                }
                else
                {
                    Console.WriteLine(arg + " is neither a file nor a directory!");
                    return;
                }
            }

            if (files.Count == 0 || showUsage)
            {
                if (!showUsage)
                {
                    Console.WriteLine("No files specified!\n");
                }
                Console.WriteLine("Usage: cmc [options] [files]\n"
                                  + "Where files is a list of files and/or directories.\n"
                                  + "Options:\n"
                                  + " -O                 Print result to screen\n"
                                  + " -F                 Write results to files\n"
                                  + " -C                 Compile result\n"
                                  + " --skipto <file>    Skips parsing until the specified file\n"
                                  + " --mono             Executes the tests with Mono\n"
                                  + "                    (mono must be in the path)\n");
                return;
            }

            Console.WriteLine("Found " + files.Count + " files.");

            Stopwatch sw = new Stopwatch();

            sw.Reset();

            bool skip = skipToFile != null;

            foreach (string fileName in files)
            {
                if (skip)
                {
                    if (fileName.EndsWith(skipToFile))
                    {
                        if (fileName.Length > skipToFile.Length)
                        {
                            char prevChar = fileName[fileName.Length - skipToFile.Length - 1];
                            if (prevChar == Path.DirectorySeparatorChar || prevChar == Path.AltDirectorySeparatorChar)
                            {
                                skip = false;
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else
                        {
                            skip = false;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                sw.Start();
                //Console.WriteLine(fileName);
                ParseFile(fileName, errors, whatToDo, useMono); // multi-thread this? :)
                sw.Stop();
            }

            Console.WriteLine("\n\nTime parsing : " + sw.Elapsed + ", for " + files.Count + " file(s).\n");

            if (errors.Count == 0)
            {
                Console.WriteLine("No errors.");
            }
            else
            {
                Console.WriteLine("The following errors occurred:");
                PrintErrors(errors);
            }
#if DEBUG
            Console.ReadKey();
#endif
        }
コード例 #20
0
ファイル: cmc.cs プロジェクト: andyhebear/Csharp-Parser
        private static void ParseFile(string fileName, List <Parser.Error> errors, WhatToDo whatToDo, bool useMono)
        {
            bool   createExe          = true;
            String compilerOptionsStr = "";
            String basePath           = Path.GetDirectoryName(fileName) + Path.DirectorySeparatorChar;

            if (basePath.Length == 1)
            {
                basePath = "";
            }
            String outAssembly = Path.GetFileNameWithoutExtension(fileName) + ".exe";

            List <String> files = new List <string>();

            files.Add(fileName);

            String[] compilerOptions, dependencies;
            if (!GetExtraOptions(fileName, out compilerOptions, out dependencies))
            {
                Console.WriteLine("GetExtraOptions failed!");
            }
            if (compilerOptions != null)
            {
                foreach (String compOpt in compilerOptions)
                {
                    if (compOpt.Length == 0)
                    {
                        continue;
                    }
                    if (compOpt[0] != '-')
                    {
                        files.Add(basePath + compOpt);
                    }
                    else if (compOpt == "-t:library")
                    {
                        createExe   = false;
                        outAssembly = Path.GetFileNameWithoutExtension(fileName) + ".dll";
                    }
                    else if (compOpt == "-t:module")
                    {
                        createExe           = false;
                        compilerOptionsStr += "/t:module ";
                        outAssembly         = Path.GetFileNameWithoutExtension(fileName) + ".netmodule";
                    }
                    else if (compOpt == "-unsafe")
                    {
                        compilerOptionsStr += "/unsafe ";
                    }
                    else if (compOpt.StartsWith("-r:"))
                    {
                        compilerOptionsStr += "/" + compOpt.Substring(1) + " ";
                    }
                    else
                    {
                        int colonPos = compOpt.IndexOf(':');
                        if (colonPos == -1)
                        {
                            continue;
                        }

                        String optionName = compOpt.Substring(1, colonPos - 1);
                        if (optionName != "res" && optionName != "linkresource" && optionName != "addmodule" &&
                            optionName != "keyfile")
                        {
                            continue;
                        }

                        String optFileName;
                        String rest     = compOpt.Substring(optionName.Length + 2);
                        int    commaPos = rest.IndexOf(',');
                        if (commaPos == -1)
                        {
                            optFileName = rest;
                            rest        = "";
                        }
                        else
                        {
                            optFileName = rest.Substring(0, commaPos);
                            rest        = rest.Substring(commaPos);
                        }
                        compilerOptionsStr += "/" + optionName + ":\"" + basePath + optFileName + "\"" + rest + " ";
                    }
                }
            }

            String[] unparsedFiles = new String[files.Count];
            for (int i = 0; i < files.Count; i++)
            {
                CompilationUnitNode cu = ParseUnit(files[i], errors);
                if (cu == null)
                {
                    return;
                }

                StringBuilder sb = new StringBuilder();
                cu.ToSource(sb);
                unparsedFiles[i] = sb.ToString();
            }

            //Console.WriteLine(toks + "\n\n");
            //Console.WriteLine(p.CurrentState + "\n\n");

            if (whatToDo == WhatToDo.PrintToScreen)
            {
                Console.WriteLine();
                foreach (String unparsedFile in unparsedFiles)
                {
                    Console.WriteLine(unparsedFile);
                }
            }
            else if (whatToDo == WhatToDo.Compile)
            {
                CSharpCodeProvider compiler   = new CSharpCodeProvider();
                CompilerParameters compParams = new CompilerParameters();
                compParams.ReferencedAssemblies.Add("System.dll");
                compParams.ReferencedAssemblies.Add("System.XML.dll");
                compParams.ReferencedAssemblies.Add("System.Data.dll");
                if (createExe)
                {
                    compParams.GenerateExecutable = true;
                }

                if (basePath.Length > 0)
                {
                    compilerOptionsStr += "/lib:\"" + basePath.Substring(0, basePath.Length - 1) + "\" ";
                }
                compParams.OutputAssembly  = basePath + outAssembly;
                compParams.CompilerOptions = compilerOptionsStr;
                CompilerResults res = null;
                try
                {
                    res = compiler.CompileAssemblyFromSource(compParams, unparsedFiles);
                }
                catch (BadImageFormatException ex)
                {
                    if (compilerOptionsStr.Contains("/t:module"))
                    {
                        AddError(errors, fileName, "\nMono tried to load a module as an assembly\n"
                                 + "(see https://bugzilla.novell.com/show_bug.cgi?id=353536)");
                    }
                    else
                    {
                        AddError(errors, fileName, ex.Message);
                    }
                    return;
                }
                catch (Exception ex)
                {
                    AddError(errors, fileName, ex.Message);
                    return;
                }
                if (res.Errors.HasErrors)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append("\nIllegal C# source code generated: ");
                    sb.Append(res.Errors.Count.ToString());
                    sb.Append(" Errors:\n");
                    foreach (CompilerError error in res.Errors)
                    {
                        sb.Append("Line: ");
                        sb.Append(error.Line.ToString());
                        sb.Append(" - ");
                        sb.Append(error.ErrorText);
                        sb.Append('\n');
                    }
                    AddError(errors, fileName, sb.ToString());
                    return;
                }
                Console.Write(". Compiled.");

                if (compParams.GenerateExecutable)
                {
                    Console.Write(" Testing");
                    ProcessStartInfo psi;
                    if (useMono)
                    {
                        psi = new ProcessStartInfo("mono", outAssembly);
                    }
                    else
                    {
                        psi = new ProcessStartInfo(basePath + outAssembly);
                    }

                    psi.CreateNoWindow   = true;
                    psi.UseShellExecute  = false;
                    psi.WorkingDirectory = basePath;
                    using (Process proc = Process.Start(psi))
                    {
                        for (int i = 0; i < 5 && !proc.HasExited; i++)
                        {
                            Console.Write('.');
                            proc.WaitForExit(1000);
                        }
                        if (!proc.HasExited)
                        {
                            proc.Kill();
                            AddError(errors, fileName, "Test seems to hang!");
                        }
                        else if (proc.ExitCode != 0)
                        {
                            AddError(errors, fileName, "Test failed! Exit code = " + proc.ExitCode);
                        }
                        else
                        {
                            Console.WriteLine(" Succeeded!");
                        }
                    }
                }
            }
            else if (whatToDo == WhatToDo.WriteToFiles)
            {
                for (int i = 0; i < files.Count; i++)
                {
                    String path = files[i].Substring(9);
                    Console.WriteLine(". Writing " + path);
                    Directory.CreateDirectory(Path.GetDirectoryName(path));
                    using (StreamWriter writer = new StreamWriter(path))
                        writer.WriteLine(unparsedFiles[i]);
                }
            }

            /*            TestVisitorVisitor visitor = new TestVisitorVisitor();
             *
             *          // if you forget to override the method 'public override object AcceptVisitor(AbstractVisitor visitor, object data)'
             *          // it will throw an exception
             *          cu.AcceptVisitor(visitor, null);*/
        }
コード例 #21
0
ファイル: Synchronizer.cs プロジェクト: nishanth2143/chorus
 private void ExplainAndThrow(Exception exception, WhatToDo whatToDo, string explanation, params object[] args)
 {
     throw new SynchronizationException(exception, whatToDo, string.Format(explanation, args));
 }
コード例 #22
0
ファイル: Synchronizer.cs プロジェクト: nishanth2143/chorus
 public SynchronizationException(Exception exception, WhatToDo whatToDo, string explanation, params object[] args)
     : base(string.Format(explanation, args), exception)
 {
     WhatToDo = whatToDo;
 }
コード例 #23
0
ファイル: Synchronizer.cs プロジェクト: JessieGriffin/chorus
 private void ExplainAndThrow(Exception exception, WhatToDo whatToDo, string explanation, params object[] args)
 {
     throw new SynchronizationException(exception, whatToDo, string.Format(explanation, args));
 }
コード例 #24
0
ファイル: Synchronizer.cs プロジェクト: JessieGriffin/chorus
 public SynchronizationException(Exception exception, WhatToDo whatToDo, string explanation, params object[] args)
     : base(string.Format(explanation, args), exception)
 {
     WhatToDo = whatToDo;
 }
コード例 #25
0
 private void btnRemovePedestrian_Click(object sender, EventArgs e)
 {
     mouseMode = WhatToDo.RemovePedestrianStream;
 }
コード例 #26
0
ファイル: cmc.cs プロジェクト: andyhebear/Csharp-Parser
        private static void ParseFile(string fileName, List<Parser.Error> errors, WhatToDo whatToDo, bool useMono)
        {
            bool createExe = true;
            String compilerOptionsStr = "";
            String basePath = Path.GetDirectoryName(fileName) + Path.DirectorySeparatorChar;
            if (basePath.Length == 1) basePath = "";
            String outAssembly = Path.GetFileNameWithoutExtension(fileName) + ".exe";

            List<String> files = new List<string>();
            files.Add(fileName);

            String[] compilerOptions, dependencies;
            if (!GetExtraOptions(fileName, out compilerOptions, out dependencies))
            {
                Console.WriteLine("GetExtraOptions failed!");
            }
            if (compilerOptions != null)
            {
                foreach (String compOpt in compilerOptions)
                {
                    if (compOpt.Length == 0) continue;
                    if (compOpt[0] != '-')
                        files.Add(basePath + compOpt);
                    else if (compOpt == "-t:library")
                    {
                        createExe = false;
                        outAssembly = Path.GetFileNameWithoutExtension(fileName) + ".dll";
                    }
                    else if (compOpt == "-t:module")
                    {
                        createExe = false;
                        compilerOptionsStr += "/t:module ";
                        outAssembly = Path.GetFileNameWithoutExtension(fileName) + ".netmodule";
                    }
                    else if (compOpt == "-unsafe")
                        compilerOptionsStr += "/unsafe ";
                    else if (compOpt.StartsWith("-r:"))
                        compilerOptionsStr += "/" + compOpt.Substring(1) + " ";
                    else
                    {
                        int colonPos = compOpt.IndexOf(':');
                        if (colonPos == -1) continue;

                        String optionName = compOpt.Substring(1, colonPos - 1);
                        if (optionName != "res" && optionName != "linkresource" && optionName != "addmodule"
                                && optionName != "keyfile")
                            continue;

                        String optFileName;
                        String rest = compOpt.Substring(optionName.Length + 2);
                        int commaPos = rest.IndexOf(',');
                        if (commaPos == -1)
                        {
                            optFileName = rest;
                            rest = "";
                        }
                        else
                        {
                            optFileName = rest.Substring(0, commaPos);
                            rest = rest.Substring(commaPos);
                        }
                        compilerOptionsStr += "/" + optionName + ":\"" + basePath + optFileName + "\"" + rest + " ";
                    }
                }
            }

            String[] unparsedFiles = new String[files.Count];
            for (int i = 0; i < files.Count; i++)
            {
                CompilationUnitNode cu = ParseUnit(files[i], errors);
                if (cu == null) return;

                StringBuilder sb = new StringBuilder();
                cu.ToSource(sb);
                unparsedFiles[i] = sb.ToString();
            }

            //Console.WriteLine(toks + "\n\n");
            //Console.WriteLine(p.CurrentState + "\n\n");

            if (whatToDo == WhatToDo.PrintToScreen)
            {
                Console.WriteLine();
                foreach (String unparsedFile in unparsedFiles)
                    Console.WriteLine(unparsedFile);
            }
            else if (whatToDo == WhatToDo.Compile)
            {
                CSharpCodeProvider compiler = new CSharpCodeProvider();
                CompilerParameters compParams = new CompilerParameters();
                compParams.ReferencedAssemblies.Add("System.dll");
                compParams.ReferencedAssemblies.Add("System.XML.dll");
                compParams.ReferencedAssemblies.Add("System.Data.dll");
                if (createExe)
                    compParams.GenerateExecutable = true;

                if (basePath.Length > 0)
                    compilerOptionsStr += "/lib:\"" + basePath.Substring(0, basePath.Length - 1) + "\" ";
                compParams.OutputAssembly = basePath + outAssembly;
                compParams.CompilerOptions = compilerOptionsStr;
                CompilerResults res = null;
                try
                {
                    res = compiler.CompileAssemblyFromSource(compParams, unparsedFiles);
                }
                catch (BadImageFormatException ex)
                {
                    if (compilerOptionsStr.Contains("/t:module"))
                        AddError(errors, fileName, "\nMono tried to load a module as an assembly\n"
                            + "(see https://bugzilla.novell.com/show_bug.cgi?id=353536)");
                    else
                        AddError(errors, fileName, ex.Message);
                    return;
                }
                catch (Exception ex)
                {
                    AddError(errors, fileName, ex.Message);
                    return;
                }
                if (res.Errors.HasErrors)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append("\nIllegal C# source code generated: ");
                    sb.Append(res.Errors.Count.ToString());
                    sb.Append(" Errors:\n");
                    foreach (CompilerError error in res.Errors)
                    {
                        sb.Append("Line: ");
                        sb.Append(error.Line.ToString());
                        sb.Append(" - ");
                        sb.Append(error.ErrorText);
                        sb.Append('\n');
                    }
                    AddError(errors, fileName, sb.ToString());
                    return;
                }
                Console.Write(". Compiled.");

                if (compParams.GenerateExecutable)
                {
                    Console.Write(" Testing");
                    ProcessStartInfo psi;
                    if (useMono)
                        psi = new ProcessStartInfo("mono", outAssembly);
                    else
                        psi = new ProcessStartInfo(basePath + outAssembly);

                    psi.CreateNoWindow = true;
                    psi.UseShellExecute = false;
                    psi.WorkingDirectory = basePath;
                    using (Process proc = Process.Start(psi))
                    {
                        for (int i = 0; i < 5 && !proc.HasExited; i++)
                        {
                            Console.Write('.');
                            proc.WaitForExit(1000);
                        }
                        if (!proc.HasExited)
                        {
                            proc.Kill();
                            AddError(errors, fileName, "Test seems to hang!");
                        }
                        else if (proc.ExitCode != 0)
                        {
                            AddError(errors, fileName, "Test failed! Exit code = " + proc.ExitCode);
                        }
                        else Console.WriteLine(" Succeeded!");
                    }
                }
            }
            else if (whatToDo == WhatToDo.WriteToFiles)
            {
                for (int i = 0; i < files.Count; i++)
                {
                    String path = files[i].Substring(9);
                    Console.WriteLine(". Writing " + path);
                    Directory.CreateDirectory(Path.GetDirectoryName(path));
                    using (StreamWriter writer = new StreamWriter(path))
                        writer.WriteLine(unparsedFiles[i]);
                }
            }

            /*            TestVisitorVisitor visitor = new TestVisitorVisitor();

                        // if you forget to override the method 'public override object AcceptVisitor(AbstractVisitor visitor, object data)'
                        // it will throw an exception
                        cu.AcceptVisitor(visitor, null);*/
        }
コード例 #27
0
 //copy contructor
 public NonPlayer(bool enemy, bool sideEffect, int steps, Direction directions, WhatToDo wtd) : this(enemy, sideEffect, steps, directions)
 {
     this.wtd = wtd;
 }
コード例 #28
0
ファイル: Command.cs プロジェクト: gevorg96/IsUakr
 public void Add(WhatToDo todo, string queueName)
 {
     QueuesCommands.First(x => x.Key == todo).Value.Add(queueName);
     previousQueue = new KeyValuePair <WhatToDo, string>(todo, queueName);
 }
コード例 #29
0
 private void btnAddSimple_Click(object sender, EventArgs e)
 {
     mouseMode = WhatToDo.SimpleCrossing;
 }
コード例 #30
0
 protected abstract void SetInitializer(WhatToDo whatToDo);
コード例 #31
0
        private void GridMouseDown_Down(object sender, MouseEventArgs e)
        {
            Point p            = e.Location;
            Point pointClicked = new Point(0, 0);//To be used differently by the different cases

            if (e.Button == MouseButtons.Right)
            {
                mouseMode             = WhatToDo.None;
                RemoveCarStreamToggle = false;
                EditCarStreamToggle   = false;
            }
            if (((p.X >= 240) && (p.X <= 1140)) && ((p.Y >= 30) && (p.Y <= 710)))
            {
                int spotInput = this.cl.ActiveGrid.GetCrossingSlot(p);
                switch (mouseMode)
                {
                case WhatToDo.SimpleCrossing:
                    if (this.cl.ActiveGrid.IsSpotFree(p))
                    {
                        SimpleCrossing cr = new SimpleCrossing(this.cl.ActiveGrid.CrossingSlots[spotInput], spotInput);
                        this.cl.ActiveGrid.AddCrossing(cr, spotInput);
                        this.cl.ActiveGrid.MakeNeighbours(cr);
                        //Reset Mouse mode
                        this.cl.ActiveGrid.IsChanged = true;
                        this.UpdateToolStrip();
                    }
                    else
                    {
                        MessageBox.Show("This slot is already taken, place the crossing on an EMPTY one!");
                    }
                    this.Refresh();
                    break;

                case WhatToDo.ComplexCrossing:
                    if (this.cl.ActiveGrid.IsSpotFree(p))
                    {
                        ComplexCrossing crCom = new ComplexCrossing(this.cl.ActiveGrid.CrossingSlots[spotInput], spotInput);
                        this.cl.ActiveGrid.MakeNeighbours(crCom);
                        this.cl.ActiveGrid.AddCrossing(crCom, spotInput);
                        this.cl.ActiveGrid.IsChanged = true;
                        this.UpdateToolStrip();
                    }
                    else
                    {
                        MessageBox.Show("This slot is already taken, place the crossing on an EMPTY one!");
                    }
                    this.Refresh();
                    break;

                case WhatToDo.RemoveCrossing:
                    Crossing s = this.cl.ActiveGrid.GetCrossing(p);

                    if (this.cl.ActiveGrid.RemoveCrossing(s))
                    {
                        this.Invalidate();
                        this.cl.ActiveGrid.IsChanged = true;
                        this.UpdateToolStrip();
                    }
                    this.Refresh();
                    break;

                case WhatToDo.AddEditCarStream:
                    SelectedStartPoint = this.cl.ActiveGrid.GetStartingPoint(p);
                    if (SelectedStartPoint != new Point(0, 0))
                    {
                        this.cl.ActiveGrid.GetCrossing(SelectedStartPoint).UserChosenStartPoint = SelectedStartPoint;
                        this.cl.ActiveGrid.CreateRoads(this.cl.ActiveGrid.GetCrossing(SelectedStartPoint), new List <Point>(), new List <Crossing>());
                        this.formNewStream = new FormCarStream(ref this.cl, this);
                        this.formNewStream.Show();
                        this.cl.ActiveGrid.ListOfAllStartPoints.Clear();
                    }
                    else
                    {
                        SelectedStartPoint = this.cl.ActiveGrid.FindPointInList(p, this.cl.ActiveGrid.GetAllCarStreamStartPoints(), 10);
                        if (SelectedStartPoint != new Point(0, 0))
                        {
                            CarStream selectedCarStream = this.cl.ActiveGrid.GetCarStreamByStartPoint(SelectedStartPoint);
                            PossibleEndPoints  = this.cl.ActiveGrid.GetAllEndPointsWithStart(SelectedStartPoint);
                            this.formNewStream = new FormCarStream(ref this.cl, this, ref selectedCarStream);
                            this.formNewStream.Show();
                        }
                    }
                    this.Invalidate();
                    this.UpdateToolStrip();

                    break;

                case WhatToDo.AddEditCarStreamEnd:
                    pointClicked = this.cl.ActiveGrid.FindPointInList(p, this.cl.ActiveGrid.GetAllEndPointsWithStart(SelectedStartPoint), 10);
                    if (pointClicked != new Point(0, 0))
                    {
                        SelectedEndPoint = pointClicked;
                        this.formNewStream.Show();
                        PossibleEndPoints.Clear();
                        this.Refresh();
                        this.UpdateToolStrip();
                    }
                    break;

                case WhatToDo.RemoveCarStream:
                    pointClicked = this.cl.ActiveGrid.FindPointInList(p, this.cl.ActiveGrid.GetAllCarStreamStartPoints(), 10);
                    if (pointClicked != new Point(0, 0))
                    {
                        this.cl.ActiveGrid.RemoveCarStream(pointClicked);
                    }
                    RemoveCarStreamToggle = false;
                    this.Refresh();
                    break;

                case WhatToDo.AddEditPedestrianStreamStart:
                    foreach (List <Point> points in this.cl.ActiveGrid.ListOfPossiblePedestrianStreams)
                    {
                        pointClicked = this.cl.ActiveGrid.FindPointInList(p, points, 2);
                    }
                    if (pointClicked != new Point(0, 0))
                    {
                        this.selectedPedestrianStartPoint = pointClicked;
                        mouseMode = WhatToDo.AddEditPedestrianStreamEnd;
                    }
                    this.Refresh();
                    break;

                case WhatToDo.AddEditPedestrianStreamEnd:
                    foreach (List <Point> possiblePedestrianStream in this.cl.ActiveGrid.ListOfPossiblePedestrianStreams)
                    {
                        pointClicked = this.cl.ActiveGrid.FindPointInList(p, possiblePedestrianStream, 2);
                    }
                    if (pointClicked != new Point(0, 0))
                    {
                        this.cl.ActiveGrid.ListOfPedestrianStreams.Add(new PedestrianStream(this.selectedPedestrianStartPoint, this.selectedPedestrianEndPoint, 5));
                    }
                    mouseMode = WhatToDo.None;
                    this.Refresh();
                    break;

                case WhatToDo.None:

                    break;
                }
            }
            else
            {
                MessageBox.Show("Click inside!");
            }
        }
コード例 #32
0
ファイル: SelectionTool.cs プロジェクト: ykafia/Paint.Net4
 protected virtual WhatToDo GetWhatToDo(WhatToDo plannedAction, bool appending, GeometryList oldSelectionGeometry, PointDouble[] newPolygon) =>
 plannedAction;
コード例 #33
0
 private void btnRemoveCrossing_Click(object sender, EventArgs e)
 {
     mouseMode = WhatToDo.RemoveCrossing;
     this.Invalidate();
 }