private void LoadImages()
 {
     lvConnections.SmallImageList = new ImageList();
     lvConnections.SmallImageList.Images.Add(RessourceManager.GetImage("McTools.Xrm.Connection.WinForms.Resources.server.png"));
     lvConnections.SmallImageList.Images.Add(RessourceManager.GetImage("McTools.Xrm.Connection.WinForms.Resources.server_key.png"));
     lvConnections.SmallImageList.Images.Add(RessourceManager.GetImage("McTools.Xrm.Connection.WinForms.Resources.CRMOnlineLive_16.png"));
 }
        private void newConnectionItem_Click(object sender, EventArgs e)
        {
            var actionMenu = (ToolStripMenuItem)sender;
            ToolStripDropDownItem parentItem = (ToolStripDropDownItem)actionMenu.OwnerItem;
            var connectionFile = (ConnectionFile)parentItem.Tag;

            ConnectionDetail detail = _formHelper.EditConnection(true, null, connectionFile);

            if (detail != null)
            {
                ToolStripMenuItem item = new ToolStripMenuItem();
                item.Text = detail.ConnectionName;
                item.Tag  = detail;

                if (detail.UseOnline)
                {
                    item.Image =
                        RessourceManager.GetImage(
                            "McTools.Xrm.Connection.WinForms.Resources.CRMOnlineLive_16.png");
                }
                else if (detail.UseOsdp)
                {
                    item.Image =
                        RessourceManager.GetImage(
                            "McTools.Xrm.Connection.WinForms.Resources.CRMOnlineLive_16.png");
                }
                else if (detail.UseIfd)
                {
                    item.Image =
                        RessourceManager.GetImage(
                            "McTools.Xrm.Connection.WinForms.Resources.server_key.png");
                }
                else
                {
                    item.Image =
                        RessourceManager.GetImage(
                            "McTools.Xrm.Connection.WinForms.Resources.server.png");
                }

                BuildActionItems(item);


                if (parentItem.DropDownItems.Count == 1)
                {
                    parentItem.DropDownItems.Insert(0, new ToolStripSeparator());
                    parentItem.DropDownItems.Insert(0, item);
                }
                else
                {
                    parentItem.DropDownItems.Insert(parentItem.DropDownItems.Count - 2, item);
                }

                MessageBox.Show(this, "Connection Created Successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds the ToolStripMenuItems representing connections to the
        /// ToolStripDropDownButton
        /// </summary>
        /// <param name="btn">ToolStripDropDownButton where to add connections</param>
        private void AddActionsList(ToolStripDropDownButton btn)
        {
            // Clearing existing connections
            btn.DropDownItems.Clear();

            if (this.cManager != null && this.cManager.ConnectionsList != null && this.cManager.ConnectionsList.Connections.Count > 0)
            {
                this.cManager.ConnectionsList.Connections.Sort();

                foreach (ConnectionDetail cDetail in this.cManager.ConnectionsList.Connections)
                {
                    ToolStripMenuItem item = new ToolStripMenuItem();
                    item.Text = cDetail.ConnectionName;
                    item.Tag  = cDetail;

                    if (cDetail.UseOnline)
                    {
                        item.Image = RessourceManager.GetImage("McTools.Xrm.Connection.WinForms.Resources.CRMOnlineLive_16.png");
                    }
                    else if (cDetail.UseOsdp)
                    {
                        item.Image = RessourceManager.GetImage("McTools.Xrm.Connection.WinForms.Resources.CRMOnlineLive_16.png");
                    }
                    else if (cDetail.UseIfd)
                    {
                        item.Image = RessourceManager.GetImage("McTools.Xrm.Connection.WinForms.Resources.server_key.png");
                    }
                    else
                    {
                        item.Image = RessourceManager.GetImage("McTools.Xrm.Connection.WinForms.Resources.server.png");
                    }

                    this.BuildActionItems(item);

                    btn.DropDownItems.Add(item);
                }

                if (this.cManager.ConnectionsList.Connections.Count > 0)
                {
                    ToolStripSeparator separator = new ToolStripSeparator();
                    btn.DropDownItems.Add(separator);
                }
            }

            ToolStripMenuItem newConnectionItem = new ToolStripMenuItem();

            newConnectionItem.Text   = "Create new connection";
            newConnectionItem.Image  = ((System.Drawing.Image)(resources.GetObject("server_add")));
            newConnectionItem.Click += new EventHandler(newConnectionItem_Click);
            btn.DropDownItems.Add(newConnectionItem);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds the ToolStripMenuItems representing connections to the
        /// ToolStripDropDownButton
        /// </summary>
        /// <param name="btn">ToolStripDropDownButton where to add connections</param>
        private void AddActionsList(ToolStripDropDownButton btn)
        {
            var list = new List <ToolStripItem>();

            if (ConnectionManager.Instance.ConnectionsList.Connections.Count > 0)
            {
                ConnectionManager.Instance.ConnectionsList.Connections.Sort();

                foreach (ConnectionDetail cDetail in ConnectionManager.Instance.ConnectionsList.Connections)
                {
                    ToolStripMenuItem item = new ToolStripMenuItem();
                    item.Text = cDetail.ConnectionName;
                    item.Tag  = cDetail;

                    if (cDetail.UseOnline)
                    {
                        item.Image =
                            RessourceManager.GetImage(
                                "McTools.Xrm.Connection.WinForms.Resources.CRMOnlineLive_16.png");
                    }
                    else if (cDetail.UseOsdp)
                    {
                        item.Image =
                            RessourceManager.GetImage(
                                "McTools.Xrm.Connection.WinForms.Resources.CRMOnlineLive_16.png");
                    }
                    else if (cDetail.UseIfd)
                    {
                        item.Image =
                            RessourceManager.GetImage(
                                "McTools.Xrm.Connection.WinForms.Resources.server_key.png");
                    }
                    else
                    {
                        item.Image =
                            RessourceManager.GetImage(
                                "McTools.Xrm.Connection.WinForms.Resources.server.png");
                    }

                    BuildActionItems(item);
                    list.Add(item);
                }

                list.Add(new ToolStripSeparator());
            }

            var newConnectionItem = new ToolStripMenuItem();

            newConnectionItem.Text   = "Create new connection";
            newConnectionItem.Image  = ((System.Drawing.Image)(resources.GetObject("server_add")));
            newConnectionItem.Click += newConnectionItem_Click;
            list.Add(newConnectionItem);

            if (InvokeRequired)
            {
                Invoke(new Action(() =>
                {
                    btn.DropDownItems.Clear();
                    btn.DropDownItems.AddRange(list.ToArray());
                }));
            }
            else
            {
                btn.DropDownItems.Clear();
                btn.DropDownItems.AddRange(list.ToArray());
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Adds the ToolStripMenuItems representing connections to the
        /// ToolStripDropDownButton
        /// </summary>
        /// <param name="btn">ToolStripDropDownButton where to add connections</param>
        private void AddActionsList(ToolStripDropDownButton btn)
        {
            var list       = new List <ToolStripItem>();
            int filesCount = ConnectionsList.Instance.Files.Count;

            if (filesCount == 0)
            {
                var defaultFilePath = Path.Combine(new FileInfo(ConnectionsList.ConnectionsListFilePath).DirectoryName, "ConnectionsList.Default.xml");

                CrmConnections cc = new CrmConnections("Default");
                cc.SerializeToFile(defaultFilePath);

                ConnectionsList.Instance.Files.Add(new ConnectionFile(cc)
                {
                    Path = defaultFilePath, LastUsed = DateTime.Now
                });
                ConnectionsList.Instance.Save();
            }

            foreach (var file in ConnectionsList.Instance.Files)
            {
                var connections = CrmConnections.LoadFromFile(file.Path);
                connections.Connections.Sort();

                var fileItem = new ToolStripMenuItem(file.Name);
                fileItem.Tag = file;
                if (!mergeConnectionFiles && filesCount > 1)
                {
                    list.Add(fileItem);
                }

                foreach (var cDetail in connections.Connections)
                {
                    ToolStripMenuItem item = new ToolStripMenuItem();
                    item.Text = cDetail.ConnectionName;
                    item.Tag  = cDetail;

                    if (cDetail.UseOnline)
                    {
                        item.Image =
                            RessourceManager.GetImage(
                                "McTools.Xrm.Connection.WinForms.Resources.CRMOnlineLive_16.png");
                    }
                    else if (cDetail.UseOsdp)
                    {
                        item.Image =
                            RessourceManager.GetImage(
                                "McTools.Xrm.Connection.WinForms.Resources.CRMOnlineLive_16.png");
                    }
                    else if (cDetail.UseIfd)
                    {
                        item.Image =
                            RessourceManager.GetImage(
                                "McTools.Xrm.Connection.WinForms.Resources.server_key.png");
                    }
                    else
                    {
                        item.Image =
                            RessourceManager.GetImage(
                                "McTools.Xrm.Connection.WinForms.Resources.server.png");
                    }

                    BuildActionItems(item);
                    if (!mergeConnectionFiles && filesCount > 1)
                    {
                        fileItem.DropDownItems.Add(item);
                    }
                    else
                    {
                        list.Add(item);
                    }
                }

                if (!mergeConnectionFiles && filesCount > 1)
                {
                    if (fileItem.DropDownItems.Count > 0)
                    {
                        fileItem.DropDownItems.Add(new ToolStripSeparator());
                    }
                }

                var newConnectionItem = new ToolStripMenuItem();
                newConnectionItem.Text   = "Create new connection";
                newConnectionItem.Image  = (Image)resources.GetObject("server_add");
                newConnectionItem.Click += newConnectionItem_Click;

                if (!mergeConnectionFiles && filesCount > 1)
                {
                    fileItem.DropDownItems.Add(newConnectionItem);
                }
            }

            if (mergeConnectionFiles || filesCount == 1)
            {
                if (list.Count > 0)
                {
                    list.Add(new ToolStripSeparator());
                }

                var newConnectionItem = new ToolStripMenuItem();
                newConnectionItem.Text   = "Create new connection";
                newConnectionItem.Image  = (Image)resources.GetObject("server_add");
                newConnectionItem.Click += newConnectionItem_Click;

                list.Add(newConnectionItem);
            }

            if (InvokeRequired)
            {
                Invoke(new Action(() =>
                {
                    btn.DropDownItems.Clear();
                    btn.DropDownItems.AddRange(list.ToArray());
                }));
            }
            else
            {
                btn.DropDownItems.Clear();
                btn.DropDownItems.AddRange(list.ToArray());
            }
        }