Ejemplo n.º 1
0
 public FormNewProfile(DataModel dm)
 {
     InitializeComponent();
     this.dm = dm;
     rename = false;
     p = new Profile();
 }
Ejemplo n.º 2
0
        public FormPerformance(Profile p)
        {
            InitializeComponent();

            profile = p;

            comboBoxMetric.DataSource = PerformanceMetrics.PerformanceMetricStrings;
            comboBoxTherapy.DataSource = profile.GetAllTherapies();
        }
Ejemplo n.º 3
0
 private void buttonOk_Click(object sender, EventArgs e)
 {
     if (textBoxName.Text.Length != 0)
     {
         Profile t = new Profile();
         t.initialize(textBoxName.Text);
         dm.Profiles.Add(t);
         this.Close();
     }
 }
Ejemplo n.º 4
0
 public FormNewProfile(DataModel dm, Profile p)
 {
     this.p = p;
     InitializeComponent();
     this.Name = "Rename Profile";
     this.labelInstruct.Text = "Please enter a unique name for the profile";
     this.textBoxName.Text = p.Name;
     this.dm = dm;
     rename = true;
 }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
 public void removeProfile(Profile p)
 {
     profiles.Remove(p);
 }
Ejemplo n.º 8
0
        public void DeserializeProfile(string filename, ref Profile p)
        {
            FileInfo fi = new FileInfo(filename);

            if (fi.Exists)
            {
                using (ZipFile zip = ZipFile.Read(filename))
                {
                    string profFile = "profile.twp";

                    foreach (string fileInZip in zip.EntryFileNames)
                    {
                        if (fileInZip.Equals(profFile, StringComparison.InvariantCultureIgnoreCase))
                        {
                            Debug.WriteLine("Found profile file in ZIP archive. Extracting it now");

                            zip[fileInZip].Extract(profFile);
                            profFile = Path.Combine(DATA_STORE_FOLDER, profFile);
                            TextReader reader = new StreamReader(profFile);

                            try
                            {
                                p = (Profile)profile_serializer.Deserialize(reader);
                            }
                            catch (Exception)
                            {
                                throw new InvalidOperationException("Invalid File Format");
                            }
                            finally
                            {
                                reader.Close();
                            }

                            if (dm.isProfileNameUnique(p.Name) && !Directory.Exists(p.GetDataFolder()))
                            {
                                zip.ExtractAll(DATA_STORE_FOLDER, ExtractExistingFileAction.OverwriteSilently);
                            }
                            else
                            {
                                throw new InvalidOperationException("There is already an existing profile named "
                                    + p.Name + ".  Delete or rename it before importing.");
                            }

                            File.Delete(profFile);
                        }
                    }
                }
            }
            else
            {
                throw new FileNotFoundException("Could not locate file: " + filename);
            }
        }
Ejemplo n.º 9
0
        public void SerializeProfile(string filename, Profile p)
        {
            Stream stream = new MemoryStream();
            TextWriter writer = new StreamWriter(stream);

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

            try
            {
                using (ZipFile zip = new ZipFile())
                {
                    zip.AddEntry("profile.twp", stream);
                    zip.AddDirectory(p.GetDataFolder(), p.Name);
                    zip.Save(filename);
                }
            }
            catch (Exception e)
            {
                throw new InvalidOperationException("Error Exporting Profile: " + e.Message);
            }

            if (writer != null)
                writer.Close();
        }
Ejemplo n.º 10
0
 private void listViewProfiles_SelectedIndexChanged(object sender, EventArgs e)
 {
     ListView l = (ListView)sender;
     if (l.SelectedItems.Count > 0)
     {
         listViewSessions.Items.Clear();
         Profile p = (Profile)l.SelectedItems[0].Tag;
         selectedProfile = p;
         ListView.ListViewItemCollection lc = p.getSessionList(listViewSessions);
         if (listViewSessions.Tag == null)
             listViewSessions.Tag = 0;
         listViewSessions.ListViewItemSorter = new ListComparer((int)listViewSessions.Tag);
         splitContainer2.Panel2.Enabled = true;
     }
     else
     {
         listViewSessions.Items.Clear();
         splitContainer2.Panel2.Enabled = false;
     }
 }
Ejemplo n.º 11
0
        private void importProfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Filter = "TheraWii Profile (*.twp.zip)|*.twp.zip|All Files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;
            openFileDialog1.RestoreDirectory = true;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Profile p = new Profile();
                try
                {
                    ds.DeserializeProfile(openFileDialog1.FileName, ref p);
                    dm.Profiles.Add(p);
                    ds.SerializeDataModel();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Import error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                listProfilesRefresh();
                listViewProfiles.Select();
                if (listViewProfiles.Items.Count > 0)
                {
                    listViewProfiles.Items[listViewProfiles.Items.Count - 1].Selected = true;
                    listViewProfiles.Items[listViewProfiles.Items.Count - 1].Focused = true;
                }
            }
        }
Ejemplo n.º 12
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();
            }
        }