Ejemplo n.º 1
0
        /// <summary>
        /// Theme1ViewModel Constructor.
        /// </summary>
        /// <param name="t">The Theme</param>
        /// <param name="s">The current SessionViewModel performing</param>
        public ThemeViewModel(Theme t, SessionViewModel s)
            : base(s)
        {
            NoteBubbleImages = new Dictionary<NoteValue, BitmapImage>();
            MelodyBubbleImages = new Dictionary<Gesture, BitmapImage>();
            Theme = t;

            BackgroundImage = new ImageBrush();
            BackgroundImage.ImageSource =
                new BitmapImage(new Uri(@"../../Resources/Images/Theme" + SessionVM.Session.ThemeID + "/background.jpg", UriKind.Relative));

            NoteGeneratorImage = new ImageBrush();
            NoteGeneratorImage.ImageSource = GetBitmapImage("notefactory");

            MelodyGeneratorImage = new ImageBrush();
            MelodyGeneratorImage.ImageSource = GetBitmapImage("melodyfactory");

            PlayImage = new ImageBrush();
            PlayImage.ImageSource = GetBitmapImage("playdrop");

            TempoImage = new List<ImageBrush>();
            for (int i = 0; i < 3; i++)
            {
                TempoImage.Add(new ImageBrush());
                TempoImage[i].ImageSource = new BitmapImage(new Uri(@"../../Resources/Images/UI_items/"+i.ToString()+".png", UriKind.Relative));
            }

            SoundPointEnableImage = new ImageBrush();
            SoundPointEnableImage.ImageSource = GetBitmapImage("soundpointenable");

            SoundPointDisableImage = new ImageBrush();
            SoundPointDisableImage.ImageSource = GetBitmapImage("soundpointdisable");

            ThemesImage = new ImageBrush();
            ThemesImage.ImageSource = new BitmapImage(new Uri(@"../../Resources/Images/Theme" + SessionVM.Session.ThemeID + "/themes.png", UriKind.Relative));

            PlayBarCache = new ImageBrush();
            PlayBarCache.ImageSource = new BitmapImage(new Uri(@"../../Resources/Images/Theme" + SessionVM.Session.ThemeID + "/theme" + SessionVM.Session.ThemeID + "_shape.png", UriKind.Relative));

            NoteBubbleImages.Add(NoteValue.crotchet, GetNoteBitmapImage("bullenoire"));
            NoteBubbleImages.Add(NoteValue.minim, GetNoteBitmapImage("bulleblanche"));
            NoteBubbleImages.Add(NoteValue.quaver, GetNoteBitmapImage("bullecroche"));

            MelodyBubbleImages.Add(Gesture.infinite , GetMelodyBitmapImage("infinite"));
            MelodyBubbleImages.Add(Gesture.s, GetMelodyBitmapImage("s"));
            MelodyBubbleImages.Add(Gesture.t, GetMelodyBitmapImage("t"));
            MelodyBubbleImages.Add(Gesture.wave, GetMelodyBitmapImage("wave"));
            MelodyBubbleImages.Add(Gesture.zigzag, GetMelodyBitmapImage("zigzag"));
        }
        /// <summary>
        /// MelodyBubbleGenerator Theme related constructor
        /// </summary>
        /// <param name="mbg">The MelodyBubbleGenerator item</param>
        /// <param name="s">The current SessionViewModel</param>
        public MelodyBubbleGeneratorViewModel(MelodyBubbleGenerator mbg, SessionViewModel s)
            : base(s)
        {
            Grid = new Grid();
            MelodyBubbleVMs = new List<MelodyBubbleViewModel>();
            MelodyBubbleGenerator = mbg;
            //default, may change
            Grid.Width = 368;
            Grid.Height = 234;
            Grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            Grid.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            Grid.Background = SessionVM.ThemeVM.MelodyGeneratorImage;

            Grid.TouchDown += new EventHandler<System.Windows.Input.TouchEventArgs>(touchDown);
        }
        /// <summary>
        /// NoteBubbleGenerator Theme related constructor
        /// </summary>
        /// <param name="nbg">The NoteBubbleGenerator item</param>
        /// <param name="s">The current SessionVM</param>
        public NoteBubbleGeneratorViewModel(NoteBubbleGenerator nbg, SessionViewModel s)
            : base(s)
        {
            Grid = new Grid();
            NoteBubbleVMs = new List<NoteBubbleViewModel>();
            NoteBubbleGenerator = nbg;
            //default, may change
            Grid.Width = 368;
            Grid.Height = 234;
            Grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            Grid.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            Grid.Background = SessionVM.ThemeVM.NoteGeneratorImage;

            Grid.TouchDown += new EventHandler<TouchEventArgs>(touchDown);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor of a TreeViewModel
        /// </summary>
        /// <param name="up"></param>
        /// <param name="t"></param>
        /// <param name="s"></param>
        public TreeViewModel(bool up, Thickness t, SessionViewModel s)
        {
            this.Up = !up;
            SessionVM = s;
            ratio = s.SessionSVI.Width / 1920.0;

            Grid = new Grid();
            Grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            Grid.Margin = t;

            Grid.Height = 210.0 * ratio;
            Grid.Width = 210.0 * ratio;

            if (Up)
            {
                Instrument1 = new Instrument(SessionVM.Session.Theme.InstrumentsTop[0].Name);
                Instrument2 = new Instrument(SessionVM.Session.Theme.InstrumentsTop[1].Name);
            }
            else
            {
                Instrument1 = new Instrument(SessionVM.Session.Theme.InstrumentsBottom[0].Name);
                Instrument2 = new Instrument(SessionVM.Session.Theme.InstrumentsBottom[1].Name);
            }

            Images = new List<Grid>();
            Images.Add(createGridForImage(Instrument1.Name.ToString(), 100.0 * ratio, 100.0 * ratio, HorizontalAlignment.Left, VerticalAlignment.Center));
            Images.Add(createGridForImage(Instrument1.Name.ToString(), 100.0 * ratio, 100.0 * ratio, HorizontalAlignment.Right, VerticalAlignment.Top));
            Images.Add(createGridForImage(Instrument2.Name.ToString(), 100.0 * ratio, 100.0 * ratio, HorizontalAlignment.Right, VerticalAlignment.Bottom));

            Grid root = createGridForLinks("root", 50.0 * ratio, 50.0 * ratio, new Thickness(0, 0, 100.0 * ratio, 0));

            Images.Add(root);
            Images.Add(createGridForLinks("lower_branch", 80.0 * ratio, 120.0 * ratio, new Thickness(50.0 * ratio, 60.0 * ratio, 50.0 * ratio, 0.0)));
            Images.Add(createGridForLinks("upper_branch", 80.0 * ratio, 120.0 * ratio, new Thickness(50.0 * ratio, 0.0, 50.0 * ratio, 60.0 * ratio)));

            Images[0].Visibility = Visibility.Visible;

            foreach (Grid g in Images) Grid.Children.Add(g);

            Grid.SetZIndex(root, 300);

            Images[0].TouchDown += new EventHandler<TouchEventArgs>(touchDown0);
            Images[1].TouchDown += new EventHandler<TouchEventArgs>(touchDown1);
            Images[2].TouchDown += new EventHandler<TouchEventArgs>(touchDown2);
            Images[3].TouchDown += new EventHandler<TouchEventArgs>(touchDown1);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Load the data from the sessionVM
        /// </summary>
        /// <param name="sessionVM">The loaded SessionViewModel</param>
        public SessionData(SessionViewModel sessionVM)
        {
            StaveTopNotes = new List<Note>();
            StaveBottomNotes = new List<Note>();

            foreach (Note note in sessionVM.Session.StaveTop.Notes)
                StaveTopNotes.Add(note);
            foreach (Note note in sessionVM.Session.StaveBottom.Notes)
                StaveBottomNotes.Add(note);

            bpm = sessionVM.Session.Bpm;

            SessionID = sessionVM.SessionID;
            TopInstrument = sessionVM.Session.StaveTop.CurrentInstrument;
            BottomInstrument = sessionVM.Session.StaveBottom.CurrentInstrument;

            ThemeID = sessionVM.Session.ThemeID;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Constructor
        /// </summary>
        public ChangeSoundViewModel(SessionViewModel s)
        {
            sessionVM = s;
            ratio = s.SessionSVI.Width / 1920.0;

            Grid = new Grid();
            Grid.VerticalAlignment = VerticalAlignment.Top;
            Grid.HorizontalAlignment = HorizontalAlignment.Left;

            Grid.Margin = new System.Windows.Thickness(0.0, 20.0 * ratio, 0, 0);

            Grid.Children.Add(createButtonForImage(true, 0.0));
            Grid.Children.Add(createButtonForImage(true, 80.0 * ratio));
            Grid.Children.Add(createButtonForImage(true, 160.0 * ratio));
            Grid.Children.Add(createButtonForImage(false, 240.0 * ratio));
            Grid.Children.Add(createButtonForImage(false, 320.0 * ratio));
            Grid.Children.Add(createButtonForImage(false, 400.0 * ratio));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Constructor
        /// Create un NoteViewModel
        /// </summary>
        /// <param name="center">The center point of the ScatterViewItem </param>
        /// <param name="n">The note in the NoteViewModel</param>
        /// <param name="sv">The ScatterView Parent (here, SessionVM.Notes)</param>
        /// <param name="s">The current SessionViewModel</param>
        public NoteViewModel(Point center, Note n, ScatterView sv, SessionViewModel s)
            : base(s)
        {
            Note = n;

            SVItem = new ScatterViewItem();
            ParentSV = sv;

            SVItem.Center = center;

            SVItem.CanScale = false;
            SVItem.HorizontalAlignment = HorizontalAlignment.Center;
            SVItem.CanRotate = false;
            SVItem.HorizontalAlignment = HorizontalAlignment.Center;

            SetStyle();

            Animation = new NoteAnimation(this, SessionVM);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// NoteBubbleViewModel Constructor.
        /// </summary>
        public MelodyBubbleViewModel(MelodyBubble mb, ScatterView sv, SessionViewModel s)
            : base(s)
        {
            MelodyBubble = mb;
            SVItem = new ScatterViewItem();
            ParentSV = sv;

            Random r = new Random();
            SVItem.Center = new Point(r.Next((int)sv.ActualWidth), r.Next((int)(635 * sv.ActualHeight / 1080), (int)sv.ActualHeight));

            SVItem.CanScale = false;
            SVItem.HorizontalAlignment = HorizontalAlignment.Center;
            SVItem.CanRotate = false;
            SVItem.HorizontalAlignment = HorizontalAlignment.Center;

            FrameworkElementFactory bubbleImage = new FrameworkElementFactory(typeof(Image));

            bubbleImage.SetValue(Image.SourceProperty, new ThemeViewModel(SessionVM.Session.Theme, SessionVM).GetMelodyBubbleImageSource(mb.Melody.gesture));

            bubbleImage.SetValue(Image.IsHitTestVisibleProperty, false);

            bubbleImage.SetValue(Image.WidthProperty, (135.0 / 1920.0) * SessionVM.SessionSVI.ActualWidth);
            bubbleImage.SetValue(Image.HeightProperty, (135.0 / 1080.0) * SessionVM.SessionSVI.ActualHeight);

            FrameworkElementFactory touchZone = new FrameworkElementFactory(typeof(Ellipse));
            touchZone.SetValue(Ellipse.FillProperty, Brushes.Transparent);
            touchZone.SetValue(Ellipse.MarginProperty, new Thickness(15));

            FrameworkElementFactory grid = new FrameworkElementFactory(typeof(Grid));
            grid.AppendChild(bubbleImage);
            grid.AppendChild(touchZone);

            ControlTemplate ct = new ControlTemplate(typeof(ScatterViewItem));
            ct.VisualTree = grid;

            Style bubbleStyle = new Style(typeof(ScatterViewItem));
            bubbleStyle.Setters.Add(new Setter(ScatterViewItem.TemplateProperty, ct));
            SVItem.Style = bubbleStyle;

            Animation = new MelodyBubbleAnimation(this, SessionVM);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Constructor.
        /// Create a ThemeChooser in the SessionViewModel s
        /// </summary>
        /// <param name="s"></param>
        public ThemeChooser(SessionViewModel s)
        {
            sessionVM = s;
            double ratio = sessionVM.SessionSVI.Width / 1920.0;
            Grid = new Grid();
            Grid.Background = new SolidColorBrush(Colors.Black);
            Grid.Opacity = 0.8;

            Themes = new Grid();
            Themes.Width = 1036 * ratio;
            Themes.Height = 626 * ratio;
            Themes.VerticalAlignment = VerticalAlignment.Center;
            Themes.HorizontalAlignment = HorizontalAlignment.Center;
            Themes.Opacity = 1;

            border1 = new Border();
            border1.BorderBrush = new SolidColorBrush(Colors.White);
            border1.BorderThickness = new Thickness(4.0 * ratio);
            border1.Margin = new Thickness(20.0 * ratio, 20.0 * ratio, 20.0 * ratio, 20.0 * ratio);
            border1.HorizontalAlignment = HorizontalAlignment.Left;
            border1.VerticalAlignment = VerticalAlignment.Top;
            GridTheme1 = new Grid();
            GridTheme1.Width = 470.0 * ratio;
            GridTheme1.Height = 265.0 * ratio;
            ImageBrush img1 = new ImageBrush();
            img1.ImageSource = new BitmapImage(new Uri(@"../../Resources/Images/Theme1/background.jpg", UriKind.Relative));
            GridTheme1.Background = img1;
            border1.Child = GridTheme1;

            GridTheme1.PreviewTouchDown += new EventHandler<TouchEventArgs>(GridTheme1_TouchDown);

            border2 = new Border();
            border2.BorderBrush = new SolidColorBrush(Colors.White);
            border2.BorderThickness = new Thickness(4.0 * ratio);
            border2.Margin = new Thickness(20.0 * ratio, 20.0 * ratio, 20.0 * ratio, 20.0 * ratio);
            border2.HorizontalAlignment = HorizontalAlignment.Right;
            border2.VerticalAlignment = VerticalAlignment.Top;
            GridTheme2 = new Grid();
            GridTheme2.Width = 470.0 * ratio;
            GridTheme2.Height = 265.0 * ratio;
            ImageBrush img2 = new ImageBrush();
            img2.ImageSource = new BitmapImage(new Uri(@"../../Resources/Images/Theme2/background.jpg", UriKind.Relative));
            GridTheme2.Background = img2;
            border2.Child = GridTheme2;

            GridTheme2.PreviewTouchDown += new EventHandler<TouchEventArgs>(GridTheme2_TouchDown);

            border3 = new Border();
            border3.BorderBrush = new SolidColorBrush(Colors.White);
            border3.BorderThickness = new Thickness(4.0 * ratio);
            border3.Margin = new Thickness(20.0 * ratio, 20.0 * ratio, 20.0 * ratio, 20.0 * ratio);
            border3.HorizontalAlignment = HorizontalAlignment.Left;
            border3.VerticalAlignment = VerticalAlignment.Bottom;
            GridTheme3 = new Grid();
            GridTheme3.Width = 470.0 * ratio;
            GridTheme3.Height = 265.0 * ratio;
            ImageBrush img3 = new ImageBrush();
            img3.ImageSource = new BitmapImage(new Uri(@"../../Resources/Images/Theme3/background.jpg", UriKind.Relative));
            GridTheme3.Background = img3;
            border3.Child = GridTheme3;

            GridTheme3.PreviewTouchDown += new EventHandler<TouchEventArgs>(GridTheme3_TouchDown);

            border4 = new Border();
            border4.BorderBrush = new SolidColorBrush(Colors.White);
            border4.BorderThickness = new Thickness(4.0 * ratio);
            border4.Margin = new Thickness(20.0 * ratio, 20.0 * ratio, 20.0 * ratio, 20.0 * ratio);
            border4.HorizontalAlignment = HorizontalAlignment.Right;
            border4.VerticalAlignment = VerticalAlignment.Bottom;
            GridTheme4 = new Grid();
            GridTheme4.Width = 470.0 * ratio;
            GridTheme4.Height = 265.0 * ratio;
            ImageBrush img4 = new ImageBrush();
            img4.ImageSource = new BitmapImage(new Uri(@"../../Resources/Images/Theme4/background.jpg", UriKind.Relative));
            GridTheme4.Background = img4;
            border4.Child = GridTheme4;

            GridTheme4.PreviewTouchDown += new EventHandler<TouchEventArgs>(GridTheme4_TouchDown);

            Bird = new Grid();
            Bird.Width = 140.0 * ratio;
            Bird.Height = 165.0 * ratio;
            Bird.Margin = new Thickness(0, 585.0 * ratio, 80.0 * ratio, 0);
            Bird.Background = new SolidColorBrush(Colors.Transparent);

            Bird.PreviewTouchDown += new EventHandler<TouchEventArgs>(Bird_TouchDown);

            Dragon = new Grid();
            Dragon.Width = 175.0 * ratio;
            Dragon.Height = 275.0 * ratio;
            Dragon.Margin = new Thickness(0, 550.0 * ratio, 40.0 * ratio, 0);
            Dragon.Background = new SolidColorBrush(Colors.Transparent);

            Dragon.PreviewTouchDown += new EventHandler<TouchEventArgs>(Dragon_TouchDown);

            Cat = new Grid();
            Cat.Width = 200.0 * ratio;
            Cat.Height = 165.0 * ratio;
            Cat.Margin = new Thickness(0, 500.0 * ratio, 450.0 * ratio, 0);
            Cat.Background = new SolidColorBrush(Colors.Transparent);

            Cat.PreviewTouchDown += new EventHandler<TouchEventArgs>(Cat_TouchDown);

            Themes.Children.Add(border1);
            Themes.Children.Add(border2);
            Themes.Children.Add(border3);
            Themes.Children.Add(border4);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Constructor specific to a sessionviewmodel.
 /// </summary>
 /// <param name="s"></param>
 public ViewModelBase(SessionViewModel s)
 {
     SessionVM = s;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Event Occured when the DesktopView is loaded
        /// Create Directory for Sessions and the Snapshot
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void DesktopView_Loaded(object sender, RoutedEventArgs e)
        {
            AnimateSimpleSessionButton();
            AnimateDoubleSessionButton();

            string sPath = "Sessions/";
            Random r = new Random();
            foreach (string sFileName in System.IO.Directory.GetFiles(sPath))
            {
                if (System.IO.Path.GetExtension(sFileName) == ".bin")
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    FileStream stream = File.Open(sFileName, FileMode.Open);
                    SessionData sd = (SessionData)formatter.Deserialize(stream);
                    stream.Close();

                    if (File.Exists("SnapShots/sc" + sd.SessionID + ".jpg"))
                    {
                        IDs.Add(sd.SessionID);

                        string path = "SnapShots/sc" + sd.SessionID + ".jpg";
                        ImageBrush ss = new ImageBrush();
                        BitmapImage bi = new BitmapImage();
                        FileStream Fs = new FileStream(path, FileMode.Open, FileAccess.Read);

                        SessionVM = new SessionViewModel(ActualWidth, ActualHeight, new Session(), IDs, sd.SessionID);
                        SessionVM.LoadReducedSession(Fs, this);

                        bi.BeginInit();
                        bi.StreamSource = Fs;
                        bi.EndInit();
                        ss.ImageSource = bi;

                        SessionVM.Grid.Background = ss;

                        Photos.Items.Add(SessionVM.SessionSVI);
                        SessionVM.SessionSVI.Center = new Point(r.Next((int)ActualWidth), r.Next((int)ActualHeight));
                        openedSessions.Add(SessionVM);
                    }
                    else
                    {
                        try { File.Delete(sFileName); }
                        catch (Exception exc) { }
                    }
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Event handling the Create Session Button Click Action.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void CreateSession_Button_Click(object sender, RoutedEventArgs e)
        {
            if (Sessions.Items.Count == 0)
            {
                SessionVM = new SessionViewModel(ActualWidth, ActualHeight, new Session(), IDs, true);
                Sessions.Items.Add(SessionVM.SessionSVI);
            }
            else if (Sessions.Items.Count == 1)
            {
                if (LeftSessionActive)
                {
                    SessionVM = new SessionViewModel(false, ActualWidth, ActualHeight, new Session(), IDs);
                    Sessions.Items.Add(SessionVM.SessionSVI);
                    RightSessionActive = true;
                }
                else
                {
                    SessionVM = new SessionViewModel(true, ActualWidth, ActualHeight, new Session(), IDs);
                    Sessions.Items.Add(SessionVM.SessionSVI);
                    LeftSessionActive = true;
                }
            }

            openedSessions.Add(SessionVM);
            SessionVM.Session.PlayBackgroundSound();
            CheckDesktopToDisplay();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Event handling the Create Session Button Click Action.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void CreateDoubleSession_Button_Click(object sender, RoutedEventArgs e)
        {
            HideDesktop();
            SessionVM = new SessionViewModel(true, ActualWidth, ActualHeight, new Session(), IDs);
            Sessions.Items.Add(SessionVM.SessionSVI);
            openedSessions.Add(SessionVM);
            SessionVM.Session.PlayBackgroundSound();

            SessionVM = new SessionViewModel(false, ActualWidth, ActualHeight, new Session(), IDs);
            Sessions.Items.Add(SessionVM.SessionSVI);
            openedSessions.Add(SessionVM);
            SessionVM.Session.PlayBackgroundSound();

            LeftSessionActive = true;
            RightSessionActive = true;
            CheckDesktopToDisplay();
        }