小编CBr*_*eze的帖子

圆角android图像按钮

我试图在Android ImageButton上圆角,代码看起来像这样;

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/imageButton"
            android:layout_marginTop="57dp"
            android:src="@drawable/friends"
            android:padding="1dp"
            android:layout_alignParentTop="true"
            android:layout_toLeftOf="@+id/imageButton2"
            android:layout_marginRight="62dp" />

    </RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

基本上我们的输出是一个ImageButton,但它有方角,我们试图圆角.

谢谢

android imagebutton

26
推荐指数
3
解决办法
8万
查看次数

MultiDataTrigger与OR而不是AND

我试图DataTriggers在我的上面设置多个Button.我做了一些研究,发现MultiDataTrigger允许你这样做.如果OR,我想将Visibilitymy 的属性Button设置为false .这就是我到目前为止所拥有的;CCTVPath == string.EmptyPermissionsFlag == false

<Button Grid.Column="3" x:Name="cctvFeedButton" Content="Live Feed"
        Width="100" FontSize="16" HorizontalAlignment="Right" Margin="5" Click="OnCCTVButtonClick">
    <Button.Style>
        <Style TargetType="Button">
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding CCTVPath}" Value=""/>
                        <Condition Binding="{Binding PermissionsFlag}" Value="False"/>
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Visibility" Value="Hidden"/>
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>
    </Button.Style>
</Button>
Run Code Online (Sandbox Code Playgroud)

在我的代码隐藏中,我这样设置PermissionsFlag;

public bool PermissionsFlag { get; set; }

private void OnPageLoaded(object sender, RoutedEventArgs e)
{
    PermissionsFlag = false;
}
Run Code Online (Sandbox Code Playgroud)

正如你所看到PermissionsFlag的那样绝对是假的,而且肯定是空的,CCTVPath但是Button永远不会被隐藏.我究竟做错了什么? …

c# wpf xaml visibility button

15
推荐指数
2
解决办法
8707
查看次数

默认路由在Asp.Net Core中不起作用

我有以下的ControllerAction我想要当用户进入我的web应用程序将加载的第一页:

[Route("auth")]
public class AuthController : Controller
{
    [Route("signin")]
    public IActionResult SignIn(bool signInError)
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

我尝试在我的app.UseMvc选项中执行以下操作:

app.UseMvc(routes =>
{
    routes.MapRoute(
        name: "default",
        template: "{controller=auth}/{action=signin}/");
});
Run Code Online (Sandbox Code Playgroud)

但是,当我启动webapp时,它只是导航至http://localhost:52608/

如果我键入http://localhost:52608/auth/signin?ReturnUrl=%2F网页,则将在用户启动Webapp时正确地加载到该页面上。

我的问题是,如何设置它以便用户打开Web应用程序后可以立即导航到此页面?

asp.net-mvc asp.net-core

5
推荐指数
1
解决办法
3711
查看次数

分辨率独立WPF应用程序

我正在开发一个需要独立于分辨率的数据库系统,一些使用仍然以1024 x 768运行的屏幕,一些使用1920 x 1080的屏幕,而其他人使用其间的所有内容.

我之前没有做过很多与WPF的合作,所以我只是刚刚开始尝试让我的头围绕高度,宽度和路线.

我现在拥有的是一个主窗口,其中包含一个网格,其中顶部有一行标签和一些导航按钮,以及登录人员的时间和用户名.然后我有一秒钟下面的行,它包含一个框架,我将页面加载到程序的主导航中.

在页面中我主要使用网格布局,偶尔使用堆栈面板.我遇到的最大问题之一就是像这样的问题;

在此输入图像描述

在低分辨率下这是常见的,因为在更高的分辨率下按钮看起来很好;

在此输入图像描述

这是其父网格中按钮的XAML代码;

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Button Content="HR" Margin="10"  Click="RunHrSystem" FontSize="18.667" />
        <Button Content="Companies" Margin="10" Click="RunCompSystem" FontSize="18.667" Grid.Row="1" />
        <Button Content="People" Margin="10" Click="RunPeopleSystem" FontSize="18.667" Grid.Row="2" />
        <Button Content="IT Management" Margin="10" Click="RunITManagementSystem" FontSize="18.667" Grid.Row="3"/>
        <Button Content="Sales" Margin="10" FontSize="18.667" Grid.Row="4" />
        <Button Content="Buying" Margin="10" FontSize="18.667" Grid.Row="5" />
        <Button Content="Estimating" Margin="10" FontSize="18.667" Grid.Row="6"/>
        <Button Content="Design" Margin="10" FontSize="18.667" Grid.Row="7"/>
    </Grid>
Run Code Online (Sandbox Code Playgroud)

有没有什么明显的我在这里做错了阻止按钮按照较低的分辨率调整大小?正如我所说,我在整个程序中使用按钮,以及矩形形状和某些情况下的标签,标签的底部也将被切断.

c# wpf layout xaml

4
推荐指数
1
解决办法
1006
查看次数

更改默认按钮高亮 WPF

我试图删除 a 上的默认背景Button,但是Button当用户用鼠标悬停在按钮上时,将其突出显示为橙色。到目前为止,这是我想出的;

<Window.Resources>
    <Style TargetType="{x:Type Button}">
        <Setter Property="FontSize" Value="20" />
        <Setter Property="Margin" Value="5" />
        <Setter Property="MaxHeight" Value="30" />
        <Setter Property="Width" Value="150" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Cursor" Value="Hand" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="Orange"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)

但是,当用户将鼠标悬停在按钮上时,它仍然以默认的蓝色突出显示,而不是我想要的橙色。如何修改它,以便按钮的文本逐渐以橙色突出显示?

c# wpf xaml button

4
推荐指数
1
解决办法
4470
查看次数

StringFormat中的空格

我想在绑定后添加一个逗号和一个"空格".我有绑定后的逗号,但我无法解决如何做一个'空间'.这就是我的意思;

<TextBlock Text="{Binding Name, StringFormat={}{0:\,}\,}" />
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我如何在逗号后添加"空格"吗?我试过在XAML中添加一个空格,但这不起作用.

wpf xaml string-formatting

4
推荐指数
1
解决办法
4149
查看次数

DataTables search on button click instead of typing in input

I would to know if it is possible to move the search function out of an input for a table modified by DataTables. Currently I have a custom input that executes this function:

<script>
    $(document).ready(function() {
        var oTable = $('#staffTable').DataTable();
        $('#searchNameField').keyup(function () {
            oTable.search($(this).val()).draw();
        });
    })
</script>
Run Code Online (Sandbox Code Playgroud)

the input looks like so:

<label for="searchNameField" class="col col-form-label">Name:</label>
<div class="col-sm-11">
    <input type="text" class="form-control ml-0 pl-2" id="searchNameField"
            placeholder="Name" autofocus/>
</div>
Run Code Online (Sandbox Code Playgroud)

What I would like to do is move this to a button. …

html javascript jquery datatables

3
推荐指数
1
解决办法
5811
查看次数

结构采用32位架构

以下代码;

struct s1 {
    void *a;
    char b[2];
    int c;
};

struct s2 {
    void *a;
    char b[2];
    int c;
}__attribute__((packed));
Run Code Online (Sandbox Code Playgroud)

如果s1大小为12个字节并且s2大小为10个字节,这是由于数据是以4个字节的块读取还是}__attribute__((packed));将大小减小void*a;到只有2个字节?

有点困惑的是什么}__attribute__((packed));.

非常感谢

c byte struct

2
推荐指数
1
解决办法
676
查看次数

在切换时旋转 Bootstrap 下拉插入符号并防止在内部单击时关闭

我有以下的代码片段旋转.caretdropdown-toggle点击。这会旋转.caret没有问题的内容,但也会旋转.caret页面上的所有其他内容。我是否需要写一个点击功能的每一个人.caret,并.dropdown-toggle在页面或者我可以有一个独立工作?

另外,有没有一种方法可以dropdown-menu在单击其中的项目时停止关闭?

$(document).ready(function() {
  $(".dropdown-toggle").click(function() {
    $(".caret").toggleClass('rotate-180');
  });
});
Run Code Online (Sandbox Code Playgroud)
ul {
  list-style: none;
}

.caret {
  -moz-transition: transform 1s;
  -webkit-transition: transform 1s;
  transition: transform 1s;
}

.rotate-180 {
  transform: rotate(-180deg);
}
Run Code Online (Sandbox Code Playgroud)
<head>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <link rel="stylesheet" type="text/css" href="index.css">
  <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>

<body>
  <ul>
    <li class="dropdown">
      <a href="#" class="dropdown-toggle" data-toggle="dropdown"> Directories <span class="caret"></span></a>
      <ul class="dropdown-menu" role="menu">
        <li><a href="#">Item 1</a></li>
        <li><a href="#">Item 2</a></li>
        <li><a …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery

2
推荐指数
1
解决办法
6180
查看次数

LINQ包括在搜索时降低性能

我们有以下方法允许我们搜索DataGrid的Projects表:

public async Task<IEnumerable<Project>> GetFilteredProjects(string searchString)
{
    var projects = _context.Projects.Where(p => p.Current);

    projects.Include(p => p.Client);
    projects.Include(p => p.Architect);
    projects.Include(p => p.ProjectManager);

    if (!string.IsNullOrEmpty(searchString))
    {
        projects = projects
            .Where(p => p.NormalizedFullProjectName.Contains(searchString)
                    || p.Client.NormalizedName.Contains(searchString)
                    || p.Architect.NormalizedFullName.Contains(searchString)
                    || p.ProjectManager.NormalizedFullName.Contains(searchString));
    }

    projects = projects.OrderBy(p => p.Name).Take(10);

    return await projects.ToListAsync();
}
Run Code Online (Sandbox Code Playgroud)

如果我们不使用Include项目,那么搜索是即时的.但是,在搜索中添加它们之后可能需要3秒多.

我们需要包含其他实体以允许用户根据需要搜索它们.

我们如何才能提高性能,但仍然Include允许搜索它们?

没有Incldue方法看起来像这样:

public async Task<IEnumerable<Project>> GetFilteredProjects(string searchString)
{
    var projects = _context.Projects.Where(p => p.Current);

    if (!string.IsNullOrEmpty(searchString))
    {
        projects = projects
            .Where(p => p.Name.Contains(searchString));
    }

    projects …
Run Code Online (Sandbox Code Playgroud)

c# sql linq entity-framework-core asp.net-core

2
推荐指数
1
解决办法
629
查看次数