I am trying to write a program. It will work at the background and it will constantly capture the screen, blur the image after that it will give me color of a pixel that I want. I tried to do this with that code. But it give me pixel color without blur effect. How can I get the blurry pixel color?
Screenshot, blur and get pixel function:
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Hide();
Bitmap foto = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
BlurBitmapEffect myBlurEffect = new BlurBitmapEffect();
System.Threading.Thread.Sleep(200);
Graphics grafik = Graphics.FromImage(foto);
grafik.CopyFromScreen(0, 0, 0, 0, new System.Drawing.Size(foto.Width, foto.Height));
imgBox.Source = BitmapToImageSource(foto);
myBlurEffect.Radius = myBlurValue;
imgBox.BitmapEffect = myBlurEffect;
colorValue.Text = foto.GetPixel(foto.Width / 2, foto.Height / 2).ToString();
this.Show();
}
XAML file:
<Image Name="imgBox" HorizontalAlignment="Left" Height="419" VerticalAlignment="Top" Width="792" ></Image>
<Button Content="Take ScreenShot" HorizontalAlignment="Left" Margin="674,389,0,0" VerticalAlignment="Top" Width="108" Cursor="Hand" Click="Button_Click"/>
<Button Name="blurDown" Content="-" HorizontalAlignment="Left" Margin="10,394,0,0" VerticalAlignment="Top" Width="75" Cursor="Hand" Click="Button_Click_Down"/>
<Button Name="blurUp" Content="+" HorizontalAlignment="Left" Margin="90,394,0,0" VerticalAlignment="Top" Width="75" Cursor="Hand" Click="Button_Click_Up"/>
<TextBox Name="blurValue" HorizontalAlignment="Center" Height="23" Margin="338,386,334,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120" TextAlignment="Center" FontWeight="Bold" Background="{x:Null}" Foreground="White" BorderBrush="{x:Null}">
<TextBox.Effect>
<DropShadowEffect/>
</TextBox.Effect>
</TextBox>
<TextBox Name="colorValue" HorizontalAlignment="Center" Height="23" Margin="261,10,257,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="274" TextAlignment="Center" FontWeight="Bold" Background="{x:Null}" Foreground="White" BorderBrush="{x:Null}">
<TextBox.Effect>
<DropShadowEffect/>
</TextBox.Effect>
</TextBox>
Related
I writing app for UWP.
I have app very similar to Windows 10 Mail app.
I have this UI
Here is xaml of this screen
<Grid BorderBrush="White" BorderThickness="1">
<Grid.Background>
<ImageBrush Stretch="Fill" ImageSource="Images/Background.png"/>
</Grid.Background>
<Grid HorizontalAlignment="Left" Height="720" VerticalAlignment="Top" Width="60" BorderBrush="#FFF5F1F1" BorderThickness="0,0,1,0">
<Button x:Name="MenuButton" Content="" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="38" Width="38">
<Button.Background>
<ImageBrush Stretch="Uniform" ImageSource="Images/Menu-100.png"/>
</Button.Background>
</Button>
<Button x:Name="logoutbutton" Content="" HorizontalAlignment="Left" Margin="10,650,0,0" VerticalAlignment="Top" Height="43" Width="38">
<Button.Background>
<ImageBrush Stretch="Uniform" ImageSource="Images/Logout_Button.png"/>
</Button.Background>
</Button>
</Grid>
<Grid HorizontalAlignment="Left" Height="47" Margin="63,2,-121,0" VerticalAlignment="Top" Width="1338" BorderBrush="#FFFDFDFD" Padding="0,0,0,1" BorderThickness="0,0,0,1">
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" TextWrapping="Wrap" Text="В Работе" VerticalAlignment="Top" Height="47" Width="1218" FontSize="32" FontFamily="SF UI Display" Padding="550,0,0,0" Foreground="White"/>
</Grid>
<ScrollViewer HorizontalAlignment="Left" Height="668" Margin="63,52,0,0" VerticalAlignment="Top" Width="350">
<GridView x:Name="OrdersGridView" >
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel >
<Grid Height="204" BorderBrush="#FFFBF8F8" BorderThickness="0,0,1,1">
<TextBlock Text="{Binding date_created}" HorizontalAlignment="Left" TextAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Top" Width="350" Height="50" FontFamily="SF UI Display" FontSize="25" FontWeight="Light" Foreground="White" />
<TextBlock TextAlignment="Center" HorizontalAlignment="Left" Margin="0,146,-1,0" TextWrapping="Wrap" Text="{Binding billing.address_1}" VerticalAlignment="Top" Height="58" Width="350" FontFamily="SF UI Display" FontSize="25" FontWeight="Light" Foreground="White" />
<TextBlock HorizontalAlignment="Left" TextAlignment="Center" Margin="0,86,-1,0" TextWrapping="Wrap" Text="{Binding billing.first_name}" VerticalAlignment="Top" Height="60" Width="350" FontFamily="SF UI Display" FontSize="25" FontWeight="Light" Foreground="White" Padding="0,0,0,0"/>
</Grid>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</ScrollViewer>
</Grid>
I make Binding in code like this:
public async void Down()
{
RestAPI rest = new RestAPI("http://simplegames.com.ua/wp-json/wc/v1/", "ck_9d64c027d2c5f81b8bed3342eeccc6d337be813d", "cs_60697b1e6cbdeb8d62d19e0765e339f8e3334754");
WCObject wc = new WCObject(rest);
//Get all products
var orders = await wc.GetOrders(new Dictionary<string, string>() {
{ "per_page", "100" }, { "status","processing"} }); // Dodelat filtr dlaya teh chto v rabote
string products = orders.ToFormattedJsonString();
List<RootObject> rootObjectData = JsonConvert.DeserializeObject<List<RootObject>>(products);
foreach (RootObject root in rootObjectData)
{
string date = root.date_created;
string name = root.billing.first_name;
Orders = new ObservableCollection<RootObject>(rootObjectData) { new RootObject { date_created = date}
};
OrdersGridView.ItemsSource = Orders;
};
}
}
}
I need to open smth like Fragment.
Here is UI how it need to be like:
How I can do this?
Thank's for help so much!
I'm trying something new. I've got a few grids, and when I try to grab a grid i want to move its parent around my top grid. At the moment I get a System.NullReferenceException on m_startOffset = new Vector(translate.X, translate.Y); in the Grid_MouseDown method. Does someone know how i should tackle this problem?
UI:
<Grid x:Name="GridHost">
<Grid x:Name="GRLogin" Margin="1401,292,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="501" d:IsHidden="True" Focusable="True">
<Grid Height="30" VerticalAlignment="Top" Background="#FF1585B5" Margin="0" MouseLeftButtonUp="Grid_MouseUp" MouseLeftButtonDown="Grid_MouseDown" MouseMove="Grid_MouseMove" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="GRLoginClose" Content="X" Background="{x:Null}" Foreground="White" FontWeight="Bold" OpacityMask="Black" Margin="470,0,0,0" Width="30" Height="30" Click="Close"/>
<Button Content="-" Background="{x:Null}" Foreground="White" FontWeight="Bold" OpacityMask="Black" Margin="0,0,30,0" Width="30" Height="30" HorizontalAlignment="Right"/>
<Label Content="Login" HorizontalAlignment="Center" Margin="0" FontWeight="Bold"/>
</Grid>
<Grid HorizontalAlignment="Left" Height="250" Margin="0,30,0,0" VerticalAlignment="Top" Width="500" Background="#FF262626">
<PasswordBox HorizontalAlignment="Center" Margin="206,130,120,94" VerticalAlignment="Center" Width="174"/>
<Label Content="Password" HorizontalAlignment="Center" Margin="122,130,308,94" VerticalAlignment="Center" RenderTransformOrigin="-1.737,0.462" Width="70"/>
<Label Content="Username" HorizontalAlignment="Center" Margin="122,99,308,125" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" Width="70"/>
<TextBox HorizontalAlignment="Center" Height="23" Margin="206,99,120,125" TextWrapping="Wrap" VerticalAlignment="Center" Width="174" RenderTransformOrigin="0.467,-0.346"/>
<Button Content="Login" HorizontalAlignment="Left" VerticalAlignment="Top" Width="258" Margin="122,180,0,0" Height="40" Background="#FF1585B5" Foreground="White" FontWeight="Bold"/>
</Grid>
</Grid>
Movement code:
private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
{
FrameworkElement element = ((Grid)sender).Parent as Grid;
TranslateTransform translate = element.RenderTransform as TranslateTransform;
m_start = e.GetPosition(GridHost);
m_startOffset = new Vector(translate.X, translate.Y);
element.CaptureMouse();
}
private void Grid_MouseMove(object sender, MouseEventArgs e)
{
FrameworkElement element = ((Grid)sender).Parent as Grid;
TranslateTransform translate = element.RenderTransform as TranslateTransform;
if (element.IsMouseCaptured)
{
Vector offset = Point.Subtract(e.GetPosition(GridHost), m_start);
translate.X = m_startOffset.X + offset.X;
translate.Y = m_startOffset.Y + offset.Y;
}
}
private void Grid_MouseUp(object sender, MouseButtonEventArgs e)
{
FrameworkElement element = ((Grid)sender).Parent as Grid;
element.ReleaseMouseCapture();
}
Declare the parent Grid's RenderTransform in the XAML:
<Grid x:Name="GRLogin" Margin="1401,292,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="501" d:IsHidden="True" Focusable="True">
<Grid.RenderTransform>
<TranslateTransform/>
</Grid.RenderTransform>
...
</Grid>
You could also check the RenderTransform for null, in which case you set it: element.RenderTransform = new TranslateTransform();
The property in the database is image. What's in the content is binary data. This is the datatemplate of the listbox:
<DataTemplate x:Key="ItemTemplate">
<Grid Width="467" Height="123" Margin="5,0,0,0">
<Image Name="imgProduct" Source="{Binding pImage}" HorizontalAlignment="Left" Margin="0,5" Width="115"/>
<TextBlock Text="{Binding pName}" Margin="120,0,133,92" Foreground="Black" FontFamily="Tahoma" FontSize="22.667"/>
<TextBlock Text="{Binding pPrice}" Margin="146,69,263,35" Foreground="Black" FontSize="13.333"/>
<TextBlock Text="{Binding pQty}" Margin="232,30,183,76" Foreground="#FF11BB00" FontSize="13.333" FontFamily="Tahoma"/>
<TextBlock Text="{Binding pRewardCost}" Margin="433,89,0,14" FontSize="13.333" Foreground="#7F000000"/>
<TextBlock Text="{Binding pSalesPrice}" Margin="155,85,233,14" Foreground="#FF005910" FontSize="17.333" RenderTransformOrigin="-0.196,0.375"/>
<TextBlock HorizontalAlignment="Left" Margin="120,31,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="13.333" Height="15" Width="114">
<Run Text="Quantity Available:"/>
<LineBreak/>
<Run Text=":"/>
</TextBlock>
<TextBlock HorizontalAlignment="Left" Margin="120,69,0,0" TextWrapping="Wrap" Text="SGD" VerticalAlignment="Top" FontSize="13.333" RenderTransformOrigin="-1.923,0.625" Foreground="Black"/>
<TextBlock HorizontalAlignment="Left" Margin="120,85,0,0" TextWrapping="Wrap" Text="SGD" VerticalAlignment="Top" FontSize="17.333" RenderTransformOrigin="-1.923,0.625"/>
<TextBlock HorizontalAlignment="Left" Margin="318,89,0,0" TextWrapping="Wrap" Text="Reward Points cost:" VerticalAlignment="Top" FontSize="13.333" Foreground="#7F000000"/>
<InkPresenter HorizontalAlignment="Left" Height="2" Margin="122,75,0,0" VerticalAlignment="Top" Width="74" Background="Black" RenderTransformOrigin="0.5,0.5">
<InkPresenter.RenderTransform>
<CompositeTransform ScaleY="-1"/>
</InkPresenter.RenderTransform>
</InkPresenter>
<InkPresenter HorizontalAlignment="Left" Height="2" Margin="0,117,0,0" VerticalAlignment="Top" Width="467" Background="#66000000"/>
</Grid>
</DataTemplate>
The C# Code that consumes the database and shows as items on the listbox is as below:
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
var pdtQry = from pdt in fypDB.Products
select pdt;
productCollection = new DataServiceCollection<Product>();
productCollection.LoadCompleted += new
EventHandler<LoadCompletedEventArgs>(productCollection_LoadCompleted);
productCollection.LoadAsync(pdtQry);
}
void productCollection_LoadCompleted(Object sender, LoadCompletedEventArgs e)
{
if (productCollection.Continuation != null) productCollection.LoadNextPartialSetAsync();
else
{
listboxSearch.ItemsSource = productCollection;
}
}
After debugging, pName, pPrice, pQty, pRewardCost, and pSalesPrice. However the image is not displayed. I think it may be because the image is not of the same format. The format in dbo is image and is <binary data>. Is there any way to convert and display it? Thanks in advance!!
I can scroll text with [DoubleAnimation] but
I'd like to show as follows:
1.I have big Grid and small Canvas
2.Text is appeared in canvas right edge
3.Test is disappeared in canvas left edge
4.I like to show text in only canvas. not grid
how to make this in C#?
this is image link
http://i.stack.imgur.com/Hmhho.jpg
1. C# code
private void animation()
{
Storyboard sb = new Storyboard();
DoubleAnimation moveLeft = new DoubleAnimation();
moveLeft.From = Canvas.Width;
moveLeft.To = -tbxText.Width;
moveLeft.Duration = new Duration(TimeSpan.FromSeconds(3));
moveLeft.RepeatBehavior = RepeatBehavior.Forever;
Storyboard.SetTarget(moveLeft, tbxText);
Storyboard.SetTargetProperty(moveLeft, new PropertyPath(Canvas.LeftProperty));
moveLeft.EasingFunction = new CircleEase() { EasingMode = System.Windows.Media.Animation.EasingMode.EaseOut };
sb.Children.Add(moveLeft);
sb.Begin();
}
2. xaml Code
<Grid HorizontalAlignment="Left" Height="59" Margin="42,33,0,0" VerticalAlignment="Top" Width="255" Background="#FFC9F594">
<Canvas x:Name="Canvas" HorizontalAlignment="Left" Height="59" VerticalAlignment="Top" Width="255">
<TextBox x:Name="tbxText" Height="34" Canvas.Left="10" TextWrapping="Wrap" Text="Test Test Test Test" Canvas.Top="6" Width="196" Background="{x:Null}" BorderBrush="{x:Null}" FontSize="20"/>
</Canvas>
</Grid>
it is good way
Panel.ZIndex="1"
<Grid Panel.ZIndex="1" HorizontalAlignment="Left" Height="55" Margin="114,83,0,0" VerticalAlignment="Top" Width="266">
<Canvas x:Name="Canvas" HorizontalAlignment="Left" Height="59" VerticalAlignment="Top" Width="255" Margin="1,0,0,-4">
<TextBox x:Name="tbxText" Height="34" Canvas.Left="10" TextWrapping="Wrap" Text="Test Test Test Test" Canvas.Top="6" Width="196" Background="{x:Null}" BorderBrush="{x:Null}" FontSize="20"/>
</Canvas>
</Grid>
I have a page in my app where the data comes from the web service. The code is:
public about()
{
InitializeComponent();
KejriwalService.aapSoapClient myclient = new KejriwalService.aapSoapClient();
myclient.getarvindAboutCompleted += new EventHandler<KejriwalService.getarvindAboutCompletedEventArgs>(myclient_getarvindAboutCompleted);
myclient.getarvindAboutAsync();
}
void myclient_getarvindAboutCompleted(object sender, KejriwalService.getarvindAboutCompletedEventArgs e)
{
var data = e.Result;
XElement xml = XElement.Parse(data);
aboutview.Text = xml.Elements("UserDetails").Elements("about_details").First().Value;
}
As the data comes from the web i want to add a spinner which runs till the data comes. Can anyone please help me how to do this for this particular page.
My xaml file is:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,12,12,0">
<Button Click="Image_Phone" BorderThickness="0" Margin="197,155,0,518" HorizontalAlignment="Left" Width="93">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Image/phone.png"/>
</Button.Background>
</Button>
<Button x:Name="Email" BorderThickness="0" Click="Image_Email" Margin="277,155,85,518">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Image/email.png"/>
</Button.Background>
</Button>
<Button x:Name="Home" BorderThickness="0" Click="Image_Home" Margin="0,155,-12,518" HorizontalAlignment="Right" Width="102">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Image/Home-icon.png"/>
</Button.Background>
</Button>
<Button x:Name="previous" BorderThickness="0" Click="Image_Back" Margin="0,0,354,673" HorizontalAlignment="Right" Width="102">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Image/Previous.png"/>
</Button.Background>
</Button>
<ScrollViewer Margin="0,256,0,6" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Auto" AllowDrop="False" ManipulationMode="Control">
<TextBlock HorizontalAlignment="Left" Name="aboutview" Text="" TextWrapping="Wrap" VerticalAlignment="Top" Width="439" FontSize="18" FontStyle="Normal" FontWeight="ExtraBlack" Foreground="Black"/>
</ScrollViewer>
<Image Height="172" HorizontalAlignment="Left" Margin="24,78,0,0" Name="image1" Source="Image/icon.png" Stretch="Fill" VerticalAlignment="Top" Width="155" />
<TextBlock Height="34" HorizontalAlignment="Left" Margin="196,78,0,0" Name="textBlock1" Text="Contact No:" VerticalAlignment="Top" Width="147" FontSize="24" Foreground="Black" FontWeight="Bold"/>
<TextBlock Height="36" HorizontalAlignment="Left" Margin="197,118,0,0" Name="textBlock2" Text="+91-9718500606" VerticalAlignment="Top" Width="191" FontSize="24" Foreground="Black" FontWeight="Bold" />
</Grid>
</Grid>
I'd recommend you ProgressBar (or better PerformanceProgressBar from the WP toolkit), if they are matching your requirements. You can add this snippet somewhere inside of ContentPanel Grid:
<ProgressBar Name="progressName"
IsIndeterminate="True"
Visibility="Collapsed"/>
And your code behind should look like this:
public about()
{
InitializeComponent();
KejriwalService.aapSoapClient myclient = new KejriwalService.aapSoapClient();
myclient.getarvindAboutCompleted += new EventHandler<KejriwalService.getarvindAboutCompletedEventArgs>(myclient_getarvindAboutCompleted);
myclient.getarvindAboutAsync();
progressName.Visibility = System.Windows.Visibility.Visible;
}
void myclient_getarvindAboutCompleted(object sender, KejriwalService.getarvindAboutCompletedEventArgs e)
{
var data = e.Result;
XElement xml = XElement.Parse(data);
aboutview.Text = xml.Elements("UserDetails").Elements("about_details").First().Value;
progressName.Visibility = System.Windows.Visibility.Collapsed;
}