Esempio n. 1
0
        public CreateBookmarkCommand(Viking.UI.Controls.SectionViewerControl parent, FolderUIObj parentFolder)
            : base(parent)
        {
            //Make the cursor something distinct and appropriate for measuring
            parent.Cursor = Cursors.Cross;
            //Cursor.Hide();

            ParentFolder = parentFolder;

            this.CommandActive = true;
        }
Esempio n. 2
0
        public static bool Load(string BookmarkFileName)
        {
            try
            {
                if (System.IO.File.Exists(BookmarkFileName))
                {
                    BookmarkXMLDoc = XRoot.Load(BookmarkFileName);
                    FolderUIObjRoot = new FolderUIObj(null, FolderRoot);
                    SelectedFolder = FolderUIObjRoot;
                    return true;
                }
            }
            catch (Xml.Schema.Linq.LinqToXsdException)
            {
                //We found it, but could not parse it
                HandleIncorrectXSDMessage();
            }
            catch
            {

            }

            return false;
        }
Esempio n. 3
0
        public bool Initialize()
        {
            //Check if there is a local favorites XML file, if it does not exist, create it, we always return true

            try
            {
                if (false == System.IO.Directory.Exists(BookmarkPath))
                {
                    System.IO.Directory.CreateDirectory(BookmarkPath);
                }

                if (false == System.IO.File.Exists(BookmarkFilePath))
                {
                    bool Restored = LoadBookmarksFromBackup();
                    if (!Restored)
                    {
                        CreateNewBookmarkFile();
                    }
                }
                else
                {
                    BookmarkXMLDoc = XRoot.Load(BookmarkFilePath);
                }
            }
            catch (System.IO.FileNotFoundException )
            {
                CreateNewBookmarkFile();
            }
            catch (Xml.Schema.Linq.LinqToXsdException )
            {
                //We found it, but could not parse it
                HandleIncorrectXSDMessage();
                LoadBookmarksFromBackup();
            }
            catch (System.Xml.XmlException )
            {
                //We found it, but could not parse it
                HandleIncorrectXSDMessage();
                LoadBookmarksFromBackup();
            }
            catch (Exception )
            {
                //We found it, but could not parse it
              //  HandleIncorrectXSDMessage();
              //  LoadBookmarksFromBackup();
            }

            FolderUIObjRoot = new FolderUIObj(null, FolderRoot);
            SelectedFolder = FolderUIObjRoot;

            return true;
        }
Esempio n. 4
0
        BookmarkUIObj RecursiveFindBookmarks(FolderUIObj parentFolder, GridVector2 position, ref double nearestDistance)
        {
            BookmarkUIObj nearestBookmark = null;
            foreach (BookmarkUIObj bookmark in parentFolder.Bookmarks)
            {
                if (Viking.UI.State.ViewerControl.Section.Number == bookmark.Z)
                {
                    double bookmarkDistance = GridVector2.Distance(position, bookmark.GridPosition);
                    if (bookmarkDistance < nearestDistance && bookmarkDistance < Global.DefaultBookmarkRadius)
                    {
                        nearestDistance = bookmarkDistance;
                        nearestBookmark = bookmark;
                    }
                }
            }

            //Walk the bookmark tree and draw every bookmark
            foreach (FolderUIObj folder in parentFolder.Folders)
            {
                double childDistance = double.MaxValue;
                BookmarkUIObj nearestChildBookmark = RecursiveFindBookmarks(folder, position, ref childDistance);
                if (childDistance < nearestDistance)
                {
                    nearestDistance = childDistance;
                    nearestBookmark = nearestChildBookmark;
                }
            }

            return nearestBookmark;
        }
Esempio n. 5
0
        void RecursiveDrawBookmarks(FolderUIObj ParentFolder,
                                    Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice,
                                    Microsoft.Xna.Framework.Graphics.BasicEffect basicEffect,
                                    VikingXNA.Scene scene)
        {
            float alpha = 1;
            GridRectangle Bounds = scene.VisibleWorldBounds;
            double Downsample = scene.Camera.Downsample;
            double maxDimension = Math.Max(Bounds.Width, Bounds.Height);
            //We use the default radius unless it would be invisible.  In that case radius is scaled after calculating the alpha value
            double BookmarkRadius = Global.DefaultBookmarkRadius;

            //If the bookmark is more than 2.5% of the screen begin making it transparent
            Microsoft.Xna.Framework.Color color = new Microsoft.Xna.Framework.Color(Microsoft.Xna.Framework.Color.Gold.ToVector3());

            double BookmarkAlphaThreshold = 0.001;
            //double BookmarkToVisibleBoundsRatio = Global.BookmarkArea / Bounds.Area;
            //if (BookmarkToVisibleBoundsRatio > BookmarkAlphaThreshold)
            double BookmarkDimensionRatio = BookmarkRadius * 2 / maxDimension;
            if(BookmarkDimensionRatio >  BookmarkAlphaThreshold)
            {
                //A circle fills 0.78% of the screen area, so divide that by four
                double BookmarkTransparentThreshold = 0.25;

                alpha = 1f - (float)Math.Sqrt(((BookmarkDimensionRatio - BookmarkAlphaThreshold) / (BookmarkTransparentThreshold - BookmarkAlphaThreshold)));
                if (alpha < 0.00)
                    alpha = 0.00f;
            }

            double ScreenPixelRadius = BookmarkRadius / Downsample;

            //What is the absolute smallest size a bookmark should have?
            double minBookmarkPixelRadius = (maxDimension / Downsample) / (BookmarkRadius * Downsample) > 7.5 ? (maxDimension / Downsample) / (BookmarkRadius * Downsample) : 7.5;

            if (ScreenPixelRadius < minBookmarkPixelRadius)
            {
                BookmarkRadius = minBookmarkPixelRadius * (Downsample * (1 + (Math.Sin((DateTime.UtcNow.Millisecond / 1000.0) * Math.PI) / 10)));

                //To make it a bit more visible, vary the alpha slightly with time
                //alpha *= (float)(0.5 + (Math.Sin((DateTime.UtcNow.Millisecond / 1000.0) * Math.PI)/2));

            }

            color.A = (byte)(255.0 * alpha);

            foreach(BookmarkUIObj bookmark in ParentFolder.Bookmarks)
            {
                if (Viking.UI.State.ViewerControl.Section.Number == bookmark.Z)
                {
                    if (Bounds.Intersects(new GridRectangle(bookmark.GridPosition, Global.DefaultBookmarkRadius)))
                    {
                        DrawCircle(graphicsDevice,
                            basicEffect,
                            bookmark.GridPosition,
                            BookmarkRadius,
                            color);

                        DrawLabel(bookmark, alpha, graphicsDevice);
                    }
                    //                    bookmark.Draw(graphicsDevice, basicEffect, DownSample);
                }
            }

            //Walk the bookmark tree and draw every bookmark
            foreach (FolderUIObj folder in ParentFolder.Folders)
            {

                RecursiveDrawBookmarks(folder, graphicsDevice, basicEffect, scene);
            }
        }
Esempio n. 6
0
 protected override void OnShowObject(object Object)
 {
     folder = Object as FolderUIObj;
     textName.Text = folder.Name;
 }