示例#1
0
 private void buttonOk_Click(object sender, EventArgs e)
 {
     if (textBoxName.Text.Length != 0)
     {
         Therapy t = new Therapy();
         t.Name = textBoxName.Text;
         dm.Therapies.Add(t);
         dm.Therapies.Sort();
         this.Close();
     }
 }
示例#2
0
        public void Initialize(Profile p, Therapy t)
        {
            therapy = t.ToString();
            profile = p.Name;
            createDate = System.DateTime.Now;
            string date = createDate.Year + "-"
                        + createDate.Month + "-"
                        + createDate.Day + " "
                        + createDate.Hour + "-"
                        + createDate.Minute +
                        + createDate.Second;

            dataFile = profile  + "_" + therapy + "_" + date + ".csv";
            csvOut = new DScsv();
            createFile();
        }
示例#3
0
文件: Game.cs 项目: naegelyd/therawii
 public Game(Therapy t, Profile p, bool fullscreen)
 {
     therapy = t;
     profile = p;
     session = new Session();
     session.Initialize(profile, therapy);
     profile.Sessions.Add(session);
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     graphics.PreferredBackBufferWidth = PREFERRED_WIDTH; // GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
     graphics.PreferredBackBufferHeight = PREFERRED_HEIGHT; // GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
     graphics.IsFullScreen = fullscreen;
     InputDevice.GAME_WIDTH = graphics.PreferredBackBufferWidth;
     InputDevice.GAME_HEIGHT = graphics.PreferredBackBufferHeight;
     this.IsFixedTimeStep = true;
     this.TargetElapsedTime = new TimeSpan(defaultTargetElapsedTime);
     graphics.PreferMultiSampling = true;
 }
示例#4
0
 public void removeTherapy(Therapy t)
 {
     therapies.Remove(t);
 }
示例#5
0
        public void SerializeTherapy(string filename, Therapy t)
        {
            TextWriter writer = new StreamWriter(filename);

            try
            {
                therapy_serializer.Serialize(writer, t);
            }
            catch (Exception e)
            {
                writer.Close();
                string s = e.StackTrace;
                throw new InvalidOperationException("Error Serialzing Therapy");
            }

            if (writer != null)
                writer.Close();
        }
示例#6
0
        public void DeserializeTherapy(string filename, ref Therapy t)
        {
            FileInfo fi = new FileInfo(filename);

            if (fi.Exists)
            {
                TextReader reader = new StreamReader(filename);
                try
                {
                    t = (Therapy)therapy_serializer.Deserialize(reader);
                }
                catch (Exception)
                {
                    throw new InvalidOperationException("Invalid File Format");
                }
                finally
                {
                    reader.Close();
                }
            }
            else
            {
                throw new FileNotFoundException("Could not locate file: " + filename);
            }
        }
示例#7
0
 private void listTherapies_SelectedIndexChanged(object sender, EventArgs e)
 {
     selectedTherapy = (Therapy)listTherapies.SelectedItem;
     treeViewTasksRefresh();
 }
示例#8
0
        private void importTherapyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Filter = "TheraWii Therapy (*.twf)|*.twf|All Files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;
            openFileDialog1.RestoreDirectory = true;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Therapy t = new Therapy();
                try
                {
                    ds.DeserializeTherapy(openFileDialog1.FileName, ref t);
                    dm.Therapies.Add(t);
                    ds.SerializeDataModel();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Import error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                listTherapiesRefresh();
                listTherapies.SelectedIndex = listTherapies.Items.Count - 1;
            }
        }
示例#9
0
        private void buttonPlay_Click(object sender, EventArgs e)
        {
            //create a dialog window to connect devices, then move onto profile select
            selectedProfile = null;
            if (listTherapies.SelectedItem != null && ((Therapy)listTherapies.SelectedItem).tasks.Count > 0)
            {
                using (FormAddDevices fad = new FormAddDevices(((Therapy)listTherapies.SelectedItem).getRequiredDevices()))
                {
                    fad.Tag = this;
                    if (fad.ShowDialog() == DialogResult.OK)
                    {
                        // create a dialog window to get the profile to use for the game
                        using (FormProfileChooser fpc = new FormProfileChooser(dm.Profiles, this))
                        {
                            fpc.Tag = this;
                            if (fpc.ShowDialog() == DialogResult.OK)
                            {
                                String selectedName = fpc.getSelectedProfileName();
                                if (selectedName == null)
                                {
                                    selectedProfile = null;
                                }
                                foreach (Profile p in dm.Profiles)
                                {
                                    if (p.Name.CompareTo(selectedName) == 0)
                                    {
                                        selectedProfile = p;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                string caption = "Therapy Required";
                DialogResult result = MessageBox.Show("Could not start Therapy. Please make sure that:\n\n  1. A Therapy is selected.\n  2. The selected Therapy contains at least one task.", caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (listTherapies.SelectedItem != null && selectedProfile != null)
            {
                //Console.WriteLine(selectedProfile + "\n");
                selectedTherapy = (Therapy)listTherapies.SelectedItem;
                Thread thread = new Thread(new ThreadStart(RunXna));
                thread.Name = "TheraWii Game";
                thread.Start();
                thread.Join();
                ds.SerializeDataModel();
            }
        }
示例#10
0
 public Therapy(Therapy t)
 {
     Name = "copy of " + t.Name;
     tasks = (RepeatTask)t.tasks.returnNew();
 }
示例#11
0
 public FormNewTask(Therapy t)
 {
     therapy = t;
     InitializeComponent();
 }