Beispiel #1
0
        public listViewPrinter(ListView lv, Point location, bool border, bool hasGroups, string title,string rezultat)
        {
            this.lv = lv;
            this.location = location;
            this.border = border;

            this.hasGroups = hasGroups;
            this.title = title;
            this.rezultat = rezultat;
            titleHeight = !string.IsNullOrEmpty(title) ? lv.FindForm().CreateGraphics().MeasureString(title, new Font(lv.Font.Name, 25)).ToSize().Height : 0;
            pd.BeginPrint += pd_BeginPrint;
            pd.PrintPage += pd_PrintPage;
        }
Beispiel #2
0
        /// <summary>
        /// Patchs the custom event ItemClick for a listView.
        /// </summary>
        /// <param name="lView">The source ListView.</param>
        private static void PatchItemClickEvent(ListView lView)
        {
            Delegate del = null;
            try
            {
                string methodName = Convert.ToString(newProperties[lView][newPropertiesEnum.ItemClickMethod]).Trim();
                if (!string.IsNullOrEmpty(methodName))
                {
                    if (!EventsPatched[lView].ContainsKey(ItemClickEventName))
                    {
                        MethodInfo mInfo = lView.FindForm().GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);

                        if (mInfo.IsStatic)
                            del = Delegate.CreateDelegate(typeof(ListView_ItemClickDelegate), mInfo);
                        else
                            del = Delegate.CreateDelegate(typeof(ListView_ItemClickDelegate), lView.FindForm(), mInfo);

                        if (!EventsPatched.ContainsKey(lView))
                            EventsPatched.Add(lView, new Dictionary<string, List<Delegate>>());

                        EventsPatched[lView].Add(ItemClickEventName, new List<Delegate>());
                        EventsPatched[lView][ItemClickEventName].Add(del);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format(UpgradeHelpers.VB6.Resources.UpgradeHelpers_VB6.UpgradeHelpers_VB6_Help_ListViewHelper_PatchItemClickEvent_Err_Msg, e.Message));
            }
        }
        public void DownloadSpoiler(XmlDocument xSet, XmlDocument xSetLang, ListView list, ProgressBar progressBar)
        {
            mList = list;

              ListViewItem item;

              if(Directory.Exists("cards"))
            Directory.Delete("cards", true);
              Directory.CreateDirectory("cards");
              foreach(XmlNode nodeSet in xSet.DocumentElement.SelectNodes("card_sets/item"))
              {
            string setCode = nodeSet.Attributes["code"].Value;
            string setName = xSetLang.DocumentElement.SelectSingleNode("card_sets_lang/item[@code='" + setCode + "' and @language='ENG']/@name").InnerText;

            if(setCode != "M12")
              continue;

            string cardsPath = "cards\\" + setCode + ".xml";
            string cardsLangPath = "cards\\" + setCode + ".eng.xml";
            if(File.Exists(cardsPath))
              File.Delete(cardsPath);
            if(File.Exists(cardsLangPath))
              File.Delete(cardsLangPath);
            XmlDocument xCards = new XmlDocument();
            xCards.LoadXml("<cards />");
            XmlDocument xCardsLang = new XmlDocument();
            xCardsLang.LoadXml("<cards />");

            DateTime setDate = XmlConvert.ToDateTime(nodeSet.Attributes["releaseDate"].Value, "yyyy-MM-ddTHH:mm:ss");
            xCards.DocumentElement.Attributes.Append(xCards.CreateAttribute("releaseDate")).Value = setDate.ToString("yyyy-MM-ddTHH:mm:ss");
            xCards.DocumentElement.Attributes.Append(xCards.CreateAttribute("code")).Value = setCode;

            xCardsLang.DocumentElement.Attributes.Append(xCardsLang.CreateAttribute("name")).Value = setName;

            string contentTextPath = Path.Combine(Path.Combine(CARDS_DIRPATH, setCode), "CONTENT.txt");
            string contentXmlPath = Path.Combine(Path.Combine(CARDS_DIRPATH, setCode), "CONTENT.xml");
            string listPath = Path.Combine(Path.Combine(CARDS_DIRPATH, setCode), "list.xml");

            item = new ListViewItem(setCode);
            ListViewItem.ListViewSubItem subItem = item.SubItems.Add("Working...");
            mList.Items.Add(item);
            mList.EnsureVisible(mList.Items.Count - 1);
            Application.DoEvents();

            progressBar.Minimum = 0;
            progressBar.Step = 1;
            progressBar.Value = 0;

            XmlDocument xCardList = new XmlDocument();
            xCardList.Load(listPath);
            XmlDocument xContent = new XmlDocument();
            string allContent;
            if(!File.Exists(contentTextPath))
            {
              // download page content
              subItem.Text = "Downloading...";
              mList.FindForm().Refresh();
              Application.DoEvents();

              allContent = string.Empty;

              xContent.LoadXml("<content />");
              progressBar.Maximum = xCardList.SelectNodes("//card").Count;
              foreach(XmlNode cardNode in xCardList.SelectNodes("//card"))
              {
            string id = cardNode.SelectSingleNode("@id").InnerText;
            string content = Download(URL_SPOILER + id);
            allContent += content;
            XmlNode nodeContent = xContent.ImportNode(GetDocument(content).DocumentElement, true);
            xContent.DocumentElement.AppendChild(nodeContent);
            progressBar.PerformStep();
            mList.FindForm().Refresh();
            Application.DoEvents();
              }

              File.WriteAllText(contentTextPath, allContent);
              xContent.Save(contentXmlPath);
              subItem.Text = "OK!";
              mList.FindForm().Refresh();
              Application.DoEvents();
            }

            subItem.Text = "Creating...";
            mList.FindForm().Refresh();
            Application.DoEvents();

            xContent.Load(contentXmlPath);
            progressBar.Value = 0;
            progressBar.Maximum = xContent.DocumentElement.SelectNodes("td").Count;
            XmlNodeList cardListNodes = xCardList.DocumentElement.SelectNodes("card");
            XmlNodeList contentNodes = xContent.DocumentElement.SelectNodes("td");
            for(int i = 0; i < cardListNodes.Count; i++)
            {
              SpoilerReader spoilerReader = new SpoilerReader(cardListNodes[i].SelectSingleNode("@name").InnerText,
            cardListNodes[i].SelectSingleNode("@color").InnerText);
              spoilerReader.CreateCardNode(contentNodes[i], xCards, xCardsLang, setCode, setDate, i + 1);
              progressBar.PerformStep();
              mList.FindForm().Refresh();
              Application.DoEvents();
            }
            subItem.Text = "OK!";
            mList.FindForm().Refresh();
            Application.DoEvents();

            xCards.Save(cardsPath);
            xCardsLang.Save(cardsLangPath);
              }
        }
Beispiel #4
0
 /// <summary>
 /// Returns a ImageListHelper created based on a VB6 ImageList (name).
 /// </summary>
 /// <param name="lView">The ListView is used to get access to 
 /// the original VB6 ImageList based on its name.</param>
 /// <param name="VB6ImageListName">The name of the VB6 Image List.</param>
 /// <param name="onDesignMode">Is Design Mode?</param>
 /// <returns>An instance of a ImageListHelper.</returns>
 private static ImageListHelper GetImageListHelper(ListView lView, string VB6ImageListName, bool onDesignMode)
 {
     ImageListHelper imgHelper = new ImageListHelper();
     Form parentForm = lView.FindForm();
     if (parentForm != null)
     {
         object imlControl = ContainerHelper.Controls(parentForm)[VB6ImageListName];
         if (imlControl != null)
         {
             imgHelper.LoadVB6ImageList(imlControl);
         }
         else
         {
             if (!onDesignMode)
             {
                 Type type = parentForm.GetType();
                 FieldInfo finfo = type.GetField(VB6ImageListName);
                 if (finfo != null)
                 {
                     object field_value = finfo.GetValue(parentForm);
                     imgHelper.NETImageList = field_value as ImageList;
                 }
             }
         }
     }
     return imgHelper;
 }