Exemple #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            UcFindAddCondition cond = new UcFindAddCondition();

            if (cond.ShowDialog() == DialogResult.OK)
            {
                Condition condition = cond.result;
                ////condition.Id = conditions.Count+1;
                ////condition.IdParent = 0;
                conditions.Add(condition);

                RadTreeNode newNode = new RadTreeNode(condition.Name + " " + condition.Operator + " " + condition.Value);
                //newNode.DataBoundItem = condition;
                this.radTreeView1.Nodes.Add(newNode);
                this.conditionsDictionary.Add(newNode, condition);
            }
        }
Exemple #2
0
        private void UcFindFile_Load(object sender, EventArgs e)
        {
            //this.radTreeView1.SelectedNode = null;
            //this.radTreeView1.DisplayMember = "DisplayName";
            //this.radTreeView1.ValueMember = "Id";
            //this.radTreeView1.ParentIDMember = "IdParent";
            //this.radTreeView1.DataSource = conditions;
            menu = new RadContextMenu();
            RadMenuItem documentoView = new RadMenuItem();

            documentoView.Text = "Add child condition";
            RadContextMenuManager manager = new RadContextMenuManager();

            manager.SetRadContextMenu(this.radTreeView1, radContextMenu1);

            addChildCond.Click += (object sender1, EventArgs e1) =>
            {
                if (this.radTreeView1.SelectedNode != null)
                {
                    UcFindAddCondition cond = new UcFindAddCondition();
                    if (cond.ShowDialog() == DialogResult.OK)
                    {
                        var conditionResult = cond.result;
                        ////conditionResult.Id = conditions.Count + 1;
                        ////conditionResult.IdParent = condition.Id;
                        conditions.Add(conditionResult);

                        RadTreeNode newNode = new RadTreeNode(conditionResult.Name + " " + conditionResult.Operator + " " + conditionResult.Value);

                        this.radTreeView1.SelectedNode.Nodes.Add(newNode);
                        this.conditionsDictionary.Add(newNode, conditionResult);
                    }
                }
                else
                {
                    btnAdd_Click(null, null);
                }
            };

            remCond.Click += (object sender1, EventArgs e1) =>
            {
                if (this.radTreeView1.SelectedNode != null)
                {
                    conditions.Remove(conditionsDictionary[radTreeView1.SelectedNode]);
                    conditionsDictionary.Remove(this.radTreeView1.SelectedNode);
                    foreach (RadTreeNode node in this.radTreeView1.SelectedNode.Nodes)
                    {
                        var nodeCondition = conditionsDictionary[node];
                        if (conditions.Contains(nodeCondition))
                        {
                            conditions.Remove(nodeCondition);
                        }
                        if (conditionsDictionary.ContainsKey(node))
                        {
                            conditionsDictionary.Remove(node);
                        }
                    }
                    this.radTreeView1.SelectedNode.Nodes.Clear();
                    this.radTreeView1.SelectedNode.Remove();
                }
            };

            editCond.Click += (object sender1, EventArgs e1) =>
            {
                if (this.radTreeView1.SelectedNode != null)
                {
                    var       condition    = conditionsDictionary[radTreeView1.SelectedNode];
                    Condition oldCondition = condition;

                    UcFindAddCondition ucDlg = new UcFindAddCondition(condition);
                    if (ucDlg.ShowDialog(this) == DialogResult.OK)
                    {
                        condition = ucDlg.result;
//                        this.radTreeView1.SelectedNode.DataBoundItem = condition;
                        this.radTreeView1.SelectedNode.Text = condition.Name + " " + condition.Operator + " " + condition.Value;
                        this.conditionsDictionary[this.radTreeView1.SelectedNode] = condition;
                        this.conditions.Remove(oldCondition);
                        this.conditions.Add(condition);
                    }
                }
            };

            manager.SetRadContextMenu(this.radGridFindResults, this.radContextMenu2);
            this.showDocument.Click += (object sender1, EventArgs e1) =>
            {
                try
                {
                    if (this.radGridFindResults.SelectedRows.Count > 0)
                    {
                        BiblosDs.Document.AdminCentral.ServiceReferenceDocument.Content content = null;
                        //e.CurrentRow.Cells["IdChain"].Value, e.CurrentRow.Cells["IdBiblos"].Value });
                        Guid id = Guid.Parse(radGridFindResults.SelectedRows[0].Cells["iddocument"].Value.ToString());
                        // Metodo nuovo
                        waitForm = new WaitForm();
                        waitForm.Show();
                        BackgroundWorker bcw = new BackgroundWorker();
                        bcw.DoWork += delegate(object sender2, DoWorkEventArgs e2)
                        {
                            using (var client = new DocumentsClient("Binding_Documents"))
                            {
                                content = client.GetDocumentContent(id, null, ContentFormat.Bynary, null);
                            }
                        };
                        bcw.RunWorkerCompleted += delegate(object sender2, RunWorkerCompletedEventArgs e2)
                        {
                            waitForm.Close();
                            if (e2.Error != null)
                            {
                                MessageBox.Show(e2.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                if (content != null)
                                {
                                    DialogResult res = MessageBox.Show("Yes Open, No Save file", "Open/Save", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                                    if (res == DialogResult.Yes)
                                    {
                                        new UcDocumentViewer(content.Blob).Show();
                                    }
                                    else if (res == DialogResult.No)
                                    {
                                        if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                                        {
                                            File.WriteAllBytes(saveFileDialog1.FileName, content.Blob);
                                        }
                                    }
                                }
                            }
                        };
                        bcw.RunWorkerAsync();
                    }
                }
                catch (Exception ex)
                {
                    waitForm.Close();
                    MessageBox.Show(ex.Message);
                }
            };

            this.showMetadata.Click += (object sender1, EventArgs e1) =>
            {
                if (this.radGridFindResults.SelectedRows.Count > 0)
                {
                    Guid id = Guid.Parse(radGridFindResults.SelectedRows[0].Cells["iddocument"].Value.ToString());
                    clientDocument.GetDocumentInfoCompleted += delegate(object senderObj, GetDocumentInfoCompletedEventArgs eRes)
                    {
                        waitForm.Close();
                        if (eRes.Error != null)
                        {
                            MessageBox.Show(eRes.Error.Message);
                            return;
                        }
                        Forms.MetaDataView metadata = new Forms.MetaDataView();
                        metadata.Attributes = eRes.Result.Where(x => x.IdDocument == Guid.Parse(radGridFindResults.SelectedRows[0].Cells["iddocument"].Value.ToString())).Single().AttributeValues;
                        metadata.ShowDialog();
                    };
                    clientDocument.GetDocumentInfoAsync(id, null, null);
                    waitForm = new WaitForm();
                    waitForm.Show();
                }
            };
            menu.Items.Add(documentoView);
        }