小编Ayo*_*b.A的帖子

将DateTime转换为TimeSpan

我想将DateTime实例转换为TimeSpan实例,是否可能?

我环顾四周但是找不到我想要的东西,我只找时差.更具体地说,我想将一个DateTime实例转换为毫秒,然后将其保存到IsolatedStorage中.

.net c#

65
推荐指数
5
解决办法
12万
查看次数

表格单元格内的 HTML 输入

我有一个包含许多列的表格,我想input在标题单元格内添加字段,但我希望输入根据正文内容适合宽度。

这是没有字段的情况input在此输入图像描述

这就是字段的样子input

可以看出,“index”和“Is Active”等列占用了太多空间,我想尽可能保持第一个布局。我尝试将输入宽度设置为 100% 和自动,但似乎没有多大帮助。

当前的 CSS 看起来像:

.table {
  font-family: Arial, Helvetica, sans-serif;
}

.table thead {
  position: sticky;
  top: 0;
}

.table thead th {
  border: 1px solid #e4eff8;
  background: white;
  cursor: pointer;
}

.table thead th.header-label {
  cursor: pointer;
  background: linear-gradient(0deg, #e4eff8, #4578a2 5%, #e4eff8 150%);
  color: white;
  border: 1px solid white;
}

.table th,
.table td {
  padding: 0.2rem 0.5rem;
  text-align: center;
}

.table td {
  border: 1px …
Run Code Online (Sandbox Code Playgroud)

html css

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

EF Core 迁移重新创建重命名的表

我正在使用 .NET 5 Identity 包并重命名它的表并使用IdentityUser. 现在,我决定向我的表添加一些属性User并应用迁移,但迁移尝试重新创建我的重命名表。

这是我的用户模型:

public class User : IdentityUser<int>, IUser
{
    public string Password { get; set; }

    public string Username { get => base.UserName; set => base.UserName = value; }
    public string Name { get; set; }

    public bool PubliclyVisible { get; set; } //New
    public IEnumerable<User> Trackers { get; set; } //New
    public IEnumerable<User> Tracked { get; set; } //New

}
Run Code Online (Sandbox Code Playgroud)

我的DbContext扩展模型配置:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{

    base.OnModelCreating(modelBuilder); …
Run Code Online (Sandbox Code Playgroud)

.net entity-framework database-migration

7
推荐指数
1
解决办法
3989
查看次数

Angular:ForkJoin ngrx observables

我有一个包含多个状态的 ngrx 商店。我试图通过收集每个州的数据来构造一个对象(Rent 对象):这是我的代码:

ngOnInit() {


  //Fetch the rent and its properties data
  const rentID = +this.route.snapshot.params['id'];

  let rentState$ = this.store.select('rentState');
  let clientState$ = this.store.select('clientState');
  let vehiculeState$ = this.store.select('vehiculesState');
  let paymentState$ = of(null);//TODO

  let importRent$ = forkJoin([rentState$, vehiculeState$, clientState$, paymentState$])
    .pipe(mergeMap(([rentData, vehiculeData, clientData, paymentData]: [any, any, any, any]) => {
      let rent = new Rent();

      rent = rentData.rentList.filter(rent => rent.id === rentID)[0];

      rent.vehicule = vehiculeData.vehicules.filter(vehicule => vehicule.id === this.rent.vehicule.id)[0];

      rent.client = clientData.clientList.filter(client => client.id === this.rent.client.id)[0];
      rent.companion = clientData.companionList.filter(companion => …
Run Code Online (Sandbox Code Playgroud)

observable rxjs angular

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

JavaFX CSS:更改 TabPane 选项卡标题形状

我正在尝试更改Tab中的标题形状css,但是当我查看此处css参考时,我找不到通过 选项卡的可访问属性。我想要梯形而不是矩形。知道如何完成这项任务吗?JavaFXcss

css java tabs javafx

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

对属性的算术运算

我创建了一个将摄氏温度转换为fahrenhait的类,反之亦然,这就是我编码的方式:

public class TempConverter
{
    public double ValueToBeConverted { get; set; }

    public TempConverter(double valueToBeConverted)
    {
        ValueToBeConverted = valueToBeConverted;
    }

    public TempConverter()
    {
    }

    public double ConvertToFahrenheit()
    {
        return 9 / 5 * ValueToBeConverted + 32;
    }

    public double ConvertToCelsuis()
    {            
        return 5 / 9 * (ValueToBeConverted - 32);
    }
}
Run Code Online (Sandbox Code Playgroud)

但ConvertToFahrenheit()返回32,另一个方法返回0,无论我传递的值是什么.

我在Main中所做的只是实例化一个TempConverter对象并传递要转换为构造函数的值.我确实放了一些断点,ValueToBeConverted确实得到了我传给构造函数的值,这最终让我相信问题出现在TempConverter类的方法中

c#

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

ControlsFX:验证结果

我想在JavaFx使用中做一些验证ControlsFX.我的代码是这样的:

ValidationSupport support = new ValidationSupport();
boolean isValid = true;
if(textField.getText().trim().isEmpty()) isValid = false;
support.registerValidator(testField, Validator.createEmptyValidator("This field is required!"));
Run Code Online (Sandbox Code Playgroud)

我的问题是,是否可以省略if条件并textField从验证支持中提取是否为空

validation javafx controlsfx

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

FXML:绑定到控制器

是否有可能像在xaml中一样在FXML中绑定到控制器到类varibale.我在做的是:

FXML

<ComboBox fx:id="searchField" 
                    HBox.hgrow="ALWAYS" editable="true" />
<GridPane hgap="5" vgap="5">
    <Label text="Nom" />
    <Label text="$selecteClient.name"
        GridPane.columnIndex="1" />

    <Label GridPane.rowIndex="1" text="tél" />
    <Label text="$electedClient.phoneNumber"
        GridPane.rowIndex="1" GridPane.columnIndex="1" />
<GridPane/>
Run Code Online (Sandbox Code Playgroud)

的Controler:

private final List<Client> clients = FXCollections.observableArrayList(ImportingDataService.importClients());
@FXML
private Client selectedClient;

@FXML
private ComboBox<Client> searchField;

@Override
public void initialize(URL location, ResourceBundle resources) {
    // Set appDtat client id so it refreshes when client is changed
    this.appState.clientViewClientIDProperty().addListener((obs, oldValue, newValue) -> {
        selectedClient = ImportingDataService.importClient(newValue.longValue());

    });

    // Set up combo box
    setUpComboBox();

}
private void …
Run Code Online (Sandbox Code Playgroud)

binding javafx fxml

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

ngrx:通用减速器

我有一个具有多个具有相同减速器功能的商店的应用程序。我试图制造一个通用的减速器,并且效果很好。

通用减速机设置:

interface State<T> {
    itemList : T[]
}

const initialState: State<any> = {
    itemList: []
}


const createReducer = <T>(type: string) => {
    return <T>(state = initialState, action: any): State<T> => {
        switch (action.type) {
            case types.get(type).Add:
                return {
                    ...state,
                    itemList: [...state.itemList, action.payload]
                }

            case types.get(type).AddList:
                return {
                    ...state,
                    itemList: [...state.itemList, ...action.payload]
                };

            default:
                return state;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

然后,我将减速器组合如下:

export const reducers: ActionReducerMap<AppState> = {
    vehiculeState: createReducer<Vehicule>('vehicule'),
    rentState: createReducer<Rent>('rent'),
    clientState : createReducer<Client>('client'),
    companionState : createReducer<Client>('companion'),
    paymentState : createReducer<Payment>('payment'), …
Run Code Online (Sandbox Code Playgroud)

refactoring typescript ngrx angular

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