Exemple #1
0
        /// <summary>
        /// 
        /// </summary>
        private void InitializeContext()
        {
            this.SetStyle(
                ControlStyles.AllPaintingInWmPaint
                | ControlStyles.UserPaint
                | ControlStyles.DoubleBuffer
                | ControlStyles.SupportsTransparentBackColor,
                true);

            var context = new EditorContext()
            {
                View = this,
                Renderers = new IRenderer[] { new EmfRenderer(72.0 / 96.0) },
                ProjectFactory = new ProjectFactory(),
                TextClipboard = new TextClipboard(),
                Serializer = new NewtonsoftSerializer(),
                PdfWriter = new PdfWriter(),
                DxfWriter = new DxfWriter(),
                CsvReader = new CsvHelperReader(),
                CsvWriter = new CsvHelperWriter()
            };
            context.InitializeEditor(new TraceLog());
            context.Editor.Renderers[0].State.DrawShapeState = ShapeState.Visible;
            context.Editor.GetImageKey = async () => await GetImageKey();

            DataContext = context;
        }
Exemple #2
0
        private void InitializeContext()
        {
            _renderer = new Win2dRenderer();

            _context = new T2d.EditorContext()
            {
                View           = this,
                Renderers      = new T2d.IRenderer[] { _renderer },
                ProjectFactory = new T2d.ProjectFactory(),
                TextClipboard  = new TextClipboard(),
                Serializer     = new T2d.NewtonsoftSerializer(),
                //PdfWriter = new T2d.PdfWriter(),
                //DxfWriter = new T2d.DxfWriter(),
                //CsvReader = new T2d.CsvHelperReader(),
                //CsvWriter = new T2d.CsvHelperWriter()
            };
            _context.InitializeEditor(null /*new T2d.TraceLog()*/);
            _context.Editor.Renderers[0].State.DrawShapeState.Flags = T2d.ShapeStateFlags.Visible;
            _context.Editor.GetImageKey = async() => await Task.Run(() => _imagePath);

            _context.Commands.OpenCommand =
                T2d.Command <object> .Create(
                    async (parameter) => await OnOpen(),
                    (parameter) => _context.IsEditMode());

            _context.Commands.SaveAsCommand =
                T2d.Command.Create(
                    async() => await OnSaveAs(),
                    () => _context.IsEditMode());

            DataContext = _context;
        }
        private void InitializeContext()
        {
            _renderer = new Win2dRenderer();

            _context = new T2d.EditorContext()
            {
                View = this,
                Renderers = new T2d.IRenderer[] { _renderer },
                ProjectFactory = new T2d.ProjectFactory(),
                TextClipboard = new TextClipboard(),
                Serializer = new T2d.NewtonsoftSerializer(),
                //PdfWriter = new T2d.PdfWriter(),
                //DxfWriter = new T2d.DxfWriter(),
                //CsvReader = new T2d.CsvHelperReader(),
                //CsvWriter = new T2d.CsvHelperWriter()
            };
            _context.InitializeEditor(null/*new T2d.TraceLog()*/);
            _context.Editor.Renderers[0].State.DrawShapeState.Flags = T2d.ShapeStateFlags.Visible;
            _context.Editor.GetImageKey = async () => await Task.Run(() => _imagePath);

            _context.Commands.OpenCommand =
                T2d.Command<object>.Create(
                    async (parameter) => await OnOpen(),
                    (parameter) => _context.IsEditMode());

            _context.Commands.SaveAsCommand =
                T2d.Command.Create(
                    async () => await OnSaveAs(),
                    () => _context.IsEditMode());

            DataContext = _context;
        }
Exemple #4
0
        /// <summary>
        /// 
        /// </summary>
        private void InitializeContext()
        {
            _context = new EditorContext()
            {
                View = this,
                Renderers = new IRenderer[] { new PerspexRenderer() },
                ProjectFactory = new ProjectFactory(),
                TextClipboard = new TextClipboard(),
                Serializer = new NewtonsoftSerializer(),
                PdfWriter = new PdfWriter(),
                DxfWriter = new DxfWriter(),
                CsvReader = new CsvHelperReader(),
                CsvWriter = new CsvHelperWriter()
            };

            _context.InitializeEditor(new TraceLog());

            _context.Editor.Renderers[0].State.DrawShapeState = ShapeState.Visible;
            _context.Editor.GetImageKey = async () => await OnGetImageKey();

            _context.Commands.OpenCommand =
                Command<object>.Create(
                    async (parameter) => await OnOpen(parameter),
                    (parameter) => _context.IsEditMode());

            _context.Commands.SaveCommand =
                Command.Create(
                    async () => await OnSave(),
                    () => _context.IsEditMode());

            _context.Commands.SaveAsCommand =
                Command.Create(
                    async () => await OnSaveAs(),
                    () => _context.IsEditMode());

            _context.Commands.ExportCommand =
                Command<object>.Create(
                    async (item) => await OnExport(),
                    (item) => _context.IsEditMode());

            // TODO: Initialize other commands.

            DataContext = _context;
        }
        /// <summary>
        /// 
        /// </summary>
        private void InitializeContext()
        {
            _context = new EditorContext()
            {
                View = this,
                Renderers = new IRenderer[] { new PerspexRenderer() },
                ProjectFactory = new ProjectFactory(),
                TextClipboard = new TextClipboard(),
                Serializer = new NewtonsoftSerializer(),
                PdfWriter = new PdfWriter(),
                DxfWriter = new DxfWriter(),
                CsvReader = new CsvHelperReader(),
                CsvWriter = new CsvHelperWriter()
            };

            _context.InitializeEditor(new TraceLog(), "Test2d.log");

            _context.Editor.Renderers[0].State.DrawShapeState.Flags = ShapeStateFlags.Visible;
            _context.Editor.GetImageKey = async () => await OnGetImageKey();

            _context.Commands.OpenCommand =
                Command<object>.Create(
                    async (parameter) => await OnOpen(parameter),
                    (parameter) => _context.IsEditMode());

            _context.Commands.SaveCommand =
                Command.Create(
                    async () => await OnSave(),
                    () => _context.IsEditMode());

            _context.Commands.SaveAsCommand =
                Command.Create(
                    async () => await OnSaveAs(),
                    () => _context.IsEditMode());

            _context.Commands.ExportCommand =
                Command<object>.Create(
                    async (item) => await OnExport(),
                    (item) => _context.IsEditMode());

            _context.Commands.ImportDataCommand =
                Command<object>.Create(
                    async (item) => await OnImportData(),
                    (item) => _context.IsEditMode());

            _context.Commands.ExportDataCommand =
                Command<object>.Create(
                    async (item) => await OnExportData(),
                    (item) => _context.IsEditMode());

            _context.Commands.UpdateDataCommand =
                Command<object>.Create(
                    async (item) => await OnUpdateData(),
                    (item) => _context.IsEditMode());
            
            _context.Commands.ImportStyleCommand =
                Command<object>.Create(
                    async (item) => await OnImportObject(item, ImportType.Style),
                    (item) => _context.IsEditMode());

            _context.Commands.ImportStylesCommand =
                Command<object>.Create(
                    async (item) => await OnImportObject(item, ImportType.Styles),
                    (item) => _context.IsEditMode());

            _context.Commands.ImportStyleLibraryCommand =
                Command<object>.Create(
                    async (item) => await OnImportObject(item, ImportType.StyleLibrary),
                    (item) => _context.IsEditMode());

            _context.Commands.ImportStyleLibrariesCommand =
                Command<object>.Create(
                    async (item) => await OnImportObject(item, ImportType.StyleLibraries),
                    (item) => _context.IsEditMode());

            _context.Commands.ImportGroupCommand =
                Command<object>.Create(
                    async (item) => await OnImportObject(item, ImportType.Group),
                    (item) => _context.IsEditMode());

            _context.Commands.ImportGroupsCommand =
                Command<object>.Create(
                    async (item) => await OnImportObject(item, ImportType.Groups),
                    (item) => _context.IsEditMode());

            _context.Commands.ImportGroupLibraryCommand =
                Command<object>.Create(
                    async (item) => await OnImportObject(item, ImportType.GroupLibrary),
                    (item) => _context.IsEditMode());

            _context.Commands.ImportGroupLibrariesCommand =
                Command<object>.Create(
                    async (item) => await OnImportObject(item, ImportType.GroupLibraries),
                    (item) => _context.IsEditMode());

            _context.Commands.ImportTemplateCommand =
                Command<object>.Create(
                    async (item) => await OnImportObject(item, ImportType.Template),
                    (item) => _context.IsEditMode());

            _context.Commands.ImportTemplatesCommand =
                Command<object>.Create(
                    async (item) => await OnImportObject(item, ImportType.Templates),
                    (item) => _context.IsEditMode());

            _context.Commands.ExportStyleCommand =
                Command<object>.Create(
                    async (item) => await OnExportObject(item, ExportType.Style),
                    (item) => _context.IsEditMode());

            _context.Commands.ExportStylesCommand =
                Command<object>.Create(
                    async (item) => await OnExportObject(item, ExportType.Styles),
                    (item) => _context.IsEditMode());

            _context.Commands.ExportStyleLibraryCommand =
                Command<object>.Create(
                    async (item) => await OnExportObject(item, ExportType.StyleLibrary),
                    (item) => _context.IsEditMode());

            _context.Commands.ExportStyleLibrariesCommand =
                Command<object>.Create(
                    async (item) => await OnExportObject(item, ExportType.StyleLibraries),
                    (item) => _context.IsEditMode());

            _context.Commands.ExportGroupCommand =
                Command<object>.Create(
                    async (item) => await OnExportObject(item, ExportType.Group),
                    (item) => _context.IsEditMode());

            _context.Commands.ExportGroupsCommand =
                Command<object>.Create(
                    async (item) => await OnExportObject(item, ExportType.Groups),
                    (item) => _context.IsEditMode());

            _context.Commands.ExportGroupLibraryCommand =
                Command<object>.Create(
                    async (item) => await OnExportObject(item, ExportType.GroupLibrary),
                    (item) => _context.IsEditMode());

            _context.Commands.ExportGroupLibrariesCommand =
                Command<object>.Create(
                    async (item) => await OnExportObject(item, ExportType.GroupLibraries),
                    (item) => _context.IsEditMode());

            _context.Commands.ExportTemplateCommand =
                Command<object>.Create(
                    async (item) => await OnExportObject(item, ExportType.Template),
                    (item) => _context.IsEditMode());

            _context.Commands.ExportTemplatesCommand =
                Command<object>.Create(
                    async (item) => await OnExportObject(item, ExportType.Templates),
                    (item) => _context.IsEditMode());

            // TODO: Initialize other commands.

            if (_enableRecent)
            {
                try
                {
                    var path = System.IO.Path.Combine(GetAssemblyPath(), _recentFileName);
                    if (System.IO.File.Exists(path))
                    {
                        _context.LoadRecent(path);
                    }
                }
                catch (Exception ex)
                {
                    if (_context.Editor.Log != null)
                    {
                        _context.Editor.Log.LogError("{0}{1}{2}",
                            ex.Message,
                            Environment.NewLine,
                            ex.StackTrace);
                    }
                }
            }
            
            DataContext = _context;
        }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the Factory class.
 /// </summary>
 /// <param name="context"></param>
 public Factory(EditorContext context)
 {
     Context = context;
 }
Exemple #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        private void InitializeCommands(EditorContext context)
        {
            context.Commands.OpenCommand =
                Command<object>.Create(
                    (parameter) => OnOpen(parameter),
                    (parameter) => context.IsEditMode());
            
            context.Commands.SaveCommand =
                Command.Create(
                    () => OnSave(),
                    () => context.IsEditMode());

            context.Commands.SaveAsCommand =
                Command.Create(
                    () => OnSaveAs(),
                    () => context.IsEditMode());

            context.Commands.ExportCommand =
                Command<object>.Create(
                    (item) => OnExport(item),
                    (item) => context.IsEditMode());

            context.Commands.ImportDataCommand =
                Command<object>.Create(
                    (item) => OnImportData(),
                    (item) => context.IsEditMode());

            context.Commands.ExportDataCommand =
                Command<object>.Create(
                    (item) => OnExportData(),
                    (item) => context.IsEditMode());

            context.Commands.UpdateDataCommand =
                Command<object>.Create(
                    (item) => OnUpdateData(),
                    (item) => context.IsEditMode());

            context.Commands.ImportStyleCommand =
                Command<object>.Create(
                    (item) => OnImportObject(item, ImportType.Style),
                    (item) => context.IsEditMode());

            context.Commands.ImportStylesCommand =
                Command<object>.Create(
                    (item) => OnImportObject(item, ImportType.Styles),
                    (item) => context.IsEditMode());

            context.Commands.ImportStyleLibraryCommand =
                Command<object>.Create(
                    (item) => OnImportObject(item, ImportType.StyleLibrary),
                    (item) => context.IsEditMode());

            context.Commands.ImportStyleLibrariesCommand =
                Command<object>.Create(
                    (item) => OnImportObject(item, ImportType.StyleLibraries),
                    (item) => context.IsEditMode());

            context.Commands.ImportGroupCommand =
                Command<object>.Create(
                    (item) => OnImportObject(item, ImportType.Group),
                    (item) => context.IsEditMode());

            context.Commands.ImportGroupsCommand =
                Command<object>.Create(
                    (item) => OnImportObject(item, ImportType.Groups),
                    (item) => context.IsEditMode());

            context.Commands.ImportGroupLibraryCommand =
                Command<object>.Create(
                    (item) => OnImportObject(item, ImportType.GroupLibrary),
                    (item) => context.IsEditMode());

            context.Commands.ImportGroupLibrariesCommand =
                Command<object>.Create(
                    (item) => OnImportObject(item, ImportType.GroupLibraries),
                    (item) => context.IsEditMode());

            context.Commands.ImportTemplateCommand =
                Command<object>.Create(
                    (item) => OnImportObject(item, ImportType.Template),
                    (item) => context.IsEditMode());

            context.Commands.ImportTemplatesCommand =
                Command<object>.Create(
                    (item) => OnImportObject(item, ImportType.Templates),
                    (item) => context.IsEditMode());

            context.Commands.ExportStyleCommand =
                Command<object>.Create(
                    (item) => OnExportObject(item, ExportType.Style),
                    (item) => context.IsEditMode());

            context.Commands.ExportStylesCommand =
                Command<object>.Create(
                    (item) => OnExportObject(item, ExportType.Styles),
                    (item) => context.IsEditMode());

            context.Commands.ExportStyleLibraryCommand =
                Command<object>.Create(
                    (item) => OnExportObject(item, ExportType.StyleLibrary),
                    (item) => context.IsEditMode());

            context.Commands.ExportStyleLibrariesCommand =
                Command<object>.Create(
                    (item) => OnExportObject(item, ExportType.StyleLibraries),
                    (item) => context.IsEditMode());

            context.Commands.ExportGroupCommand =
                Command<object>.Create(
                    (item) => OnExportObject(item, ExportType.Group),
                    (item) => context.IsEditMode());

            context.Commands.ExportGroupsCommand =
                Command<object>.Create(
                    (item) => OnExportObject(item, ExportType.Groups),
                    (item) => context.IsEditMode());

            context.Commands.ExportGroupLibraryCommand =
                Command<object>.Create(
                    (item) => OnExportObject(item, ExportType.GroupLibrary),
                    (item) => context.IsEditMode());

            context.Commands.ExportGroupLibrariesCommand =
                Command<object>.Create(
                    (item) => OnExportObject(item, ExportType.GroupLibraries),
                    (item) => context.IsEditMode());

            context.Commands.ExportTemplateCommand =
                Command<object>.Create(
                    (item) => OnExportObject(item, ExportType.Template),
                    (item) => context.IsEditMode());

            context.Commands.ExportTemplatesCommand =
                Command<object>.Create(
                    (item) => OnExportObject(item, ExportType.Templates),
                    (item) => context.IsEditMode());

            context.Commands.CopyAsEmfCommand =
                Command.Create(
                    () => OnCopyAsEmf(),
                    () => context.IsEditMode());
            
            context.Commands.ZoomResetCommand =
                Command.Create(
                    () => OnZoomReset(),
                    () => true);

            context.Commands.ZoomExtentCommand =
                Command.Create(
                    () => OnZoomExtent(),
                    () => true);

            context.Commands.ProjectWindowCommand =
                Command.Create(
                    () => (_layouts["project"] as LayoutAnchorable).Show(),
                    () => true);

            context.Commands.OptionsWindowCommand =
                Command.Create(
                    () => (_layouts["options"] as LayoutAnchorable).Show(),
                    () => true);

            context.Commands.TemplatesWindowCommand =
                Command.Create(
                    () => (_layouts["templates"] as LayoutAnchorable).Show(),
                    () => true);

            context.Commands.GroupsWindowCommand =
                Command.Create(
                    () => (_layouts["groups"] as LayoutAnchorable).Show(),
                    () => true);

            context.Commands.DatabasesWindowCommand =
                Command.Create(
                    () => (_layouts["databases"] as LayoutAnchorable).Show(),
                    () => true);

            context.Commands.DatabaseWindowCommand =
                Command.Create(
                    () => (_layouts["database"] as LayoutAnchorable).Show(),
                    () => true);

            //context.Commands.ContainerWindowCommand = 
            //    Command.Create(
            //        () => ,
            //        () => true);

            //context.Commands.DocumentWindowCommand = 
            //    Command.Create(
            //        () => ,
            //        () => true);

            context.Commands.StylesWindowCommand =
                Command.Create(
                    () => (_layouts["styles"] as LayoutAnchorable).Show(),
                    () => true);

            context.Commands.LayersWindowCommand =
                Command.Create(
                    () => (_layouts["layers"] as LayoutAnchorable).Show(),
                    () => true);

            context.Commands.ShapesWindowCommand =
                Command.Create(
                    () => (_layouts["shapes"] as LayoutAnchorable).Show(),
                    () => true);

            context.Commands.TemplateWindowCommand =
                Command.Create(
                    () => (_layouts["template"] as LayoutAnchorable).Show(),
                    () => true);

            context.Commands.PropertiesWindowCommand =
                Command.Create(
                    () => (_layouts["properties"] as LayoutAnchorable).Show(),
                    () => true);

            context.Commands.StateWindowCommand =
                Command.Create(
                    () => (_layouts["state"] as LayoutAnchorable).Show(),
                    () => true);

            context.Commands.DataWindowCommand =
                Command.Create(
                    () => (_layouts["data"] as LayoutAnchorable).Show(),
                    () => true);

            context.Commands.StyleWindowCommand =
                Command.Create(
                    () => (_layouts["style"] as LayoutAnchorable).Show(),
                    () => true);

            context.Commands.LoadWindowLayoutCommand =
                Command.Create(
                    () => OnLoadLayout(),
                    () => true);

            context.Commands.SaveWindowLayoutCommand =
                Command.Create(
                    () => OnSaveLayout(),
                    () => true);

            context.Commands.ResetWindowLayoutCommand =
                Command.Create(
                    () => OnResetLayout(),
                    () => true);
        }
Exemple #8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="context"></param>
 /// <param name="invalidate"></param>
 public ZoomState(EditorContext context, Action invalidate)
 {
     _context = context;
     _invalidate = invalidate;
 }
Exemple #9
0
 /// <summary>
 /// Auto save docking manager layout.
 /// </summary>
 /// <param name="context"></param>
 private void AutoSaveLayout(EditorContext context)
 {
     try
     {
         SaveLayout(_defaultLayoutPath);
     }
     catch (Exception ex)
     {
         if (context.Editor.Log != null)
         {
             context.Editor.Log.LogError("{0}{1}{2}",
                 ex.Message,
                 Environment.NewLine,
                 ex.StackTrace);
         }
     }
 }
Exemple #10
0
        /// <summary>
        /// 
        /// </summary>
        private void InitializeContext()
        {
            var context = new EditorContext()
            {
                View = this,
                Renderers = new IRenderer[] { new WpfRenderer(), new WpfRenderer() },
                ProjectFactory = new ProjectFactory(),
                TextClipboard = new TextClipboard(),
                Serializer = new NewtonsoftSerializer(),
                PdfWriter = new PdfWriter(),
                DxfWriter = new DxfWriter(),
                CsvReader = new CsvHelperReader(),
                CsvWriter = new CsvHelperWriter()
            };

            context.InitializeEditor(new TraceLog());
            context.Editor.Renderers[0].State.DrawShapeState = ShapeState.Visible;
            context.Editor.Renderers[1].State.DrawShapeState = ShapeState.Visible;
            context.Editor.GetImageKey = async () => await GetImageKey();

            InitializeCommands(context);
            InitializeZoom(context);
            InitializeDrop(context);

            Loaded +=
                (s, e) =>
                {
                    if (_isLoaded)
                        return;
                    else
                        _isLoaded = true;

                    InitializeLayouts();

                    if (_autoLoadRecent)
                    {
                        AutoLoadRecent(context);
                    }

                    if (_autoRestoreLayout)
                    {
                        AutoLoadLayout(context);
                    }
                };

            Unloaded += (s, e) =>
            {
                if (!_isLoaded)
                    return;
                else
                    _isLoaded = false;

                DeInitializeContext();

                if (_autoLoadRecent)
                {
                    AutoSaveRecent(context);
                }

                if (_autoRestoreLayout)
                {
                    AutoSaveLayout(context);
                }
            };

            DataContext = context;
        }
Exemple #11
0
 /// <summary>
 /// Auto save recent project files.
 /// </summary>
 /// <param name="context"></param>
 private void AutoSaveRecent(EditorContext context)
 {
     try
     {
         SaveRecent(_recentProjectsPath, context);
     }
     catch (Exception ex)
     {
         if (context.Editor.Log != null)
         {
             context.Editor.Log.LogError("{0}{1}{2}",
                 ex.Message,
                 Environment.NewLine,
                 ex.StackTrace);
         }
     }
 }
Exemple #12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        private void InitializeDrop(EditorContext context)
        {
            containerControl.AllowDrop = true;

            containerControl.DragEnter +=
                (s, e) =>
                {
                    if (!e.Data.GetDataPresent(DataFormats.FileDrop)
                        && !e.Data.GetDataPresent(typeof(XGroup))
                        && !e.Data.GetDataPresent(typeof(Record))
                        && !e.Data.GetDataPresent(typeof(ShapeStyle)))
                    {
                        e.Effects = DragDropEffects.None;
                        e.Handled = true;
                    }
                };

            containerControl.Drop +=
                (s, e) =>
                {
                    if (e.Data.GetDataPresent(DataFormats.FileDrop))
                    {
                        try
                        {
                            var files = (string[])e.Data.GetData(DataFormats.FileDrop);
                            if (context.Drop(files))
                            {
                                e.Handled = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            if (context.Editor.Log != null)
                            {
                                context.Editor.Log.LogError("{0}{1}{2}",
                                    ex.Message,
                                    Environment.NewLine,
                                    ex.StackTrace);
                            }
                        }
                    }

                    if (e.Data.GetDataPresent(typeof(XGroup)))
                    {
                        try
                        {
                            var group = e.Data.GetData(typeof(XGroup)) as XGroup;
                            if (group != null)
                            {
                                var p = e.GetPosition(containerControl);
                                context.DropAsClone(group, p.X, p.Y);
                                e.Handled = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            if (context.Editor.Log != null)
                            {
                                context.Editor.Log.LogError("{0}{1}{2}",
                                    ex.Message,
                                    Environment.NewLine,
                                    ex.StackTrace);
                            }
                        }
                    }

                    if (e.Data.GetDataPresent(typeof(Record)))
                    {
                        try
                        {
                            var record = e.Data.GetData(typeof(Record)) as Record;
                            if (record != null)
                            {
                                var p = e.GetPosition(containerControl);
                                context.Drop(record, p.X, p.Y);
                                e.Handled = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            if (context.Editor.Log != null)
                            {
                                context.Editor.Log.LogError("{0}{1}{2}",
                                    ex.Message,
                                    Environment.NewLine,
                                    ex.StackTrace);
                            }
                        }
                    }

                    if (e.Data.GetDataPresent(typeof(ShapeStyle)))
                    {
                        try
                        {
                            var style = e.Data.GetData(typeof(ShapeStyle)) as ShapeStyle;
                            if (style != null)
                            {
                                var p = e.GetPosition(containerControl);
                                context.Drop(style, p.X, p.Y);
                                e.Handled = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            if (context.Editor.Log != null)
                            {
                                context.Editor.Log.LogError("{0}{1}{2}",
                                    ex.Message,
                                    Environment.NewLine,
                                    ex.StackTrace);
                            }
                        }
                    }
                };
        }
Exemple #13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        private void InitializeZoom(EditorContext context)
        {
            border.InvalidateChild =
                (z, x, y) =>
                {
                    bool invalidate = context.Editor.Renderers[0].State.Zoom != z;
                    context.Editor.Renderers[0].State.Zoom = z;
                    context.Editor.Renderers[0].State.PanX = x;
                    context.Editor.Renderers[0].State.PanY = y;
                    if (invalidate)
                    {
                        context.InvalidateCache(isZooming: true);
                    }
                };

            border.AutoFitChild =
                (width, height) =>
                {
                    if (border != null
                        && context != null
                        && context.Editor.Project != null
                        && context.Editor.Project.CurrentContainer != null)
                    {
                        border.AutoFit(
                            width,
                            height,
                            context.Editor.Project.CurrentContainer.Width,
                            context.Editor.Project.CurrentContainer.Height);
                    }
                };

            border.MouseDown +=
                (s, e) =>
                {
                    if (e.ChangedButton == MouseButton.Middle && e.ClickCount == 2)
                    {
                        panAndZoomGrid.AutoFit();
                    }

                    if (e.ChangedButton == MouseButton.Middle && e.ClickCount == 3)
                    {
                        panAndZoomGrid.ResetZoomAndPan();
                    }
                };
        }
 /// <summary>
 /// Auto load recent project files.
 /// </summary>
 /// <param name="context"></param>
 private void AutoLoadRecent(EditorContext context)
 {
     try
     {
         LoadRecent(_recentFileName, context);
     }
     catch (Exception ex)
     {
         if (context.Editor.Log != null)
         {
             context.Editor.Log.LogError("{0}{1}{2}",
                 ex.Message,
                 Environment.NewLine,
                 ex.StackTrace);
         }
     }
 }
Exemple #15
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="context"></param>
 public ZoomState(EditorContext context)
 {
     _context = context;
 }