小编Ali*_*Tor的帖子

为什么IntelliJ Idea无法识别JQuery的美元运算符?

尽管文件与js文件位于同一目录中,但当鼠标悬停在符号上时,IntelliJ会显示警告" 未解析的函数或方法$() " $.因此在键入$函数时我无法利用intellisense .

只有一行代码和IDE无法识别它.但它的确有效.我该如何解决这个问题?

$(".container").get(0).appendChild(proDiv);
Run Code Online (Sandbox Code Playgroud)

jquery intellij-idea dollar-sign

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

我怎么知道哪个cookie必须做出正确的HttpWebRequest?

我正在开发一个下载管理器并尝试使用获取cookie所需的内容HttpWebRequest.我想将我的应用程序集成到Chrome,因此我可以从浏览器中获取必要的Cookie标头和值.

但首先我需要知道是否需要cookie才能获得要下载的内容以及它们是哪些cookie.我找不到有关此主题的任何有用资源.

这就是我的想象:

HttpWebRequest req = (WebRequest.Create(url)) as HttpWebRequest;
//At first, get if cookies are necessary?
//If it is, get the required cookie headers 
//Then add the cookies to the request
CookieContainer cc = new CookieContainer();
Cookie c1 = new Cookie("header1", "value1");
Cookie c2 = new Cookie("header2", "value2");
CookieCollection ccollection = new CookieCollection();
ccollection.Add(c1);
ccollection.Add(c2);
cc.Add(uri, ccollection);
req.CookieContainer = cc;
//Get response and other stuff......
Run Code Online (Sandbox Code Playgroud)

我该怎么做这些步骤?

c# cookies httpwebrequest

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

使用ShowDialog和无边框窗口时,IsMouseOver触发器不起作用

我有两个Windows申请.其中一个MainWindow是设置,另一个是设置.SettingsWindow当设置按钮被点击使用打开ShowDialog并设置其OwnerMainWindow.

SettingsWindow我窗口的最底部一个按钮,它的颜色变为红色时,IsMouseOverTrue蓝色False.但是当光标在MainWindow上时它不会改变.图像在下面是清楚的.我该如何解决这个问题?

CASE:光标不在SettingsWindow中,但它保持红色,没有变化.

在此输入图像描述

Xaml代码:

<Window x:Class="AltoSS.SettingsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="SettingsWindow"
        Height="150"
        Width="360"
        WindowStyle="None"
        AllowsTransparency="True"
        WindowStartupLocation="CenterOwner">

  <!-- Other control codes-->
  <Button Grid.Row="2" Content="KAYDET" 
          FontSize="15"
          FontWeight="Bold"
          BorderBrush="Gray"
          BorderThickness="0,2,0,2">
    <Button.Style>
      <Style TargetType="Button">
        <Setter Property="Background" Value="Blue"/>
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="Button">
              <Border Background="{TemplateBinding Background}">
                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
              </Border>
              <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                  <Setter Property="Background" Value="Red"/>
                  <Setter Property="Foreground" Value="White"/>
                </Trigger>
              </ControlTemplate.Triggers> …
Run Code Online (Sandbox Code Playgroud)

wpf triggers ismouseover

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

播放时如何快进或快退mp3文件?

我有一个课程来帮助我从URL源播放mp3文件.它在播放,暂停和恢复时效果很好.但我对快进或落后感到困惑.

我正在使用临时文件来存储mp3数据,我想FileStream根据用户选择的位置重新定位.但它有一个问题.

问题:如果该职位尚不存在.(尚未下载)在此输入图像描述

这可以使用WebRequest.AddRange()但是在这种情况下,我们必须打开一个新的FileStream来分别存储字节,并且AddRange()每次用户想要前进或后退时调用方法意味着将从该位置重新下载文件.但是,如果这种情况经常发生,我们必须下载与前向或后向数量一样多的文件.

因此,如果有一个简单且配额友好的解决方案,请告诉我.我无法弄清楚该怎么做.请帮忙!

我的代码:

public class NAudioPlayer
{
    HttpWebRequest req;
    HttpWebResponse resp;
    Stream stream;
    WaveOut waveOut;
    Mp3WaveFormat format;
    AcmMp3FrameDecompressor decompressor;
    BufferedWaveProvider provider;
    FileStream tempFileStream;
    System.Windows.Forms.Timer ticker;
    private int bufferedDuration;   

    string url, path;
    long size, streamPos;
    int timeOffset, timePosition, avgBytes, duration;
    bool formatKnown, waitinloop, exitloop;

    State currentState;

    public NAudioPlayer(string mp3Url)
    {
        this.url = mp3Url;
        this.currentState = State.Stopped;
        this.size = -1;
        this.timeOffset = 0;
        this.timePosition = 0;
        this.avgBytes = 0;
        this.duration = 0; …
Run Code Online (Sandbox Code Playgroud)

c# audio-streaming

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

如何通过在桌面上绘图来截取屏幕截图?

我想制作一个SS应用程序.但我对这个问题有疑问.我希望用户能够选择一个特殊区域来截取屏幕截图.我还希望桌面在用户选择区域时处于活动状态.例如,用户想要拍摄视频特定帧的SS.用户必须能够在播放视频时执行此操作.我已经尝试使用直接在桌面上绘图.但它闪烁得那么厉害.我该如何解决这个问题还是有其他办法吗?

我的代码:

    [DllImport("User32.dll")]
    static extern IntPtr GetDC(IntPtr hwnd);

    [DllImport("user32.dll")]
    static extern bool InvalidateRect(IntPtr hWnd, IntPtr lpRect, bool bErase);

    public Form1()
    {
        InitializeComponent();
        this.Load += Form1_Load;
    }

    void Form1_Load(object sender, EventArgs e)
    {
        Start();
    }

    IntPtr handle;
    Graphics grp;

    void Start()
    {
        handle = GetDC(IntPtr.Zero);
        grp = Graphics.FromHdc(handle);
        grp.SmoothingMode = SmoothingMode.HighQuality;
        timer2.Start();
    }
    private void timer2_Tick(object sender, EventArgs e)
    {

        grp.DrawLine(Pens.Red, 0, Cursor.Position.Y, Screen.PrimaryScreen.Bounds.Width, Cursor.Position.Y);
        InvalidateRect(IntPtr.Zero, IntPtr.Zero, false);
    }
Run Code Online (Sandbox Code Playgroud)

c# pinvoke screenshot

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

如何使 DataGridView 的宽度和高度适合其内容?

我有一种动态创建 DataGridView 的方法,但是当它显示出来时,宽度大于内容宽度(列的总宽度)。高度也没有足够的长度来满足行的长度。

我尝试使用这种方法,但没有奏效:

    DataGridView CreateInputBox(int proc, int mac)
        {
            DataGridView databox = new DataGridView();
            for (int i = 0; i < mac; i++)
            {
                databox.Columns.Add("col" + (i + 1), "M" + (i + 1));
                databox.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                databox.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            databox.RowTemplate.DefaultHeaderCellType = typeof(CustomHeaderCell);
            databox.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
            databox.RowHeadersDefaultCellStyle.Padding = new Padding(2);
            for (int i = 0; i < proc; i++)
            {
                databox.Rows.Add();
                databox.Rows[i].HeaderCell.Value = "P" + (i + 1);
            }
            databox.DefaultCellStyle.SelectionBackColor = Color.LightGray;
            databox.AllowUserToAddRows = false;
            databox.AllowUserToDeleteRows = false; …
Run Code Online (Sandbox Code Playgroud)

c# datagridview winforms

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

如何在不下载整个文件的情况下计算VBR mp3的BitRate?

我想在下载开始时获取远程mp3文件的持续时间信息.我可以先获取帧,但不知道哪些必须读取,Xing或VBRi.

如何通过阅读标签获取此信息?

MemoryStream ms = new MemoryStream();
waveOut.Play();
long offset = from;
ms.Position = 0;
byte[] decBuffer = new byte[50 * 1024];
while (true)
{
   if (paused)
   {
      waveOut.Stop();
      bwProvider.ClearBuffer();
      break;
   }
      lock (LockObj)
      {
         byte[] readed = Helper.ReadStreamPartially(localStream, offset, 100 * 1024, orders);
         if (readed == null)
            continue;
         ms = new MemoryStream(readed);
      }
      Mp3Frame frame;
      try
      {
         frame = Mp3Frame.LoadFromStream(ms);
      }
      catch
      {
         continue;
      }
      if (frame == null)
         continue;

      int decompressed = decompressor.DecompressFrame(frame, decBuffer, 0);

      bwProvider.AddSamples(decBuffer, 0, decompressed); …
Run Code Online (Sandbox Code Playgroud)

c# streaming mp3 duration

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

如何在WinForm中使用GraphicsPath绘制圆形进度条饼?

我想在WinForm中使用自定义循环进度条.但结果不符合我的想法.如何在这张图片中绘制相同的形状?我上传了两张图片,以清楚我的问题.

目标形状

我的代码结果

我的代码是这样做的:

void Form1_Paint(object sender, PaintEventArgs e)
    {
        int angle = 120;

        e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

        Rectangle outerRect = new Rectangle(50, 50, 100, 100);
        Rectangle innerRect = new Rectangle(70, 70, 60, 60);

        int innerRadius = innerRect.Width / 2;
        int outerRadius = outerRect.Width / 2;

        Point innerCenter = new Point(innerRect.X + innerRadius, innerRect.Y + innerRadius);
        Point outerCenter = new Point(outerRect.X + outerRadius, outerRect.Y + outerRadius);

        GraphicsPath outerCircle = new GraphicsPath();
        outerCircle.AddEllipse(outerRect);

        GraphicsPath innerCircle = new GraphicsPath();
        innerCircle.AddEllipse(innerRect);

        GraphicsPath progPath = new GraphicsPath(); …
Run Code Online (Sandbox Code Playgroud)

c# gdi+ custom-controls winforms

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

如何设置要在工具箱中显示的自定义控件的说明?

我想在设计时向自定义控件添加一个文本,告诉设计者我的控件是什么。就像这里的VS默认控件:

我已经尝试过了,///summary但是对我没有用。怎么做到呢?

c# custom-controls windows-forms-designer visual-studio winforms

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

如何将包含错误土耳其语字符的字符串转换为显示正确的字符?

我有一个包含 ASCII 字符的字符串,例如

\n\n
"Tu%C4%9F%C3%A7e%20Kandemir%20-%20G%C3%BCl%C3%BC%20Soldurmam.mp3" \n
Run Code Online (Sandbox Code Playgroud)\n\n

正确的文件名是

\n\n
"Tu\xc4\x9f\xc3\xa7e Kandemir - G\xc3\xbcl\xc3\xbc Soldurmam" \n
Run Code Online (Sandbox Code Playgroud)\n\n

我该如何转换它?

\n

c# encoding

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