小编Loc*_* Le的帖子

在 linux 中打开文件。我不想创建写保护文件

我在 Linux 中创建文件时遇到问题,它使我的文件被写保护,我不知道为什么会这样。

void fileOperation::openFileWrite(char x, off_t s)
{
  int fd;
  char c[2] = {x};

  fd = open("/home/stud/txtFile", O_CREAT | O_WRONLY);  //open file
  if(fd == -1)
      cout << "can't open file" << endl;
  else
  {
      lseek(fd, s, SEEK_SET);//seek at first byte
      write(fd, (void*)&c, 2);//write to file
  }
  syncfs(fd);
  ::close(fd);
}
Run Code Online (Sandbox Code Playgroud)

c++ linux unistd.h

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

Unity中游戏对象的水平重力

我正在做一个简单的2D游戏.

我有gameobject一个rigidbody组件.

标准刚体重力拉下我的游戏对象,但我想重力将游戏对象拉到左边.

我知道如何在编辑 - >项目设置 - >中将重力设置为向左拉动...但是此设置会将重力更改为所有刚体,这在我的情况下是个问题.

我只想为1个游戏对象设置引力.

c# rigid-bodies unity-game-engine game-physics gameobject

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

WPF数据绑定ProgressBar

我正在制作WebClient用于下载文件的WPF应用程序。我想ProgressPercentageProgressBar控制器中显示。我在WebClient用于下载文件的类中有一个方法。我的问题是如何将绑定ProgressBare.ProgressPercentage

类中的方法(DownloadFile):

public async Task DownloadProtocol(string address, string location)
{

        Uri Uri = new Uri(address);
        using (WebClient client = new WebClient())
        {
            //client.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
            //client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgress);
            client.DownloadProgressChanged += (o, e) =>
            {
                Console.WriteLine(e.BytesReceived + " " + e.ProgressPercentage);
                //ProgressBar = e.ProgressPercentage???
            };

            client.DownloadFileCompleted += (o, e) =>
            {
                if (e.Cancelled == true)
                {
                    Console.WriteLine("Download has been canceled.");
                }
                else
                {

                    Console.WriteLine("Download completed!");
                }

            }; …
Run Code Online (Sandbox Code Playgroud)

c# data-binding wpf progress-bar

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

触发鼠标悬停时,Wpf 文本框不会更改边框?

在我的 WPF 应用程序中,我想在鼠标进入时更改 TextBox 的边框颜色,但它不会将颜色更改为我想要的颜色,而是更改为天蓝色(我猜它是标准颜色)。

这是我的 XAML 代码:

 <Window x:Class="OnePlayApp.Views.LoginDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:OnePlayApp.Views"
        WindowStyle="None"
        ResizeMode="NoResize"
        Title="LoginDialog" Height="350" Width="550" Foreground="Black">

    <Grid Background="#282828">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="24*"/>
            <ColumnDefinition Width="43*"/>
            <ColumnDefinition Width="43*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="59*"/>
            <RowDefinition Height="50*"/>
            <RowDefinition Height="50*"/>
            <RowDefinition Height="191*"/>
        </Grid.RowDefinitions>

        <Image Margin="9,10,173,6" Source="/Resources/logo.png" Grid.ColumnSpan="2"/>


        <Label x:Name="AccountName" Content="Account name" Margin="6,10,1,13" Foreground="#FFAFADAD" HorizontalContentAlignment="Right" Grid.Row="1"/>
        <Label x:Name="Password" Content="Password&#xD;&#xA;" Margin="6,10,1,13" Foreground="#FFAFADAD" HorizontalContentAlignment="Right" Grid.Row="2"/>

        <TextBox x:Name="username" Margin="6,11,15,8" Background="#FF282828" Foreground="White" FontSize="15" Text="Ahsep12015@one.com" FontFamily="Yu Gothic UI Semibold" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" VerticalContentAlignment="Center" BorderThickness="10">
            <TextBox.Style>
                <Style TargetType="{x:Type TextBox}"> …
Run Code Online (Sandbox Code Playgroud)

c# wpf textbox

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

UICollectionView重复单元格

我有一个UICollectionView,其中每个单元格中都有一个图像。这些图像通过URL加载。但是,当某个单元格滚动出视线时,它会在重新加载之前显示另一单元格的图像一秒钟。我不知道为什么会这样。

这是我的代码:

我的UIImageView扩展要从url加载:

extension UIImageView {
    public func imageFromUrl(urlString: String) {

        Alamofire.request(.GET, urlString).responseJSON{
            response in

            if let tilbudimage = UIImage(data: response.data!){
                self.image = tilbudimage

            }

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

UICollectionView:

func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
        return 1
    }

    func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {

        print(DealArr.count)

        return DealArr.count
    }

    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

        let cell = collectionView.dequeueReusableCellWithReuseIdentifier("DealCell", forIndexPath: indexPath) as! DealCell

        let deal = self.DealArr[indexPath.row]

        cell.backgroundColor = UIColor.whiteColor()

        cell.DealImage.imageFromUrl(deal["image"].string!)
        cell.DealLabel.text = deal["title"].string! + …
Run Code Online (Sandbox Code Playgroud)

uicollectionview uicollectionviewcell swift xcode7

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

Azure COSMOS DB 如何查询数组中的包含

如何进行查询以获取文档数组“角色”中包含某些内容的文档?我想获得以下文档,其中 Trainer 是数组中的一个元素。

"enabled": true,
"profilePicture": null,
"roles": [
   "Trainer",
   "Client"
 ],
Run Code Online (Sandbox Code Playgroud)
SELECT * FROM u WHERE u['$type'] = 'User' AND //roles contains Trainer
Run Code Online (Sandbox Code Playgroud)

sql azure azure-cosmosdb azure-cosmosdb-sqlapi

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

保存样式元素以在其他视图控制器中重用

我正在使用 Xcode 制作一个 iOS 应用程序,其中我的所有按钮都应该具有相同的样式。这些按钮之间的唯一区别是它们的高度和宽度。有没有办法保存我设计的第一个样式,然后在不同的视图控制器中再次使用它,而无需复制?我在想如果这可能的话,它会为我节省很多时间。

xcode styling ios swift

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