예제 #1
0
        private void TagTextBox_GotFocus(object sender, RoutedEventArgs e)
        {
            // Quando clicco nella textbox, non si aggiorna la foto (perché l'evento viene consumato)
            // devo selezionare la riga io a mano

            ListViewItem lvi = AiutanteUI.GetAncestorByType(e.OriginalSource as DependencyObject, typeof(ListViewItem)) as ListViewItem;

            if (lvi != null)
            {
                bool front = true;

                if (front)
                {
                    // provoco lo spostamento sulla ListView del frontend
                    var idx = onrideListView.ItemContainerGenerator.IndexFromContainer(lvi);
                    onrideListView.SelectedIndex = idx;
                    lvi.IsSelected = true;
                }
                else
                {
                    // cosi funziona ma agisto sul viemwodel
                    FotoItem item = (FotoItem)lvi.Content;
                    viewModel.fotoItemsCW.MoveCurrentTo(item);
                }
            }
        }
예제 #2
0
        T findComponentFromTemplate <T>(Fotografia f, string nomeComponente)
        {
            // Per ricavare il componente desiderato, devo fare diversi passaggi

            // 2. dalla foto ricavo il ListBoxItem che la contiene
            ContentPresenter contentPresenter;
            var test = itemsControl.ItemContainerGenerator.ContainerFromItem(f);

            if (test is ContentControl)
            {
                // 3. dal ListBoxItem ricavo il suo ContentPresenter
                ContentControl listBoxItem = (ContentControl)test;
                contentPresenter = AiutanteUI.FindVisualChild <ContentPresenter>(listBoxItem);
            }
            else
            {
                // IL componente è già avvolto direttamente nel presenter
                contentPresenter = (ContentPresenter)test;
            }

            // 4. con il ContentPresenter ricavo il DataTemplate (del singolo elemento)
            DataTemplate dataTemplate = contentPresenter.ContentTemplate;

            // 5. con il DataTemplate ricavo l'Image contenuta

            return((T)dataTemplate.FindName(nomeComponente, contentPresenter));
        }
예제 #3
0
        private void mostraAreaStampabileButton_Click(object sender, RoutedEventArgs e)
        {
            ContentPresenter myContentPresenter = AiutanteUI.FindVisualChild <ContentPresenter>(LsImageGallery);

            // ListBoxItem co = (ListBoxItem)LsImageGallery.ItemContainerGenerator.ContainerFromIndex( 0 );

            iteraAlberoFigli(myContentPresenter);
            // iteraAlberoVisibili();
        }
        private void uploadNuovaImmagine()
        {
            string nomeFile = AiutanteUI.scegliFileImmagineDialog(null);

            if (nomeFile != null)
            {
                AiutanteFoto.setImmagineFotografo(nomeFile, entitaCorrente);
                caricaImmagineEsistente();
            }
        }
예제 #5
0
        void iteraAlberoFigli(FrameworkElement ele)
        {
            int quanti = VisualTreeHelper.GetChildrenCount(ele);

            for (int i = 0; i < quanti; i++)
            {
                var child = VisualTreeHelper.GetChild(ele, i) as FrameworkElement;
                if (child.Name == "fotoCanvas")
                {
                    // Per far prima, invece che applicarlo a tutti, la applico soltanto ai componenti visibili
                    if (AiutanteUI.IsUserVisible(ele, LsImageGallery))
                    {
                        Canvas canvas = (Canvas)child;

                        // prima controllo che non ce l'ho già messo
                        if (AiutanteUI.FindVisualChild <Border>(canvas, "borderCopriA") == null)
                        {
                            Border borderA = new Border();
                            borderA.Name = "borderCopriA";
                            borderA.HorizontalAlignment = HorizontalAlignment.Left;
                            borderA.VerticalAlignment   = VerticalAlignment.Top;
                            borderA.Style = (Style)FindResource("styleBorderCopriA");
                            canvas.Children.Add(borderA);
                            borderA.SetValue(Canvas.ZIndexProperty, 99);
                        }

                        if (AiutanteUI.FindVisualChild <Border>(canvas, "borderCopriB") == null)
                        {
                            Border borderB = new Border();
                            borderB.Name = "borderCopriB";
                            borderB.HorizontalAlignment = HorizontalAlignment.Left;
                            borderB.VerticalAlignment   = VerticalAlignment.Top;
                            borderB.Style = (Style)FindResource("styleBorderCopriB");
                            canvas.Children.Add(borderB);
                            borderB.SetValue(Canvas.ZIndexProperty, 99);
                        }
                    }
                }
                else
                {
                    iteraAlberoFigli(child);
                }
            }
        }
예제 #6
0
        public void gestioneAreaStampabileHQ(bool spegniForzatamente)
        {
            // Se non so il ratio dell'area stampabile, esco subito
            if (fotoGalleryViewModel.ratioAreaStampabile == 0f)
            {
                return;
            }

            if (fotoGalleryViewModel.fotografieCW == null)
            {
                return;
            }

            if (spegniForzatamente == false && fotoGalleryViewModel.vorreiVisualizzareAreaDiRispettoHQ == false)
            {
                return;
            }

            if (spegniForzatamente == false && fotoGalleryViewModel.isAltaQualita)
            {
                if (fotoGalleryViewModel.fotografieCW.Count > 2)
                {
                    return;
                }

                itemsControl.UpdateLayout();


                if (coperturaRispettoStyle == null)
                {
                    coperturaRispettoStyle = contentControl.FindResource("coperturaRispettoStyle") as Style;
                }

                // Le foto in alta qualità possono essere 1 oppure 2 affiancate
                foreach (Fotografia foto in fotoGalleryViewModel.fotografieCW)
                {
                    Rectangle[] rettangoli = new Rectangle[2];
                    bool        esiste     = false;

                    Grid fotoGrid = findFotoGrid(foto);

                    for (char ab = 'A'; ab <= 'B'; ab++)
                    {
                        // -- areaStampabileA - areaStampabileB
                        int    pos  = ab - 'A';
                        string nome = string.Format("areaStampabile{0}", ab);

                        rettangoli[pos] = (Rectangle)AiutanteUI.FindChild(fotoGrid, nome, typeof(Rectangle));

                        esiste = rettangoli[pos] != null;
                        if (!esiste)
                        {
                            rettangoli[pos]       = new Rectangle();
                            rettangoli[pos].Name  = nome;
                            rettangoli[pos].Style = coperturaRispettoStyle;
                        }
                    }

                    dimensionaRettangoloPerAreaDiRispetto(rettangoli, fotoGrid);


                    if (!esiste)
                    {
                        fotoGrid.Children.Add(rettangoli[0]);
                        fotoGrid.Children.Add(rettangoli[1]);
                    }
                }
            }
            else
            {
                // Elimino tutti i rettangoli. Possono essere 2 o 4
                foreach (Fotografia foto in fotoGalleryViewModel.fotografieCW)
                {
                    Grid fotoGrid = findFotoGrid(foto);
                    for (char ab = 'A'; ab <= 'B'; ab++)
                    {
                        // -- areaStampabileA - areaStampabileB
                        int       pos        = ab - 'A';
                        string    nome       = string.Format("areaStampabile{0}", ab);
                        Rectangle rettangolo = (Rectangle)AiutanteUI.FindChild(fotoGrid, nome, typeof(Rectangle));
                        if (rettangolo != null)
                        {
                            fotoGrid.Children.Remove(rettangolo);
                        }
                    }
                }
            }
        }