Esempio n. 1
0
        private void Library_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            e.Handled = true;
            if (Library.SelectedItems.Count != 1)
            {
                preview.Slide = null;
                propertyGrid.SelectedObject = new SlmProperties(null, _slideLib);
                return;
            }

            SlmVignette item = Library.SelectedItem as SlmVignette;
            SlideObject sld  = _slideLib._Slides [item.Name];

            preview.Slide = sld;
            propertyGrid.SelectedObject = new SlmProperties(sld, _slideLib);
        }
Esempio n. 2
0
        private ObservableCollection <SlmVignette> MergeAndGenerateBadges(string [] files)
        {
            Point pt = Library.PointToScreen(new Point(0, 0));

            _margins = new Thickness(pt.X, pt.Y, pt.X + Library.ActualWidth, pt.Y + Library.ActualHeight);

            _waitThread = new Thread(this.RunWaitThread);
            _waitThread.IsBackground = true;
            _waitThread.SetApartmentState(ApartmentState.STA);
            _waitThread.Start();
            Thread.Sleep(0);

            ObservableCollection <SlmVignette> newItems = new ObservableCollection <SlmVignette> ();
            ObservableCollection <SlmVignette> items    = new ObservableCollection <SlmVignette> ();

            if (Library.ItemsSource != null)
            {
                items = new ObservableCollection <SlmVignette> ((IEnumerable <SlmVignette>)Library.ItemsSource);
            }
            foreach (string fileName in files)
            {
                if (SlideLibObject.IsSlideLibrary(fileName))
                {
                    SlideLibObject slb = new SlideLibObject(fileName);
                    //_slideLib._Slides =_slideLib._Slides.Concat (slb._Slides).GroupBy (d => d.Key)
                    //	.ToDictionary (d => d.Key, d => d.First ().Value) ;
                    foreach (KeyValuePair <string, SlideObject> slide in slb._Slides)
                    {
                        string name = slide.Key;
                        if (_slideLib._Slides.ContainsKey(slide.Key))
                        {
                            for (int i = 0;; i++)
                            {
                                string st = name + i;
                                if (!_slideLib._Slides.ContainsKey(st))
                                {
                                    name = st;
                                    break;
                                }
                            }
                        }
                        _slideLib._Slides.Add(name, slide.Value);

                        SlmVignette badge = new SlmVignette()
                        {
                            Name  = name,
                            Type  = slide.Value._Size.Width + "x" + slide.Value._Size.Height,
                            Image = slide.Value.Export(70, 70)
                        };
                        items.Add(badge);
                        newItems.Add(badge);
                    }
                    _dirty = true;
                }
                if (SlideObject.IsSlide(fileName) && !_slideLib._Slides.ContainsKey(System.IO.Path.GetFileNameWithoutExtension(fileName)))
                {
                    SlideObject sld = new SlideObject(fileName);
                    sld._Name = System.IO.Path.GetFileNameWithoutExtension(fileName);
                    _slideLib._Slides.Add(sld._Name, sld);
                    _dirty = true;

                    SlmVignette badge = new SlmVignette()
                    {
                        Name  = sld._Name,
                        Type  = sld._Size.Width + "x" + sld._Size.Height,
                        Image = sld.Export(70, 70)
                    };
                    items.Add(badge);
                    newItems.Add(badge);
                }
                Thread.Sleep(0);
            }

            Library.ItemsSource = items;
            Library.Items.Refresh();

            Thread.Sleep(200);
            while (_waitDialog == null)
            {
                Thread.Sleep(100);
            }
            _waitDialog.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => {
                _waitDialog.Close();
            }));
            if (_waitThread.IsAlive)
            {
                _waitThread.Abort();
            }

            return(newItems);
        }
        private ObservableCollection<SlmVignette> MergeAndGenerateBadges(string[] files)
        {
            Point pt = Library.PointToScreen(new Point(0, 0));
            _margins = new Thickness(pt.X, pt.Y, pt.X + Library.ActualWidth, pt.Y + Library.ActualHeight);

            _waitThread = new Thread(this.RunWaitThread);
            _waitThread.IsBackground = true;
            _waitThread.SetApartmentState(ApartmentState.STA);
            _waitThread.Start();
            Thread.Sleep(0);

            ObservableCollection<SlmVignette> newItems = new ObservableCollection<SlmVignette>();
            ObservableCollection<SlmVignette> items = new ObservableCollection<SlmVignette>();
            if (Library.ItemsSource != null)
                items = new ObservableCollection<SlmVignette>((IEnumerable<SlmVignette>)Library.ItemsSource);
            foreach (string fileName in files)
            {
                if (SlideLibObject.IsSlideLibrary(fileName))
                {
                    SlideLibObject slb = new SlideLibObject(fileName);
                    //_slideLib._Slides =_slideLib._Slides.Concat (slb._Slides).GroupBy (d => d.Key)
                    //	.ToDictionary (d => d.Key, d => d.First ().Value) ;
                    foreach (KeyValuePair<string, SlideObject> slide in slb._Slides)
                    {
                        string name = slide.Key;
                        if (_slideLib._Slides.ContainsKey(slide.Key))
                        {
                            for (int i = 0; ; i++)
                            {
                                string st = name + i;
                                if (!_slideLib._Slides.ContainsKey(st))
                                {
                                    name = st;
                                    break;
                                }
                            }
                        }
                        _slideLib._Slides.Add(name, slide.Value);

                        SlmVignette badge = new SlmVignette()
                        {
                            Name = name,
                            Type = slide.Value._Size.Width + "x" + slide.Value._Size.Height,
                            Image = slide.Value.Export(70, 70)
                        };
                        items.Add(badge);
                        newItems.Add(badge);
                    }
                    _dirty = true;
                }
                if (SlideObject.IsSlide(fileName) && !_slideLib._Slides.ContainsKey(System.IO.Path.GetFileNameWithoutExtension(fileName)))
                {
                    SlideObject sld = new SlideObject(fileName);
                    sld._Name = System.IO.Path.GetFileNameWithoutExtension(fileName);
                    _slideLib._Slides.Add(sld._Name, sld);
                    _dirty = true;

                    SlmVignette badge = new SlmVignette()
                    {
                        Name = sld._Name,
                        Type = sld._Size.Width + "x" + sld._Size.Height,
                        Image = sld.Export(70, 70)
                    };
                    items.Add(badge);
                    newItems.Add(badge);
                }
                Thread.Sleep(0);
            }

            Library.ItemsSource = items;
            Library.Items.Refresh();

            Thread.Sleep(200);
            while (_waitDialog == null)
                Thread.Sleep(100);
            _waitDialog.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() =>
            {
                _waitDialog.Close();
            }));
            if (_waitThread.IsAlive)
                _waitThread.Abort();

            return (newItems);
        }