Esempio n. 1
0
            public void Init(Main main)
            {
                this.main = main;
                var reg = GetRegPath();

                Active       = (int)reg.GetValue("ACTIVE", 1) > 0;
                Mute         = (int)reg.GetValue("MUTE", 0) > 0;
                Solo         = (int)reg.GetValue("SOLO", 0) > 0;
                Port         = (int)reg.GetValue("PORT", Port);
                FileTransfer = (FileTransferFlag)reg.GetValue("FILE", FileTransfer);
                Notify       = (NotifyFlag)reg.GetValue("NOTIFY", Notify);

                if (reg.GetValue("HOSTS", null) is string hosts2)
                {
                    var hosts = hosts2.Split('|');
                    foreach (var host in hosts)
                    {
                        main.AddHost(host);
                    }
                }

                main.__file0.Tag    = FileTransferFlag.Block;
                main.__file1.Tag    = FileTransferFlag.Single;
                main.__file2.Tag    = FileTransferFlag.Allow;
                main.__notify0.Tag  = NotifyFlag.Silent;
                main.__notify1.Tag  = NotifyFlag.Informative;
                main.__notify2.Tag  = NotifyFlag.Verbose;
                main.__version.Text = "v" + Utility.GetVersion();
                Validate();
            }
Esempio n. 2
0
 public void Reset()
 {
     Active       = true;
     Mute         = false;
     Solo         = false;
     Port         = 5000;
     FileTransfer = FileTransferFlag.Allow;
     Notify       = NotifyFlag.Informative;
     Validate(true);
 }
        private void OnFileTransferProgressEventHandler(RemoteFileAdapterHandler adapterHandler, FileTransferFlag state, string fileName, long position, long fileSize)
        {
            if (this.RemoteFileAdapterHandler.WhetherClose)//UI未关闭时才允许操作控件
            {
                return;
            }

            switch (state)
            {
            case FileTransferFlag.Begin:
                if (fileSize > 0)
                {
                    this.transferProgress.Value = Convert.ToInt32(position / (float)fileSize * 100);
                }
                this.transferDatalenght.Text = $"已传输{FileHelper.LengthToFileSize(position).PadRight(10)}";
                this.time.Text = "传输时间:{0}s".FormatTo((DateTime.Now - _startTime).TotalSeconds.ToString("0"));
                break;

            case FileTransferFlag.Transfering:
                this.transferProgress.Value  = Convert.ToInt32(position / (float)fileSize * 100);
                this.transferCaption.Text    = $"正在传输:{Path.GetFileName(fileName)} 文件大小:{FileHelper.LengthToFileSize(fileSize)}";
                this.transferDatalenght.Text = $"已传输:{FileHelper.LengthToFileSize(position).PadRight(10)}";
                this.time.Text = "传输时间:{0}s".FormatTo((DateTime.Now - _startTime).TotalSeconds.ToString("0"));
                break;

            case FileTransferFlag.End:
                this.transferProgress.Value  = 0;
                this.transferCaption.Text    = $"目录装载完成";
                this.transferDatalenght.Text = "已传输0KB";
                break;
            }
        }