コード例 #1
0
        private void bindEvent()
        {
            //Save Relationship
            btnSaveConvert.Click += (sender, e) => XmlControl.WriteXml(dgvDataTables, dgvColumns);

            this.btnGeneWord.Click += (sender, e) => WordControl.Generate(this.dgvDataTables, this.rbPascal.Checked, dbType);

            #region Display DataGridView Line Number

            dgvColumns.RowPostPaint += (sender, e) =>
            {
                var rectangle = new Rectangle(e.RowBounds.Location.X,
                                              e.RowBounds.Location.Y,
                                              dgvColumns.RowHeadersWidth - 4,
                                              e.RowBounds.Height);

                TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
                                      dgvColumns.RowHeadersDefaultCellStyle.Font,
                                      rectangle,
                                      dgvColumns.RowHeadersDefaultCellStyle.ForeColor,
                                      TextFormatFlags.VerticalCenter |
                                      TextFormatFlags.Right);
            };

            dgvDataTables.RowPostPaint += (sender, e) =>
            {
                var rectangle = new Rectangle(e.RowBounds.Location.X,
                                              e.RowBounds.Location.Y,
                                              dgvDataTables.RowHeadersWidth - 4,
                                              e.RowBounds.Height);

                TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
                                      dgvDataTables.RowHeadersDefaultCellStyle.Font,
                                      rectangle,
                                      dgvDataTables.RowHeadersDefaultCellStyle.ForeColor,
                                      TextFormatFlags.VerticalCenter |
                                      TextFormatFlags.Right);
            };

            #endregion
        }
コード例 #2
0
ファイル: Word.cs プロジェクト: kilof17/WordApp
        public List <WordControl> GetContorlsFromTemplate(object templatePath)
        {
            List <WordControl> controls = new List <WordControl>();

            RunWord(templatePath); // may demand type casting (object)file.FilePath
            foreach (wordInt.ContentControl cc in myDoc.ContentControls)
            {
                if (cc.Type != 0 && cc.Title != null)// is not the selected text
                {
                    WordControl control = new WordControl()
                    {
                        Control_ID = cc.ID,
                        Title      = cc.Title,
                        Tag        = cc.Tag,
                        Type       = (int)cc.Type,
                        Text       = "",
                        Multiline  = cc.MultiLine,
                        Checked    = false
                    };

                    if (control.Tag == null)
                    {
                        control.Tag = "empty";
                    }                           //tag can not be empty, becaouse it is couses errors

                    if ((int)cc.Type == 3 || (int)cc.Type == 4)
                    {
                        control.Dropdown = new List <string>();

                        for (int i = 2; i <= cc.DropdownListEntries.Count; i++)  // index counted from 1. Start from 2 to skip tag "Select item"
                        {
                            control.Dropdown.Add(cc.DropdownListEntries[i].Text.ToString());
                        }
                    }
                    controls.Add(control);
                }
            }
            Close();
            return(controls);
        }
コード例 #3
0
        public ActionResult CreateToWord(Word word, int productId, WordControl control)
        {
            int sayfaNumarasi = 0;
            int sayfadakiSira = 0;
            int genelSiralama = 0;

            string urunlink = string.Empty;

            using (var dbc = new SortingFinderContext())
            {
                urunlink = dbc.Products.SingleOrDefault(m => m.Id == productId).Url;
            }

            HtmlAgilityPack.HtmlDocument doc = new HtmlWeb().Load(urunlink);
            string categoryLinkOfProduct     = doc.DocumentNode.SelectSingleNode("//*[@id='breadCrumb']/ul/li[3]/a").GetAttributeValue("href", string.Empty);

            HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlWeb().Load(categoryLinkOfProduct);


            string[] pages = new string[10];

            for (int i = 1; i < 11; i++)
            {
                try
                {
                    pages[i - 1] = htmlDocument.DocumentNode.SelectSingleNode("//*[@class='pagination']/a[" + i + "]").GetAttributeValue("href", string.Empty);
                }
                catch (NullReferenceException)
                {
                    continue;
                }
            }

            string klm = string.Empty;

            HtmlAgilityPack.HtmlDocument sayfaNumarasıLink;
            for (int x = 1; x <= pages.Length; x++)
            {
                try
                {
                    sayfaNumarasıLink = new HtmlWeb().Load(pages[x - 1]);
                }
                catch (ArgumentNullException)
                {
                    continue;
                }


                for (int li = 1; li <= 28; li++)
                {
                    try
                    {
                        klm = sayfaNumarasıLink.DocumentNode.SelectSingleNode("//*[@id='view']/ul/li[" + li + "]/div/div[1]/a/h3").InnerText;
                    }
                    catch (NullReferenceException)
                    {
                        continue;
                    }


                    using (var con = new SortingFinderContext())
                    {
                        control.WordComeFromSite = klm;
                        con.WordControls.Add(control);
                        con.SaveChanges();
                    }

                    bool VarMi;
                    using (var connec = new SortingFinderContext())
                    {
                        VarMi = connec.WordControls.Any(m => m.WordComeFromSite.Contains(word.TheWord));
                    }

                    if (VarMi)
                    {
                        sayfaNumarasi = x;
                        sayfadakiSira = li;
                        genelSiralama = ((x - 1) * 28) + li;


                        using (var dbCon = new SortingFinderContext())
                        {
                            var wordEntry = dbCon.Entry(control);
                            wordEntry.State = EntityState.Deleted;
                            dbCon.SaveChanges();
                        }

                        goto atla;
                    }

                    using (var dbCon = new SortingFinderContext())
                    {
                        var wordEntry = dbCon.Entry(control);
                        wordEntry.State = EntityState.Deleted;
                        dbCon.SaveChanges();
                    }

                    //    char[] sitedenGelenKelime = new char[klm.Length];
                    //        char[] KullanıcınınGirdigi = new char[word.TheWord.Length];

                    //        for (int c = 0; c < sitedenGelenKelime.Length; c++)
                    //        {
                    //            sitedenGelenKelime[c] = klm[c];
                    //        }
                    //        for (int d = 0; d < KullanıcınınGirdigi.Length; d++)
                    //        {
                    //            KullanıcınınGirdigi[d] = word.TheWord[d];
                    //        }

                    //char[] kelime = new char[KullanıcınınGirdigi.Length];
                    //for (int e = 0; e < sitedenGelenKelime.Length; e = e + KullanıcınınGirdigi.Length)
                    //{
                    //    for (int f = 0; f < KullanıcınınGirdigi.Length; f++)
                    //    {
                    //        if (KullanıcınınGirdigi[f] == sitedenGelenKelime[e])
                    //        {
                    //            kelime[f] = sitedenGelenKelime[e];
                    //        }

                    //    }
                    //}


                    //int kıyaslamaSayisi=0;
                    //for(int j = 0; j < KullanıcınınGirdigi.Length; j++)
                    //{
                    //   if (kelime[j] == KullanıcınınGirdigi[j])
                    //    {
                    //        kıyaslamaSayisi++;
                    //    }
                    //}
                    //            if (kıyaslamaSayisi==kelime.Length)
                    //            {
                    //                sayfaNumarasi = x;
                    //                sayfadakiSira = li;
                    //                genelSiralama = ((x - 1) * 28) + li;

                    //                goto atla;

                    //            }
                }
            }


            atla :    using (var db = new SortingFinderContext())
            {
                int kelimeSayisi = db.Words.Count();


                if (kelimeSayisi < 50)
                {
                    word.ProductId   = productId;
                    word.AddingTime  = DateTime.Now;
                    word.Page        = sayfaNumarasi;
                    word.SortOfPage  = sayfadakiSira;
                    word.GeneralSort = genelSiralama;

                    db.Words.Add(word);
                    db.SaveChanges();
                }
                else
                {
                    TempData["kelimeSınırı"] = "50'den fazla kelime giremezsiniz";
                }
            }
            return(RedirectToAction("Index"));
        }
コード例 #4
0
        private void SetResource(string filePath, bool loadWithTypeNone = false)
        {
            var typeInfo = FileType.GetFileViewType(filePath);

            if (loadWithTypeNone)
            {
                typeInfo.Type = FileViewType.None;
            }
            if (lastViewType != typeInfo.Type || MyGrid.Children[0] is HelloControl)
            {
                lastViewType = typeInfo.Type;
                MyGrid.Children.Clear();
            }
            else if (MyGrid.Children.Count == 1)
            {
                (MyGrid.Children[0] as FileControl).OnFileChanged((filePath, typeInfo.Ext));
                return;
            }
            FileControl fc;

            switch (typeInfo.Type)
            {
            case FileViewType.Image:
                fc = new ImageControl();
                GlobalNotify.OnResizeMode(true);
                break;

            case FileViewType.Code:
            case FileViewType.Txt:
                fc = new TextControl();
                GlobalNotify.OnResizeMode(true);
                break;

            case FileViewType.Music:
                fc = new MusicControl();
                GlobalNotify.OnResizeMode(false);
                break;

            case FileViewType.Video:
                fc = new VideoControl();
                GlobalNotify.OnResizeMode(true);
                break;

            case FileViewType.Pdf:
                fc = new PdfControl();
                GlobalNotify.OnResizeMode(true);
                break;

            case FileViewType.Excel:
                fc = new ExcelControl();
                GlobalNotify.OnResizeMode(true);
                break;

            case FileViewType.Word:
                fc = new WordControl();
                GlobalNotify.OnResizeMode(true);
                break;

            case FileViewType.PowerPoint:
                fc = new PowerPointControl();
                GlobalNotify.OnResizeMode(true);
                break;

            default:
                fc = new CommonControl();
                GlobalNotify.OnResizeMode(false);
                break;
            }
            if (fc != null)
            {
                LoadFile(fc, filePath, typeInfo.Ext);
            }
        }