Esempio n. 1
0
 public void CaricaSequenza(PersisterMapper <Sequenza> sequenza)
 {
     _sequenza = sequenza.Element;
     _wrapper  = sequenza;
     FillList();
     OpenEditorForIndex(0);
 }
Esempio n. 2
0
        private void OnLabelDoubleClick(object sender, EventArgs args)
        {
            Label    clicked = (Label)sender;
            Sequenza s       = clicked.Tag as Sequenza;

            if (null == s)
            {
                return;
            }
            VisualizzaEditorPer(s);
        }
Esempio n. 3
0
        private void OnEliminaSequenzaClick(object sender, EventArgs args)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            Sequenza          s    = item.Tag as Sequenza;

            _wrapper.Element.Remove(s ?? throw new ArgumentNullException("La label selezionata non ha un tag valido"));
            if (0 == _wrapper.Element.Sequenze.Count())
            {
                _wrapper.Element.InserisciSequenza(Sequenza.Default, new FasciaOraria(0, 4));
                VisualizzaEditorPer(_wrapper.Element.Sequenze.ElementAt(0));
            }
            UpdateLabels();
        }
Esempio n. 4
0
        public SequenzaEditorPresenter(Modello modello)
        {
            _editor        = new SequenzaEditor();
            _editorFactory = Documento.getInstance().EditorFactory;
            _editor.Dock   = DockStyle.Fill;
            Sequenza s = new Sequenza();

            s.AggiungiElemento(Elemento.Default, 30);
            CaricaSequenza(new PersisterMapper <Sequenza>(s));

            _draggedElementIndex = -1;

            PopulateElementChoices();
            OnLibreriaChange(this, EventArgs.Empty);
            AttachHandlers();
        }
Esempio n. 5
0
        private void VisualizzaEditorPer(Sequenza s)
        {
            if (null != _sequenzaEditor)
            {
                _editor.EditorContainer.Controls.Remove(_sequenzaEditor.Editor);
            }
            _sequenzaEditor = Documento.getInstance().EditorFactory.GetEditorHandler(s.GetType(), Documento.getInstance().ModelloRiferimento);
            _sequenzaEditor.CaricaModello(new PersisterMapper <Sequenza>(s));
            _editor.EditorContainer.Controls.Add(_sequenzaEditor.Editor);
            _sequenzaEditor.Editor.BringToFront();
            _editor.NomeField.Text = s.Nome;
            FasciaOraria fo = _wrapper.Element.GetFasciaOrariaOf(s);

            _currentSequenza = s;
            _editor.StartPicker.InitValue = fo.StartToDateTime();
            _editor.EndPicker.InitValue   = fo.EndToDateTime();
            ControllaPickers(fo);
        }
Esempio n. 6
0
        private void OnAggiungiSequenzaClick(object sender, EventArgs args)
        {
            if (0 > _selectedLabel)
            {
                return;
            }
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            Sequenza          s    = item.Tag as Sequenza;

            if (null == s)
            {
                throw new ArgumentException("Tag nullo nella lista delle sequenze da libreria");
            }
            _wrapper.Element.InserisciSequenza(s, new FasciaOraria((uint)_selectedLabel, (uint)++_selectedLabel));
            VisualizzaEditorPer(s);
            UpdateLabels();
            _selectedLabel = -1;
        }
Esempio n. 7
0
        private void OnNuovaSequenzaClick(object sender, EventArgs args)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            int      index         = (int)item.Tag;
            Sequenza s             = new Sequenza();

            s.AggiungiElemento(Elemento.Default, 10);
            string name = InputPrompt.ShowInputDialog("Inserisci un nome per la nuova sequenza", "Nuova sequenza", "OK", "annulla");

            if (null == name)
            {
                return;
            }
            s.Nome = name;
            _wrapper.Element.InserisciSequenza(s, new FasciaOraria((uint)index, (uint)++index));
            VisualizzaEditorPer(s);
            UpdateLabels();
        }
Esempio n. 8
0
        private void OnRinominaSequenzaClick(object sender, EventArgs args)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            Sequenza          s    = item.Tag as Sequenza;

            if (null == s)
            {
                throw new ArgumentNullException("La label selezionata non ha un tag valido");
            }
            string newName = InputPrompt.ShowInputDialog("Inserisci il nuovo nome per la sequenza selezionata", "Modifica nome", "OK", "Annulla", s.Nome);

            s.Nome = newName ?? s.Nome;
            if (s == _currentSequenza)
            {
                _editor.NomeField.Text = newName;
            }
            UpdateLabels();
        }
Esempio n. 9
0
        private void SetSequenzaOnLabels(Sequenza s, FasciaOraria fasciaOraria, bool odd)
        {
            _editor.SuspendLayout();
            int argb = ALPHA_CHANNEL | 200 << (odd ? 16 : 0);
            int startingNameIndex = fasciaOraria.CoveredQuarters < s.Nome.Length ? 0 : ((int)fasciaOraria.CoveredQuarters - s.Nome.Length) / 2;

            for (uint i = fasciaOraria.StartQuarter; i < fasciaOraria.EndQuarter; i++)
            {
                uint relativeIndex = i - fasciaOraria.StartQuarter;
                bool isInside      = relativeIndex >= startingNameIndex && relativeIndex <= startingNameIndex + s.Nome.Length - 1;
                char content       = isInside ? s.Nome.ToCharArray()[relativeIndex - startingNameIndex] : ' ';
                _editor.Labels[i].Text        = String.Format("{0}", content);
                _editor.Labels[i].BackColor   = Color.FromArgb(argb);
                _editor.Labels[i].BorderStyle = BorderStyle.None;
                _editor.Labels[i].ForeColor   = Color.White;
                _editor.Labels[i].Tag         = s;
                _editor.ToolTip.SetToolTip(_editor.Labels[i], s.Nome);
                _editor.Labels[i].DoubleClick += OnLabelDoubleClick;
            }
            _editor.ResumeLayout();
        }
Esempio n. 10
0
 public void N_zero()
 {
     int[] valori = new int[] {};
     Assert.Equal(valori, Sequenza.Verifica(0));
 }
Esempio n. 11
0
 public void N_negativo_torna_vuoto()
 {
     int[] valori = new int[] { };
     Assert.Equal(valori, Sequenza.Verifica(-5));
 }
Esempio n. 12
0
 public void N_cinque()
 {
     int[] valori = new int[] { 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5 };
     Assert.Equal(valori, Sequenza.Verifica(5));
 }
Esempio n. 13
0
 public void N_quattro()
 {
     int[] valori = new int[] { 1, 2, 2, 3, 3, 3, 4, 4, 4, 4 };
     Assert.Equal(valori, Sequenza.Verifica(4));
 }
Esempio n. 14
0
 public void N_tre()
 {
     int[] valori = new int[] { 1, 2, 2, 3, 3, 3 };
     Assert.Equal(valori, Sequenza.Verifica(3));
 }
Esempio n. 15
0
 public void N_due()
 {
     int[] valori = new int[] { 1, 2, 2 };
     Assert.Equal(valori, Sequenza.Verifica(2));
 }
Esempio n. 16
0
 public void N_uno()
 {
     int[] valori = new int[] { 1 };
     Assert.Equal(valori, Sequenza.Verifica(1));
 }