Exemple #1
0
        private void RefreshLoyat()
        {
            PageCount = 1;
            double lineWidth  = 0;
            double lineHeight = 0;

            foreach (UIElement child in InternalChildren)
            {
                if (lineWidth + child.RenderSize.Width > _pageWidth)
                {
                    lineHeight += child.RenderSize.Height;
                    lineWidth   = 0;
                }
                if (lineHeight + child.RenderSize.Height > _pageHeight)
                {
                    lineHeight = 0;
                    lineWidth  = 0;
                    PageCount++;
                }

                child.Arrange(new Rect((PageCount - 1) * _pageWidth + lineWidth, lineHeight,
                                       child.RenderSize.Width, child.RenderSize.Height));
                lineWidth += child.RenderSize.Width;
            }
            OnLoad?.Invoke(this, null);
            CurrentPage = 0;
        }
 public ILocalSettingsService Load()
 {
     try
     {
         if (Info.Exists)
         {
             using (StreamReader streamReader = new StreamReader($"{FilePath}/{Filename}"))
             {
                 var data = streamReader.ReadToEnd();
                 OnLoad?.Invoke(data);
                 config = JsonSerializer.Deserialize <LocalSettings>(data, Options);
             }
         }
         else
         {
             config = LocalSettings.Default;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("configuration not found. use default configuration."); //replace to logger
         config = LocalSettings.Default;
     }
     finally
     {
         Save();
     }
     return(this);
 }
Exemple #3
0
 public async void RaiseOnLoad()
 {
     if (OnLoad != null)
     {
         await OnLoad.Invoke();
     }
 }
Exemple #4
0
 public void LoadCloudSave(PlayerData playerData)
 {
     PlayerData = playerData;
     MergeSaveIntoInitialData();
     CharacterSelector.RefreshCurrentCharacterDisplay();
     OnLoad?.Invoke();
 }
Exemple #5
0
 static public void InvokeOnLoad()
 {
     if (OnLoad != null)
     {
         OnLoad.Invoke(null, new EventArgs());
     }
 }
        private void _lifeStream_OnMessageReceived(MessageReader reader)
        {
            STCHeader header = (STCHeader)reader.ReadShort();

            switch (header)
            {
            case STCHeader.REQUEST_PLATFORM_TYPE:
                _sessionId = reader.ReadInt();
                MessageWriter message = new MessageWriter(CTSHeader.HELLO_ACK);
                message.WriteInt(0);
                _lifeStream.Send(message);
                break;

            case STCHeader.REQUEST_PIPE_CONNECTION:
                string pipeName = reader.ReadString();
                _messageStream = new IPCStream(pipeName);
                _messageStream.OnMessageReceived    += _messageStream_OnMessageReceived;
                _messageStream.OnClientDisconnected += _messageStream_OnClientDisconnected;
                _messageStream.Send(new MessageWriter(CTSHeader.READY_CONNECTION_ACK));

                if (OnLoad != null)
                {
                    OnLoad.Invoke();
                }
                break;
            }
        }
Exemple #7
0
 protected void NotifyOnLoad()
 {
     if (OnLoad != null)
     {
         OnLoad.Invoke(this);
     }
 }
Exemple #8
0
        public void Load()
        {
            string path = Setup.ConfigRootPath + "PVPCharacterPicker" + LoadSlot + ".preset";

            //If preset exist
            if (File.Exists(path))
            {
                Settings.PlayableCharactersList.Clear();
                //Load config
                string[] presetLines = File.ReadAllLines(path);
                for (int i = 0; i < presetLines.Length; i++)
                {
                    //If not empty
                    if (presetLines[i].Length != 0)
                    {
                        //If not a comment
                        if (presetLines[i][0] != '#')
                        {
                            Settings.PlayableCharactersList.Add(presetLines[i]);
                        }
                    }
                }
            }
            OnLoad?.Invoke();
        }
        private IEnumerator LoadSequence(List <SaveData> saveData)
        {
            Processing = true;
            yield return(new WaitForSecondsRealtime(0.5f));

            yield return(new WaitForSecondsRealtime(loadDelay));

            for (int i = 0; i < saveData.Count; i++)
            {
                SaveData  data     = saveData[i];
                ISaveable saveable = saveables.SingleOrDefault(x => x.Id == data.id);
                if (saveable != null && saveable.ToString() != "null")
                {
                    saveable.Load(data);
                }
            }

            Processing = false;

            ClearTrash();
            List <ISaveable> redundant = saveables.Where(x => !saveData.Any(y => y.id == x.Id)).ToList();

            for (int i = redundant.Count - 1; i >= 0; i--)
            {
                Destroy(redundant[i].GO);
            }

            DevTools.Instance().DisableAll();
            yield return(new WaitForEndOfFrame());

            onLoad?.Invoke();
        }
Exemple #10
0
 internal void Close()
 {
     managers.WriteLine("Calling close-event on factories & managers", "HostContext");
     if (OnLoad != null)
     {
         OnLoad.Invoke(this, EventArgs.Empty);
     }
 }
Exemple #11
0
 public void Load()
 {
     list = BirthDayDesirealize(fileName);
     if (list != null)
     {
         OnLoad?.Invoke(this);
     }
 }
Exemple #12
0
        /// <summary>
        /// Construct stage and build early scene resources, or load a previously saved app state.
        /// </summary>
        /// <param name="entryPoint"></param>
        public void Load(String entryPoint)
        {
            // Use Load to handle any remaining setup, and to initiate the async creation of objects and loading
            // of resources. If you need to create any temporary files or data, such as procedurally generated
            // assets, do it here too.
            Debug.LogMessage("App.Load");

            OnLoad?.Invoke(this, new EventArgs()); // Does this make sense if SceneManager is constructed in the method.
        }
Exemple #13
0
    // Use this for initialization
    void Start()
    {
        MaxDashCount = DashCount;

        pointer         = Camera.main.GetComponent <PointerToPos>();
        pointer.OnFire += Pointer_OnDash;
        if (OnLoad != null)
        {
            OnLoad.Invoke(this);
        }
    }
Exemple #14
0
        public void Load(string filePath)
        {
            TmxMap map = Scene.Content.LoadTiledMap(filePath);

            tiledMap = Scene.AddEntity(new TiledMap(map));

            LoadSceneInfo();
            LoadBuildings();
            OnLoad?.Invoke();
            mapIsLoaded = true;
        }
Exemple #15
0
        public TopPalette(Camera camera, IScreenParentObject parent = null, MyTexture2D texture = null) : base(camera, PalettePosition, PaletteSize, parent, texture)
        {
            CreatePaletteButton("Save", t => OnSave?.Invoke());
            CreatePaletteButton("Load", t => OnLoad?.Invoke());
            CreatePaletteButton("Group", t => OnGroup?.Invoke());
            CreatePaletteButton("Ungroup", t => OnUnGroup?.Invoke());
            CreatePaletteButton("Remove", t => OnRemove?.Invoke());
            CreatePaletteButton("Undo remove", t => OnUndoRemove?.Invoke());
            CreatePaletteButton("Duplicate", t => OnDuplicate?.Invoke());

            ColorChanger.ResetColor(Color.LightGray);
        }
Exemple #16
0
        public void LoadSnapshot()
        {
            if (JsonSystem.GetJson(SNAPSHOT_NAME, out DataSnapshot snap))
            {
                this.Snapshot = snap;

                OnLoad?.Invoke(snap);

                return;
            }

            throw new Exception("Snapshot cannot be loaded.");
        }
Exemple #17
0
        private void Resuming(object sender, object args)
        {
            Debug.LogMessage("App.Resuming");
            // https://docs.microsoft.com/en-us/windows/uwp/launch-resume/resume-an-app
            // This is relevant to desktop apps, because it provides a mechanism for handling
            // change of focus from this app to another and back again.

            // Restore any data or state that was unloaded on suspend. By default, data and
            // state are persisted when resuming from suspend. Note that this event does not
            // occur if the app was previously terminated.

            OnLoad?.Invoke(this, new EventArgs());
        }
Exemple #18
0
 public void RequestLoaded(double fromX, double fromY, double toX, double toY)
 {
     for (int i = GMath.DivDown(GMath.Floor(fromX), CHUNK_SIZE); i < GMath.DivUp(GMath.Ceil(toX), CHUNK_SIZE); i++)
     {
         for (int j = GMath.DivDown(GMath.Floor(fromY), CHUNK_SIZE); j < GMath.DivUp(GMath.Ceil(toY), CHUNK_SIZE); j++)
         {
             if (!loadedChunks.Contains(new Vec2i(i, j)))
             {
                 OnLoad?.Invoke(i * CHUNK_SIZE, j * CHUNK_SIZE, (i + 1) * CHUNK_SIZE, (j + 1) * CHUNK_SIZE);
                 loadedChunks.Add(new Vec2i(i, j));
             }
         }
     }
 }
Exemple #19
0
        public static void Load(Assembly assembly, AppDomain appDomain = null)
        {
            if (libs.ContainsKey(assembly))
            {
                return;
            }
            var attrData = assembly.CustomAttributes
                           .FirstOrDefault(a => a.AttributeType == typeof(InitLoaderAttribute));

            if (attrData != null)
            {
                var p1            = attrData.ConstructorArguments[0];
                var initLoaderAtt = (InitLoaderAttribute)Activator.CreateInstance(
                    typeof(InitLoaderAttribute),
                    p1.Value);

                object t;
                if (appDomain is null)
                {
                    t = Activator.CreateInstance(initLoaderAtt.InitType);
                }
                else
                {
                    throw new NotImplementedException();
                    //t = appDomain.CreateInstanceAndUnwrap(
                    //    assembly.FullName,
                    //    initLoaderAtt.InitType.FullName);
                }

                if (t is LibInitializer init)
                {
                    LibInfo libInfo = new LibInfo(appDomain, assembly, init);
                    if (!(appDomain is null))
                    {
                        domainLibs.Add(appDomain, libInfo);
                    }
                    libs.Add(assembly, libInfo);
                    libInfo.Registers.ItemRegistered += Registers_MethodRegistered;
                    PreLoad?.Invoke(libInfo);
                    if (init is PlatformInitializer platformInitializer)
                    {
                        var platform = (PlatformRegister)Activator.CreateInstance(platformInitializer.PlatformType);
                        platformInitializer.Platform = platform;
                        libInfo.Registers.RegisterPlatform(platform);
                    }
                    init.Initialize(libInfo.Registers);
                    OnLoad?.Invoke(libInfo);
                }
            }
        }
        public void Run()
        {
            _world.Load();
            _server.Open();
            OnLoad?.Invoke(this);

            double ticksPerFrame = 1d / UpdatesPerSecond * TimeSpan.TicksPerSecond;

            _ticker.Start(TimeSpan.FromTicks((long)ticksPerFrame));

            _server.Close();
            _world.Unload();
            OnUnload?.Invoke(this);
        }
Exemple #21
0
        public void Load()
        {
            string path = Setup.ConfigRootPath + "PVPBanItem" + LoadSlot + ".preset";

            Settings.BannedItems.Clear();
            Settings.BannedEquipments.Clear();

            //If preset exist
            if (File.Exists(path))
            {
                //Load config
                string[] presetLines = File.ReadAllLines(path);
                for (int i = 0; i < presetLines.Length; i++)
                {
                    //If not empty
                    if (presetLines[i].Length != 0)
                    {
                        //If not a comment
                        if (presetLines[i][0] != '#')
                        {
                            char   identifier = char.ToUpperInvariant(presetLines[i][0]);
                            string entryID    = presetLines[i].Substring(1, presetLines[i].Length - 1);
                            if (identifier == char.ToUpperInvariant('I'))
                            {
                                if (int.TryParse(entryID, out int itemIndex))
                                {
                                    ItemIndex index = (ItemIndex)itemIndex;
                                    if (!Settings.BannedItems.ContainsKey(index))
                                    {
                                        Settings.BannedItems.Add(index, index);
                                    }
                                }
                            }
                            else if (identifier == char.ToUpperInvariant('E'))
                            {
                                if (int.TryParse(entryID, out int equipmentIndex))
                                {
                                    EquipmentIndex index = (EquipmentIndex)equipmentIndex;
                                    if (!Settings.BannedEquipments.ContainsKey(index))
                                    {
                                        Settings.BannedEquipments.Add(index, index);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            OnLoad?.Invoke();
        }
        public bool Load( )
        {
            if (!File.Exists(FileName))
            {
                return(false);
            }

            lock ( FileLock )
            {
                Collection = JsonConvert.DeserializeObject <TCollection> (File.ReadAllText(FileName),
                                                                          SerializerSettings);
                OnLoad?.Invoke(this);
            }

            return(true);
        }
Exemple #23
0
        private void ReLoad()
        {
            _logger.LogInformation("正在加载配置文件");

            YandeSetting.HotImg = _configuration.GetSection("Yande").GetSection("HotImg")
                                  .Get <YandeSetting.HotImgSetting>();
            YandeSetting.CustomTags = _configuration.GetSection("Yande").GetSection("CustomTags")
                                      .Get <YandeSetting.CustomTagsSetting[]>();

            TwitterSetting.Monitor = _configuration.GetSection("Twitter").GetSection("Monitor")
                                     .Get <TwitterSetting.MonitorSetting[]>().ToDictionary(m => m.Name);

            BiliSetting = _configuration.GetSection("BiliBili").Get <BiliSetting>();

            OnLoad?.Invoke(this);
        }
        public void Load(ProgressDelegate onProgress)
        {
            if (IsLoaded)
            {
                if (_firstLoadOccured)
                {
                    Unload();
                }
            }
            else
            {
                _firstLoadOccured = true;
            }

            AtlasData atlasData;
            var       cachedFile = new FileInfo(Path.Combine(_atlasCacheDirectory.FullName, "CachedAtlas.json"));

            if (cachedFile.Exists)
            {
                try
                {
                    atlasData = _jsonSerializer.Deserialize <AtlasData>(cachedFile);
                }
                finally
                {
                    cachedFile.Delete();
                }
                // TODO: this just screams for some kind of progress chain,
                void WeightedProgress(float x) => onProgress?.Invoke(x * 49 / 50f); //       there are like 5 places where a progress chain is needed

                // Progress Chain: multiple progress delegates with offsets and weights
                _textures = LoadTextures(atlasData, WeightedProgress);
            }
            else
            {
                var watch = Stopwatch.StartNew();
                (atlasData, _textures) = StitchAtlas((x) => onProgress?.Invoke(x * 49 / 50f));
                watch.Stop();

                Log.Info("Atlas stiching took " + watch.Elapsed.ToPreciseString());
            }
            UpdateKeys(atlasData);

            IsLoaded = true;
            OnLoad?.Invoke(this);
            onProgress?.Invoke(1f);
        }
Exemple #25
0
        public void Load(string imgFileName, Enums.ImageLoadMode loadMode = Enums.ImageLoadMode.Full)
        {
            Task.Factory.StartNew(() =>
            {
                Path = imgFileName;
                switch (loadMode)
                {
                case Enums.ImageLoadMode.Full:
                    Bitmap = new Bitmap(imgFileName);
                    Width  = Bitmap.PixelSize.Width;
                    Height = Bitmap.PixelSize.Height;
                    break;

                case Enums.ImageLoadMode.Miniature:
                    using (var stream = new SKFileStream(imgFileName))
                        using (var src = SKBitmap.Decode(stream))
                        {
                            Width       = src.Width;
                            Height      = src.Height;
                            var scale   = 100f / src.Width;
                            var resized = new SKBitmap(
                                (int)(src.Width * scale),
                                (int)(src.Height * scale),
                                src.ColorType,
                                src.AlphaType);
                            src.ScalePixels(resized, SKFilterQuality.Low);
                            Bitmap = new Bitmap(
                                resized.ColorType.ToPixelFormat(),
                                resized.GetPixels(),
                                new PixelSize(resized.Width, resized.Height),
                                SkiaPlatform.DefaultDpi,
                                resized.RowBytes);
                        }
                    break;

                default:
                    throw new Exception($"invalid ImageLoadMode:{loadMode.ToString()}");
                }
                Dispatcher.UIThread.InvokeAsync(() =>
                {
                    ImageBrush.Source = Bitmap;
                    OnLoad?.Invoke();
                });
            });
        }
Exemple #26
0
 public void LoadGameEntities(Map map)
 {
     for (int i = 0; i < map.Width; i++)
     {
         for (int j = 0; j < map.Height; j++)
         {
             char c = map[i, j];
             if (charGameEntityMapper.ContainsKey(c))
             {
                 GameEntity ge = charGameEntityMapper[c](new Vector2(i, j));
                 ge.OnDestroy += Ge_OnDestroy;
                 gameEntities.Add(ge);
                 MapController.Bind(ge, map);
             }
         }
     }
     OnLoad?.Invoke(this, EventArgs.Empty);
 }
Exemple #27
0
        public void Load()
        {
            XmlSerializer xmlFormat = new XmlSerializer(typeof(List <QuestTrueFalse>));
            Stream        fStream;

            try
            {
                fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            }
            catch
            {
                OnError?.Invoke(string.Format("Ошибка открытия файла \"{0}\"", fileName));
                return;
            }
            list = (List <QuestTrueFalse>)xmlFormat.Deserialize(fStream);
            fStream.Close();
            OnLoad?.Invoke(this);
        }
 // Use this for initialization
 void Start()
 {
     maxVie  = vie;
     manager = GetComponent <dashManager>();
     if (GameData.gameStarted)
     {
         vie = GameData.vie;
     }
     else
     {
         GameData.vie = vie;
     }
     //Debug.Log(vie);
     if (OnLoad != null)
     {
         OnLoad.Invoke(this.gameObject);
     }
 }
Exemple #29
0
    void OnEnable()
    {
        OnLoad?.Invoke();
        if (debugMode)
        {
            Debug.LogError("Deleting player prefs");
            PlayerPrefs.DeleteAll();
        }
        if (!PlayerPrefs.HasKey("volume"))
        {
            PlayerPrefs.SetFloat("volume", 1);
            Debug.LogError("volume key not found");
        }
        if (!PlayerPrefs.HasKey("smoothmove"))
        {
            Debug.LogError("smoothmove key not found");
            PlayerPrefs.SetInt("smoothmove", 1);
        }

        if (!PlayerPrefs.HasKey("snapangle"))
        {
            PlayerPrefs.SetInt("snapangle", 15);
            Debug.LogError("snapangle key not found");
        }

        AudioListener.volume = PlayerPrefs.GetFloat("volume");
        MoveVolumeIndicator();

        filePath = Application.persistentDataPath + "/game_data.json";

        if (File.Exists(filePath))
        {
            Debug.Log("Save file located at " + filePath);
            resumeButton.SetActive(true);
        }
        else
        {
            Debug.LogWarning("No save file located");
        }

        smoothMoveCheck.enabled = PlayerPrefs.GetInt("smoothmove") == 1 ? false : true;

        OnFinishedLoad?.Invoke();
    }
 private void BtnStopExecute(object parametr)
 {
     if (Loaded || !Start)
     {
         Link   = "";
         Loaded = false;
         Source = new BitmapImage();
         OnLoad?.Invoke(0, 0);
         OnReset?.Invoke();
         Start = false;
         Size  = 0;
         Load  = 0;
     }
     else if (StartLoad)
     {
         stop = true;
         webClient.CancelAsync();
     }
 }