示例#1
0
        public GifskiInterop()
        {
            #region Get Gifski version

            var info = new FileInfo(UserSettings.All.GifskiLocation);
            info.Refresh();

            Version = info.Length == 502_208 ? new Version(0, 9, 3) : new Version(0, 0);

            #endregion

            #region Load functions

            _new          = (NewDelegate)FunctionLoader.LoadFunction <NewDelegate>(UserSettings.All.GifskiLocation, "gifski_new");
            _addPngFrame  = (AddPngFrameDelegate)FunctionLoader.LoadFunction <AddPngFrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_png_file");
            _addRgbaFrame = (AddRgbaFrameDelegate)FunctionLoader.LoadFunction <AddRgbaFrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_rgba");

            if (Version.Major == 0 && Version.Minor < 9)
            {
                //Older versions of the library.
                _endAddingFrames = (EndAddingFramesDelegate)FunctionLoader.LoadFunction <EndAddingFramesDelegate>(UserSettings.All.GifskiLocation, "gifski_end_adding_frames");
                _write           = (WriteDelegate)FunctionLoader.LoadFunction <WriteDelegate>(UserSettings.All.GifskiLocation, "gifski_write");
                _drop            = (DropDelegate)FunctionLoader.LoadFunction <DropDelegate>(UserSettings.All.GifskiLocation, "gifski_drop");
            }
            else
            {
                //Newer versions.
                _setFileOutput = (SetFileOutputDelegate)FunctionLoader.LoadFunction <SetFileOutputDelegate>(UserSettings.All.GifskiLocation, "gifski_set_file_output");
                _finish        = (FinishDelegate)FunctionLoader.LoadFunction <FinishDelegate>(UserSettings.All.GifskiLocation, "gifski_finish");
            }

            #endregion
        }
示例#2
0
        internal Deflater(object deflaterInstance)
        {
            Type type = deflaterInstance.GetType();

            setLevelMethod = (SetLevelDelegate)Delegate.CreateDelegate(
                typeof(SetLevelDelegate),
                deflaterInstance,
                type.GetMethod("SetLevel", new Type[] { typeof(int) }));

            setInputMethod = (SetInputDelegate)Delegate.CreateDelegate(
                typeof(SetInputDelegate),
                deflaterInstance,
                type.GetMethod("SetInput", new Type[] { typeof(byte[]), typeof(int), typeof(int) }));

            finishMethod = (FinishDelegate)Delegate.CreateDelegate(
                typeof(FinishDelegate),
                deflaterInstance,
                type.GetMethod("Finish", Type.EmptyTypes));

            getIsFinishedMethod = (GetIsFinishedDelegate)Delegate.CreateDelegate(
                typeof(GetIsFinishedDelegate),
                deflaterInstance,
                type.GetMethod("get_IsFinished", Type.EmptyTypes));

            deflateMethod = (DeflateDelegate)Delegate.CreateDelegate(
                typeof(DeflateDelegate),
                deflaterInstance,
                type.GetMethod("Deflate", new Type[] { typeof(byte[]) }));
        }
示例#3
0
 public void StartCreateBot2(int totalCount, string pre, CreateDelegate createDelegate,
                             FinishDelegate finishDelegate)
 {
     for (int i = 0; i < totalCount; i++)
     {
         try
         {
             string fullName = pre + i;
             ManagerCore.Instance.GetUserByAccount(fullName, "emulator", 1);
             int tempid   = RandomHelper.GetInt32(1, 8);
             var response = ManagerCore.Instance.RegisterManager(fullName, fullName, "1", tempid, true, "0:0:0:0");
             if (response.Code == (int)MessageCode.Success)
             {
                 //LadderCore.Instance.GetLadderManager(response.Data);
                 Dispatcher.Invoke((Action) delegate { createDelegate(""); });
             }
             else
             {
                 Dispatcher.Invoke((Action) delegate { createDelegate(EmulatorHelper.BuildErrorinfo(response.Code)); });
                 return;
             }
         }
         catch (Exception ex)
         {
             LogHelper.Insert(ex);
             Dispatcher.Invoke((Action) delegate { createDelegate(ex.Message); });
             return;
         }
     }
     Dispatcher.Invoke((Action) delegate { finishDelegate(); });
 }
示例#4
0
        internal Deflater(object deflaterInstance)
        {
            Type type = deflaterInstance.GetType();

            setLevelMethod = (SetLevelDelegate)Delegate.CreateDelegate(
                typeof(SetLevelDelegate),
                deflaterInstance,
                type.GetMethod("SetLevel", new Type[] { typeof(int) }));

            setInputMethod = (SetInputDelegate)Delegate.CreateDelegate(
                typeof(SetInputDelegate),
                deflaterInstance,
                type.GetMethod("SetInput", new Type[] { typeof(byte[]), typeof(int), typeof(int) }));

            finishMethod = (FinishDelegate)Delegate.CreateDelegate(
                typeof(FinishDelegate),
                deflaterInstance,
                type.GetMethod("Finish", Type.EmptyTypes));

            getIsFinishedMethod = (GetIsFinishedDelegate)Delegate.CreateDelegate(
                typeof(GetIsFinishedDelegate),
                deflaterInstance,
                type.GetMethod("get_IsFinished", Type.EmptyTypes));

            deflateMethod = (DeflateDelegate)Delegate.CreateDelegate(
                typeof(DeflateDelegate),
                deflaterInstance,
                type.GetMethod("Deflate", new Type[] { typeof(byte[]) }));
        }
示例#5
0
        public GifskiInterop()
        {
            #region Get Gifski version

            var info = new FileInfo(UserSettings.All.GifskiLocation);
            info.Refresh();

            //I really need another way to differentiate gifski versions.
            switch (info.Length)
            {
            case 524_752:
                Version = new Version(1, 2, 0);
                break;

            case 502_720:
                Version = new Version(0, 10, 2);
                break;

            case 502_208:
                Version = new Version(0, 9, 3);
                break;

            default:
                Version = new Version(0, 0);
                break;
            }

            #endregion

            #region Load functions

            _new         = (NewDelegate)FunctionLoader.LoadFunction <NewDelegate>(UserSettings.All.GifskiLocation, "gifski_new");
            _addPngFrame = (AddPngFrameDelegate)FunctionLoader.LoadFunction <AddPngFrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_png_file");
            //_addRgbaFrame = (AddRgbaFrameDelegate)FunctionLoader.LoadFunction<AddRgbaFrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_rgba");

            if (Version.Major == 0 && Version.Minor < 10)
            {
                _addRgbFrame = (AddRgbFrameDelegate)FunctionLoader.LoadFunction <AddRgbFrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_rgb");
            }
            else
            {
                _addRgb2Frame = (AddRgb2FrameDelegate)FunctionLoader.LoadFunction <AddRgb2FrameDelegate>(UserSettings.All.GifskiLocation, "gifski_add_frame_rgb");
            }

            if (Version.Major == 0 && Version.Minor < 9)
            {
                //Older versions of the library.
                _endAddingFrames = (EndAddingFramesDelegate)FunctionLoader.LoadFunction <EndAddingFramesDelegate>(UserSettings.All.GifskiLocation, "gifski_end_adding_frames");
                _write           = (WriteDelegate)FunctionLoader.LoadFunction <WriteDelegate>(UserSettings.All.GifskiLocation, "gifski_write");
                _drop            = (DropDelegate)FunctionLoader.LoadFunction <DropDelegate>(UserSettings.All.GifskiLocation, "gifski_drop");
            }
            else
            {
                //Newer versions.
                _setFileOutput = (SetFileOutputDelegate)FunctionLoader.LoadFunction <SetFileOutputDelegate>(UserSettings.All.GifskiLocation, "gifski_set_file_output");
                _finish        = (FinishDelegate)FunctionLoader.LoadFunction <FinishDelegate>(UserSettings.All.GifskiLocation, "gifski_finish");
            }

            #endregion
        }
示例#6
0
        /// <summary>
        /// 下载
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="sizeData"></param>
        /// <param name="finishCallBack"></param>
        public void BeginDownLoadAsset(DownLoadType type, AssetUpdateMgr parent, DownloadAssetSizeCaculate sizeData, FinishDelegate finishCallBack)
        {
            mDownloadType = type;
            mParent       = parent;
            mCurrentDownloadAssetSizeCaculate = sizeData;
            mFinishCallBack = finishCallBack;

            if (null == sizeData.mVersionDataConfig || 0 == sizeData.mVersionDataConfig.Count)
            {
                CallBackDownLoadSucess();

                return;
            }

            mNewVersionDataConfig = sizeData.mVersionDataConfig;
            mAllVersionDataDic.Clear();

            if (mDownloadType == DownLoadType.FIRST_PHASE && null != mParent)
            {
                mParent.UpdateProgress("开始下载更新资源文件", 0);
            }

            mMaxDownLoadCount = mDownloadType == DownLoadType.FIRST_PHASE ? 8 : 3;
            DownLoadAsset();
            mDownLoadAssetCount = mNewVersionDataConfig.Count;
        }
示例#7
0
 public void execute(FinishDelegate callback)
 {
     Console.WriteLine("execute");
     if (callback != null)
     {
         callback(true, "NO_ERROR");
     }
 }
示例#8
0
        public void startDecryptionProcess(UpdateDelegate pUpdate, FinishDelegate pFinish, ErrorDelegate pError)
        {
            StringBuilder userName = new StringBuilder(Convert.ToInt32(maxUserNameLength));
            RetCode       ret      = startDecryption(pUpdate, pFinish, pError);

            if (RetCode.NoError != ret)
            {
                Auxiliary.Logger._log.Error("Can't start decryption process with :" + ret);
                throw new System.Exception("Error: start encryption");
            }
        }
示例#9
0
    public DelegateSample()
    {
        // デリゲートの生成
        FinishDelegate fd = delegate(bool isSuccess, string errorCode) {
            Console.WriteLine(string.Format(
                                  "isSuccess = {0}, errorCode = {1}", isSuccess, errorCode));
        };

        User user = new User();

        user.execute(fd); // コールバック
    }
示例#10
0
        /// <summary>
        /// Initializes a new instance of the FormParser class.
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="fileName"></param>
        public FormParser(Settings settings, string fileName)
        {
            this.settings    = settings;
            this.fileName    = fileName;
            this.logParser   = new LogParser(this, settings, fileName);
            this.parseThread = new Thread(new ThreadStart(logParser.Parse));
            this.setProgressBarMaximumDelegate = new SetProgressBarMaximumDelegate(SetProgressBarMaximum);
            this.setProgressDelegate           = new SetProgressDelegate(SetProgress);
            this.finish = new FinishDelegate(Finish);
            InitializeComponent();
            Assembly asm = Assembly.GetExecutingAssembly();

            this.Text += string.Format(" {0}", asm.GetName().Version.ToString());
        }
示例#11
0
文件: Form1.cs 项目: Grukz/Sample
        // 非同期処理ボタンメソッドAsyncButton.
        public void AsyncButton()
        {
            // RunningDelegateの生成.
            RunningDelegate running = new RunningDelegate(Running); // runningの生成.
            IAsyncResult    iar1    = button1.BeginInvoke(running); // button1.BeginInvokeでrunningが持つメソッドに委譲.

            button1.EndInvoke(iar1);                                // button1.EndInvokeで完了.

            // 10秒待つ.(擬似的な重たい処理.)
            Thread.Sleep(10000);    // Thread.Sleepで10秒休止.

            // FinishDelegateの生成.
            FinishDelegate finish = new FinishDelegate(Finish);  // finishの生成.
            IAsyncResult   iar2   = button1.BeginInvoke(finish); // button1.BeginInvokeでfinishが持つメソッドに委譲.

            button1.EndInvoke(iar2);                             // button1.EndInvokeで完了.
        }
示例#12
0
        public void Start(int totalCount, CreateDelegate createDelegate, FinishDelegate finishDelegate)
        {
            List <DicPlayerEntity> list = DicPlayerMgr.GetAllForCache();

            for (int i = 0; i < totalCount; i++)
            {
                try
                {
                    CreateTemplate(list);
                    Dispatcher.Invoke((Action) delegate { createDelegate(true); });
                }
                catch (Exception ex)
                {
                    LogHelper.Insert(ex);
                    Dispatcher.Invoke((Action) delegate { createDelegate(false); });
                }
            }
            Dispatcher.Invoke((Action) delegate { finishDelegate(); });
        }
示例#13
0
 private void UpdateForFinished()
 {
     // Is this method on the UI thread? If not then we need to marshal it to the UI thread.
     if (this.InvokeRequired)
     {
         FinishDelegate finishDelegate = new FinishDelegate(UpdateForFinished);
         Invoke(finishDelegate);
     }
     else
     {
         if (this.textBoxState.Text != "Completed" && !Abort.Status)
         {
             DispatchStartMessage();
         }
         else
         {
             this.buttonStart.Enabled = true;
         }
     }
 }
示例#14
0
 public void dailyGoalAni(float percentOfDailyGoal, string barType, FinishDelegate callBack)
 {
     if (handle.activeInHierarchy)
     {
         float process = (float)(percentOfDailyGoal / 0.3);
         Slider1.DOValue(process, 1.0f).onComplete = delegate() {
             if (barType != "normal")
             {
                 setAwardAndHandle(percentOfDailyGoal);
             }
             callBack();
         };
     }
     else if (handle1.activeInHierarchy)
     {
         Slider1.value = 1.0f;
         float process = (float)((percentOfDailyGoal - 0.3) / 0.3);
         Slider2.DOValue(process, 1.0f).onComplete = delegate() {
             if (barType != "normal")
             {
                 setAwardAndHandle(percentOfDailyGoal);
             }
             callBack();
         };
     }
     else if (handle2.activeInHierarchy)
     {
         Slider1.value = 1.0f;
         Slider2.value = 1.0f;
         float process = (float)((percentOfDailyGoal - 0.6) / 0.4);
         Slider3.DOValue(process, 1.0f).onComplete = delegate() {
             if (barType != "normal")
             {
                 setAwardAndHandle(percentOfDailyGoal);
             }
             callBack();
         };
     }
 }
示例#15
0
        public MainWindow()
        {
            InitializeComponent();
            _log                  = new ObservableCollection <string>();
            Log.ItemsSource       = _log;
            Topmost               = true;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            //_updateProcess = Process.Start(@"\update progress.exe");

            worker = new BackgroundWorker
            {
                WorkerReportsProgress      = true,
                WorkerSupportsCancellation = true
            };
            worker.DoWork             += bgWorker_DoWork;
            worker.ProgressChanged    += bgWorker_ProgressChanged;
            worker.RunWorkerCompleted += bgWorker_RunWorkerCompleted;
            worker.RunWorkerAsync();

            _report  = Report;
            _finish  = FinishUpdate;
            _disable = Disable;
        }
示例#16
0
 static extern RetCode startDecryption([MarshalAs(UnmanagedType.FunctionPtr)] UpdateDelegate pUpdate, [MarshalAs(UnmanagedType.FunctionPtr)] FinishDelegate pFinish, ErrorDelegate pError);
示例#17
0
 private void UpdateForFinished()
 {
     // Is this method on the UI thread? If not then we need to marshal it to the UI thread.
     if (this.InvokeRequired)
     {
         FinishDelegate finishDelegate = new FinishDelegate(UpdateForFinished);
         Invoke(finishDelegate);
     }
     else
     {
         if (this.textBoxState.Text != "Completed" && !Abort.Status)
         {
             DispatchStartMessage();
         }
         else
         {
             this.buttonStart.Enabled = true;
         }
     }
 }
示例#18
0
        void CreateMatch(MatchInput transfer, int matchTimes, bool needStatistics, CreateDelegate createDelegate, FinishDelegate finishDelegate)
        {
            int i    = 1;
            var hmid = transfer.HomeManager.Mid;
            var amid = transfer.AwayManager.Mid;

            while (i <= matchTimes)
            {
                if (transfer != null)
                {
                    var watch = new System.Diagnostics.Stopwatch();
                    watch.Start();
                    transfer.MatchId = ShareUtil.GenerateComb();

                    try
                    {
                        IMatch match = new MatchEntity(transfer);

                        if (needStatistics)
                        {
                            statisticsMatch = new StatisticsMatchEntity(match);
                        }
                        EmulatorHelper.CreateMatch(match, statisticsMatch);
                        var  result = match.Report;
                        long cost   = watch.ElapsedMilliseconds;

                        _testStatisticsDic.Add(i, statisticsMatch);
                        _testMatchEntityDic.Add(i, result);
                        Dispatcher.Invoke((Action) delegate { createDelegate(transfer.MatchId, i, cost, result); });
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Insert(ex);
                    }
                }
                i++;
            }
            Dispatcher.Invoke((Action) delegate { finishDelegate(); });
        }
示例#19
0
        public void StartCreateBot(int totalCount, string pre, CreateDelegate createDelegate, FinishDelegate finishDelegate)
        {
            for (int i = 0; i < totalCount; i++)
            {
                try
                {
                    string fullName = pre + i;

                    var response = ManagerCore.Instance.CreateManager(fullName);
                    if (response.Code == (int)MessageCode.Success)
                    {
                        Dispatcher.Invoke((Action) delegate { createDelegate(""); });
                    }
                    else
                    {
                        Dispatcher.Invoke((Action) delegate { createDelegate(EmulatorHelper.BuildErrorinfo(response.Code)); });
                        return;
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Insert(ex);
                    Dispatcher.Invoke((Action) delegate { createDelegate(ex.Message); });
                    return;
                }
            }
            Dispatcher.Invoke((Action) delegate { finishDelegate(); });
        }
示例#20
0
 public static void Play2D(string _package, string _file, int _track, FinishDelegate _finish)
 {
     VRXX.Action.Sound.Play2D.Play(_package, _file, _track, _finish);
 }