コード例 #1
0
        public virtual void Paste()
        {
            var     scene = this.Scene;
            IVisual item  = null;

#if TRACE
            Trace.WriteLine($"{this.GetType ().Name}.{nameof(Paste)}:\t" + string.Join(" | ", Clipboard.GetTypesAvailable().Select(f => f.Id)));
#endif
            if (InprocDragDrop.ClipboardData != null)
            {
                // TODO: refactor to use same code as above
                var source = InprocDragDrop.ClipboardData as GraphCursor <IVisual, IVisualEdge>;
                if (source != null && source.Cursor != item)
                {
                    item = Mesh.LookUp(source.Graph, scene.Graph, source.Cursor);
                    if (item == null)
                    {
                        //TODO: error here
                        //return;
                    }
                }
            }

            if (item == null)
            {
                item = DragDropViz.VisualOfTransferData(scene.Graph, Clipboard.GetTransferData(Clipboard.GetTypesAvailable())); //DragDropViz.DataManager.DataTypes));
            }
            if (item != null)
            {
                SceneExtensions.PlaceVisual(scene, scene.Focused, item, Layout);
            }
        }
コード例 #2
0
        public virtual void Insert(Point cursorPosition)
        {
            DetachEditor(true);
            Exclusive = Resolved = true;
            Current   = Registry.Pooled <IVisualFactory> ().CreateItem("XXXXXXXX");
            var scene = Scene;
            var root  = scene.Focused;

            if (root == null)
            {
                var pt = Camera.ToSource(cursorPosition) - Layout.Distance;
                SceneExtensions.AddItem(scene, Current, Layout, pt);
            }
            else
            {
                SceneExtensions.PlaceVisual(scene, root, Current, Layout);
            }

            Display.Perform();
            TextToData(Current, string.Empty);

            AttachEditor();
        }
コード例 #3
0
ファイル: SplitView0.cs プロジェクト: git-thinh/limada
        public void CreateNewNote(string title)
        {
            var currentDiplay = CurrentDisplay;

            if (currentDiplay == null)
            {
                return;
            }
            var scene = currentDiplay.Data;

            if (scene == null)
            {
                return;
            }

            var content = new Content <Stream> (new MemoryStream(), CompressionType.bZip2);

            content.Description = title;

            if (Registry.Factory.Contains <IMarkdownEdit>())
            {
                content.ContentType = ContentTypes.Markdown;
                var writer = new StreamWriter(content.Data);
                writer.Write(title);
                writer.Flush();
                content.Data.Position = 0;
            }
            else
            {
                content.ContentType = ContentTypes.RTF;
                var writer = new StreamWriter(content.Data);

                writer.Write("{\\rtf1\\ansi\\deff0");
                writer.Write("{\\info{\\doccomm limada.note}}");

                writer.Write($"{{\\fonttbl{{\\f0\\froman {Xwt.Drawing.Font.SystemSerifFont.Family}}}}}");
                writer.Write("\\pard\\plain ");
                writer.Write(title);
                writer.Write("}");
                writer.Flush();
                content.Data.Position = 0;
            }

            var visual = scene.VisualOfContent(content);
            var root   = scene.Focused;

            var layout = currentDiplay.Layout;

            if (root == null)
            {
                var pt = new Point(layout.Border.Width, scene.Shape.BoundsRect.Bottom);
                SceneExtensions.AddItem(scene, visual, layout, pt);
            }
            else
            {
                SceneExtensions.PlaceVisual(scene, root, visual, layout);
            }
            scene.Selected.Clear();
            scene.Focused = visual;
            currentDiplay.Perform();
            currentDiplay.OnSceneFocusChanged();

            var md = ContentVidget as IMarkdownEdit;

            if (md != null)
            {
                md.InEdit = true;
            }
        }