Esempio n. 1
0
        protected virtual void ComposePagesDisplay(IGraphSceneDisplay <IVisual, IVisualEdge> display)
        {
            display.SceneFocusChanged += (s, e) => {
                var docMan      = new DigidocViz();
                var pageContent = docMan.PageContent(e.Scene.Graph, e.Item);
                PageContent = pageContent;
                if (pageContent != null && ContentViewer != null)
                {
                    AttachScroller(display, ContentViewer.Frontend as IDisplay);
                    var thing = e.Scene.Graph.ThingOf(e.Item);
                    ContentViewer.ContentId = thing.Id;
                }
            };

            var layout = display.Layout;

            Border            = new Size(0, -5);
            layout.StyleSheet = DefaultStyleSheet;

            var focusAction = display.ActionDispatcher.GetAction <GraphSceneFocusAction <IVisual, IVisualEdge> > ();

            if (focusAction != null)
            {
                focusAction.HitSize = -1;
            }

            var folding = display.Folding();

            folding.Folder.RemoveOrphans = false;
        }
Esempio n. 2
0
        public static void Wink <TItem, TEdge> (this IGraphSceneDisplay <TItem, TEdge> display) where TEdge : TItem, IEdge <TItem>
        {
            if (display == null)
            {
                return;
            }

            var color      = display.BackColor;
            var zoomState  = display.ZoomState;
            var zoomFactor = display.Viewport.ZoomFactor;

            Action <Color, ZoomState, double> setDispay = (c, s, f) => {
                display.BackColor           = c;
                display.ZoomState           = s;
                display.Viewport.ZoomFactor = f;
                display.Viewport.UpdateZoom();
                Application.MainLoop.DispatchPendingEvents();
            };

            Application.MainLoop.QueueExitAction(() => {
                setDispay(Colors.AliceBlue, ZoomState.Custom, zoomFactor + 0.1);
                Application.TimeoutInvoke(10, () => { setDispay(color, zoomState, zoomFactor); display.QueueDraw(); return(false); });
            });

            Application.MainLoop.DispatchPendingEvents();
        }
Esempio n. 3
0
        protected virtual void AttachScroller(IGraphSceneDisplay <IVisual, IVisualEdge> pagesDisplay, IDisplay contentDisplay)
        {
            if (contentDisplay == null)
            {
                return;
            }

            var scroller = contentDisplay.ActionDispatcher.GetAction <DigidocKeyScrollAction> ();
            var scene    = pagesDisplay.Data;
            var pages    = scene.Elements.Where(e => !(e is IVisualEdge)).OrderBy(e => e.Location.Y).ToList();

            if (scroller != null)
            {
                scroller.KeyProcessed = (r) => {
                    var inc = (int)(r.X + r.Y + r.Bottom + r.Right);
                    if (scene.Focused != null && inc != 0)
                    {
                        var iPage = pages.IndexOf(scene.Focused);
                        if (iPage != -1 && pages.Count > iPage + inc && iPage + inc >= 0)
                        {
                            scene.SetFocused(pages [iPage + inc]);
                            scene.ClearSelection();
                            pagesDisplay.Perform();
                            pagesDisplay.OnSceneFocusChanged();
                        }
                    }
                };
            }
        }
Esempio n. 4
0
 public static void Clear <TItem, TEdge>(this IGraphSceneDisplay <TItem, TEdge> d) where TEdge : TItem, IEdge <TItem>
 {
     d.Info   = new SceneInfo {
     };
     d.DataId = 0;
     d.Text   = string.Empty;
 }
Esempio n. 5
0
 /// <summary>
 /// copies some propterties of sourceDisplay into targetDisplay
 /// they will have the same SourceGraph
 /// BackColor, ZoomState
 /// sets Action.Enabled of SelectAction and ScrollAction
 /// </summary>
 /// <param name="sourceDisplay"></param>
 /// <param name="targetDisplay"></param>
 public virtual void CopyDisplayProperties(IGraphSceneDisplay <TItem, TEdge> sourceDisplay, IGraphSceneDisplay <TItem, TEdge> targetDisplay)
 {
     targetDisplay.BackColor                 = sourceDisplay.BackColor;
     targetDisplay.ZoomState                 = sourceDisplay.ZoomState;
     targetDisplay.SelectAction.Enabled      = sourceDisplay.SelectAction.Enabled;
     targetDisplay.MouseScrollAction.Enabled = sourceDisplay.MouseScrollAction.Enabled;
 }
Esempio n. 6
0
 public void AddDisplay(IGraphSceneDisplay <TItem, TEdge> display)
 {
     if (display != null)
     {
         Displays.Add(display);
         AddScene(display.Data);
     }
 }
Esempio n. 7
0
 public void GraphChanged(
     object sender,
     GraphChangeArgs <IVisual, IVisualEdge> args,
     IVisual sinkItem, IGraphScene <IVisual, IVisualEdge> sinkScene,
     IGraphSceneDisplay <IVisual, IVisualEdge> sinkDisplay)
 {
     // everything is done in MeshBackHandler
     return;
 }
Esempio n. 8
0
        public void Call(IGraphSceneDisplay <IVisual, IVisualEdge> display, Action <Aligner <IVisual, IVisualEdge>, IEnumerable <IVisual> > call)
        {
            if (display == null)
            {
                return;
            }

            Call(display, call, display.Data.Selected.Elements);
        }
Esempio n. 9
0
        public void Save(IGraphSceneDisplay <IVisual, IVisualEdge> display)
        {
            Scene  = display.Data;
            Layout = display.Layout;
            Info   = SceneInfo.FromInfo(display.Info);

            Offset    = display.Viewport.ClipOrigin;
            Zoom      = display.Viewport.ZoomFactor;
            ZoomState = display.Viewport.ZoomState;
        }
Esempio n. 10
0
        public static void AssignScene(this ISceneManager sceneManager, IGraphSceneDisplay <IVisual, IVisualEdge> display, IGraphScene <IVisual, IVisualEdge> scene, SceneInfo info)
        {
            if (display == null || scene == null)
            {
                return;
            }

            AssignScene(display, scene, info);
            sceneManager.SheetStore.RegisterSceneInfo(info);
        }
Esempio n. 11
0
 public virtual IGraphSceneDisplay <IVisual, IVisualEdge> AdjacentDisplay(IGraphSceneDisplay <IVisual, IVisualEdge> display)
 {
     if (display == Display2)
     {
         return(Display1);
     }
     else
     {
         return(Display2);
     }
 }
Esempio n. 12
0
 public void RemoveDisplay(IGraphSceneDisplay <TItem, TEdge> display)
 {
     if (display != null)
     {
         Displays.Remove(display);
         if (display.Data != null &&
             !Displays.Any(d => d != display && display.Data == d.Data))
         {
             RemoveScene(display.Data);
         }
     }
 }
Esempio n. 13
0
 protected virtual void StoreUndo(IGraphSceneDisplay <IVisual, IVisualEdge> display, Aligner <IVisual, IVisualEdge> aligner, IEnumerable <IVisual> items)
 {
     _undo   = new List <ICommand <IVisual> > ();
     _undoID = display.DataId;
     foreach (var item in aligner.GraphScene.Requests.Select(c => c.Subject))
     {
         _undo.Add(new MoveCommand <IVisual> (item, i => i.Shape, item.Location));
     }
     foreach (var edge in aligner.Locator.AffectedEdges)
     {
         _undo.Add(new LayoutCommand <IVisual> (edge, LayoutActionType.Justify));
     }
 }
Esempio n. 14
0
        public static void Store(this ISceneManager sceneManager, IGraphSceneDisplay <IVisual, IVisualEdge> display)
        {
            if (display != null && display.Data != null && display.Data.Count > 0)
            {
                if (display.DataId == 0)
                {
                    display.DataId = Isaac.Long;
                }

                display.Perform();
                if (sceneManager.SaveInStore(display.Data, display.Layout, display.DataId))
                {
                    sceneManager.SheetStore.RegisterSceneInfo(display.Info);
                }
            }
        }
Esempio n. 15
0
        public static void AssignScene(this IGraphSceneDisplay <IVisual, IVisualEdge> display, IGraphScene <IVisual, IVisualEdge> scene, SceneInfo info)
        {
            if (scene == null || display == null || scene == display.Data)
            {
                return;
            }
            Trace.WriteLine($"{nameof (SceneManagerExtensions)}.{nameof (AssignScene)}:{display.Info} => {info}");

            Mesh.RemoveScene(display.Data);
            Mesh.AddScene(scene);

            display.Data = scene;
            display.Info = info;
            display.Data.CreateMarkers();
            display.QueueDraw();
        }
Esempio n. 16
0
        /// <summary>
        /// tests if scene.Focused with a call to HtmlViewer is an infinite loop
        /// </summary>
        /// <param name="display"></param>
        public void TestInfinitLoopIfHtmlContentIsFocused(IGraphSceneDisplay <IVisual, IVisualEdge> display)
        {
            var scene = display.Data;

            if (scene != null)
            {
                foreach (var item in scene.Elements
                         .Select(v => scene.Graph.ThingOf(v)).OfType <IStreamThing>()
                         .Where(s => s.StreamType == ContentTypes.HTML))
                {
                    scene.Focused = scene.Graph.VisualOf(item);
                    display.OnSceneFocusChanged();
                }
                scene.Selected.Clear();
                scene.Focused = null;
            }
        }
Esempio n. 17
0
        public void Call(IGraphSceneDisplay <IVisual, IVisualEdge> display, Action <Aligner <IVisual, IVisualEdge>, IEnumerable <IVisual> > call, IEnumerable <IVisual> items)
        {
            if (display == null)
            {
                return;
            }

            var aligner = new Aligner <IVisual, IVisualEdge> (display.Data, display.Layout);

            call(aligner, items);

            aligner.Locator.Commit(aligner.GraphScene.Requests);

            StoreUndo(display, aligner, items);

            display.Perform();
        }
Esempio n. 18
0
        public static void Load(this ISceneManager sceneManager, IGraphSceneDisplay <IVisual, IVisualEdge> display, Int64 id, bool checkOpen = true)
        {
            if (id == 0)
            {
                return;
            }

            if (checkOpen && sceneManager.IsSceneOpen(id, true, true))
            {
                return;
            }

            var scene = sceneManager.Load(display.Data.Graph, display.Layout, id);
            var info  = sceneManager.SheetStore.GetSheetInfo(id);

            display.AssignScene(scene, info);
        }
Esempio n. 19
0
 public virtual void Undo(IGraphSceneDisplay <IVisual, IVisualEdge> display)
 {
     if (display == null)
     {
         return;
     }
     if (_undo != null && _undoID == display.DataId)
     {
         foreach (var comm in _undo)
         {
             display.Data.Requests.Add(comm);
         }
         display.Perform();
         _undo   = null;
         _undoID = 0;
     }
 }
Esempio n. 20
0
        public void InstrumentLayer(IRenderAction renderAction, IGraphSceneDisplay <IVisual, IVisualEdge> display)
        {
            var layer = renderAction as ILayer <IGraphScene <IVisual, IVisualEdge> >;

            if (layer != null)
            {
                layer.Data   = () => display.Data;
                layer.Camera = () => display.Viewport.Camera;
            }
            var graphLayer = layer as GraphSceneLayer <IVisual, IVisualEdge>;

            if (graphLayer != null)
            {
                graphLayer.Layout = () => display.Layout;
            }
            display.ActionDispatcher.Add(renderAction);
        }
Esempio n. 21
0
        protected virtual bool DisplaySheet(IGraphSceneDisplay <IVisual, IVisualEdge> display, IThing thing, IThingGraph thingGraph)
        {
            var streamThing = thing as IStreamThing;

            try {
                if (streamThing != null && streamThing.StreamType == ContentTypes.LimadaSheet)
                {
                    var content = thingGraph.ContentOf(streamThing);
                    content.Source = streamThing.Id;
                    DisplaySheet(display, content);
                    return(true);
                }
            } catch (Exception e) {
                Trace.WriteLine("Error on displaying sheet {0}", e.Message);
                Debug.WriteLine(e.StackTrace);
            }
            return(false);
        }
Esempio n. 22
0
        public void Navigate(IGraphSceneDisplay <IVisual, IVisualEdge> display, ISceneManager sceneManager, bool forward)
        {
            Store(display, sceneManager);

            var info        = display.Info;
            var currSheedId = info != null ? info.Id : 0;

            var sheetId = forward ? History.Forward() : History.Back();

            if (sheetId != currSheedId)
            {
                Load(display, sceneManager, sheetId);
            }

            if (currSheedId == 0)
            {
                History.Remove(p => p == currSheedId);
            }
        }
Esempio n. 23
0
        public static void Load(this ISceneManager sceneManager, IGraphSceneDisplay <IVisual, IVisualEdge> display, Content <Stream> content, bool checkOpen = true)
        {
            if (content == null)
            {
                return;
            }

            var id = sceneManager.IdOf(content);

            if (checkOpen && sceneManager.IsSceneOpen(id, true, true))
            {
                return;
            }

            var scene = sceneManager.LoadFromContent(content, display.Data.Graph, display.Layout);
            var info  = sceneManager.SheetStore.GetSheetInfo(id);

            display.AssignScene(scene, info);
        }
Esempio n. 24
0
        public void ChangeData()
        {
            IList <IGraphSceneDisplay <IVisual, IVisualEdge> > displays = new IGraphSceneDisplay <IVisual, IVisualEdge>[] { Display2 };

            Clear();

            CurrentDisplay = null;

            displays
            .Where(d => d != Display1)
            .ForEach(d => {
                Mesh.CopyDisplayProperties(Display1, d);
            });

            FavoriteManager.GoHome(Display1, true);
            GraphGraphView();
            GraphContentView();

            CurrentDisplay = Display1;
        }
Esempio n. 25
0
        public void InitializeDisplay(IGraphSceneDisplay <IVisual, IVisualEdge> display)
        {
            var         styleSheets = Registry.Pooled <StyleSheets>();
            IStyleSheet styleSheet  = null;

            if (styleSheets.TryGetValue(display.StyleSheet.Name, out styleSheet))
            {
                display.StyleSheet = styleSheet;
            }
            else
            {
                styleSheets.Add(display.StyleSheet.Name, display.StyleSheet);
            }

            display.SceneFocusChanged -= SceneFocusChanged;
            display.SceneFocusChanged += SceneFocusChanged;

            AttachVidget(display);

            Mesh.AddDisplay(display);
        }
Esempio n. 26
0
        public void Restore(IGraphSceneDisplay <IVisual, IVisualEdge> display)
        {
            display.Data = Scene;

            display.Info = SceneInfo.FromInfo(Info);

            var layout = Layout;

            if (layout == null)
            {
                var styleSheet = Registry.Pooled <StyleSheets>()[StyleSheetName];
                Func <IGraphScene <IVisual, IVisualEdge> > scene = () => display.Data;
                layout = Registry.Create <IGraphSceneLayout <IVisual, IVisualEdge> >(scene, styleSheet);
            }
            display.Layout = layout;
            display.Viewport.ClipOrigin = Offset;
            display.Viewport.ZoomState  = ZoomState;
            if (ZoomState == ZoomState.Custom)
            {
                display.Viewport.ZoomFactor = Zoom;
            }
        }
Esempio n. 27
0
 public virtual void Restore(string tag, IGraphSceneDisplay <IVisual, IVisualEdge> display)
 {
     SavedDisps[tag].Restore(display);
     Mesh.AddDisplay(display);
 }
Esempio n. 28
0
 public virtual void Save(string tag, IGraphSceneDisplay <IVisual, IVisualEdge> display)
 {
     SavedDisps[tag] = new GraphSceneDisplayMemento(display);
     display.Data    = null;
     Mesh.RemoveDisplay(display);
 }
Esempio n. 29
0
 public GraphSceneDisplayMemento(IGraphSceneDisplay <IVisual, IVisualEdge> display)
 {
     Save(display);
 }
Esempio n. 30
0
 public virtual IGraphSceneDisplay <IVisual, IVisualEdge> AdjacentDisplay(IGraphSceneDisplay <IVisual, IVisualEdge> display)
 {
     return(null);
 }