Ejemplo n.º 1
0
 //利用该函数,静态地从仍何存在的IControllable建立控制器
 static public Controller From <T>(Existence <T> obj)
     where T : class, IControllable
 {
     return(new Controller(
                new Existence <IControllable>((IControllable)obj.Unwrap())
                ));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a shallow copy of the argument.
 /// </summary>
 /// <param name="toCopy">the object to copy</param>
 public Category(Category toCopy)
 {
     canDelete = toCopy.canDelete;
     id = toCopy.id;
     name = toCopy.name;
     exists = toCopy.exists;
 }
Ejemplo n.º 3
0
        private async void btnGenerateUniverse_Click(object sender, EventArgs e)
        {
            // this is meant to create the universe
            int number = 0;

            if (!int.TryParse(txtEntitiesNumber.Text, out number))
            {
                MessageBox.Show(String.Format("Please insert a valid integer {0} - {1}", 0, int.MaxValue));
                return;
            }
            universalTimeUnit             = 0;
            lblGenerating.Visible         = true;
            lblGenratingLabelOnly.Visible = true;

            statingPopulationNumber = number;
            IProgress <int> ProgressForNumberCreated = new Progress <int>(v =>
            {
                ShowUpdate(v);
            });

            currentExistence = await existenceManager.CreateLimitedOnePhaseExistence(number, 50, 50, 500, 500, ProgressForNumberCreated);

            lblGenerating.Visible         = false;
            lblGenratingLabelOnly.Visible = false;
            StartingTime = DateTime.Now;
        }
Ejemplo n.º 4
0
    //load when mouse clicked
    private void OnMouseDown()
    {
        var next_bird = this.GetBird();

        if (next_bird != null)
        {
            var temp = new Existence <Bird>(next_bird);
            this.Load(temp);
        }
    }
Ejemplo n.º 5
0
 //load the bird onto SlingShot. The slingshot's bullet cannot be NULL!!!
 //The existence simplify the implemantation. It ensures the load to change states.
 public void Load(Existence <Bird> bullet)
 {
     //since the bullet reflects the state, this ensures call only works under unloaded state
     if (!this.IsLoaded)
     {
         this.bullet                    = bullet.Unwrap();
         this.bullet.physicsLock        = true;
         this.bullet.transform.position = positioner.position;
     }
 }
        public async Task <Existence> CreateLimitedOnePhaseExistence(int numberOfEntities, int minX, int minY, int maxX, int maxY, IProgress <int> progress)
        {
            Existence existence = new Existence();

            if (maxX < 1)
            {
                throw new ArgumentException("Max X can't be less than 1");
            }
            if (maxY < 1)
            {
                throw new ArgumentException("Max Y can't be less than 1");
            }
            if (minX < 1)
            {
                throw new ArgumentException("Min X can't be less than 1");
            }
            if (minY < 1)
            {
                throw new ArgumentException("Min Y can't be less than 1");
            }

            existence.Phases.Add(new Phase("Real", PhaseType.Real, new Point(minX, minY), new Point(maxX, maxY)));
            await Task.Run(() =>
            {
                for (int i = 0; i < numberOfEntities; i++)
                {
                    int posX = 0;
                    int posY = 0;
                    do
                    {
                        posX = random.Next(minX, maxX);
                        posY = random.Next(minX, maxY);
                    }while (existence.Phases.First().UniversalObjectsInside.Where(j => DoOverlap(j.Position, new Point(posX, posY))).FirstOrDefault() != null);

                    existence.Phases.First().UniversalObjectsInside.Add(new Being(new Point(posX, posY)));
                    progress.Report(i + 1);
                }
            }
                           );

            return(existence);
        }
Ejemplo n.º 7
0
        private void btnProcess_Click(object sender, RoutedEventArgs e)
        {
            var analyzedWords = new List <DAL.Entities.AnalizedWord>();
            var highlighted   = new Dictionary <int, int>();

            txtSecondary.Text = string.Empty;

            TextRange textRange     = new TextRange(mainSearchInput.Document.ContentStart, mainSearchInput.Document.ContentEnd);
            var       txtRichText   = textRange.Text;
            var       listSentences = txtRichText.Split(new Char[] { '.', '!', '?', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).ToList();

            foreach (var sentence in listSentences)
            {
                var listWords = sentence.Split(new Char[] { ' ', ',', '"' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                analyzedWords.AddRange(Existence.GetConvertedWordsByText(listWords));
            }

            var unidentifiedWords = analyzedWords.Where(word => word.Exists == false).ToList();

            foreach (var word in unidentifiedWords)
            {
                var indexes = txtRichText.AllIndexesOf(word.Name);
                foreach (var index in indexes)
                {
                    if (!highlighted.Contains(index))
                    {
                        highlighted.Add(index.Key, index.Value);
                    }
                }
            }

            var txtRichSelection = mainSearchInput.Selection;

            txtRichSelection.ClearAllProperties();

            txtSecondary.Text = string.Join("\n", highlighted);
        }
Ejemplo n.º 8
0
        public Flat(string nam, double val, double ar, string loc, double we, double le, double ge, double inc, double outc, short gr, short na, short nf, Existence el) : base(nam, val, ar, loc, we, le, ge, inc, outc)
        {
            garages      = gr;
            nrApartments = na;
            nrFloors     = nf;

            if (el == Existence.yes)
            {
                elevator = true;
            }
            else
            {
                elevator = false;
            }
        }
Ejemplo n.º 9
0
        public Apartment(string nam, double val, double ar, string loc, double we, double le, double ge, double inc, double outc, short fl, short nr, short nb, Existence bal, Existence gr) : base(nam, val, ar, loc, we, le, ge, inc, outc)
        {
            floors      = fl;
            nrRooms     = nr;
            nrBathrooms = nb;

            if (bal == Existence.yes)
            {
                balcony = true;
            }
            else
            {
                balcony = false;
            }

            if (gr == Existence.yes)
            {
                garage = true;
            }
            else
            {
                garage = false;
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates a shallow copy of the argument.
 /// </summary>
 /// <param name="toCopy">the object to copy</param>
 public Contact(Contact toCopy)
 {
     uri = toCopy.uri;
     exists = toCopy.exists;
 }
Ejemplo n.º 11
0
        public void TestElementDoesNotExist()
        {
            SetUpFindElementsReturnsEmpty();

            Actor.AsksFor(Existence.Of(Locator)).Should().BeFalse();
        }
Ejemplo n.º 12
0
 public override void setExists(Existence exists)
 {
     this.exists = exists;
 }
Ejemplo n.º 13
0
 Controller(Existence <IControllable> control)
 {
     this.control = control.Unwrap();
 }
        public Existence CreateExistence()
        {
            Existence ex = new Existence();

            return(ex);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Form Constructor
        /// </summary>
        public Main()
        {
            InitializeComponent();
            Icon = global::TextureMaxLoadEditor.Properties.Resources.icon;

            #region Check for existing instanstance

            using (InitMain initialize = new InitMain())
            {
                if (!initialize.IsSingleInstance(Text))
                {
                    MessageBox.Show("Another instance of this application is already running.",
                        "Multiple application instances", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    requireExit = true;
                }
            }

            #endregion

            #region Check if FSX is running

            using (InitMain initialize = new InitMain())
            {
                if (initialize.IsProcessOpen("fsx"))
                {
                    fsxIsRunning = true;
                }
            }

            #endregion

            #region Integrity Checks

            #region Check File Existence and Hash

            using (Hash hash = new Hash())
            {
                if (File.Exists(Application.StartupPath + @"\Resources\core.resource"))
                {
                    if (hash.Match(Application.StartupPath + @"\Resources\core.resource", "DDAE1DD174117AC9ABADCBA70323590F77F67513"))
                    {
                        // Get the file lines one by one
                        string[] lines = File.ReadAllLines(Application.StartupPath + @"\Resources\core.resource");

                        for (int i = 0; i < lines.Length; i++)
                        {
                            // Split the line
                            string[] splitLine = lines[i].Split(';');

                            if (File.Exists(Application.StartupPath + splitLine[0]))
                            {
                                if (!hash.Match(Application.StartupPath + splitLine[0], splitLine[1]))
                                {
                                    // Show an error
                                    MessageBox.Show("The file " + splitLine[0] + " has been modified or is corrupt. Please reinstall the Texture Max Load Editor.",
                                        "Integrity Check", MessageBoxButtons.OK, MessageBoxIcon.Error);

                                    // Require an exit
                                    requireExit = true;
                                }
                            }
                            else
                            {
                                // Show an error
                                MessageBox.Show("The file " + splitLine[0] + " could not be found. Please reinstall the Texture Max Load Editor.",
                                    "Integrity Check", MessageBoxButtons.OK, MessageBoxIcon.Error);

                                // Require an exit
                                requireExit = true;
                            }
                        }
                    }
                    else
                    {
                        // Show an error
                        MessageBox.Show("The file core.resource has been modified or is corrupt. Please reinstall the Texture Max Load Editor.",
                            "Integrity Check", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        // Require an exit
                        requireExit = true;
                    }
                }
                else
                {
                    // Show an error
                    MessageBox.Show("The file core.resource could not be found. Please reinstall the Texture Max Load Editor.",
                        "Integrity Check", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    // Require an exit
                    requireExit = true;
                }
            }

            #endregion

            #region Check INI Files

            using (IniFile iniFile = new IniFile())
            {
                /// <switch>current profile</switch>
                iniFile.IniPath = Application.StartupPath + @"\locations.ini";

                if (!File.Exists(Application.StartupPath + @"\locations.ini"))
                {
                    // Copy the locations resource
                    File.Copy(Application.StartupPath + @"\Resources\locations.resource",
                        Application.StartupPath + @"\locations.ini", false);
                }

                if (!File.Exists(Application.StartupPath + iniFile.ReadValue("PROFILES", "0")))
                {
                    try
                    {
                        if (!Directory.Exists(Application.StartupPath + @"\Profiles\"))
                        {
                            Directory.CreateDirectory(Application.StartupPath + @"\Profiles\");
                        }

                        if (!File.Exists(Application.StartupPath + @"\Profiles\default.ini"))
                        {
                            // Copy the resource
                            File.Copy(Application.StartupPath + @"\Resources\profile.resource",
                                Application.StartupPath + @"\Profiles\default.ini", false);
                        }

                        // Write the new path value
                        iniFile.WriteValue("PROFILES", "0", @"\Profiles\default.ini");

                        // Success message
                        MessageBox.Show("The default profile specified in 'locations.ini' could not be found. A new one has been automatically generated.",
                            "Integrity Check", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    catch
                    {
                        // Error message
                        MessageBox.Show("The default profile specified in 'locations.ini' could not be found and a new profile could not be generated. Please reinstall the Texture Max Load Editor.",
                            "Integrity Check", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            #endregion

            #region Check INI Variables

            using (IniFile iniFile = new IniFile())
            {
                using (Existence existence = new Existence())
                {
                    /// <switch>current profile</switch>
                    iniFile.IniPath = Application.StartupPath + @"\locations.ini";

                    if (!Directory.Exists(iniFile.ReadValue("LOCATIONS", "exe")) &&
                        !Directory.Exists(iniFile.ReadValue("LOCATIONS", "cfg")) &&
                        !Directory.Exists(iniFile.ReadValue("LOCATIONS", "self")))
                    {
                        // Require a locations reset
                        iniFile.WriteValue("GENERAL", "reset", "1");
                    }
                }
            }

            #endregion

            #endregion

            #region Check For Reset Switch

            using (IniFile iniFile = new IniFile())
            {
                /// <switch>locations.ini</switch>
                iniFile.IniPath = Application.StartupPath + @"\locations.ini";

                if (iniFile.ReadValue("GENERAL", "reset") == "1")
                {
                    using (Locations.FSX fsxLocations = new Locations.FSX())
                    {
                        // Reset the location variables
                        iniFile.WriteValue("LOCATIONS", "exe", fsxLocations.GetExe());
                        iniFile.WriteValue("LOCATIONS", "cfg", fsxLocations.GetCfg());
                        iniFile.WriteValue("LOCATIONS", "self", Application.StartupPath);
                    }

                    try
                    {
                        if (File.Exists(iniFile.ReadValue("LOCATIONS", "cfg") + @"\exe.xml"))
                        {
                            string dateTime = DateTime.Now.ToString();
                            dateTime = dateTime.Replace("/", "");
                            dateTime = dateTime.Replace(" ", "_");
                            dateTime = dateTime.Replace(":", "");

                            if (!Directory.Exists(Application.StartupPath + @"\Backups\"))
                            {
                                Directory.CreateDirectory(Application.StartupPath + @"\Backups\");
                            }

                            // Make a copy of exe.xml
                            File.Copy(iniFile.ReadValue("LOCATIONS", "cfg") + @"\exe.xml", Application.StartupPath + @"\Backups\exe_xml_backup_" + dateTime + ".bak");
                        }
                    }
                    catch
                    {
                        // Show an error
                        MessageBox.Show("Unable to make a copy of exe.xml. The file has not been backed up.",
                            "Unable to backup exe.xml", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    // Set the reset value back to 0
                    iniFile.WriteValue("GENERAL", "reset", "0");
                }
            }

            #endregion

            #region Set Main Resolutions

            using (Resolutions resolutions = new Resolutions())
            {
                // Set the resolution list items
                resolutions.FillField(homeResolution, null);
            }

            #endregion

            #region Set Location Fields

            using (IniFile iniFile = new IniFile())
            {
                /// <switch>locations.ini</switch>
                iniFile.IniPath = Application.StartupPath + @"\locations.ini";

                // Set the location fields
                homeExePath.Text = iniFile.ReadValue("LOCATIONS", "exe");
                homeCfgPath.Text = iniFile.ReadValue("LOCATIONS", "cfg");
            }

            #endregion

            #region Switch Main Resolution To Current

            using (Resolutions resolutions = new Resolutions())
            {
                // Select the current resolution in fsx.cfg
                resolutions.SelectCurrentResolution(homeResolution, null);

                // Set the current value
                string[] selectedItem = homeResolution.SelectedItem.ToString().Split(' ');
                currentValue = selectedItem[0];
                selectedItem = null;
            }

            #endregion

            #region Check for exe.xml existence and entry

            using (IniFile iniFile = new IniFile())
            {
                ///<switch>locations.ini</switch>
                iniFile.IniPath = Application.StartupPath + @"\locations.ini";

                using (ExeXML exeXml = new ExeXML(iniFile.ReadValue("LOCATIONS", "cfg") + @"\exe.xml"))
                {
                    ///<switch>current profile</switch>
                    iniFile.IniPath = Application.StartupPath + iniFile.ReadValue("PROFILES", "0");

                    if (iniFile.ReadValue("OPTIONS.GENERAL", "runfsx") == "1")
                    {
                        // Check the existence of the document
                        exeXml.CheckExistence("Texture Max Load Editor", false, Application.ExecutablePath);
                    }
                    else
                    {
                        // Check the existence of the document
                        exeXml.CheckExistence("Texture Max Load Editor", true, Application.ExecutablePath);
                    }
                }
            }

            #endregion

            #region Minimize the Form

            using (IniFile iniFile = new IniFile())
            {
                /// <switch>current profile</switch>
                iniFile.IniPath = Application.StartupPath + @"\locations.ini";
                iniFile.IniPath = Application.StartupPath + iniFile.ReadValue("PROFILES", "0");

                if (iniFile.ReadValue("OPTIONS.GENERAL", "minimize") == "1")
                {
                    if (iniFile.ReadValue("OPTIONS.GENERAL", "sub") == "0")
                    {
                        if (fsxIsRunning)
                            this.WindowState = FormWindowState.Minimized;
                    }
                    else
                        this.WindowState = FormWindowState.Minimized;
                }
            }

            #endregion

            #region Auto Change

            using (IniFile iniFile = new IniFile())
            {
                /// <switch>current profile</switch>
                iniFile.IniPath = Application.StartupPath + @"\locations.ini";
                iniFile.IniPath = Application.StartupPath + iniFile.ReadValue("PROFILES", "0");

                if (iniFile.ReadValue("OPTIONS.AUTO", "auto") == "1")
                {
                    // Get the auto resolution
                    string autoResolution = iniFile.ReadValue("OPTIONS.AUTO", "resolution");

                    if (autoResolution != "")
                    {
                        /// <switch>fsx.cfg</switch>
                        iniFile.IniPath = Application.StartupPath + @"\locations.ini";
                        iniFile.IniPath = iniFile.ReadValue("LOCATIONS", "cfg") + @"\fsx.cfg";

                        // Set the Texture Max Load Value in fsx.cfg
                        iniFile.WriteValue("GRAPHICS", "TEXTURE_MAX_LOAD", autoResolution);

                        /// <switch>current profile</switch>
                        iniFile.IniPath = Application.StartupPath + @"\locations.ini";
                        iniFile.IniPath = Application.StartupPath + iniFile.ReadValue("PROFILES", "0");
                    }
                    else
                    {
                        // Show an error informing the user that the TML value has not been set
                        MessageBox.Show("Unable to set a null resolution. The Texture Max Load value has not been changed in fsx.cfg.",
                            "Null resolution", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    if (iniFile.ReadValue("OPTIONS.AUTO", "application") != "")
                    {
                        try
                        {
                            // Try to start the specified process
                            System.Diagnostics.Process.Start(iniFile.ReadValue("OPTIONS.AUTO", "application"));
                        }
                        catch
                        {
                            // Show an error informing the user that their application could not be started
                            MessageBox.Show("Unable to run the post auto change application you specified.",
                                "External process error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }

                    if (iniFile.ReadValue("OPTIONS.AUTO", "close") == "1")
                    {
                        // Set the seconds for the timer
                        autoSeconds = Int32.Parse(iniFile.ReadValue("MISCELLANEOUS", "autotime"));

                        // Require an exit
                        autoCounter = 0;
                        autoChangeExit = true;
                    }
                    else
                    {
                        // Make the auto counter negative
                        autoCounter = -1;
                    }
                }
            }

            #endregion
        }
Ejemplo n.º 16
0
 public ActionOnce(Existence <Action> action)
 {
     this.action = action.Unwrap();
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Creates a shallow copy of the argument.
 /// </summary>
 /// <param name="toCopy">the object to copy</param>
 public User(User toCopy)
 {
     avatarHash = toCopy.avatarHash;
     currentStatus = toCopy.currentStatus;
     dateOfBirth = toCopy.dateOfBirth;
     displayName = toCopy.displayName;
     ecoid = toCopy.ecoid;
     emailAddress = toCopy.emailAddress;
     gender = toCopy.gender;
     installedApps = toCopy.installedApps;
     location = toCopy.location;
     maxVcardSize = toCopy.maxVcardSize;
     nickname = toCopy.nickname;
     nowPlayingMessage = toCopy.nowPlayingMessage;
     personalMessage = toCopy.personalMessage;
     personalMessageTimestamp = toCopy.personalMessageTimestamp;
     personalMessageTpaUri = toCopy.personalMessageTpaUri;
     pin = toCopy.pin;
     pins = toCopy.pins;
     showBusy = toCopy.showBusy;
     showLocationTimezone = toCopy.showLocationTimezone;
     systemNotifications = toCopy.systemNotifications;
     timezone = toCopy.timezone;
     uri = toCopy.uri;
     exists = toCopy.exists;
 }
Ejemplo n.º 18
0
 public FnOnce(Existence <Func <R> > func)
 {
     this.func = func.Unwrap();
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Creates a shallow copy of the argument.
 /// </summary>
 /// <param name="toCopy">the object to copy</param>
 public TypingUser(TypingUser toCopy)
 {
     conversationUri = toCopy.conversationUri;
     userUri = toCopy.userUri;
     exists = toCopy.exists;
 }
Ejemplo n.º 20
0
 //为控制器绑定新的可控制对象
 public void BindsTo <T>(Existence <T> obj)
     where T : class, IControllable
 {
     this.control = (IControllable)obj.Unwrap();
 }
Ejemplo n.º 21
0
        //constructor without restaurant
        public Hotel(string nam, double val, double ar, string loc, double we, double le, double ge, double inc, double outc, short nr, Existence cf) : base(nam, val, ar, loc, we, le, ge, inc, outc)
        {
            nrRooms = nr;

            if (cf == Existence.yes)
            {
                cafeteria = true;
            }
            else
            {
                cafeteria = false;
            }
        }
Ejemplo n.º 22
0
 public void TestElementExists()
 {
     Actor.AsksFor(Existence.Of(Locator)).Should().BeTrue();
 }