예제 #1
0
        //Загружает данные из примечания к ячейке
        private void LoadFromCell()
        {
            var    sh = _book.ActiveShape();
            string comment = null, address = null;

            if (sh != null)
            {
                if (sh.Type == MsoShapeType.msoTextBox || sh.Type == MsoShapeType.msoGroup)
                {
                    comment = sh.Title;
                    address = sh.Name;
                }
            }
            else
            {
                var activeCell = GeneralRep.Application.ActiveCell;
                comment = activeCell.Comment == null ? null : activeCell.Comment.Text();
                address = activeCell.Address.Replace("$", "");
            }

            if (comment == null)
            {
                CurrentLink.Text = "";
                return;
            }
            GetCurrentLink(comment, address);
            var dic = comment.ToPropertyDictionary();

            if (IsLoadFromCell.Checked)
            {
                if (dic.ContainsKey("Project") && dic.ContainsKey("Code") && dic.ContainsKey("Field"))
                {
                    var proj  = dic["Project"];
                    var lpar  = dic["Code"];
                    var field = dic["Field"].ToLinkField();
                    if (_book.Projects.ContainsKey(proj) && _book.Projects[proj].Params.ContainsKey(lpar))
                    {
                        if (CurProject.CodeFinal.ToLower() != dic["Project"].ToLower())
                        {
                            return;
                        }
                        foreach (DataGridViewRow r in Params.Rows)
                        {
                            try
                            {
                                if (r.Get("Code").ToLower() == lpar.ToLower())
                                {
                                    var cell = field.ParamsTableName() == null ? r.Cells[4] : r.Cells[field.ParamsTableName()];
                                    cell.Selected      = true;
                                    Params.CurrentCell = cell;
                                    ApplyParam();
                                    _book.GetLinkProps(dic);
                                    break;
                                }
                            }
                            catch { }
                        }
                        if (dic.ContainsKey("CellComment") && dic["CellComment"] != CellComment.Text)
                        {
                            CellComment.Text = dic["CellComment"];
                        }
                    }
                }
            }
        }