Beispiel #1
0
        private void TsbAddIconClick(object sender, EventArgs e)
        {
            var icForm = new ImageCreationForm(Service);

            icForm.ShowDialog();

            if (icForm.WebResourcesCreated.Count > 0)
            {
                var imageList16    = listViewWebRessources16.LargeImageList;
                var imageList32    = listViewWebRessources32.LargeImageList;
                var imageListOther = listViewWebRessourcesOther.LargeImageList;

                foreach (var webResource in icForm.WebResourcesCreated)
                {
                    var imageConverted = ImageHelper.ConvertWebResContent(webResource.Attributes["content"].ToString());

                    if (imageConverted.Size.Height == 32 && imageConverted.Size.Width == 32)
                    {
                        var lvi = new ListViewItem(webResource.Attributes["name"].ToString())
                        {
                            Tag        = webResource,
                            ImageIndex = imageList32.Images.Count
                        };
                        listViewWebRessources32.Items.Add(lvi);
                        imageList32.Images.Add(imageConverted);
                    }
                    else if (imageConverted.Size.Height == 16 && imageConverted.Size.Width == 16)
                    {
                        var lvi = new ListViewItem(webResource.Attributes["name"].ToString())
                        {
                            Tag        = webResource,
                            ImageIndex = imageList16.Images.Count
                        };
                        listViewWebRessources16.Items.Add(lvi);
                        imageList16.Images.Add(imageConverted);
                    }
                    else
                    {
                        var listWrImage = new WebResourcesManager.WebResourceAndImage
                        {
                            Image       = imageConverted,
                            Webresource = webResource
                        };
                        var lvi = new ListViewItem(webResource.Attributes["name"].ToString())
                        {
                            Tag        = listWrImage,
                            ImageIndex = imageListOther.Images.Count,
                        };
                        listViewWebRessourcesOther.Items.Add(lvi);
                        imageListOther.Images.Add(imageConverted);
                    }
                    webResourceRetrivedList.Add(webResource);
                }

                listViewWebRessources32.LargeImageList    = imageList32;
                listViewWebRessources16.LargeImageList    = imageList16;
                listViewWebRessourcesOther.LargeImageList = imageListOther;
            }
        }
Beispiel #2
0
        private void TsbAddIconClick(object sender, EventArgs e)
        {
            var icForm = new ImageCreationForm(Service);
            icForm.ShowDialog();

            if (icForm.WebResourcesCreated.Count > 0)
            {
                var imageList16 = listViewWebRessources16.LargeImageList;
                var imageList32 = listViewWebRessources32.LargeImageList;
                var imageListOther = listViewWebRessourcesOther.LargeImageList;

                foreach (var webResource in icForm.WebResourcesCreated)
                {
                    var imageConverted = ImageHelper.ConvertWebResContent(webResource.Attributes["content"].ToString());

                    if (imageConverted.Size.Height == 32 && imageConverted.Size.Width == 32)
                    {
                        var lvi = new ListViewItem(webResource.Attributes["name"].ToString())
                        {
                            Tag = webResource,
                            ImageIndex = imageList32.Images.Count
                        };
                        listViewWebRessources32.Items.Add(lvi);
                        imageList32.Images.Add(imageConverted);
                    }
                    else if (imageConverted.Size.Height == 16 && imageConverted.Size.Width == 16)
                    {
                        var lvi = new ListViewItem(webResource.Attributes["name"].ToString())
                        {
                            Tag = webResource,
                            ImageIndex = imageList16.Images.Count
                        };
                        listViewWebRessources16.Items.Add(lvi);
                        imageList16.Images.Add(imageConverted);
                    }
                    else
                    {
                        var listWrImage = new WebResourcesManager.WebResourceAndImage
                        {
                            Image = imageConverted,
                            Webresource = webResource
                        };
                        var lvi = new ListViewItem(webResource.Attributes["name"].ToString())
                        {
                            Tag = listWrImage,
                            ImageIndex = imageListOther.Images.Count,
                        };
                        listViewWebRessourcesOther.Items.Add(lvi);
                        imageListOther.Images.Add(imageConverted);
                    }
                    webResourceRetrivedList.Add(webResource);
                }

                listViewWebRessources32.LargeImageList = imageList32;
                listViewWebRessources16.LargeImageList = imageList16;
                listViewWebRessourcesOther.LargeImageList = imageListOther;
            }
        }
Beispiel #3
0
        private void DoAction()
        {
            listViewEntities.Items.Clear();
            listViewWebRessources16.Items.Clear();
            listViewWebRessources32.Items.Clear();
            listViewWebRessourcesOther.Items.Clear();

            WorkAsync("Loading Entities...",
                      (bw, e) =>
            {
                var cc = new CrmComponents();

                // Display retrieved entities
                var queryEntities = from entityList in MetadataManager.GetEntitiesList(Service)
                                    orderby entityList.DisplayName.UserLocalizedLabel.Label
                                    select entityList;

                foreach (var entity in queryEntities)
                {
                    var lvi = new ListViewItem(entity.DisplayName.UserLocalizedLabel.Label)
                    {
                        Tag = entity
                    };
                    lvi.SubItems.Add(entity.LogicalName);
                    cc.Entities.Add(lvi);
                }

                bw.ReportProgress(0, "Loading Web resources...");

                var queryWebResources =
                    from webResourceList in WebResourcesManager.GetWebResourcesOnSolution(Service).Entities
                    orderby webResourceList.Attributes["name"]
                    select webResourceList;

                foreach (var webResource in queryWebResources)
                {
                    var imageConverted =
                        ImageHelper.ConvertWebResContent(webResource.Attributes["content"].ToString());



                    if (imageConverted.Size.Height == 32 && imageConverted.Size.Width == 32)
                    {
                        var lvi = new ListViewItem(webResource.Attributes["name"].ToString())
                        {
                            Tag        = webResource,
                            ImageIndex = cc.Images32.Count
                        };
                        cc.Icons32.Add(lvi);
                        cc.Images32.Add(imageConverted);
                    }
                    else if (imageConverted.Size.Height == 16 && imageConverted.Size.Width == 16)
                    {
                        var lvi = new ListViewItem(webResource.Attributes["name"].ToString())
                        {
                            Tag        = webResource,
                            ImageIndex = cc.Images16.Count
                        };
                        cc.Icons16.Add(lvi);
                        cc.Images16.Add(imageConverted);
                    }
                    else
                    {
                        var listWrImage = new WebResourcesManager.WebResourceAndImage
                        {
                            Image       = imageConverted,
                            Webresource = webResource
                        };
                        var lvi = new ListViewItem(webResource.Attributes["name"].ToString())
                        {
                            Tag        = listWrImage,
                            ImageIndex = cc.ImagesOthers.Count,
                        };
                        cc.IconsOthers.Add(lvi);
                        cc.ImagesOthers.Add(imageConverted);
                    }

                    webResourceRetrivedList.Add(webResource);
                }

                e.Result = cc;
            },
                      e =>
            {
                if (e.Error != null)
                {
                    MessageBox.Show(this, "Error while loading Crm components: " + e.Error.Message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var cc = (CrmComponents)e.Result;

                    var imageList16 = new ImageList
                    {
                        ImageSize  = new Size(16, 16),
                        ColorDepth = ColorDepth.Depth32Bit
                    };
                    var imageList32 = new ImageList
                    {
                        ImageSize  = new Size(32, 32),
                        ColorDepth = ColorDepth.Depth32Bit
                    };
                    var imageListOther = new ImageList {
                        ColorDepth = ColorDepth.Depth32Bit
                    };

                    imageList16.Images.AddRange(cc.Images16.ToArray());
                    imageList32.Images.AddRange(cc.Images32.ToArray());
                    imageListOther.Images.AddRange(cc.ImagesOthers.ToArray());

                    listViewWebRessources16.LargeImageList    = imageList16;
                    listViewWebRessources32.LargeImageList    = imageList32;
                    listViewWebRessourcesOther.LargeImageList = imageListOther;

                    listViewEntities.Items.AddRange(cc.Entities.ToArray());
                    listViewWebRessources16.Items.AddRange(cc.Icons16.ToArray());
                    listViewWebRessources32.Items.AddRange(cc.Icons32.ToArray());
                    listViewWebRessourcesOther.Items.AddRange(cc.IconsOthers.ToArray());
                }
                tsbAddIcon.Enabled = true;
                tsbApply.Enabled   = true;

                SetEnableState(true);
            },
                      e => SetWorkingMessage(e.UserState.ToString()));
        }
Beispiel #4
0
        private void DoAction()
        {
            listViewEntities.Items.Clear();
            listViewWebRessources16.Items.Clear();
            listViewWebRessources32.Items.Clear();
            listViewWebRessourcesOther.Items.Clear();

            WorkAsync("Loading Entities...",
                (bw, e) =>
                {
                    var cc = new CrmComponents();

                    // Display retrieved entities
                    var queryEntities = from entityList in MetadataManager.GetEntitiesList(Service)
                        orderby entityList.DisplayName.UserLocalizedLabel.Label
                        select entityList;

                    foreach (var entity in queryEntities)
                    {
                        var lvi = new ListViewItem(entity.DisplayName.UserLocalizedLabel.Label) {Tag = entity};
                        lvi.SubItems.Add(entity.LogicalName);
                        cc.Entities.Add(lvi);
                    }

                    bw.ReportProgress(0, "Loading Web resources...");

                    var queryWebResources =
                        from webResourceList in WebResourcesManager.GetWebResourcesOnSolution(Service).Entities
                        orderby webResourceList.GetAttributeValue<string>("name")
                        select webResourceList;

                    foreach (var webResource in queryWebResources)
                    {
                        try
                        {
                            var imageConverted =
                                ImageHelper.ConvertWebResContent(webResource.GetAttributeValue<string>("content"));

                            if (imageConverted == null)
                                continue;

                            if (imageConverted.Size.Height == 32 && imageConverted.Size.Width == 32)
                            {
                                var lvi = new ListViewItem(webResource.GetAttributeValue<string>("name"))
                                {
                                    Tag = webResource,
                                    ImageIndex = cc.Images32.Count
                                };
                                cc.Icons32.Add(lvi);
                                cc.Images32.Add(imageConverted);
                            }
                            else if (imageConverted.Size.Height == 16 && imageConverted.Size.Width == 16)
                            {
                                var lvi = new ListViewItem(webResource.GetAttributeValue<string>("name"))
                                {
                                    Tag = webResource,
                                    ImageIndex = cc.Images16.Count
                                };
                                cc.Icons16.Add(lvi);
                                cc.Images16.Add(imageConverted);
                            }
                            else
                            {
                                var listWrImage = new WebResourcesManager.WebResourceAndImage
                                {
                                    Image = imageConverted,
                                    Webresource = webResource
                                };
                                var lvi = new ListViewItem(webResource.GetAttributeValue<string>("name"))
                                {
                                    Tag = listWrImage,
                                    ImageIndex = cc.ImagesOthers.Count,
                                };
                                cc.IconsOthers.Add(lvi);
                                cc.ImagesOthers.Add(imageConverted);
                            }

                            webResourceRetrivedList.Add(webResource);
                        }
                        catch { }
                    }

                    e.Result = cc;
                },
                e =>
                {
                    if (e.Error != null)
                    {
                        MessageBox.Show(this, "Error while loading Crm components: " + e.Error.Message, "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        var cc = (CrmComponents) e.Result;

                        var imageList16 = new ImageList
                        {
                            ImageSize = new Size(16, 16),
                            ColorDepth = ColorDepth.Depth32Bit
                        };
                        var imageList32 = new ImageList
                        {
                            ImageSize = new Size(32, 32),
                            ColorDepth = ColorDepth.Depth32Bit
                        };
                        var imageListOther = new ImageList {ColorDepth = ColorDepth.Depth32Bit};

                        imageList16.Images.AddRange(cc.Images16.ToArray());
                        imageList32.Images.AddRange(cc.Images32.ToArray());
                        imageListOther.Images.AddRange(cc.ImagesOthers.ToArray());

                        listViewWebRessources16.LargeImageList = imageList16;
                        listViewWebRessources32.LargeImageList = imageList32;
                        listViewWebRessourcesOther.LargeImageList = imageListOther;

                        listViewEntities.Items.AddRange(cc.Entities.ToArray());
                        listViewWebRessources16.Items.AddRange(cc.Icons16.ToArray());
                        listViewWebRessources32.Items.AddRange(cc.Icons32.ToArray());
                        listViewWebRessourcesOther.Items.AddRange(cc.IconsOthers.ToArray());
                    }
                    tsbAddIcon.Enabled = true;
                    tsbApply.Enabled = true;

                    SetEnableState(true);
                },
                e => SetWorkingMessage(e.UserState.ToString()));
        }