예제 #1
0
        public void CopyPathToNode(object sender, EventArgs e)
        {
            string nodePath = explorerPresenter.CurrentNodePath;

            if (Apsim.Get(explorerPresenter.ApsimXFile, nodePath) is Models.Functions.IFunction)
            {
                nodePath += ".Value()";
            }
            explorerPresenter.SetClipboardText(Path.GetFileNameWithoutExtension(explorerPresenter.ApsimXFile.FileName) + nodePath, "CLIPBOARD");
        }
예제 #2
0
 public void CopyPathToNode(object sender, EventArgs e)
 {
     try
     {
         explorerPresenter.SetClipboardText(explorerPresenter.CurrentNodePath, "CLIPBOARD");
     }
     catch (Exception err)
     {
         explorerPresenter.MainPresenter.ShowError(err);
     }
 }
예제 #3
0
        public void CopyPathToNode(object sender, EventArgs e)
        {
            try
            {
                string nodePath = explorerPresenter.CurrentNodePath;
                if (Apsim.Get(explorerPresenter.ApsimXFile, nodePath) is IFunction)
                {
                    nodePath += ".Value()";
                }

                explorerPresenter.SetClipboardText(Path.GetFileNameWithoutExtension(explorerPresenter.ApsimXFile.FileName) + nodePath, "CLIPBOARD");
            }
            catch (Exception err)
            {
                explorerPresenter.MainPresenter.ShowError(err);
            }
        }
예제 #4
0
        /// <summary>
        /// Copies data from a cell or range of cells to the clipboard.
        /// If the first cell is the same as the last cell, only the data from that cell will be copied.
        /// </summary>
        private void CopyCells(object sender, GridCellActionArgs args)
        {
            StringBuilder textToCopy = new StringBuilder();

            for (int row = args.StartCell.RowIndex; row <= args.EndCell.RowIndex; row++)
            {
                for (int column = args.StartCell.ColumnIndex; column <= args.EndCell.ColumnIndex; column++)
                {
                    textToCopy.Append(grid.GetCell(column, row).Value.ToString());
                    if (column != args.EndCell.ColumnIndex)
                    {
                        textToCopy.Append('\t');
                    }
                }
                textToCopy.AppendLine();
            }
            presenter.SetClipboardText(textToCopy.ToString(), "CLIPBOARD");
        }
예제 #5
0
        /// <summary>A node has begun to be dragged.</summary>
        /// <param name="sender">Sending object</param>
        /// <param name="e">Drag arguments</param>
        private void OnDragStart(object sender, DragStartArgs e)
        {
            e.DragObject = null; // Assume failure
            string modelName = e.NodePath;

            // We want to create an object of the named type
            Type modelType = null;

            this.explorerPresenter.MainPresenter.ShowWaitCursor(true);
            try
            {
                foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    foreach (Type t in assembly.GetTypes())
                    {
                        if (t.FullName == modelName.TrimStart('.') && t.IsPublic && t.IsClass)
                        {
                            modelType = t;
                            break;
                        }
                    }
                }

                if (modelType != null)
                {
                    object child       = Activator.CreateInstance(modelType, true);
                    string childString = FileFormat.WriteToString(child as IModel);
                    explorerPresenter.SetClipboardText(childString);

                    DragObject dragObject = new DragObject();
                    dragObject.NodePath    = e.NodePath;
                    dragObject.ModelType   = modelType;
                    dragObject.ModelString = childString;
                    e.DragObject           = dragObject;
                }
            }
            finally
            {
                explorerPresenter.MainPresenter.ShowWaitCursor(false);
            }
        }