Exemple #1
0
 internal static void ShowEditDialog(Game game)
 {
     if (activeDialog != null && !activeDialog.IsDisposed)
     {
         return;
     }
     activeDialog = new EditDialog(game);
     activeDialog.Show();
 }
Exemple #2
0
 private void HideEditDialog(object sender, EventArgs e)
 {
     if (activeDialog == null && activeDialog.IsDisposed)
     {
         return;
     }
     activeDialog.Dispose();
     activeDialog = null;
 }
Exemple #3
0
 void handleEdit(object sender, EventArgs e)
 {
     EditDialog.ShowEditDialog(gameData);
 }
Exemple #4
0
 void HandleAdd(object sender, EventArgs e)
 {
     EditDialog.ShowAddDialog();
 }
Exemple #5
0
        private EditDialog(Game game)
        {
            if (game == null)
            {
                Title = "Add";
            }
            else
            {
                Title      = "Edit";
                gameToEdit = game;
            }
            activeDialog         = this;
            activeDialog.Closed += HideEditDialog;

            this.Content = VBox;
            // Name
            HBox nameBox = new HBox();

            nameBox.PackStart(new Label("Name:"));
            nameBox.PackStart(NameEntry);
            NameEntry.WidthRequest = 300;
            VBox.PackStart(nameBox);
            // Command
            HBox commandBox = new HBox();

            commandBox.PackStart(new Label("Command:"));
            commandBox.PackStart(CommandEntry);
            CommandEntry.WidthRequest = 300;
            VBox.PackStart(commandBox);
            // Image
            HBox imageBox = new HBox();

            imageBox.PackStart(new Label("Image:"));
            ImageShow.WidthRequest  = 460;
            ImageShow.HeightRequest = 215;
            imageBox.PackStart(ImageShow);
            VBox.PackStart(imageBox);
            // Image select
            ImageSelector = new FileSelector();
            ImageSelector.Filters.Add(new FileDialogFilter("Image files", "*.bmp;*.jpg;*.jpeg;*.png;"));
            ImageSelector.FileChanged += FileChanged;
            VBox.PackStart(ImageSelector);
            // Tags
            VBox tagList = new VBox();

            tagList.PackStart(new Label("Tags:"));
            foreach (String tag in ConfigurationData.getInstance().Tags)
            {
                var check = new CheckBox(tag);
                if (gameToEdit != null && gameToEdit.tags.Contains(tag))
                {
                    check.State = CheckBoxState.On;
                }
                check.Toggled += CheckBoxClicked;
                tagList.PackStart(check);
            }
            VBox.PackStart(tagList);
            // Buttons
            Button saveButton = new Button("Save");

            saveButton.Clicked += SaveAndCloseDialog;
            VBox.PackEnd(saveButton);

            if (gameToEdit != null)
            {
                NameEntry.Text    = game.name;
                CommandEntry.Text = game.command;
                ImageShow.Image   = game.GetImage();
            }
            else
            {
                gameToEdit = new Game();
            }
        }