Exemplo n.º 1
0
        /// <summary>
        /// This function create the AddCharacterWindow and modify the database if needed (adding a character)
        /// </summary>
        public void OnFire()
        {
            //Show the window
            var w = new AddPlaceWindow(m_wd);

            w.ShowDialog();

            AddPlaceDatas datas = w.DataContext as AddPlaceDatas;

            //Commit the Dialog
            if (datas.PlaceAdded)
            {
                String key = datas.PlaceIconKey;
                m_wd.CommitDB.AddPlace(new Place {
                    Name = datas.Name, Icon = key, Story = datas.PlaceStory
                });
                if (datas.IconDefined)
                {
                    AddPlaceDatas data = (w.DataContext as AddPlaceDatas);
                    if (data.IconDefined)
                    {
                        using (FileStream fs = new FileStream(data.IconPath, FileMode.Open))
                            m_wd.AddResource(fs, key);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This function create the AddCharacterWindow and modify the database if needed (adding a character)
        /// </summary>
        public void OnFire()
        {
            //Show the window
            var w = new AddCharacterWindow(m_wd);

            w.ShowDialog();

            //Commit the Dialog
            if (w.Datas.CharacterAdded)
            {
                m_wd.CommitDB.AddCharacter(w.Datas.NewCharacters.ToArray());

                //Add the icon as a new resources.
                //TODO only one icon currently is added...
                if (w.Datas.IconDefined)
                {
                    using (FileStream fs = new FileStream(w.Datas.IconPath, FileMode.Open))
                        m_wd.AddResource(fs, w.Datas.NewCharacters[0].Icon);
                }
            }
        }