Esempio n. 1
0
        private void ListViewActivities_DoubleClick(object sender, EventArgs e)
        {
            Point mousePosition     = listViewActivities.PointToClient(Control.MousePosition);
            ListViewHitTestInfo hit = listViewActivities.HitTest(mousePosition);
            int columnindex         = hit.Item.SubItems.IndexOf(hit.SubItem);

            switch (columnindex)
            {
            case 2:     //Regarding
                DisplayApplicationForm appForm = new DisplayApplicationForm();
                appForm.DataFile  = DataStoreLayer.GetFileNameFromTitle(listViewActivities.SelectedItems[0].SubItems[columnindex].Text);
                appForm.MdiParent = this.MdiParent;

                if (this.MdiParent.MdiChildren.Length > 2)
                {
                    this.MdiParent.MdiChildren[2].Close();
                }
                appForm.Show();
                appForm.MdiParent.MdiChildren[2].Activate();
                break;

            case 5:     //Body
                DisplayBodyForm DisplayBodyForm = new DisplayBodyForm();
                DisplayBodyForm.Body = listViewActivities.SelectedItems[0].SubItems[columnindex].Text;
                DisplayBodyForm.ShowDialog(this);
                break;
            }
        }
Esempio n. 2
0
        private void mainTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Node.Parent != null && e.Button == MouseButtons.Left)
            {
                switch (e.Node.FullPath)
                {
                case string a when a.Contains("My Job Applications\\Applications\\") && e.Node.Level == 3:
                case string b when b.Contains("My Job Applications\\Companies\\") && e.Node.Level == 3:
                case string c when c.Contains("My Job Applications\\Contacts\\") && e.Node.Level == 3:
                    DisplayApplicationForm appForm = new DisplayApplicationForm();

                    if (!Array.Exists(records, x => x.Contains(e.Node.Name)))
                    {
                        MessageBox.Show("No Record is found in the system");
                        return;
                    }
                    appForm.DataFile = Array.FindAll(records, x => x.Contains(e.Node.Name))[0];
                    if (this.MdiParent.MdiChildren.Length > 2)
                    {
                        this.MdiParent.MdiChildren[2].Close();
                    }
                    appForm.MdiParent = this.MdiParent;
                    appForm.Show();
                    this.MdiParent.MdiChildren[2].Activate();
                    break;

                case string d when d.Contains("My Job Applications\\Activities\\Activities") && e.Node.Level == 2:
                    Activities actForm = new Activities(records);

                    if (this.MdiParent.MdiChildren.Length > 2)
                    {
                        this.MdiParent.MdiChildren[2].Close();
                    }
                    actForm.MdiParent = this.MdiParent;
                    actForm.Show();
                    this.MdiParent.MdiChildren[2].Activate();
                    break;

                case string f when f.Contains("My Job Applications\\Activities\\Activities\\") && e.Node.Level == 3:
                    DisplayJobActivityForm jobActForm = new DisplayJobActivityForm();

                    if (!Array.Exists(records, x => x.Contains(e.Node.Name)))
                    {
                        MessageBox.Show("No Record is found in the system");
                        return;
                    }
                    jobActForm.DataFile = Array.FindAll(records, x => x.Contains(e.Node.Name))[0];
                    if (this.MdiParent.MdiChildren.Length > 2)
                    {
                        this.MdiParent.MdiChildren[2].Close();
                    }
                    jobActForm.MdiParent = this.MdiParent;
                    jobActForm.Show();
                    this.MdiParent.MdiChildren[2].Activate();
                    break;

                case string g when g.Contains("My Job Applications\\Activities\\Regarding\\") && e.Node.Level == 3:
                    //search all activities for selected item
                    List <string> strParams = new List <string>();

                    foreach (string dataFile in records)
                    {
                        XDocument doc = XDocument.Load(dataFile);

                        foreach (var dm in doc.Descendants("jobActivity"))
                        {
                            if (dm.Element("regarding").Value.Contains(e.Node.Name))
                            {
                                strParams.Add(dataFile);
                            }
                        }
                    }

                    actForm = new Activities(strParams.ToArray <string>());

                    if (this.MdiParent.MdiChildren.Length > 2)
                    {
                        this.MdiParent.MdiChildren[2].Close();
                    }
                    actForm.MdiParent = this.MdiParent;
                    actForm.Show();
                    this.MdiParent.MdiChildren[2].Activate();

                    break;

                case string h when h.Contains("My Job Applications\\Activities\\Contacts\\") && e.Node.Level == 3:
                    actForm = new Activities(records.Where(x => x.Contains(e.Node.Name)).ToArray <string>());

                    if (this.MdiParent.MdiChildren.Length > 2)
                    {
                        this.MdiParent.MdiChildren[2].Close();
                    }
                    actForm.MdiParent = this.MdiParent;
                    actForm.Show();
                    this.MdiParent.MdiChildren[2].Activate();
                    break;

                case string i when i.Contains("My Job Applications\\Activities\\FollowUps\\") && e.Node.Level == 3:
                    jobActForm = new DisplayJobActivityForm();

                    if (!Array.Exists(records, x => x.Contains(e.Node.Name)))
                    {
                        MessageBox.Show("No Record is found in the system");
                        return;
                    }
                    jobActForm.DataFile = Array.FindAll(records, x => x.Contains(e.Node.Name))[0];
                    if (this.MdiParent.MdiChildren.Length > 2)
                    {
                        this.MdiParent.MdiChildren[2].Close();
                    }
                    jobActForm.MdiParent = this.MdiParent;
                    jobActForm.Show();
                    this.MdiParent.MdiChildren[2].Activate();
                    break;
                }

                mainTreeView.SelectedNode = e.Node;
            }

            if (e.Button == MouseButtons.Right)
            {
                switch (e.Node.FullPath)
                {
                case "My Job Applications\\Applications":
                    mainTreeView.ContextMenuStrip      = contextMenuStrip1;
                    contextMenuStrip1.Items[0].Visible = true;
                    contextMenuStrip1.Items[1].Visible = false;
                    contextMenuStrip1.Items[2].Visible = false;
                    contextMenuStrip1.Items[3].Visible = false;
                    contextMenuStrip1.Items[4].Visible = false;
                    break;

                case string a when a.Contains("My Job Applications\\Applications\\Open") && e.Node.Level == 3:
                    mainTreeView.ContextMenuStrip = contextMenuStrip1;

                    contextMenuStrip1.Items[0].Visible = false;
                    contextMenuStrip1.Items[1].Visible = false;
                    contextMenuStrip1.Items[2].Visible = true;
                    contextMenuStrip1.Items[3].Visible = false;
                    contextMenuStrip1.Items[4].Visible = true;
                    break;

                case "My Job Applications\\Activities":
                    mainTreeView.ContextMenuStrip      = contextMenuStrip1;
                    contextMenuStrip1.Items[0].Visible = false;
                    contextMenuStrip1.Items[1].Visible = true;
                    contextMenuStrip1.Items[2].Visible = false;
                    contextMenuStrip1.Items[3].Visible = false;
                    contextMenuStrip1.Items[4].Visible = false;
                    break;

                case string b when b.Contains("My Job Applications\\Activities\\FollowUps") && e.Node.Level == 3:
                    mainTreeView.ContextMenuStrip = contextMenuStrip1;

                    contextMenuStrip1.Items[0].Visible = false;
                    contextMenuStrip1.Items[1].Visible = false;
                    contextMenuStrip1.Items[2].Visible = false;
                    contextMenuStrip1.Items[3].Visible = true;
                    contextMenuStrip1.Items[4].Visible = false;
                    break;

                default:
                    mainTreeView.ContextMenuStrip = null;
                    break;
                }
            }
        }