Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is there an issue with this script? Pin
Eddy Vluggen13-Dec-12 6:43
professionalEddy Vluggen13-Dec-12 6:43 
Questionстрана говна Pin
WebMaster12-Dec-12 22:00
WebMaster12-Dec-12 22:00 
AnswerRe: страна говна Pin
Pete O'Hanlon12-Dec-12 22:41
mvePete O'Hanlon12-Dec-12 22:41 
GeneralRe: страна говна Pin
Killzone DeathMan12-Dec-12 23:30
Killzone DeathMan12-Dec-12 23:30 
GeneralRe: страна говна Pin
Richard MacCutchan13-Dec-12 2:50
mveRichard MacCutchan13-Dec-12 2:50 
AnswerRe: страна говна Pin
Keith Barrow13-Dec-12 0:40
professionalKeith Barrow13-Dec-12 0:40 
GeneralRe: страна говна Pin
Richard Deeming13-Dec-12 1:24
mveRichard Deeming13-Dec-12 1:24 
QuestionHOW TO WRITE IN CONNECTION captcha XML?? Pin
WebMaster12-Dec-12 21:23
WebMaster12-Dec-12 21:23 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;

namespace centersborki.page.c
{
    /// <summary>
    /// Summary description for CaptchaImage.
    /// </summary>
    public class CaptchaImage
    {
        // Общественный свойств (все только для чтения)..
        public string Text
        {
            get { return this.text; }
        }
        public Bitmap Image
        {
            get { return this.image; }
        }
        public int Width
        {
            get { return this.width; }
        }
        public int Height
        {
            get { return this.height; }
        }

        // Внутренние свойства.
        private string text;
        private int width;
        private int height;
        private string familyName;
        private Bitmap image;

        // For generating random numbers.
        private Random random = new Random();

        // ====================================================================
        // Инициализация нового экземпляра класса CaptchaImage помощью
        // Заданный текст, ширину и высоту.
        // ====================================================================
        public CaptchaImage(string s , int width , int height)
        {
            this.text = s;
            this.SetDimensions(width , height);
            this.GenerateImage();
        }

        // ====================================================================
        // Initializes a new instance of the CaptchaImage class using the
        // specified text, width, height and font family.
        // ====================================================================
        public CaptchaImage(string s , int width , int height , string familyName)
        {
            this.text = s;
            this.SetDimensions(width , height);
            this.SetFamilyName(familyName);
            this.GenerateImage();
        }

        // ====================================================================
        // This member overrides Object.Finalize.
        // ====================================================================
        ~CaptchaImage()
        {
            Dispose(false);
        }

        // ====================================================================
        // Releases all resources used by this object.
        // ====================================================================
        public void Dispose()
        {
            GC.SuppressFinalize(this);
            this.Dispose(true);
        }

        // ====================================================================
        // Custom Dispose method to clean up unmanaged resources.
        // ====================================================================
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
                // Dispose of the bitmap.
                this.image.Dispose();
        }

        // ====================================================================
        // Sets the image width and height.
        // ====================================================================
        private void SetDimensions(int width , int height)
        {
            // Check the width and height.
            if (width <= 0)
                throw new ArgumentOutOfRangeException("width" , width , "Argument out of range, must be greater than zero.");
            if (height <= 0)
                throw new ArgumentOutOfRangeException("height" , height , "Argument out of range, must be greater than zero.");
            this.width = width;
            this.height = height;
        }

        // ====================================================================
        // Sets the font used for the image text.
        // ====================================================================
        private void SetFamilyName(string familyName)
        {
            // If the named font is not installed, default to a system font.
            try
            {
                Font font = new Font(this.familyName , 12F);
                this.familyName = familyName;
                font.Dispose();
            }
            catch (Exception ex)
            {
                this.familyName = System.Drawing.FontFamily.GenericSerif.Name;
            }
        }

        // ====================================================================
        // Creates the bitmap image.
        // ====================================================================
        private void GenerateImage()
        {
            // Create a new 32-bit bitmap image.
            Bitmap bitmap = new Bitmap(this.width , this.height , PixelFormat.Format32bppArgb);

            // Create a graphics object for drawing.
            Graphics g = Graphics.FromImage(bitmap);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            Rectangle rect = new Rectangle(0 , 0 , this.width , this.height);

            // Fill in the background.
            HatchBrush hatchBrush = new HatchBrush(HatchStyle.SmallConfetti , Color.LightGray , Color.White);
            g.FillRectangle(hatchBrush , rect);

            // Set up the text font.
            SizeF size;
            float fontSize = rect.Height + 1;
            Font font;
            // Adjust the font size until the text fits within the image.
            do
            {
                fontSize--;
                font = new Font(this.familyName , fontSize , FontStyle.Bold);
                size = g.MeasureString(this.text , font);
            } while (size.Width > rect.Width);

            // Set up the text format.
            StringFormat format = new StringFormat();
            format.Alignment = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;

            // Create a path using the text and warp it randomly.
            GraphicsPath path = new GraphicsPath();
            path.AddString(this.text , font.FontFamily , (int) font.Style , font.Size , rect , format);
            float v = 4F;
            PointF[] points =
			{
				new PointF(this.random.Next(rect.Width) / v, this.random.Next(rect.Height) / v),
				new PointF(rect.Width - this.random.Next(rect.Width) / v, this.random.Next(rect.Height) / v),
				new PointF(this.random.Next(rect.Width) / v, rect.Height - this.random.Next(rect.Height) / v),
				new PointF(rect.Width - this.random.Next(rect.Width) / v, rect.Height - this.random.Next(rect.Height) / v)
			};
            Matrix matrix = new Matrix();
            matrix.Translate(0F , 0F);
            path.Warp(points , rect , matrix , WarpMode.Perspective , 0F);

            // Draw the text.
            hatchBrush = new HatchBrush(HatchStyle.LargeConfetti , Color.LightGray , Color.DarkGray);
            g.FillPath(hatchBrush , path);

            // Add some random noise.
            int m = Math.Max(rect.Width , rect.Height);
            for (int i = 0 ; i < (int) (rect.Width * rect.Height / 30F) ; i++)
            {
                int x = this.random.Next(rect.Width);
                int y = this.random.Next(rect.Height);
                int w = this.random.Next(m / 50);
                int h = this.random.Next(m / 50);
                g.FillEllipse(hatchBrush , x , y , w , h);
            }

            // Clean up.
            font.Dispose();
            hatchBrush.Dispose();
            g.Dispose();

            // Set the image.
            this.image = bitmap;
        }
    }
}


1)Я соединил страницы через using как класс

2) У меня есть код на xaml
XML
<Grid x:Name="formregistration" Background="#FFE5E5E5" DataContext="{StaticResource tblUserViewSource}">
                    <Grid x:Name="grid3" HorizontalAlignment="Left" Margin="24,20,0,0" VerticalAlignment="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Label Content="User Name:" Grid.Column="0" HorizontalAlignment="Left" Margin="3" Grid.Row="0" VerticalAlignment="Center"/>
                        <TextBox x:Name="userNameTextBox" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="3" Grid.Row="0" Text="{Binding UserName, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="120"/>
                    </Grid>
                    <Grid x:Name="grid4" HorizontalAlignment="Left" Margin="10,57,0,0" VerticalAlignment="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Label Content="Email Address:" Grid.Column="0" HorizontalAlignment="Left" Margin="3" Grid.Row="0" VerticalAlignment="Center"/>
                        <TextBox x:Name="emailAddressTextBox1" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="3" Grid.Row="0" Text="{Binding EmailAddress, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="120"/>
                    </Grid>
                    <Grid x:Name="grid5" HorizontalAlignment="Left" Margin="24,94,0,0" VerticalAlignment="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Label Content="Description:" Grid.Column="0" HorizontalAlignment="Left" Margin="3" Grid.Row="0" VerticalAlignment="Center"/>
                        <TextBox x:Name="descriptionTextBox" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="3" Grid.Row="0" Text="{Binding Description, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="120"/>
                    </Grid>
                    <Grid x:Name="grid6" HorizontalAlignment="Left" Margin="61,131,0,0" VerticalAlignment="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Label Content="pass:" Grid.Column="0" HorizontalAlignment="Left" Margin="3" Grid.Row="0" VerticalAlignment="Center"/>
                        <TextBox x:Name="passTextBox1" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="3" Grid.Row="0" Text="{Binding pass, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="120"/>
                    </Grid>
                    <Button x:Name="btnreg" Content="Button" HorizontalAlignment="Center" Margin="0,215,0,0" VerticalAlignment="Top" Width="122" Click="btnreg_Click" Height="37"/>
                    <Grid x:Name="grid7" DataContext="{StaticResource gorodViewSource}" HorizontalAlignment="Left" Margin="317,10,0,0" VerticalAlignment="Top" Height="218">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                    </Grid>
                    <Grid x:Name="grid9" DataContext="{StaticResource gorodViewSource}" HorizontalAlignment="Left" Margin="289,20,0,0" VerticalAlignment="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Label Content="name:" Grid.Column="0" HorizontalAlignment="Left" Margin="3" Grid.Row="0" VerticalAlignment="Center"/>
                        <ComboBox x:Name="nameComboBox" Grid.Column="1" DisplayMemberPath="name" HorizontalAlignment="Left" Height="Auto" ItemsSource="{Binding}" Margin="3" Grid.Row="0" VerticalAlignment="Center" Width="120">
                            <ComboBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <VirtualizingStackPanel/>
                                </ItemsPanelTemplate>
                            </ComboBox.ItemsPanel>
                        </ComboBox>
                    </Grid>
                    <CheckBox Content="CheckBox" HorizontalAlignment="Left" Margin="229,184,0,0" VerticalAlignment="Top"/>
                    <Button x:Name="bref" Content="refrash" HorizontalAlignment="Left" Margin="357,160,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>
                    <Grid x:Name="bcap" HorizontalAlignment="Left" Height="61" Margin="289,94,0,0" VerticalAlignment="Top" Width="214"/>
                </Grid>

HOW TO WRITE IN CONNECTION captcha XML??
C#


capcha

AnswerRe: HOW TO WRITE IN CONNECTION captcha XML?? Pin
Mycroft Holmes12-Dec-12 22:20
professionalMycroft Holmes12-Dec-12 22:20 
QuestionProblem when loading dll file in my project: Unable to load DLL “…” The specified module could not be found. (Exception from HRESULT: 0x8007007E) Pin
taibc12-Dec-12 19:21
taibc12-Dec-12 19:21 
AnswerRe: Problem when loading dll file in my project: Unable to load DLL “…” The specified module could not be found. (Exception from HRESULT: 0x8007007E) Pin
Sivaraman Dhamodharan12-Dec-12 19:26
Sivaraman Dhamodharan12-Dec-12 19:26 
GeneralRe: Problem when loading dll file in my project: Unable to load DLL “…” The specified module could not be found. (Exception from HRESULT: 0x8007007E) Pin
taibc12-Dec-12 23:48
taibc12-Dec-12 23:48 
AnswerRe: Problem when loading dll file in my project: Unable to load DLL “…” The specified module could not be found. (Exception from HRESULT: 0x8007007E) Pin
Mycroft Holmes12-Dec-12 22:24
professionalMycroft Holmes12-Dec-12 22:24 
GeneralRe: Problem when loading dll file in my project: Unable to load DLL “…” The specified module could not be found. (Exception from HRESULT: 0x8007007E) Pin
taibc12-Dec-12 23:49
taibc12-Dec-12 23:49 
QuestionDescrypt a file - PGP Pin
jbradshaw12-Dec-12 9:10
jbradshaw12-Dec-12 9:10 
AnswerRe: Descrypt a file - PGP Pin
Matt U.12-Dec-12 9:13
Matt U.12-Dec-12 9:13 
GeneralRe: Descrypt a file - PGP Pin
jbradshaw12-Dec-12 9:48
jbradshaw12-Dec-12 9:48 
GeneralRe: Descrypt a file - PGP Pin
Garth J Lancaster12-Dec-12 22:48
professionalGarth J Lancaster12-Dec-12 22:48 
QuestionMVVM. Buttons and thair content Pin
boryborawski12-Dec-12 9:00
boryborawski12-Dec-12 9:00 
AnswerRe: MVVM. Buttons and thair content Pin
SledgeHammer0112-Dec-12 9:17
SledgeHammer0112-Dec-12 9:17 
GeneralRe: MVVM. Buttons and thair content Pin
boryborawski12-Dec-12 9:40
boryborawski12-Dec-12 9:40 
GeneralRe: MVVM. Buttons and thair content Pin
SledgeHammer0112-Dec-12 11:30
SledgeHammer0112-Dec-12 11:30 
GeneralRe: MVVM. Buttons and thair content Pin
boryborawski12-Dec-12 13:22
boryborawski12-Dec-12 13:22 
QuestionWeb scraping Pin
Kalenzo12-Dec-12 7:12
Kalenzo12-Dec-12 7:12 
AnswerRe: Web scraping Pin
Matt U.12-Dec-12 7:20
Matt U.12-Dec-12 7:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.