/// <summary>
        /// Gestisce l'azione dell'add button permettendo l'inserimento di una
        /// nuova categoria
        /// </summary>
        private void AddHandler(Object sender, EventArgs eventArgs)
        {
            ICategory selectedNode = _categoryTree.SelectedNode?.Tag as ICategory ?? null;

            if (selectedNode == null)
            {
                MessageBox.Show("Devi selezionare una categoria radice");
                return;
            }
            // Genero una finestra di dialogo per inserire il nome della categoria
            string catName = "";

            using (StringDialog sd = new StringDialog("Inserisci il nome della categoria"))
            {
                if (sd.ShowDialog() == DialogResult.OK)
                {
                    catName = sd.Response;
                }
                else
                {
                    return;
                }
            }
            // Se il nodo selezionato non è un contenitore lo elimino e lo faccio diventare
            // un contenitore
            if (!(selectedNode is IGroupCategory))
            {
                IGroupCategory parent = selectedNode.Parent;
                parent.RemoveChild(selectedNode);
                selectedNode = CategoryFactory.CreateGroup(selectedNode.Name, parent);
            }
            // Creo la categoria
            CategoryFactory.CreateCategory(catName, selectedNode as IGroupCategory);
        }
Exemple #2
0
        private void saveMemoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StringDialog stDialog = new StringDialog("Enter the number of bytes you want to save...");

            if (stDialog.ShowDialog() == DialogResult.OK)
            {
                int byteLength = 0;
                try
                {
                    byteLength = Convert.ToInt32(stDialog.Message, 16);
                }
                catch
                {
                    MessageBox.Show("The entered value was not a valid hex number.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                SaveFileDialog dialog = new SaveFileDialog();
                dialog.Filter = "Binary File|*.bin|All Files|*.*";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    ulong         cellAddress = (ulong)getSelectedCellAddress();
                    API.ErrorCode error;
                    File.WriteAllBytes(dialog.FileName, API.read <byte>(cellAddress, byteLength, out error));
                }
            }
        }
Exemple #3
0
        internal void Find()
        {
            Person       foundPerson = null;
            StringDialog dialog      = new StringDialog("A partial last name");

            dialog.ShowDialog();
            if (dialog.Accept)
            {
                string        lastName   = dialog.YourString;
                List <Person> candidates = _personRepository.ListByLastName(lastName);
                switch (candidates.Count)
                {
                case 0:
                    ReportIt("No person has last name " + lastName);
                    return;

                case 1:
                    foundPerson = candidates[0];
                    break;

                default:
                    foundPerson = ChooseAUniquePerson(candidates);
                    break;
                }
                PersonView view = new PersonView(this);
                view.Show();
            }
        }
        internal void AddContributor(Role role)
        {
            StringDialog dialog = new StringDialog("A partial last name");

            dialog.ShowDialog();
            if (dialog.Accept)
            {
                string lastName = dialog.YourString;
                if (lastName == "")
                {
                    ReportIt("You must enter a nonempty last name");
                    return;
                }
                Person p = GetPersonFor(lastName);
                if (p == null)
                {
                    return;
                }
                FilmPerson fp = new FilmPerson();
                fp.FilmId   = CurrentFilm.Id;
                fp.PersonId = p.Id;
                fp.Roles.Add(role);
                _filmPersonRepository.Add(fp);
            }
        }
Exemple #5
0
        internal void Find()
        {
            StringDialog dialog = new StringDialog("A partial description");

            dialog.ShowDialog();
            if (dialog.Accept)
            {
                string description = dialog.YourString;
                AbstractLocationRepository lRepo = _locationRepository;
                Location loc = null;
                try
                {
                    loc = lRepo.GetByDescription(description);
                }
                catch (Exception ex)
                {
                    ReportIt("The description must specify a unique location");
                }
                if (loc != null)
                {
                    LocationView view = new LocationView(this);
                    view.ShowDialog();
                }
            }
        }
Exemple #6
0
        private void enterNewValueToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItem item = listView.SelectedItems[0];

            API.ErrorCode error;
            Registers     regs = API.getRegisters(out error);

            if (error != API.ErrorCode.NO_ERROR)
            {
                return;
            }

            StringDialog dialog = new StringDialog("Enter new register value");

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    string[] itemSplit = item.Text.Split(new char[] { ':' });
                    string   register  = itemSplit[0];
                    regs = setRegister(regs, register, dialog.Message);
                    API.setRegisters(regs);
                    refresh();
                }
                catch { }
            }
        }
        private void notify()
        {
            StringDialog dialog = new StringDialog("Notification Message");

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                API.notify(dialog.Message);
            }
        }
Exemple #8
0
        public void Stash(params RawPacketReference[] packets)
        {
            var dialog = new StringDialog("Stash packets", "Your selected packets will be stored with the name below");

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                _Stash.Add(dialog.Result.Value, packets);
            }
        }
Exemple #9
0
        private void goToAddressToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StringDialog dialog = new StringDialog("Go to address");

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                addressPointer = Convert.ToUInt64(dialog.Message, 16);
                refresh();
            }
        }
Exemple #10
0
        internal void Find()
        {
            StringDialog dialog = new StringDialog("A country abbreviation");

            dialog.ShowDialog();
            if (dialog.Accept)
            {
                string abbrev = dialog.YourString;
                CurrentCountry = _countryRepository.GetByAbbreviation(abbrev);
                CountryView view = new CountryView(this);
                view.ShowDialog();
            }
        }
        private void RenameButton_Click(object sender, EventArgs e)
        {
            StringDialog dlg = new StringDialog {
                String = CurrentArea.Name
            };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                CurrentArea.Name       = dlg.String;
                Context.UnsavedChanges = true;

                AreaList.Items[AreaList.SelectedIndex] = CurrentArea;
            }
        }
Exemple #12
0
        private void BtnAddSubject_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new StringDialog("New Subject", "Enter name:")
            {
                Icon = (BtnAddSubject.Content as Image)?.Source
            };

            if (dialog.ShowDialog() == true)
            {
                _subjects.Add(new TimetableModel(dialog.Value));
                SortSubjectList();
                _changed = true;
            }
        }
        private void AddArea_Click(object sender, EventArgs e)
        {
            StringDialog dlg = new StringDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Wip.ZoneArea area = new Wip.ZoneArea {
                    Name = dlg.String
                };
                ZoneData.Areas.Add(area);
                Context.UnsavedChanges = true;

                AreaList.Items.Add(area);
                Select(area);
            }
        }
        internal void Addountry()
        {
            StringDialog dialog = new StringDialog("A country abbreviation");

            dialog.ShowDialog();
            if (dialog.Accept)
            {
                string abbreviation             = dialog.YourString;
                AbstractCountryRepository cRepo = _countryRepository;
                Country     c  = cRepo.GetByAbbreviation(abbreviation);
                FilmCountry fc = new FilmCountry();
                fc.FilmId    = CurrentFilm.Id;
                fc.CountryId = c.Id;
                AbstractFilmCountryRepository fcRepo = _filmCountryRepository;
                fcRepo.Add(fc);
            }
        }
        public void AddTrackingDeviceButtonHandler(Object obj, EventArgs e)
        {
            DateRange range = new DateRange(_fromDateTimePicker.Value, _toDateTimePicker.Value);

            using (StringDialog sd = new StringDialog("Nome da associare a prenotazione base: "))
            {
                if (sd.ShowDialog() == DialogResult.OK)
                {
                    string name = sd.Response;

                    if (name != null)
                    {
                        _desc = new AssociationDescriptor(range, name);
                    }
                }
                else
                {
                    return;
                }
            }
            if (_desc == null)
            {
                _desc = new AssociationDescriptor(range, "Base");
            }
            try
            {
                _baseTrackingDevice = _tdCoord.Next;
            }catch (Exception exception)
            {
                MessageBox.Show("Non è possibile recuperare un tracking device. Chiedi allo staff");
                _view.Close();
                return;
            }

            _trackingDeviceLabel.Text = _desc.InformationString + " -> " + _baseTrackingDevice.Id;
            _associateTrackingDeviceButton.Enabled = false;
            if (CanCreate())
            {
                _createButton.Enabled = true;
            }
            _clearButton.Enabled = true;
        }
Exemple #16
0
        private void BtnRenameSubject_Click(object sender, RoutedEventArgs e)
        {
            if (LvSubjects.SelectedItem == null)
            {
                return;
            }

            var dialog = new StringDialog("Rename Subject", "Enter name:", TimetableControl.Model.Name)
            {
                Icon = (BtnRenameSubject.Content as Image)?.Source
            };

            if (dialog.ShowDialog() == true && TimetableControl.Model.Name != dialog.Value)
            {
                TimetableControl.Model.Rename(dialog.Value);
                UpdateTimetable();
                SortSubjectList();
                _changed = true;
            }
        }
        private void ToolStripButton3_Click(object sender, EventArgs e)
        {
            TreeNode node = treeView1.SelectedNode;

            if (node.ImageIndex == PROJECT || node.ImageIndex == FOLDER || node.ImageIndex == FOLDER_OPEN)
            {
                string path =
                    _filePath.Replace(Path.DirectorySeparatorChar + Path.GetFileName(_filePath) ?? string.Empty, "");
                string replace = node.FullPath?.Replace(Path.GetFileName(_filePath) ?? string.Empty, "");
                string target  = path + replace.Replace("\\", Path.DirectorySeparatorChar.ToString());
                if (Directory.Exists(target))
                {
                    StringDialog dialog = new StringDialog((text) => !string.IsNullOrEmpty(text));
                    dialog.Description = "Create Directory Name";
                    dialog.ShowDialog();
                    if (dialog.DialogResult == DialogResult.OK)
                    {
                        string newDir = target + Path.DirectorySeparatorChar + dialog.ResultString;
                        if (!Directory.Exists(newDir))
                        {
                            Directory.CreateDirectory(newDir);
                            string  name = replace.Split(Path.DirectorySeparatorChar)[1];
                            Project proj = _projects[name];
                            proj.AddItem("Folder", newDir.Replace(path + "\\" + name + "\\", "") + "\\");
                            proj.Save();

                            LoadSolution(_solution, _filePath);
                        }
                        else
                        {
                            MessageBox.Show("Created Directory");
                        }
                    }
                }
            }
        }
        private void listView1_DoubleClick(Object sender, EventArgs e)
        {
            var item = this.listView1.SelectedItems[0];

            if (item == null)
            {
                return;
            }

            if (item.Text == "mPath" || item.Text == "mInjectionSet" || item.Text == "mnVersion")
            {
                return;
            }

            var type = (Type)item.Tag;

            if (type == typeof(Boolean))
            {
                var currentBoolean = (Boolean)this._worldData[item.Text];
                item.SubItems[1].Text      = (!currentBoolean).ToString();
                this._worldData[item.Text] = !currentBoolean;
            }
            if (type == typeof(Int64))
            {
                var currentInt = (Int64)this._worldData[item.Text];
                using (var nd = new NumericDialog(currentInt, 0))
                {
                    if (nd.ShowDialog() == DialogResult.OK)
                    {
                        item.SubItems[1].Text      = Convert.ToInt64(nd.Result).ToString("N0");
                        this._worldData[item.Text] = Convert.ToInt64(nd.Result);
                    }
                }
            }
            if (type == typeof(Int32))
            {
                var currentInt = (Int32)this._worldData[item.Text];
                using (var nd = new NumericDialog(currentInt, 0))
                {
                    if (nd.ShowDialog() == DialogResult.OK)
                    {
                        item.SubItems[1].Text      = Convert.ToInt32(nd.Result).ToString("N0");
                        this._worldData[item.Text] = Convert.ToInt32(nd.Result);
                    }
                }
            }
            if (type == typeof(Single))
            {
                var currentFloat = (Single)this._worldData[item.Text];
                using (var nd = new NumericDialog(currentFloat, 7))
                {
                    if (nd.ShowDialog() == DialogResult.OK)
                    {
                        item.SubItems[1].Text      = Convert.ToSingle(nd.Result).ToString("N7").TrimEnd('0').TrimEnd('.');
                        this._worldData[item.Text] = Convert.ToSingle(nd.Result);
                    }
                }
            }
            if (type.BaseType == typeof(Enum))
            {
                var currentEnum = (Enum)this._worldData[item.Text];
                using (var ed = new EnumDialog(currentEnum))
                {
                    if (ed.ShowDialog() == DialogResult.OK)
                    {
                        item.SubItems[1].Text      = ed.Result.ToString();
                        this._worldData[item.Text] = ed.Result;
                    }
                }
            }
            if (type == typeof(string))
            {
                var currentStr = (string)this._worldData[item.Text];
                using (var sd = new StringDialog(currentStr))
                {
                    if (sd.ShowDialog() == DialogResult.OK)
                    {
                        item.SubItems[1].Text      = sd.Result;
                        this._worldData[item.Text] = sd.Result;
                    }
                }
            }
        }