private bool Validate(IProjectEditor editor, object sender, DragEventArgs e, bool bExecute) { var point = DropHelper.GetPosition(sender, e); if (e.Data.Contains(DataFormats.Text)) { var text = e.Data.GetText(); if (bExecute) { editor?.OnTryPaste(text); } return(true); } foreach (var format in e.Data.GetDataFormats()) { var data = e.Data.Get(format); switch (data) { case IBaseShape shape: return(editor?.OnDropShape(shape, point.X, point.Y, bExecute) == true); case IRecord record: return(editor?.OnDropRecord(record, point.X, point.Y, bExecute) == true); case IShapeStyle style: return(editor?.OnDropStyle(style, point.X, point.Y, bExecute) == true); case IPageContainer page: return(editor?.OnDropTemplate(page, point.X, point.Y, bExecute) == true); default: break; } } if (e.Data.Contains(DataFormats.FileNames)) { var files = e.Data.GetFileNames().ToArray(); if (bExecute) { editor?.OnDropFiles(files); } return(true); } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="ProjectObserver"/> class. /// </summary> /// <param name="editor">The current <see cref="IProjectEditor"/> object.</param> public ProjectObserver(IProjectEditor editor) { if (editor?.Project != null) { _editor = editor; _invalidateContainer = () => { }; _invalidateStyles = () => InvalidateAndClearCache(); _invalidateLayers = () => Invalidate(); _invalidateShapes = () => Invalidate(); Add(_editor.Project); } }
protected void ToolProjectSaveAsClick(object sender, EventArgs e) { IProjectEditor ip = (IProjectEditor)currentWidget; saveFD.Title = "Save"; saveFD.Filters.Clear(); saveFD.Filters.Add(new FileDialogFilter(ip.Project.TypeName, "*" + ip.Project.Type.Filter)); saveFD.InitialFileName = ip.Project.FileName; if (saveFD.Run()) { ip.Project.FileName = saveFD.FileName; ip.Project.Save(); } if (!GuiEnvironment.ProjectsInfo.Contains(ip.Project)) { GuiEnvironment.ProjectsInfo.Add(ip.Project); } }
/// <summary> /// Initializes a new instance of the <see cref="ProjectEditorInputTarget"/> class. /// </summary> /// <param name="editor">The current <see cref="IProjectEditor"/> object.</param> public ProjectEditorInputTarget(IProjectEditor editor) { _editor = editor; }