Example #1
0
 public void onNotify(Completed.GameManager.GameEvent e)
 {
     if (e.type == Completed.GameManager.EventType.DATA_EVENT)
     {
         //Debug.Log (e.data);
     }
 }
        public void LoadTiles(JsonTileMap jsonTileMap, Completed completed)
        {
            int height = jsonTileMap.MapHeight * jsonTileMap.TileHeight;
            int width = jsonTileMap.MapWidth * jsonTileMap.TileWidth;

            for (int x = 0; x < width; x += jsonTileMap.TileWidth) {
                for (int y = 0; y < height; y += jsonTileMap.TileHeight) {
                    //load just the xy width*height of the canvas into a tile object for caching mostly.
                    var tile = new Tile(x, y, jsonTileMap);
                    //store each tile in a hash of name-x-y
                    loadedTiles[tile.Key] = tile;
                }
            }
            completed();
        }
        public void LoadTiles(JsonTileMap jsonTileMap, ImageElement tileImage, Completed completed)
        {
            var canvas = CanvasInformation.Create(tileImage);

            int height = jsonTileMap.MapHeight * jsonTileMap.TileHeight;
            int width = jsonTileMap.MapWidth * jsonTileMap.TileWidth;

            for (int x = 0; x < width; x += jsonTileMap.TileWidth) {
                for (int y = 0; y < height; y += jsonTileMap.TileHeight) {
                    //load just the xy width*height of the canvas into a tile object for caching mostly.
                    var tile = new DrawTile(canvas, x, y, jsonTileMap);
                    //store each tile in a hash of name-x-y
                    loadedTiles[tile.Key] = tile;
                }
            }
            completed();
        }
 public void CompleteRequest()
 {
     Completed.TrySetResult(null);
 }
Example #5
0
 public override bool CompleteAs(ref State state, Completed completedState)
 {
     var s = Interlocked.CompareExchange(ref state, completedState, this);
     if (s != this) {
         //log mismatch... ?
         return s.CompleteAs(ref state, completedState);
     }
     return true;
 }
Example #6
0
 protected override bool OnBackgroundClicked()
 {
     Completed?.Invoke(this, new List <PopData>());
     return(true);
 }
Example #7
0
 /// <summary>
 /// 取消
 /// </summary>
 /// <param name="Sender"></param>
 /// <param name="args"></param>
 public void Cancel_Clicked(Object Sender, EventArgs args)
 {
     Completed?.Invoke(this, new List <PopData>());
     CloseAllPopup();
 }
Example #8
0
 /// <summary>
 ///     Called to trigger <see cref="Completed" /> event.
 /// </summary>
 protected virtual void OnCompleted()
 {
     Completed.InvokeSafely(this);
 }
Example #9
0
        private void InterstitialAd_adduplex_AdClicked(object sender, InterstitialAdClickEventArgs e)
        {
            HockeyClient.Current.TrackEvent("Adduplex Ads clicked");

            Completed?.Invoke();
        }
 public void LoadTiles(JsonTileMap jsonTileMap, Completed completed)
 {
     TileManager.LoadTiles(jsonTileMap, completed);
 }
 protected virtual void OnCompleted(DownloadProgressCompleted e) => Completed?.Invoke(this, e);
Example #12
0
        public string body;             // and body

        public string Info()            // looking at state
        {
            return(Mission.MissionInformation() + ((Completed != null) ? (Environment.NewLine + Completed.MissionInformation()) : ""));
        }
Example #13
0
 private void IntTaskSocketAsyncEventArgs_Completed(object sender, TaskSocketAsyncEventArgs <int> e)
 {
     Completed?.Invoke(sender, this);
 }
Example #14
0
 public void Dispose()
 {
     IsCompleted = true;
     Completed?.Invoke(this, EventArgs.Empty);
 }
Example #15
0
        public void Search()
        {
            string[]    keyPaths = { @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run",
                                     @"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce",
                                     @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run",
                                     @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\RunOnce" };
            RegistryKey key;
            RegistryKey subKey = null;

            ResultCount = 0;
            foreach (var item in keyPaths)
            {
                foreach (var regHive in new RegistryHive[] { RegistryHive.LocalMachine, RegistryHive.CurrentUser })
                {
                    try
                    {
                        key    = RegistryKey.OpenBaseKey(regHive, RegistryView.Default);
                        subKey = key.OpenSubKey(item);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                        subKey?.Close();
                        continue;
                    }
                    if (subKey != null)
                    {
                        SearchInRegistry(subKey, key);
                        subKey.Close();
                    }
                }
            }
            ;

            string shellFolders    = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders";
            string startupApproved = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\StartupFolder";

            RegistryKey startupApprovedKey = null;
            object      startupFolder;

            foreach (var regHive in new RegistryHive[] { RegistryHive.LocalMachine, RegistryHive.CurrentUser })
            {
                try
                {
                    key    = RegistryKey.OpenBaseKey(regHive, RegistryView.Default);
                    subKey = key.OpenSubKey(shellFolders);

                    if (regHive == RegistryHive.CurrentUser)
                    {
                        startupFolder = subKey?.GetValue("Startup");
                    }
                    else
                    {
                        startupFolder = subKey?.GetValue("Common Startup");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                    continue;
                }
                finally
                {
                    subKey?.Close();
                }

                if ((startupFolder == null))
                {
                    MessageBox.Show("Не удалось получить данные о каталоге 'Автозагрузка'", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                    startupApprovedKey?.Close();
                    continue;
                }

                try
                {
                    startupApprovedKey = key.OpenSubKey(startupApproved, true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                SearchInStartMenu(startupFolder.ToString(), startupApprovedKey);
            }
            Completed?.Invoke(ResultCount);
        }
Example #16
0
 protected virtual void OnCompleted()
 {
     IsCompleted = true;
     Completed?.Invoke(this, EventArgs.Empty);
 }
Example #17
0
        void scan_ScanCompleted(object sender, ScanCompletedEventArgs e)
        {
            if (this.InvokeRequired)
            {
                Completed completed = new Completed(scan_ScanCompleted);
                this.Invoke(completed, new object[] { sender, e });
            }
            else
            {
                if (!Canceled)
                {
                    //addressListView.EndUpdate();
                    //addressListView.ResumeLayout();
                    ProgressBar.Value = 0;

                    int TotalFound = (int)(e.TotalFoundSize / (Int64)DataTypeSize.Int64);

                    if (TotalFound > 0)
                    {
                        CurrentScanAddresses = MemoryMappedFile.CreateFromFile(@ExecutablePath + @"/Scan Data/CurrentScanAddresses", FileMode.Open, "CurrentScanAddresses", e.TotalFoundSize);
                        CurrentAddressAccessor = CurrentScanAddresses.CreateViewAccessor(0, e.TotalFoundSize);
                    }

                    AddressCount.Text = "Items: " + TotalFound.ToString();
                    AddressListView.VirtualListSize = TotalFound;

                    NewScanButton.Enabled = true;
                    AbortScanButton.Enabled = false;
                    UpdateFoundTimer.Enabled = true;
                    NextScanButton.Enabled = true;
                    UndoScanButton.Enabled = true;
                }
            }
        }
Example #18
0
 public void OnCompleted()
 {
     Completed?.Invoke();
 }
Example #19
0
 public Task CompleteAsync()
 {
     IsCompleted = true;
     Completed?.Invoke(this, EventArgs.Empty);
     return(Task.CompletedTask);
 }
Example #20
0
 private void Batch_Completed(object sender, CompositionBatchCompletedEventArgs args)
 {
     _manualResetEvent.Set();
     Completed?.Invoke(this, new EventArgs());
 }
Example #21
0
 protected virtual void OnCompleted(EventArgs e)
 => Completed?.Invoke(this, e);
Example #22
0
 public void Release()
 {
     Completed?.Invoke(this, EventArgs.Empty);
 }
        private async Task Decrypt(FileInfo file, FileInfo key, IProgress <long> progress, CancellationToken token)
        {
            RSA.RSAKeyPair?decryptKey = null;

            DecryptMessage = "키 불러오는 중...";
            await Task.Delay(500);

            using (var fs = key.OpenRead())
            {
                BinaryFormatter bf = new BinaryFormatter();
                decryptKey = bf.Deserialize(fs) as RSA.RSAKeyPair?;
            }

            string originalFileName;

            if (!ExtractFileName(file.Name, out originalFileName))
            {
                DecryptMessage = "파일 이름이 올바르지 않습니다.";
                await Task.Delay(500);

                return;
            }
            string originalExtension = ExtractExtension(originalFileName);


            if (decryptKey != null)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.FileName = originalFileName;
                if (!string.IsNullOrWhiteSpace(originalExtension))
                {
                    sfd.Filter = $"Original File|*.{originalExtension}";
                }

                if (sfd.ShowDialog() ?? false)
                {
                    Queue <byte> buffer = new Queue <byte>();
                    saveFilePath   = sfd.FileName;
                    DecryptMessage = "키 불러오기 완료.";
                    await Task.Delay(500);

                    RSA.RSAKeyPair keyPair = decryptKey.Value;


                    State       = RSA.EncryptionState.CreateMap;
                    MaxProgress = 255;
                    var map = await Decrypter.CreateByteMap(keyPair, progress);

                    var updateTick = EncryptViewModel.GetUpdateTick(EncryptedFileLength);

                    State       = RSA.EncryptionState.ConvertByte;
                    MaxProgress = EncryptedFileLength;
                    await Task.Delay(500);

                    using (var inStream = file.OpenRead())
                    {
                        using (var reader = new BinaryReader(inStream))
                        {
                            using (var outStream = File.OpenWrite(saveFilePath))
                            {
                                using (var writer = new BinaryWriter(outStream))
                                {
                                    timeHelper.Reset(EncryptedFileLength);
                                    for (long i = 0; i < EncryptedFileLength; i++)
                                    {
                                        token.ThrowIfCancellationRequested();
                                        byte b = reader.ReadByte();
                                        buffer.Enqueue(map[b]);
                                        if (i % updateTick == 0)
                                        {
                                            while (buffer.Count > 0)
                                            {
                                                writer.Write(buffer.Dequeue());
                                            }
                                            progress.Report(i);
                                            buffer.Clear();
                                            await Task.Delay(1);
                                        }
                                    }
                                    while (buffer.Count > 0)
                                    {
                                        writer.Write(buffer.Dequeue());
                                    }
                                    progress.Report(EncryptedFileLength);
                                }
                            }
                        }
                    }
                    DecryptMessage = "작업이 완료 되었습니다.";
                    var now = DateTime.Now;
                    Completed?.Invoke("작업 완료", $"완료 시간 : {now}\n걸린 시간 : {(now - timeHelper.StartTime).TotalSeconds} 초");
                }
                else
                {
                    DecryptMessage = "사용자가 작업을 취소했습니다.";
                }
            }
            else
            {
                DecryptMessage = "키가 잘못된 듯 합니다.";
            }
            await Task.Delay(500);
        }
Example #24
0
 private void OnCompleted()
 {
     Completed?.Invoke(this, EventArgs.Empty);
 }
Example #25
0
 public string FullInfo()    // DLL Uses this for mission info
 {
     return(Mission.MissionBasicInfo() + "," + Mission.MissionDetailedInfo() + ((Completed != null) ? (Environment.NewLine + Completed.MissionInformation()) : ""));
 }
Example #26
0
        public static async Task ReadFileandSaveAsync(IEnumerable <StorageFile> files)
        {
            var opr   = SQLOperator.Current();
            var total = files.Count();
            int i     = 1;

            var newlist = new List <SONG>();

            var durationFilter = Settings.Current.FileDurationFilterEnabled;
            var duration       = Convert.ToInt32(Settings.Current.FileDurationFilter);

            var scan           = Consts.Localizer.GetString("FileReadText");
            var oneDriveFailed = false;

            foreach (var file in files.OrderBy(f => f.Path))
            {
                try
                {
                    if (!file.IsAvailable || file.Attributes.HasFlag(FileAttributes.LocallyIncomplete))
                    {
                        if (file.Provider.Id != "OneDrive" || oneDriveFailed || !Settings.Current.OnedriveRoaming)
                        {
                            continue;
                        }
                        try
                        {
                            var oneDriveFile = await OneDrivePropertyProvider.GetOneDriveFilesAsync(file.Path);

                            var properties = oneDriveFile.OneDriveItem;
                            var audioProp  = properties.Audio;
                            var basic      = properties.LastModifiedDateTime ?? DateTimeOffset.MinValue;
                            if (durationFilter && audioProp.Duration < duration)
                            {
                                continue;
                            }
                            var artist    = audioProp?.Artist is null ? null : new[] { audioProp.Artist };
                            var composers = audioProp?.Composers is null ? null : new[] { audioProp.Composers };
                            var song      = await Song.CreateAsync(null, file.Path, (audioProp?.Title, audioProp?.Album, artist, artist, composers, null, TimeSpan.FromMilliseconds(audioProp?.Duration ?? 0), (uint)(audioProp?.Bitrate * 1000 ?? 0), 0, basic.DateTime), null, oneDriveFile);

                            var t = await opr.InsertSongAsync(song);

                            if (t != null)
                            {
                                newlist.Add(t);
                            }
                        }
                        catch
                        {
                            // Prevent another try by next file.
                            oneDriveFailed = true;
                            // Will be handled by outer catch block.
                            throw;
                        }
                    }
                    else
                    {
                        using (var tagTemp = File.Create(file.Path))
                        {
                            var prop = await file.Properties.GetMusicPropertiesAsync();

                            var d = prop.Duration.Milliseconds < 1 ? tagTemp.Properties.Duration : prop.Duration;

                            if (durationFilter && d.Milliseconds < duration)
                            {
                                continue;
                            }

                            var song = await Song.CreateAsync(tagTemp.Tag, file.Path, await file.GetViolatePropertiesAsync(), tagTemp.Properties, null);

                            var t = await opr.InsertSongAsync(song);

                            if (t != null)
                            {
                                newlist.Add(t);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    continue;
                }
                finally
                {
                    ProgressUpdated?.Invoke(null, new ProgressReport()
                    {
                        Description = SmartFormat.Smart.Format(scan, i, total), Current = i, Total = total, CanHide = true
                    });
                    i++;
                }
            }

            await RemoveDuplicateAsync();

            await SortAlbumsAsync();

            Completed?.Invoke(null, EventArgs.Empty);
        }
Example #27
0
 protected void OnCompleted(EventArgs e)
 {
     Completed?.Invoke(this, e);
 }
 internal void OnCompleted(ICommand result)
 {
     Completed?.Invoke(this, new ResultEventArgs {
         Result = result
     });
 }
Example #29
0
 protected override bool OnBackButtonPressed()
 {
     Completed?.Invoke(this, new List <PopData>());
     return(true);
 }
Example #30
0
 protected void OnCompleted(object sender, EventArgs args)
 {
     Completed?.Invoke(this, args);
 }
Example #31
0
 /// <summary>
 /// Mirrors <see cref="E:System.Windows.Media.Animation.Storyboard.Completed"/>.
 /// </summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void OnCompleted(object sender, EventArgs e)
 {
     Completed?.Invoke(this, e);
 }
Example #32
0
 public void InvokeCompleted()
 {
     Completed?.Invoke(this, null);
 }
Example #33
0
 public virtual bool CompleteAs(ref State state, Completed completedState)
 {
     return false;
 }
 public void SendCompleted()
 {
     Completed?.Invoke(this, EventArgs.Empty);
 }
Example #35
0
 public override bool CompleteAs(ref State state, Completed completedState)
 {
     var s = Interlocked.CompareExchange(ref state, completedState,  this);
     if (s != this) {
         //log mismatch... ?
         return s.CompleteAs(ref state, completedState);
     }
     var x = this;
     do {
         try {
             x.cont();
         } catch (Exception err) {
             //swallow error
             //TODO: log error
         }
         x = x.next;
     } while (x != null);
     return true;
 }
 public void Stop()
 {
     listenSocket.Close();
     Completed?.Invoke(null, ServerSocketAction.Close);
 }
    // This method is invoked when an asynchronous receive operation completes. 
    // If the remote host closed the connection, then the socket is closed.  
    // If data was received then the data is echoed back to the client.
    //
    private void ProcessReceive(SocketAsyncEventArgs e)
    {
        // check if the remote host closed the connection
        AsyncUserToken token = (AsyncUserToken)e.UserToken;
        if (e.BytesTransferred > 0 && e.SocketError == SocketError.Success)
        {
            //increment the count of the total bytes receive by the server
            Interlocked.Add(ref m_totalBytesRead, e.BytesTransferred);
            //Console.WriteLine("The server has read a total of {0} bytes", m_totalBytesRead);
            
            try
            {
//                // 消息提交外部的回调函数处理
//                Completed?.Invoke(e, ServerSocketAction.Receive);
//                receiveCallBack?.Invoke(e, e.Buffer, e.Offset, e.BytesTransferred);
//                
//                if (!token.Socket.ReceiveAsync(e))//为接收下一段数据,投递接收请求,这个函数有可能同步完成,这时返回false,并且不会引发SocketAsyncEventArgs.Completed事件
//                {
//                    //同步接收时处理接收完成事件
//                    ProcessReceive(e);
//                }

                // 真正的互联网环境下会有消息包被截断的情况,所以发送的时候必须在开始定义4个字节的包长度,目前是测试阶段,暂时不开放。
                //读取数据  
                byte[] data = new byte[e.BytesTransferred];
                //Log($"Server Found data received - {e.BytesTransferred} byts");
                Array.Copy(e.Buffer, e.Offset, data, 0, e.BytesTransferred);  
                lock (m_buffer)  
                {  
                    m_buffer.AddRange(data);  
                }  
  
                do  
                {  
                    //注意: 这里是需要和服务器有协议的,我做了个简单的协议,就是一个完整的包是包长(4字节)+包数据,便于处理,当然你可以定义自己需要的;   
                    //判断包的长度,前面4个字节.  
                    byte[] lenBytes = m_buffer.GetRange(0, 4).ToArray();  
                    int packageLen = BitConverter.ToInt32(lenBytes, 0);  
                    if (packageLen <= m_buffer.Count - 4)  
                    {  
                        //包够长时,则提取出来,交给后面的程序去处理  
                        byte[] rev = m_buffer.GetRange(4, packageLen).ToArray();  
                        //从数据池中移除这组数据,为什么要lock,你懂的  
                        lock (m_buffer)  
                        {  
                            m_buffer.RemoveRange(0, packageLen + 4);  
                        }  
                        //将数据包交给前台去处理  
                        Completed?.Invoke(e, ServerSocketAction.Receive);
                        receiveCallBack?.Invoke(e, rev, 0, rev.Length);
                    }  
                    else  
                    {   //长度不够,还得继续接收,需要跳出循环  
                        break;  
                    }  
                } while (m_buffer.Count > 4);  
                //注意:你一定会问,这里为什么要用do-while循环?     
                //如果当服务端发送大数据流的时候,e.BytesTransferred的大小就会比服务端发送过来的完整包要小,    
                //需要分多次接收.所以收到包的时候,先判断包头的大小.够一个完整的包再处理.    
                //如果服务器短时间内发送多个小数据包时, 这里可能会一次性把他们全收了.    
                //这样如果没有一个循环来控制,那么只会处理第一个包,    
                //剩下的包全部留在m_buffer中了,只有等下一个数据包过来后,才会放出一个来.  
                //继续接收  
                if (!token.Socket.ReceiveAsync(e))
                {
                    ProcessReceive(e);
                }
            }
            catch (Exception exp)
            {
                int size = e.BytesTransferred;
                string dataStr = System.Text.Encoding.UTF8.GetString(e.Buffer);
                string errorMsg = $"Server ProcessReceive() Exception - size:{size} - data:{dataStr} - {exp}";
                e.SetBuffer(System.Text.Encoding.UTF8.GetBytes(errorMsg), 0, errorMsg.Length);
                Completed?.Invoke(e, ServerSocketAction.Error);
                throw;
            }
        }
        else
        {
            Log($"MicrosfotServer ProcessReceive Error - SocketError : {e.SocketError}");
            CloseClientSocket(e);
        }
    }
Example #38
0
 public void InvokeCompleted()
 {
     Completed?.Invoke(this, null);
     CompletedCommand?.Execute(null);
 }
 public void LoadTiles(JsonTileMap jsonTileMap, Completed completed)
 {
     CHelp.LoadImageFromUrl(jsonTileMap.TileMapURL,
                            (image) => { ( (DrawTileManager) TileManager ).LoadTiles(jsonTileMap, image, completed); });
 }
Example #40
0
 public void Add(int a, int b, Completed msg)
 {
     msg("Result sum is " + (a + b));
 }