Example #1
0
        /// <summary>
        /// Handles the Click event of the btnName control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnName_Click(object sender, EventArgs e)
        {
            PromptBox pbox = new PromptBox(GuiResources.NewName);

            if (pbox.ShowDialog() == DialogResult.OK)
            {
                bool ok = true;
                if (String.IsNullOrEmpty(pbox.Value))
                {
                    ok = false;
                }
                else
                {
                    foreach (char ch in pbox.Value)
                    {
                        char ch2 = Char.ToLower(ch);
                        if (!((ch2 >= 'a' && ch2 <= 'z') || (ch2 >= '0' && ch2 <= '9') || (" ._".IndexOf(ch) >= 0)))
                        {
                            ok = false;
                            break;
                        }
                    }
                }
                if (ok)
                {
                    _treeView.AddLevel(pbox.Value);
                }
                else
                {
                    MessageBox.Show("Invalid name. (Only [a-z]|[0-9]|[ ._])");
                }
            }
        }
Example #2
0
        /// <summary>
        /// Allows to change brake diameter
        /// </summary>
        /// <param name="isFrontBrakes"></param>
        private void _ChangeBrakesDiameter(bool isFrontBrakes)
        {
            string currentValue = (isFrontBrakes
                                       ? frontBrakesLabel.Text.Split('ø')[1]
                                       : rearBrakesLabel.Text.Split('ø')[1]);
            string       message = (isFrontBrakes ? _MESSAGE_ENTER_FRONT_DIAMETER : _MESSAGE_ENTER_REAR_DIAMETER);
            PromptBox    pBox    = new PromptBox(_TITLE_BRAKES_DIAMETER, message, currentValue);
            DialogResult dr      = pBox.ShowDialog(this);

            if (dr == DialogResult.OK && pBox.IsValueChanged)
            {
                Cursor = Cursors.WaitCursor;

                // Changing displacement
                string columnName = (isFrontBrakes
                                         ? SharedConstants.BRAKES_DIM_FRONT_PHYSICS_DB_COLUMN
                                         : SharedConstants.BRAKES_DIM_REAR_PHYSICS_DB_COLUMN);
                string newValue = pBox.ReturnValue;

                DatabaseHelper.UpdateCellFromTopicWherePrimaryKey(_PhysicsTable, columnName, _CurrentVehicle, newValue);

                // Reloading
                _InitializeDatasheetContents();

                // Modification flag
                _IsDatabaseModified = true;

                StatusBarLogManager.ShowEvent(this, _STATUS_CHANGING_BRAKE_DIAMETER_OK);

                Cursor = Cursors.Default;
            }
        }
Example #3
0
        private void displacementToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Click on 'Displacement' menu item
            try
            {
                PromptBox    pBox = new PromptBox("Engine displacement...", _MESSAGE_ENTER_DISPLACEMENT, engineDisplacementLabel.Text);
                DialogResult dr   = pBox.ShowDialog(this);

                if (dr == DialogResult.OK && pBox.IsValueChanged)
                {
                    Cursor = Cursors.WaitCursor;

                    // Changing displacement
                    string newValue = pBox.ReturnValue;

                    DatabaseHelper.UpdateCellFromTopicWherePrimaryKey(_PhysicsTable, SharedConstants.DISPLACEMENT_PHYSICS_DB_COLUMN, _CurrentVehicle, newValue);

                    // Reloading
                    _InitializeDatasheetContents();

                    // Modification flag
                    _IsDatabaseModified = true;

                    StatusBarLogManager.ShowEvent(this, _STATUS_CHANGING_DISPLACEMENT_OK);

                    Cursor = Cursors.Default;
                }
            }
            catch (Exception ex)
            {
                MessageBoxes.ShowError(this, ex);
            }
        }
Example #4
0
        private void setNameButton_Click(object sender, EventArgs e)
        {
            // Click on 'Set name...' button
            try
            {
                if (creditsListView.SelectedItems.Count == 1)
                {
                    ListViewItem selectedRole = creditsListView.SelectedItems[0];
                    int          roleIndex    = selectedRole.Index;
                    string       currentName  = selectedRole.SubItems[1].Text;
                    PromptBox    pBox         = new PromptBox(_TITLE_PATCH_EDITOR, _MESSAGE_SET_NAME_CUSTOM, currentName);

                    if (pBox.ShowDialog(this) == DialogResult.OK && !pBox.ReturnValue.Equals(currentName))
                    {
                        Cursor = Cursors.WaitCursor;

                        _CurrentPatch.SetRoleAuthorName(roleIndex, pBox.ReturnValue);

                        // Refresh
                        _UpdateRoleInformationTable();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBoxes.ShowError(this, ex);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
Example #5
0
        /// <summary>
        /// Ajoute une configuration de lancement
        /// </summary>
        private void _AddLaunchConfiguration()
        {
            // Nom de la configuration
            PromptBox pBox = new PromptBox(Application.ProductName, _CONFIG_NAME_MESSAGE, null);

            pBox.ShowDialog(this);

            if (pBox.DialogResult == DialogResult.OK)
            {
                // Nouvelle config
                LaunchConfiguration newConf = new LaunchConfiguration();

                // Nettoyage du nom pour éviter les conflits avec le sérialiseur
                string name = pBox.ReturnValue;

                if (!string.IsNullOrEmpty(name))
                {
                    name = name.Trim();
                }

                // Une chaîne vide n'est pas autorisée
                if (string.IsNullOrEmpty(name))
                {
                    throw new Exception(_ERROR_INVALID_CONFIG_NAME);
                }

                name = name.Replace('|', '!');
                name = name.Replace('¤', '*');

                // Vérification de l'existence d'une config de même nom
                foreach (LaunchConfiguration anotherConf in _TemporaryConfigList)
                {
                    if (anotherConf.Name.Equals(name))
                    {
                        throw new Exception(_ERROR_CONFIG_NAME_EXISTS);
                    }
                }

                newConf.Name = name;
                _UpdateConfiguration(ref newConf);

                // Ajout à la liste IHM
                configComboBox.Items.Add(newConf.Name);

                // Ajout à la config
                _TemporaryConfigList.Add(newConf);

                // Sélection de la config ajoutée
                configComboBox.SelectedIndex = configComboBox.Items.Count - 1;
            }
        }
        private void InsertUsingEncoding(Encoding encoding, HexBox _hexbox, bool Multiline)
        {
            PromptBox prompt = new PromptBox(Multiline);

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                byte[] bytes = new byte[prompt.Value.Length * encoding.GetByteCount("A")];

                encoding.GetBytes(prompt.Value, 0, prompt.Value.Length, bytes, 0);

                _hexbox.ByteProvider.DeleteBytes(_hexbox.SelectionStart, _hexbox.SelectionLength);
                _hexbox.ByteProvider.InsertBytes(_hexbox.SelectionStart, bytes);
                _hexbox.Select(_hexbox.SelectionStart, bytes.Length);
            }
        }
        private void InsertUsingEncoding(Encoding encoding, HexBox _hexbox, bool Multiline)
        {
            PromptBox prompt = new PromptBox(Multiline);

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                byte[] bytes = new byte[prompt.Value.Length * encoding.GetByteCount("A")];

                encoding.GetBytes(prompt.Value, 0, prompt.Value.Length, bytes, 0);

                _hexbox.ByteProvider.DeleteBytes(_hexbox.SelectionStart, _hexbox.SelectionLength);
                _hexbox.ByteProvider.InsertBytes(_hexbox.SelectionStart, bytes);
                _hexbox.Select(_hexbox.SelectionStart, bytes.Length);
            }
        }
        private void InsertNumber(HexBox _hexbox, int byteCount, bool BigEndian)
        {
            PromptBox prompt = new PromptBox();

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                byte[] bytes = new byte[byteCount];
                long number = (long)BaseConverter.ToNumberParse(prompt.Value);

                for (int i = 0; i < bytes.Length; i++)
                {
                    bytes[BigEndian ? (bytes.Length - i - 1) : i] = (byte)((number >> (i * 8)) & 0xff);
                }

                _hexbox.ByteProvider.DeleteBytes(_hexbox.SelectionStart, _hexbox.SelectionLength);
                _hexbox.ByteProvider.InsertBytes(_hexbox.SelectionStart, bytes);
                _hexbox.Select(_hexbox.SelectionStart, bytes.Length);
            }
        }
        private void InsertNumber(HexBox _hexbox, int byteCount, bool BigEndian)
        {
            PromptBox prompt = new PromptBox();

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                byte[] bytes  = new byte[byteCount];
                long   number = (long)BaseConverter.ToNumberParse(prompt.Value);

                for (int i = 0; i < bytes.Length; i++)
                {
                    bytes[BigEndian ? (bytes.Length - i - 1) : i] = (byte)((number >> (i * 8)) & 0xff);
                }

                _hexbox.ByteProvider.DeleteBytes(_hexbox.SelectionStart, _hexbox.SelectionLength);
                _hexbox.ByteProvider.InsertBytes(_hexbox.SelectionStart, bytes);
                _hexbox.Select(_hexbox.SelectionStart, bytes.Length);
            }
        }
Example #10
0
        /// <summary>
        /// Execute the command
        /// </summary>
        public void Exec()
        {
            if (_layer == null)
            {
                return;
            }
            XmiImporter importer = new XmiImporter(_layer);

            PromptBox prompt = new PromptBox("Xmi file name", "xmi files|*.xmi");

            if (prompt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    importer.Import(prompt.Value);
                }
                catch (Exception ex)
                {
                    ServiceLocator.Instance.IDEHelper.ShowError("Import error : " + ex.Message);
                }
            }
        }
Example #11
0
        /// <summary>
        /// Méthode appelée quand la clr n'arrive pas à résoudre l'assembly
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The <see cref="System.ResolveEventArgs"/> instance containing the event data.</param>
        /// <returns></returns>
        Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            string name = args.Name;
            int    pos  = name.IndexOf(',');

            if (pos > 0)
            {
                name = name.Substring(0, pos).Trim();
            }
            name += ".dll";

            Assembly assembly = null;

            try
            {
                assembly = Assembly.ReflectionOnlyLoad(args.Name);
            }
            catch
            {
                try
                {
                    assembly = Assembly.ReflectionOnlyLoadFrom(Path.Combine(_initialAssemblyPath, name));
                }
                catch
                {
                    // On demande à l'utilisateur
                    PromptBox prompt = new PromptBox("Veuillez indiquer l'emplacement de l'assembly : " + name, "Assemblies|*.dll");
                    if (prompt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        assembly = Assembly.ReflectionOnlyLoadFrom(Path.Combine(prompt.Value, name));
                    }
                }
            }
            if (assembly != null)
            {
                _referencedAssemblies.Add(assembly);
            }
            return(assembly);
        }
Example #12
0
        private void readWriteAddressMemoryMenuItem_Click(object sender, EventArgs e)
        {
            PromptBox prompt = new PromptBox();

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                IntPtr address = new IntPtr(-1);
                IntPtr regionAddress = IntPtr.Zero;
                long regionSize = 0;
                bool found = false;

                try
                {
                    address = ((long)BaseConverter.ToNumberParse(prompt.Value)).ToIntPtr();
                }
                catch
                {
                    PhUtils.ShowError("You have entered an invalid address.");

                    return;
                }

                List<MemoryItem> items = new List<MemoryItem>();

                foreach (MemoryItem item in _provider.Dictionary.Values)
                    items.Add(item);

                items.Sort((i1, i2) => i1.Address.CompareTo(i2.Address));

                int i = 0;

                foreach (MemoryItem item in items)
                {
                    if (item.Address.CompareTo(address) > 0)
                    {
                        MemoryItem regionItem = items[i - 1];

                        listMemory.Items[regionItem.Address.ToString()].Selected = true;
                        listMemory.Items[regionItem.Address.ToString()].EnsureVisible();
                        regionAddress = regionItem.Address;
                        regionSize = regionItem.Size;
                        found = true;

                        break;
                    }

                    i++;
                }

                if (!found)
                {
                    PhUtils.ShowError("Unable to find the memory address.");
                    return;
                }

                MemoryEditor m_e = MemoryEditor.ReadWriteMemory(_pid, regionAddress, (int)regionSize, false,
                   new Program.MemoryEditorInvokeAction(delegate(MemoryEditor f) { f.Select(address.Decrement(regionAddress).ToInt64(), 1); }));
            }
        }
Example #13
0
        private void readWriteAddressMemoryMenuItem_Click(object sender, EventArgs e)
        {
            PromptBox prompt = new PromptBox();

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                IntPtr address       = new IntPtr(-1);
                IntPtr regionAddress = IntPtr.Zero;
                long   regionSize    = 0;
                bool   found         = false;

                try
                {
                    address = ((long)BaseConverter.ToNumberParse(prompt.Value)).ToIntPtr();
                }
                catch
                {
                    PhUtils.ShowError("You have entered an invalid address.");

                    return;
                }

                List <MemoryItem> items = new List <MemoryItem>();

                foreach (MemoryItem item in _provider.Dictionary.Values)
                {
                    items.Add(item);
                }

                items.Sort((i1, i2) => i1.Address.CompareTo(i2.Address));

                int i = 0;

                foreach (MemoryItem item in items)
                {
                    MemoryItem regionItem = null;

                    if (item.Address.CompareTo(address) > 0)
                    {
                        if (i > 0)
                        {
                            regionItem = items[i - 1];
                        }
                    }
                    else if (item.Address.CompareTo(address) == 0)
                    {
                        regionItem = items[i];
                    }

                    if (regionItem != null && address.CompareTo(regionItem.Address) >= 0)
                    {
                        listMemory.Items[regionItem.Address.ToString()].Selected = true;
                        listMemory.Items[regionItem.Address.ToString()].EnsureVisible();
                        regionAddress = regionItem.Address;
                        regionSize    = regionItem.Size;
                        found         = true;

                        break;
                    }

                    i++;
                }

                if (!found)
                {
                    PhUtils.ShowError("Unable to find the memory address.");
                    return;
                }

                MemoryEditor m_e = MemoryEditor.ReadWriteMemory(_pid, regionAddress, (int)regionSize, false,
                                                                new Program.MemoryEditorInvokeAction(delegate(MemoryEditor f) { f.Select(address.Decrement(regionAddress).ToInt64(), 1); }));
            }
        }
Example #14
0
        private void Button4_Click(object sender, EventArgs e)
        {
            PromptBox box = new PromptBox();

            box.ShowDialog();
        }
Example #15
0
        private void exportToolStripButton_Click(object sender, EventArgs e)
        {
            // Click on Export button...
            Collection <ListViewItem> checkedItems = ListView2.GetCheckedItems(customTracksListView);

            Cursor = Cursors.WaitCursor;

            try
            {
                if (checkedItems.Count == 0)
                {
                    MessageBoxes.ShowWarning(this, _WARNING_CHECK_EXPORT);
                }
                else
                {
                    // All tracks must have replacing information
                    foreach (ListViewItem anotherItem in checkedItems)
                    {
                        DFE currentTrack = anotherItem.Tag as DFE;

                        if (currentTrack != null)
                        {
                            FileInfo fi = new FileInfo(currentTrack.FileName);
                            DFE      replacedChallenge = _GetReplacedChallenge(fi.Name);

                            if (replacedChallenge == null)
                            {
                                throw new Exception(_ERROR_REPLACE_EXPORT);
                            }
                        }
                    }


                    // Asks for track name
                    PromptBox    pBox = new PromptBox(_TITLE_EXPORT, _MSG_EXPORT, _NAME_EXPORT);
                    DialogResult dr   = pBox.ShowDialog(this);

                    if (dr == DialogResult.OK)
                    {
                        // Displays export target folder
                        folderBrowserDialog.Description = _MSG_PATH_EXPORT;
                        dr = folderBrowserDialog.ShowDialog(this);

                        if (dr == DialogResult.OK)
                        {
                            _ExportTracks(checkedItems, pBox.ReturnValue, folderBrowserDialog.SelectedPath);

                            string msg = string.Format(_FORMAT_EXPORT_OK, checkedItems.Count);

                            StatusBarLogManager.ShowEvent(this, msg);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBoxes.ShowError(this, ex);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
Example #16
0
        /// <summary>
        /// Sélection d'un modèle
        /// </summary>
        /// <param name="component">The component.</param>
        /// <param name="metaData">The meta data.</param>
        /// <returns></returns>
        bool IModelsMetadata.SelectModel(ExternalComponent component, out ComponentModelMetadata metaData)
        {
            metaData = null;

            // Ici on veut saisir le fichier décrivant le système
            ComponentType?ct = null;

            if (component.MetaData != null)
            {
                ct = component.MetaData.ComponentType;
            }

            RepositoryTreeForm wizard = new RepositoryTreeForm(true, ct);

            if (wizard.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // On doit le créer
                if (wizard.SelectedItem == null)
                {
                    //
                    // Création d'un composant externe
                    //
                    if (component.Name == String.Empty)
                    {
                        PromptBox pb = new PromptBox("Name of the new component");
                        if (pb.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                        {
                            return(false);
                        }

                        // Vérification des doublons.
                        if (_metadatas.NameExists(pb.Value))
                        {
                            IIDEHelper ide = ServiceLocator.Instance.IDEHelper;
                            if (ide != null)
                            {
                                ide.ShowMessage("This model already exists in this model.");
                            }
                            return(false);
                        }

                        component.Name = pb.Value;
                    }

                    // Création d'un modèle vide dans un répertoire temporaire
                    string relativeModelFileName = component.Name + ModelConstants.FileNameExtension;
                    string fn = Utils.GetTemporaryFileName(relativeModelFileName);
                    Directory.CreateDirectory(System.IO.Path.GetDirectoryName(fn));

                    // Persistence du modèle
                    CandleModel model = ModelLoader.CreateModel(component.Name, component.Version);
                    component.ModelMoniker = model.Id;
                    SerializationResult result = new SerializationResult();
                    CandleSerializationHelper.Instance.SaveModel(result, model, fn);

                    // Et ouverture du modèle
                    ServiceLocator.Instance.ShellHelper.Solution.DTE.ItemOperations.OpenFile(fn, EnvDTE.Constants.vsViewKindDesigner);
                }
                else // Sinon affectation
                {
                    metaData = wizard.SelectedItem;
                    ExternalComponent externalComponent = component.Model.FindExternalComponent(metaData.Id);
                    if (externalComponent != null)
                    {
                        IIDEHelper ide = ServiceLocator.Instance.IDEHelper;
                        if (ide != null)
                        {
                            ide.ShowMessage("This model already exists in this model.");
                        }
                        return(false);
                    }
                    metaData.UpdateComponent(component);
                }

                return(true); // On ne passe pas dans le rollback
            }
            return(false);
        }