Exemplo n.º 1
0
        public void ParseEndpoint(Endpoint endpoint)
        {
            AddTitle(endpoint);
            AddUrl(endpoint);
            AddDescription(endpoint);

            if (endpoint.Headers.Count > 0)
            {
                ParseHeaders(endpoint.Headers);
            }

            if (endpoint.QueryParams.Count > 0)
            {
                ParseQueryParams(endpoint.QueryParams);
            }

            if (endpoint.Body.Count > 0)
            {
                Styler.SetBodyTitleStyle(Document.InsertParagraph("Body [" + endpoint.BodyMode + "]"));
                ParseBody(endpoint.BodyMode, endpoint.Body);
            }

            //generate CURL example
            GenerateCurlExampleRequest(endpoint);

            if (endpoint.Response.Count > 0)
            {
                Styler.SetResponseTitleStyle(Document.InsertParagraph("Responses"));
                ParseResponse(endpoint.Response);
            }
        }
Exemplo n.º 2
0
 public Expanded(double[,] collection, Styler styler)
     : this()
 {
     Styler         = styler;
     CollectionList = collection;
     createRowCol(collection);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a style classification to the StyleSheet.
        /// </summary>
        /// <param name="target">The string to be styled.</param>
        /// <param name="color">The color to be applied to the target.</param>
        public void AddStyle(string target, Color color)
        {
            Styler.MatchFound handler = (s, l, m) => m;
            Styler styler = new Styler(target, color, handler);

            Styles.Add(styler);
        }
Exemplo n.º 4
0
        public void AddTitle(Endpoint endpoint)
        {
            Paragraph p = Document.InsertParagraph();

            Styler.SetMethodStyle(p.Append(endpoint.Method), endpoint.Method);
            Styler.SetEndpointTitleStyle(p.Append(" " + endpoint.Title));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds a style classification to the StyleSheet.
        /// </summary>
        /// <param name="target">The string to be styled.</param>
        /// <param name="color">The color to be applied to the target.</param>
        /// <param name="matchHandler">A delegate instance which describes a simpler transformation that
        /// can be applied to the target.</param>
        public void AddStyle(string target, Color color, Styler.MatchFoundLite matchHandler)
        {
            Styler.MatchFound wrapper = (s, l, m) => matchHandler.Invoke(m);
            Styler styler = new Styler(target, color, wrapper);

            Styles.Add(styler);
        }
Exemplo n.º 6
0
        private void CariListesi_Load(object sender, EventArgs e)
        {
            try
            {
                DataTable cariList = new DataTable();
                sqlCmd     = new SqlCommand("SELECT CARI_INCKEY, CARI_KOD, TC_NO, ADSOYAD, IL, ILCE, ADRES, TICARI_UNVAN, VERGI_DAIRE, VERGI_NO, TEL_NO, EPOSTA, CEP_TEL, FAX_NO, CARI_DURUM FROM CARI ORDER BY CARI_INCKEY DESC", Program.connection);
                sqlAdapter = new SqlDataAdapter(sqlCmd);
                sqlAdapter.Fill(cariList);

                typeof(DataGridView).InvokeMember(
                    "DoubleBuffered",
                    BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty,
                    null,
                    cariListesiGridView,
                    new object[] { true });

                cariListesiGridView.DataSource = cariList;
                Styler.gridViewCommonStyle(cariListesiGridView);

                cariListesiGridView.Columns[0].Visible = false;
            }catch (Exception ex)
            {
                Notification.messageBoxError(ex.Message);
            }
        }
Exemplo n.º 7
0
 public ContentList(int count, int item, Styler styler)
     : this()
 {
     Styler = styler;
     called(count, Styler.Lists[item]);
     Styler.windowState = WindowState.Minimized;
 }
Exemplo n.º 8
0
        private void TumKayitListe()
        {
            try
            {
                StokRaporTable     = new DataTable();
                sqlCmd             = new SqlCommand("dbo.Stok_Raporu", Program.connection);
                sqlCmd.CommandType = CommandType.StoredProcedure;
                sqlCmd.Parameters.AddWithValue("@STARTDATE", DBNull.Value);
                sqlCmd.Parameters.AddWithValue("@ENDDATE", DBNull.Value);
                sqlDataAdapter = new SqlDataAdapter(sqlCmd);
                sqlDataAdapter.Fill(StokRaporTable);

                Styler.gridViewCommonStyle(StokRaporuGridView);
                StokRaporuGridView.DataSource = StokRaporTable;

                typeof(DataGridView).InvokeMember(
                    "DoubleBuffered",
                    BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty,
                    null,
                    StokRaporuGridView,
                    new object[] { true });

                StokRaporuGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            }
            catch (Exception ex)
            {
                Notification.messageBoxError(ex.Message);
            }
        }
        private void btnTarihAraligi_Click(object sender, EventArgs e)
        {
            try
            {
                operatorRaporTable = new DataTable();
                sqlCmd             = new SqlCommand("dbo.Operator_Raporu", Program.connection);
                sqlCmd.CommandType = CommandType.StoredProcedure;
                sqlCmd.Parameters.AddWithValue("@STARTDATE", dtStartDate.Value);
                sqlCmd.Parameters.AddWithValue("@ENDDATE", dtEndDate.Value);
                sqlDataAdapter = new SqlDataAdapter(sqlCmd);
                sqlDataAdapter.Fill(operatorRaporTable);

                Styler.gridViewCommonStyle(OperatorRaporuGridView);
                OperatorRaporuGridView.DataSource = operatorRaporTable;

                typeof(DataGridView).InvokeMember(
                    "DoubleBuffered",
                    BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty,
                    null,
                    OperatorRaporuGridView,
                    new object[] { true });

                OperatorRaporuGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            }
            catch (Exception ex)
            {
                Notification.messageBoxError(ex.Message);
            }
        }
Exemplo n.º 10
0
        private void SiparisOlustur_Load(object sender, EventArgs e)
        {
            kaydetBttn.Enabled                     = false;
            siparisTipi.SelectedIndex              = 0;
            txtSiparisTarih.Text                   = DateTime.Now.ToString("dd.MM.yyyy");
            txtSiparisTeslimTarih.Text             = DateTime.Now.ToString("dd.MM.yyyy");
            siparisListesiGridView.ColumnCount     = 9;
            siparisListesiGridView.Columns[0].Name = "STOK_DEPO_INCKEY";
            siparisListesiGridView.Columns[1].Name = "STOK_INCKEY";
            siparisListesiGridView.Columns[2].Name = "STOK_KODU";
            siparisListesiGridView.Columns[3].Name = "STOK_ADI";
            siparisListesiGridView.Columns[4].Name = "DEPO";
            siparisListesiGridView.Columns[5].Name = "MIKTAR";
            siparisListesiGridView.Columns[6].Name = "BIRIM";
            siparisListesiGridView.Columns[7].Name = "BIRIM_FIYAT";
            siparisListesiGridView.Columns[8].Name = "TUTAR";

            siparisListesiGridView.Columns[0].Visible = false;
            siparisListesiGridView.Columns[1].Visible = false;

            Styler.gridViewCommonStyle(siparisListesiGridView);
            siparisListesiGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

            siparisListesiGridView.Rows.Clear();
            siparisListesiGridView.Refresh();
        }
Exemplo n.º 11
0
        public void StylizeTest_Latin_IncompletedOneStyle()
        {
            string textToBeStylized1 = "Confusing!q";
            string textToBeStylized2 = "You are GREAT";

            Assert.AreEqual("Cᵒⁿᶠᵘˢⁱⁿᵍ!q", Styler.Stylize(textToBeStylized1, UnicodeSets.LatinModifierUppercaseSet, UnicodeSets.LatinModifierLowercaseSet));
            Assert.AreEqual("𐌖ou are GR𐌄𐌀𐌕", Styler.Stylize(textToBeStylized2, UnicodeSets.LatinOldItalicUppercaseSet));
        }
Exemplo n.º 12
0
        public void BaseStyling()
        {
            Styler.SetTextColor(UsernameTextField, Colors.mainFontColor);
            Styler.SetTextColor(PasswordTextField, Colors.mainFontColor);
            Styler.SetTextColor(ErrorLabel, UIColor.Red);

            Styler.SetShadows(LoginButton, UIColor.Black, 2, 3, 3f);
        }
Exemplo n.º 13
0
        private void frmNotification_Load(object sender, System.EventArgs e)
        {
            Styler.Start();
            var player = new SoundPlayer(Resources.iPhone_tone);

            player.Play();
            ClosingTimer.Start();
        }
Exemplo n.º 14
0
        public void StylizeTest_Latin_OneStyle()
        {
            string textToBeStylized1 = "Style me!";
            string textToBeStylized2 = "/*- Holy sxxt I gotta go -*/";

            Assert.AreEqual("𝐒𝐭𝐲𝐥𝐞 𝐦𝐞!", Styler.Stylize(textToBeStylized1, UnicodeSets.LatinBoldUppercaseSet, UnicodeSets.LatinBoldLowercaseSet));
            Assert.AreEqual("/*- ℌ𝔬𝔩𝔶 𝔰𝔵𝔵𝔱 ℑ 𝔤𝔬𝔱𝔱𝔞 𝔤𝔬 -*/", Styler.Stylize(textToBeStylized2, UnicodeSets.LatinFrakturUppercaseSet, UnicodeSets.LatinFrakturLowercaseSet));
        }
Exemplo n.º 15
0
        public void StylizeTest_Latin_WithFallbackStyle()
        {
            string textToBeStylized1 = "Without You";
            string textToBeStylized2 = "See You Again";

            Assert.AreEqual("ᵂⁱᵗʰᵒᵘᵗ 𝚈ᵒᵘ", Styler.Stylize(textToBeStylized1, UnicodeSets.LatinModifierUppercaseSet, UnicodeSets.LatinModifierLowercaseSet, UnicodeSets.LatinMonospaceUppercaseSet, UnicodeSets.LatinMonospaceLowercaseSet));
            Assert.AreEqual("🄢ₑₑ 🄨ₒᵤ 🄐⒢ₐᵢₙ", Styler.Stylize(textToBeStylized2, UnicodeSets.LatinSubscriptLowercaseSet, UnicodeSets.LatinParenthesizedUppercaseSet, UnicodeSets.LatinParenthesizedLowercaseSet));
        }
Exemplo n.º 16
0
        public void StylizeTest_Number_OneStyle()
        {
            string textToBeStylized1 = "00039039000";
            string textToBeStylized2 = "95423165877";

            Assert.AreEqual("00039039000", Styler.Stylize(textToBeStylized1, UnicodeSets.NumberFullWidthSet));
            Assert.AreEqual("𝟵𝟱𝟰𝟮𝟯𝟭𝟲𝟱𝟴𝟳𝟳", Styler.Stylize(textToBeStylized2, UnicodeSets.NumberSansSerifBoldSet));
        }
Exemplo n.º 17
0
        public void StylizeTest_Specials()
        {
            string textNull  = null;
            string textEmpty = "";

            Assert.IsNull(Styler.Stylize(textNull, UnicodeSets.LatinBoldUppercaseSet));
            Assert.AreEqual(textEmpty, Styler.Stylize(textEmpty, UnicodeSets.LatinItalicUppercaseSet));
        }
Exemplo n.º 18
0
        public void OneTimeTearDown()
        {
            Task.WaitAll(
                Task.Run(() => WebDriver.Close()),
                Task.Run(() => WebServer.AfterTests()));

            Styler.Set(new EmptyStyle());
        }
Exemplo n.º 19
0
 public ContentList(int m, int n, int item, Styler styler)
     : this()
 {
     Styler           = styler;
     TempMatListValue = new double[m, n];
     Mat(m, n, Styler.MatList[item]);
     Styler.windowState = WindowState.Minimized;
 }
Exemplo n.º 20
0
        public void AddUrl(Endpoint endpoint)
        {
            Table table = (Table)AddTable(1, 1);

            table.Rows[0].Cells[0].Paragraphs[0].Append(endpoint.Url);
            Styler.SetTableStyle(table);
            Document.InsertParagraph("").InsertTableAfterSelf(table);
        }
        public void TestMarkupExtensionHandling()
        {
            string testInput = MethodBase.GetCurrentMethod().Name + ".xaml";

            Styler styler = new Styler();
            styler.Options.FormatMarkupExtension = true;

            DoTest(testInput, styler);
        }
Exemplo n.º 22
0
        public void BaseStyling()
        {
            Styler.SetTextColor(ErrorLabel, UIColor.Red);
            Styler.SetBorderRadius(AddImageButton, 20f);
            Styler.SetShadows(AddImageButton, UIColor.Black, 2, 3, 2f);
            Styler.SetTextColor(AddImageButton, UIColor.Clear);

            Styler.SetShadows(RegisterButton, UIColor.Black, 2, 3, 3f);
        }
Exemplo n.º 23
0
 private void StokDepoListesi_Load(object sender, EventArgs e)
 {
     cellsOfSelectedItem = stokListesi.getSelectedItem().Item2;
     txtStokKod.Text     = cellsOfSelectedItem[1].Value.ToString();
     txtStokAdi.Text     = cellsOfSelectedItem[2].Value.ToString();
     txtStokBirim.Text   = cellsOfSelectedItem[3].Value.ToString();
     Styler.gridViewCommonStyle(stokDepoListGridView);
     listStokDepo();
 }
Exemplo n.º 24
0
        public void NormalizeTest_NumberOnly_MultiStylesPerText()
        {
            string testText1 = "𝟣𝟤𝟥𝟰𝟱𝟲𝟟𝟠𝟡𝟘";
            string testText2 = "𝟼𝟼𝟺𝟼𝟻𝟾𝟸𝟹𝟹𝟺𝟻𝟾𝟼𝟿𝟽𝟻⑼⑼⑷⑵⑴₃₅₇₈₉₉₅⑻⑸⑵⑵⑴⑷⑵⑸";
            string testText3 = "011202354456𝟫𝟨𝟦𝟪𝟩𝟧𝟤𝟣𝟢𝟠𝟞𝟡𝟟𝟝𝟙𝟚𝟜𝟠𝟞𝟛𝟚𝟛𝟝";

            Assert.AreEqual("1234567890", Styler.Unstylize(testText1), false);
            Assert.AreEqual("664658233458697599421357899585221425", Styler.Unstylize(testText2), false);
            Assert.AreEqual("01120235445696487521086975124863235", Styler.Unstylize(testText3), false);
        }
Exemplo n.º 25
0
        public void NormalizeTest_OneStylePerText_MixWithSpecialCharacters()
        {
            string testText1 = "𝐔𝐧𝐝𝐞𝐫 𝐭𝐡𝐞 𝐭𝐫𝐞𝐞 𝐰𝐡𝐞𝐫𝐞 𝐭𝐡𝐞 𝐠𝐫𝐚𝐬𝐬 𝐝𝐨𝐧'𝐭 𝐠𝐫𝐨𝐰 @@@@##$%!*";
            string testText2 = "𝑊𝑎𝑡𝑎𝑠ℎ𝑖, 𝐾𝑖 𝑛𝑖 𝑁𝑎𝑟𝑖𝑚𝑎𝑠𝑢! -/**\\|\\()";
            string testText3 = "𝒮𝒸ℴℴ𝓉ℯ𝓇 𝒷𝓇ℴ𝓉𝒽ℯ𝓇𝓈! 𝒮𝒞𝒪𝒪𝒯ℰℛ ℬℛ𝒪𝒯ℋℰℛ𝒮!!! ##^&**%!(**)";

            Assert.AreEqual("Under the tree where the grass don't grow @@@@##$%!*", Styler.Unstylize(testText1), false);
            Assert.AreEqual("Watashi, Ki ni Narimasu! -/**\\|\\()", Styler.Unstylize(testText2), false);
            Assert.AreEqual("Scooter brothers! SCOOTER BROTHERS!!! ##^&**%!(**)", Styler.Unstylize(testText3), false);
        }
Exemplo n.º 26
0
        public void NormalizeTest_NumberOnly_OneStylePerText()
        {
            string testText1 = "𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗𝟎";
            string testText2 = "③⑥②③①⑥④⑧⑨④⑥⑤①⑤③①③②①①⑥①⑥⑤⓪①⑥⑧④⑥④⑧⑨⑨⑤⑦⑨⑧⑤②③⓪";
            string testText3 = "❾❾❽❾❺❻❶❻❺❶❺❷⓿⓿❶❹❻❹❽❼❹❽❾❾❺❻❷❸⓿❶❺❹❻❹❽❾";

            Assert.AreEqual("1234567890", Styler.Unstylize(testText1), false);
            Assert.AreEqual("362316489465153132116165016846489957985230", Styler.Unstylize(testText2), false);
            Assert.AreEqual("998956165152001464874899562301546489", Styler.Unstylize(testText3), false);
        }
Exemplo n.º 27
0
        public void NormalizeTest_MixAllTogether()
        {
            string testText1 = "𝖶𝖾 𝖺𝗋𝖾 𝗒𝗈𝗎𝗇𝗀. 𝖾𝗏𝖾𝗇 𝗂𝖿 𝗒𝗈𝗎 𝖺𝗋𝖾 𝟣𝟢𝗌, 𝟤𝟢𝗌, 𝟧𝟢𝗌, 𝖺𝗇𝖽 𝟣𝟢𝟢𝗌!";
            string testText2 = "𝚃𝚑𝚎 𝙧𝙖𝙙𝙞𝙪𝙨 𝙤𝙛 𝙩𝙝𝙚 𝙀𝙖𝙧𝙩𝙝 𝚒𝚜 𝚊𝚋𝚘𝚞𝚝 𝟼,𝟹𝟽𝟷𝚔𝚖.";
            string testText3 = "🄘⒯ ⒲⒤⒧⒧ ⒯⒜⒦⒠ ⒜⒝⒪⒰⒯ 𝟞𝟜 𝕙𝕠𝕦𝕣𝕤 ⒝⒴ ⒜ ⒞⒜⒭ ⒜⒯ ①⓪⓪ⓚⓜ/ⓗ.";

            Assert.AreEqual("We are young. even if you are 10s, 20s, 50s, and 100s!", Styler.Unstylize(testText1), false);
            Assert.AreEqual("The radius of the Earth is about 6,371km.", Styler.Unstylize(testText2), false);
            Assert.AreEqual("It will take about 64 hours by a car at 100km/h.", Styler.Unstylize(testText3), false);
        }
Exemplo n.º 28
0
        public void NormalizeTest_MultiStylesPerText()
        {
            string testText1 = "Ⓗⓔⓐⓡⓣⓐⓒⓗⓔ, 𝗁𝖾𝖺𝗋𝗍𝖻𝗋𝖾𝖺𝗄, ᵃˡˡ ᵒᵛᵉʳ ᵗᵒʷⁿ";
            string testText2 = "𝗯𝘂𝘁 𝘀𝗼𝗺𝗲𝘁𝗵𝗶𝗻𝗴 𝘧𝘭𝘪𝘱𝘱𝘦𝘥 𝘭𝘪𝘬𝘦 𝚊 𝚜𝚠𝚒𝚝𝚌𝚑";
            string testText3 = "𝙬𝙝𝙚𝙣 𝙮𝙤𝙪 came ar𝖔𝖚𝓷𝓭";

            Assert.AreEqual("Heartache, heartbreak, all over town", Styler.Unstylize(testText1), false);
            Assert.AreEqual("but something flipped like a switch", Styler.Unstylize(testText2), false);
            Assert.AreEqual("when you came around", Styler.Unstylize(testText3), false);
        }
Exemplo n.º 29
0
        private void KullaniciListeleDuzenle_Load(object sender, EventArgs e)
        {
            Styler.gridViewCommonStyle(kullaniciListesiGridView);
            cbGrupKey.DataSource    = KullaniciOlustur.getGrupDataTableForBindToComboBox();
            cbGrupKey.DisplayMember = "GRUP_ADI";
            cbGrupKey.ValueMember   = "GRUP_INCKEY";
            listKullanici();

            cbGrupKey.SelectedIndex = 0;
        }
Exemplo n.º 30
0
        public void NormalizeTest_OneStylePerText()
        {
            string testText1 = "𝐘𝐨𝐮 𝐚𝐫𝐞 𝐦𝐲 𝐒𝐇𝐘 𝐁𝐎𝐘";
            string testText2 = "𝔸𝕝𝕝 𝕀 𝕎𝕒𝕟𝕥 𝔽𝕠𝕣 ℂ𝕙𝕣𝕚𝕤𝕥𝕞𝕒𝕤 𝕀𝕤 𝔾𝕆𝔻𝔻𝔸𝕄ℕ 𝕄𝕆ℕ𝔼𝕐";
            string testText3 = "ℌ𝔢𝔶 𝔟𝔯𝔬 ℑ 𝔤𝔬𝔱𝔱𝔞 𝔪𝔬𝔳𝔢 𝔬𝔫";
            string testText4 = "🇹🇭🇪 🇶🇺🇮🇨🇰 🇧🇷🇴🇼🇳 🇫🇴🇽 🇯🇺🇲🇵🇸 🇴🇻🇪🇷 🇹🇭🇪 🇱🇦🇿🇾 🇩🇴🇬";

            Assert.AreEqual("You are my SHY BOY", Styler.Unstylize(testText1), false);
            Assert.AreEqual("All I Want For Christmas Is GODDAMN MONEY", Styler.Unstylize(testText2), false);
            Assert.AreEqual("Hey bro I gotta move on", Styler.Unstylize(testText3), false);
            Assert.AreEqual("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG", Styler.Unstylize(testText4), false);
        }
Exemplo n.º 31
0
        public void NormalizeTest_ContainingCJKChars()
        {
            string testText1 = "이젠 𝐒𝐞𝐚로 떠날거에요";
            string testText2 = "거미로 𝚆𝚎𝚋 쳐서 🄕⒤⒮⒣ 잡으러";
            string testText3 = "そう ℍ𝕒𝕟𝕕 𝕚𝕟 ℍ𝕒𝕟𝕕 君のその手は";
            string testText4 = "知らない誰かのℋ𝒶𝓃𝒹を";

            Assert.AreEqual("이젠 Sea로 떠날거에요", Styler.Unstylize(testText1), false);
            Assert.AreEqual("거미로 Web 쳐서 Fish 잡으러", Styler.Unstylize(testText2), false);
            Assert.AreEqual("そう Hand in Hand 君のその手は", Styler.Unstylize(testText3), false);
            Assert.AreEqual("知らない誰かのHandを", Styler.Unstylize(testText4), false);
        }
        public void TestAttributeThresholdHandling()
        {
            string testInput = MethodBase.GetCurrentMethod().Name + ".xaml";

            Styler styler = new Styler();
            styler.Options.AttributesTolerance = 0;
            styler.Options.MaxAttributeCharatersPerLine = 80;
            styler.Options.MaxAttributesPerLine = 3;
            styler.Options.PutEndingBracketOnNewLine = true;

            DoTest(testInput, styler);
        }
Exemplo n.º 33
0
 public Others(Styler styler, Mode solve)
     : this()
 {
     Styler             = styler;
     Solve              = solve;
     Styler.ItemSources = new ObservableCollection <ObservableCollection <string> >()
     {
         _angle, _area, _base, _energy, _length, _power, _pressure, _temperature, _time, _velocity, _volume, _weight
     };
     Styler.ItemSource  = _angle;
     from.SelectedIndex = 0;
     to.SelectedIndex   = 0;
 }
Exemplo n.º 34
0
 public void ParseResponse(List <Response> responses)
 {
     foreach (Response response in responses)
     {
         Styler.SetResponseNameStyle(Document.InsertParagraph(response.Name + " [" + response.Status + "]"));
         Document.InsertParagraph("");
         Document.InsertParagraph("Response Status Code: " + response.StatusCode);
         Table table = (Table)AddTable(1, 1);
         table.Rows[0].Cells[0].Paragraphs[0].Append(response.Body);
         Styler.SetTableStyle(table, Styler.Table1Row);
         Document.InsertParagraph("").InsertTableAfterSelf(table);
     }
 }
        public void TestAttributeSortingOptionHandling()
        {
            string testInput = MethodBase.GetCurrentMethod().Name + ".xaml";

            Styler styler = new Styler();
            styler.Options.AttributeOrderClass = "x:Class";
            styler.Options.AttributeOrderWpfNamespace = "xmlns, xmlns:x";
            styler.Options.AttributeOrderKey = "Key, x:Key";
            styler.Options.AttributeOrderName = "Name, x:Name, Title";
            styler.Options.AttributeOrderAttachedLayout = "Grid.Column, Grid.ColumnSpan, Grid.Row, Grid.RowSpan, Canvas.Right, Canvas.Bottom, Canvas.Left, Canvas.Top";
            styler.Options.AttributeOrderCoreLayout = "MinWidth, MinHeight, Width, Height, MaxWidth, MaxHeight, Margin";
            styler.Options.AttributeOrderAlignmentLayout = "Panel.ZIndex, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment";
            styler.Options.AttributeOrderOthers = "Offset, Color, TargetName, Property, Value, StartPoint, EndPoint, PageSource, PageIndex";
            styler.Options.AttributeOrderBlendRelated = "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText";

            DoTest(testInput, styler);
        }
        private void DoTest(string testInput, Styler styler)
        {
            string actualOutputFile = testInput.Replace(".xaml", "_output.xaml");
            string expectedOutputFile = testInput.Replace(".xaml", "_output_expected.xaml");

            string output = styler.FormatFile(testInput);

            File.WriteAllText(actualOutputFile, output);

            Assert.IsTrue(this.FileCompare(actualOutputFile, expectedOutputFile));
        }
        /// <summary>
        /// Beautifies a document.
        /// </summary>
        /// <param name="document">The document to beautify.</param>
        private void BeautifyDocument(Document document)
        {
            if (!IsFormattableDocument(document))
            {
                return;
            }

            var xamlEditorProps = DTE.get_Properties("TextEditor", "XAML");
            var insertTabs = (bool)xamlEditorProps.Item("InsertTabs").Value;

            var styler = new Styler()
            {
                IndentCharacter = insertTabs ? '\t' : ' ',
                IndentSize = Int32.Parse(xamlEditorProps.Item("IndentSize").Value.ToString()),
                Options = StylerOptions
            };

            var textDocument = document.Object("TextDocument") as TextDocument;

            var currentPoint = textDocument.Selection.ActivePoint;
            int originalLine = currentPoint.Line;
            int originalOffset = currentPoint.LineCharOffset;

            var startPoint = textDocument.StartPoint.CreateEditPoint();
            var endPoint = textDocument.EndPoint.CreateEditPoint();

            var xamlSource = styler.Format(startPoint.GetText(endPoint));

            startPoint.ReplaceText(endPoint, xamlSource, 0);

            if (originalLine <= textDocument.EndPoint.Line)
                textDocument.Selection.MoveToLineAndOffset(originalLine, originalOffset, false);
            else
                textDocument.Selection.GotoLine(textDocument.EndPoint.Line);
        }
Exemplo n.º 38
0
        /// <summary>
        /// Adds a style classification to the StyleSheet.
        /// </summary>
        /// <param name="target">The string to be styled.</param>
        /// <param name="color">The color to be applied to the target.</param>
        /// <param name="matchHandler">A delegate instance which describes a transformation that
        /// can be applied to the target.</param>
        public void AddStyle(string target, Color color, Styler.MatchFound matchHandler)
        {
            Styler styler = new Styler(target, color, matchHandler);

            Styles.Add(styler);
        }