示例#1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="width">The real Width</param>
        /// <param name="height">The real Height</param>
        /// <param name="s">The Session</param>
        /// <param name="IDs">List of IDs</param>
        /// <param name="animated">True if animated</param>
        public SessionViewModel(Double width, Double height, Session s, List<int> IDs, bool animated)
        {
            Session = s;
            BeingDeleted = false;
            InitialScale = true;
            removeDeleteButtonsOnTouchUp = false;
            SessionSVI = new ScatterViewItem();
            SessionSVI.Width = width;
            SessionSVI.Height = height;

            ratio = width / 1920.0;
            originalRatio = width / 1920.0;

            ThemeVM = new ThemeViewModel(Session.Theme, this);
            Grid = new Grid();
            UpdateSound = new ChangeSoundViewModel(this);
            Bubbles = new ScatterView();
            Notes = new ScatterView();
            NotesOnStave = new List<NoteViewModel>();
            NbgVM = new NoteBubbleGeneratorViewModel(Session.NoteBubbleGenerator, this);
            MbgVM = new MelodyBubbleGeneratorViewModel(Session.MelodyBubbleGenerator, this);

            Orientation = "bottom";
            SessionSVI.Opacity = 0;
            Bubbles.Visibility = Visibility.Visible;
            Notes.Visibility = Visibility.Visible;

            Grid.Background = (new ThemeViewModel(Session.Theme, this)).BackgroundImage;

            Play_Button = new Grid();
            Play_Button.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            Play_Button.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            Play_Button.Background = ThemeVM.PlayImage;
            Play_Button.Visibility = Visibility.Visible;
            IsPlaying = false;

            previewGrid = new Grid();
            ImageBrush previewGridImage = new ImageBrush();
            previewGridImage.ImageSource = new BitmapImage(new Uri(@"../../Resources/Images/ui_items/previewGrid.png", UriKind.Relative));
            previewGrid.Background = previewGridImage;
            previewGrid.Opacity = 0;
            previewGrid.Margin = new Thickness(150.0 * ratio, 90.0 * ratio, 90.0 * ratio, 480.0 * ratio);

            topStaveHighlight = new Grid();
            ImageBrush tSHImage = new ImageBrush();
            tSHImage.ImageSource = new BitmapImage(new Uri(@"../../Resources/Images/ui_items/blackStaveHighlight.png", UriKind.Relative));
            topStaveHighlight.Background = tSHImage;
            topStaveHighlight.Opacity = 0;
            topStaveHighlight.Margin = new Thickness(0.0, 60.0 * ratio, 0.0, 480.0 * ratio);

            bottomStaveHighlight = new Grid();
            ImageBrush bSHImage = new ImageBrush();
            bSHImage.ImageSource = new BitmapImage(new Uri(@"../../Resources/Images/ui_items/whiteStaveHighlight.png", UriKind.Relative));
            bottomStaveHighlight.Background = bSHImage;
            bottomStaveHighlight.Opacity = 0;
            bottomStaveHighlight.Margin = new Thickness(0.0, 60.0 * ratio, 0.0, 480.0 * ratio);

            Play_Button.PreviewTouchDown += new EventHandler<TouchEventArgs>(Play_Button_TouchDown);

            Theme_Button = new Grid();
            Theme_Button.Width = 351;
            Theme_Button.Height = 110;
            Theme_Button.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            Theme_Button.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            Theme_Button.Margin = new Thickness(0, 0, 100.0 * ratio, 0);
            Theme_Button.Background = ThemeVM.ThemesImage;

            Tempo_Button = new Grid();
            Tempo_Button.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            Tempo_Button.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            Tempo_Button.Margin = new Thickness(0, 0, 470.0 * ratio, 0);
            Tempo_Button.Background = ThemeVM.TempoImage[1];
            Tempo_Button.PreviewTouchDown += new EventHandler<TouchEventArgs>(Tempo_Button_TouchDown);

            SessionSVI.CanMove = false;
            SessionSVI.CanRotate = false;
            SessionSVI.ShowsActivationEffects = false;

            displayTrees(new Thickness(20.0 * ratio, 0, 0, 130.0 * ratio), new Thickness(20.0 * ratio, 0, 0, 580.0 * ratio));

            PlayBar = new Grid();
            PlayBar.Width = 12.0 * ratio;
            PlayBar.Height = 490.0 * ratio;
            ImageBrush PBImage = new ImageBrush();
            PBImage.ImageSource = new BitmapImage(new Uri(@"../../Resources/Images/ui_items/play_bar.png", UriKind.Relative));
            PlayBar.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            PlayBar.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            PlayBar.Margin = new Thickness(120.0 * ratio, 99.0 * ratio, 0.0, 0.0);
            PlayBar.Background = PBImage;
            PlayBar.Opacity = 0.0;

            PlayBarCache = new Grid();
            PlayBarCache.Width = 1920.0 * ratio;
            PlayBarCache.Height = 531.0 * ratio;
            PlayBarCache.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            PlayBarCache.Margin = new Thickness(0.0, 98.0 * ratio, 0.0, 0.0);
            PlayBarCache.Background = ThemeVM.PlayBarCache;
            PlayBarCache.Opacity = 0.0;

            StaveCache = new Grid();
            StaveCache.Width = 1920.0 * ratio;
            StaveCache.Height = 491.0 * ratio;
            ImageBrush SCImage = new ImageBrush();
            SCImage.ImageSource = new BitmapImage(new Uri(@"../../Resources/Images/ui_items/staves.png", UriKind.Relative));
            StaveCache.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            StaveCache.Margin = new Thickness(0.0, 98.0 * ratio, 0.0, 0.0);
            StaveCache.Background = SCImage;
            StaveCache.Opacity = 0.0;

            Grid.Children.Add(PlayBar);
            Grid.Children.Add(PlayBarCache);
            Grid.Children.Add(StaveCache);
            Grid.Children.Add(Bubbles);
            Grid.Children.Add(Notes);
            Grid.Children.Add(NbgVM.Grid);
            Grid.Children.Add(MbgVM.Grid);
            Grid.Children.Add(Play_Button);
            Grid.Children.Add(Tempo_Button);
            Grid.Children.Add(UpdateSound.Grid);
            Grid.Children.Add(previewGrid);
            Grid.Children.Add(topStaveHighlight);
            Grid.Children.Add(bottomStaveHighlight);

            Grid.SetZIndex(UpdateSound.Grid, 7);
            Grid.SetZIndex(TreeUp.Grid, 6);
            Grid.SetZIndex(TreeDown.Grid, 6);
            Grid.SetZIndex(Bubbles, 5);
            Grid.SetZIndex(Notes, 4);
            Grid.SetZIndex(NbgVM.Grid, 3);
            Grid.SetZIndex(MbgVM.Grid, 3);
            Grid.SetZIndex(Play_Button, 3);
            Grid.SetZIndex(Theme_Button, 3);
            Grid.SetZIndex(Tempo_Button, 3);
            Grid.SetZIndex(previewGrid, 2);
            Grid.SetZIndex(StaveCache, 2);
            Grid.SetZIndex(topStaveHighlight, 2);
            Grid.SetZIndex(bottomStaveHighlight, 2);
            Grid.SetZIndex(PlayBarCache, 1);
            Grid.SetZIndex(PlayBar, 0);

            SessionSVI.Content = Grid;

            ThemeChooser = new ThemeChooser(this);
            Theme_Button.PreviewTouchDown += new EventHandler<TouchEventArgs>(ThemeChooser.Theme_Button_TouchDown);

            int i = 1;
            while (IDs.Contains(i)) i++;
            SessionID = i;
            IDs.Add(i);

            SetDimensions(width, height);
            SessionSVI.Center = new Point(width / 2.0, height / 2.0);

            if (animated) Animation = new SessionAnimation(this);

            DeleteButton = new SurfaceButton();
            DeleteButton.Visibility = Visibility.Hidden;
            ImageBrush ib = new ImageBrush();
            ib.ImageSource = new BitmapImage(new Uri(@"../../Resources/Images/ui_items/delete-icon.png", UriKind.Relative));
            DeleteButton.Background = ib;
            DeleteButton.Width = 25.0;
            DeleteButton.Height = 25.0;
            DeleteButton.HorizontalAlignment = HorizontalAlignment.Left;
            DeleteButton.VerticalAlignment = VerticalAlignment.Top;
            Grid.Children.Add(DeleteButton);

            Grid.SetZIndex(DeleteButton, 1000);

            DeleteButton.PreviewTouchDown += new EventHandler<TouchEventArgs>(DeleteButton_PreviewTouchDown);

            SessionSVI.SizeChanged += new SizeChangedEventHandler(SessionSVI_SizeChanged);
            SessionSVI.PreviewTouchUp += new EventHandler<TouchEventArgs>(SessionSVI_TouchLeave);
        }
示例#2
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);
        }