Пример #1
0
        /// <summary>
        /// Handles changes to the IsAnimated property.
        /// </summary>
        private static void OnIsAnimatedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            BaseWindow target        = (BaseWindow)d;
            bool       oldIsAnimated = (bool)e.OldValue;
            bool       newIsAnimated = target.IsAnimated;

            target.OnIsAnimatedChanged(oldIsAnimated, newIsAnimated);
        }
Пример #2
0
        public BaseWindow AddWindow(BaseWindow window, bool bringToFront = true)
        {
            zuiContainer.Add(window).Show(bringToFront);
            BindWindow(window);

            //GalleryWindow gw = window as GalleryWindow; //TODO: try to remove this patch (needed to be able to load activities with saved gallery that has a filter set to it)
            //if (gw != null) gw.RefreshFilter(); //could use (window as GalleryWindow)?.RefreshFilter() in next C# version

            return(window);
        }
Пример #3
0
        public static void SaveWindow(BaseWindow window, ZipFile zip, string zipFolder = "") //save window to nested archive
        {
            string title = ((string)window.Title).TrimStart();                               //using TrimStart() to not have filenames start with space chars in case it's an issue with ZIP spec

            if (title == "")
            {
                title = window.GetType().Name;
            }
            zip.AddEntry(
                zipFolder + "/" + title.ReplaceInvalidFileNameChars() + " - " + window.View.ID + BaseWindow.CLIPFLAIR_ZIP_EXTENSION, //using .clipflair.zip extension for nested components' state to ease examining with ZIP archivers
                new WriteDelegate((entryName, stream) => { window.SaveOptions(stream); }));                                          //save ZIP file for child window
        }
Пример #4
0
        public override void LoadOptions(FileInfo f)
        {
            if (!f.Name.EndsWith(new string[] { CLIPFLAIR_EXTENSION, CLIPFLAIR_ZIP_EXTENSION }))
            {
                IFileWindowFactory windowFactory = GetFileWindowFactory(f.Extension.ToUpper()) ?? new TextEditorWindowFactory();

                BaseWindow window = windowFactory.CreateWindow();
                activity.AddWindow(window);               //some components may require to be added to a parent container first, then add content to them
                window.LoadContent(f.OpenRead(), f.Name); //not closing the stream (components like MediaPlayerWindow require it open) //TODO: make sure those components close the streams when not using them anymore
            }
            else
            {
                base.LoadOptions(f);
            }
        }
Пример #5
0
        public BaseWindow AddWindowInViewCenter(BaseWindow window, bool autozoom = false) //TODO: have param to add some randomness (within given x,y offsets)
        {
            ZoomAndPanControl host = zuiContainer.ZoomHost;

            if (autozoom) //TODO: see why when using autozoom at zoomed out container on small screens, new windows can get out of screen bounds on the top
            {
                double zoom = host.ContentScale;
                window.Scale = 1.0d / zoom;
            }

            Point startPoint = new Point(host.ContentOffsetX + host.ContentViewportWidth / 2,
                                         host.ContentOffsetY + host.ContentViewportHeight / 2); //Center at current view //must use ContentViewport methods, not Viewport ones (they give width/height in content coordinates)

            zuiContainer.Add(window).Show(startPoint, true);
            BindWindow(window); //Note: this is the moment after adding the window to the visual tree
            return(window);
        }
Пример #6
0
        public static BaseWindow LoadWindow(ZipFile zip, string zipFolder = "") //doesn't close stream
        {
            foreach (ZipEntry options in zip.SelectEntries("*.options.xml", zipFolder))
            {
                int offset = zipFolder.Length;
                if (offset != 0)
                {
                    offset += 1;      //add +1 for the "/" path separator, only if a folder path has been given
                }
                string typeName = options.FileName.Substring(offset, options.FileName.Length - offset - ".options.xml".Length);

                BaseWindow window = GetWindowFactory(typeName).CreateWindow();
                window.LoadOptions(zip, zipFolder);
                return(window);
            }
            return(null);
        }
Пример #7
0
 private void BindWindow(BaseWindow window)
 {
     window.ViewChanged += (d, e) => { BindWindow(window); }; //rebind the window if its view changes (e.g. after it loads new state)
     //TODO: remove this when no hard-coded bindings are needed any more
     if (window is MediaPlayerWindow)
     {
         BindMediaPlayerWindow((MediaPlayerWindow)window);
     }
     else if (window is CaptionsWindow)
     {
         BindCaptionsGridWindow((CaptionsWindow)window);
     }
     else if (window is TextEditorWindow)
     {
         BindTextEditorWindow((TextEditorWindow)window);
     }
     else if (window is ImageWindow)
     {
         BindImageWindow((ImageWindow)window);
     }
     else if (window is MapWindow)
     {
         BindMapWindow((MapWindow)window);
     }
     else if (window is NewsWindow)
     {
         BindNewsWindow((NewsWindow)window);
     }
     else if (window is BrowserWindow)
     {
         BindBrowserWindow((BrowserWindow)window);
     }
     else if (window is GalleryWindow)
     {
         BindGalleryWindow((GalleryWindow)window);
     }
 }
Пример #8
0
        public BaseWindow AddWindow(IWindowFactory windowFactory, bool newInstance = false)
        {
            try
            {
                BaseWindow w = windowFactory.CreateWindow();

                if (!newInstance)
                {
                    AddWindow(w);
                }
                else
                {                                                   //TODO: must change this scheme to remove hardcoded logic here, by using reverse binding order (source=container, target=component) when adding a new component manually than when loading saved state
                    TimeSpan      activityTime     = View.Time;     //Since settings Captions can change Time (jump to 0), must cache it here
                    CaptionRegion activityCaptions = View.Captions; //Since we use it at various if/else clauses below, better do this once here (doesn't cost much) to generate smaller compiled code

                    //for new child window instances (that the user adds), must reset their properties to match their containers so that they don't cause other components bound to the container to lose their Time/Captions when these get bound as sources to the container (which AddWindow does by calling BindWindow)
                    if (w is MediaPlayerWindow)
                    {
                        IMediaPlayer v = ((MediaPlayerWindow)w).MediaPlayerView;
                        //v.Captions = activityCaptions; //first set Captions, then Time //Note: this one is not needed since we added reverse binding logic for the Clip component (both at loading from saved state and for new one added in activity) - it doesn't store captions in its saved state
                        v.Time = activityTime;
                    }
                    else if (w is CaptionsWindow)
                    {
                        ICaptionsGrid v = ((CaptionsWindow)w).CaptionsGridView;
                        v.Captions = activityCaptions; //first set Captions, then Time
                        v.Time     = activityTime;
                    }
                    else if (w is TextEditorWindow)
                    {
                        ITextEditor2 v = ((TextEditorWindow)w).TextEditorView2;
                        //v.Captions = activityCaptions; //first set Captions, then Time
                        v.Time = activityTime;
                    }
                    else if (w is ImageWindow)
                    {
                        IImageViewer v = ((ImageWindow)w).ImageView;
                        v.Time = activityTime;
                    }
                    else if (w is MapWindow)
                    {
                        IMapViewer v = ((MapWindow)w).MapView;
                        //v.Captions = activityCaptions; //first set Captions, then Time
                        v.Time = activityTime;
                    }
                    else if (w is NewsWindow)
                    {
                        INewsReader v = ((NewsWindow)w).NewsView;
                        //v.Time = activityTime; //doesn't use the Time property
                    }
                    else if (w is BrowserWindow)
                    {
                        IBrowser v = ((BrowserWindow)w).BrowserView;
                        //v.Time = activityTime; //doesn't use the Time property
                    }
                    else if (w is GalleryWindow)
                    {
                        IGallery v = ((GalleryWindow)w).GalleryView;
                        //v.Time = activityTime; //doesn't use the Time property
                    }
                    AddWindowInViewCenter(w);
                };

                return(w);
            }
            catch (Exception e)
            {
                ErrorDialog.Show("Failed to create component", e);
                return(null);
            }
        }