示例#1
0
        private void OnTimerTick(object sender, EventArgs e)
        {
            if (_index == _layerList.Count)
            {
                _timer.Stop();
                RefreshFinished?.Invoke(this, null);
                return;
            }
            bool selected = (0 == Controls.Count) ? _firstLayerSelected : false;

            ILayer2D layer = _layerList[_index];

            // create button and add to panel
            Button btn = new Button
            {
                Image    = TryGenerateLayerImage(_layerList[_index], szButtons, selected),
                Location = new Point(_x, _y) + (Size)AutoScrollPosition,
                Size     = new Size(szButtons.Width, szButtons.Height),
                Tag      = new LayerItem(layer, selected)
            };

            btn.Click += OnLayerSelected;
            Controls.Add(btn);
            // give button a tooltip
            tooltip.SetToolTip(btn, layer.Tooltip(_contHeight));

            // adjust i, x and y for next image
            AdjustXY(ref _x, ref _y);
            ++_index;
        }
        private void OnTimerTick(object sender, EventArgs e)
        {
            if (_index == HCylLayouts.Count)
            {
                timer.Stop();
                if (Controls.Count > 0)
                {
                    var            bt     = Controls[0] as Button;
                    HCylLayoutItem btItem = bt.Tag as HCylLayoutItem;
                    btItem.Selected = true;
                    OnLayoutSelected(bt, null);
                }
                RefreshFinished?.Invoke(this, null);
                return;
            }
            bool selected = (0 == Controls.Count) ? FirstLayoutSelected : false;
            var  layout   = HCylLayouts[_index];

            // create pattern and add to panel
            var btn = new Button
            {
                Image    = TryGeneratePatternImage(HCylLayouts[_index], szButtons, selected),
                Location = new Point(_x, _y) + (Size)AutoScrollPosition,
                Size     = new Size(szButtons.Width, szButtons.Height),
                Tag      = new HCylLayoutItem(layout, selected)
            };

            btn.Click += OnLayoutSelected;
            Controls.Add(btn);
            // give button a tooltip
            tooltip.SetToolTip(btn, layout.Tooltip);
            // adjust i, x and y for next image
            AdjustXY(ref _x, ref _y);
            ++_index;
        }
示例#3
0
        private void Controller()
        {
            journalmonitor = new EDJournalUIScanner(InvokeAsyncOnUiThread);
            journalmonitor.OnNewJournalEntry += (je) => { Entry(je, false, true); };
            journalmonitor.OnNewUIEvent      += (ui) => { InvokeAsyncOnUiThread(() => NewUI?.Invoke(ui)); };

            LogLine?.Invoke("Detecting Journals");
            Reset();
            journalmonitor.SetupWatchers();
            // order the reading of last 2 files (in case continue) and fire back the last two
            LogLine?.Invoke("Reading Journals");
            journalmonitor.ParseJournalFilesOnWatchers(UpdateWatcher, 2, (a, ji, jt, ei, et) => InvokeAsyncOnUiThread(() => {
                // System.Diagnostics.Debug.WriteLine("In FG {0} {1} {2} {3} {4} {5}", EDCommander.GetCommander(a.CommanderId).Name, ji, jt, ei, et, a.EventTypeStr );
                Entry(a, true, ei - et > -recentlimit);
            }), 2);

            InvokeAsyncOnUiThread(() => { RefreshFinished?.Invoke(currenthe); });

            LogLine?.Invoke("Finished reading Journals");

            journalmonitor.StartMonitor(false);

            while (!stopit)
            {
                if (RequestRescan)
                {
                    RequestRescan = false;

                    LogLine?.Invoke("Re-reading Journals");
                    journalmonitor.StopMonitor();
                    Reset();
                    journalmonitor.SetupWatchers();
                    journalmonitor.ParseJournalFilesOnWatchers(UpdateWatcher, 2,
                                                               (a, ji, jt, ei, et) => InvokeAsyncOnUiThread(() => { Entry(a, true, ei - et > -recentlimit); }), 2);
                    journalmonitor.StartMonitor(false);
                    InvokeAsyncOnUiThread(() => { RefreshFinished?.Invoke(currenthe); });
                    LogLine?.Invoke("Finished reading Journals");
                }

                Thread.Sleep(100);
            }

            journalmonitor.StopMonitor();
        }
示例#4
0
        public void Refresh()
        {
            Profiler.Start("AssetManager_Refresh");
            BeginAssetEditing();

            var paths        = Paths.GetAllFilePaths();
            var assetsOnDisk = paths.Select(path => new Asset(path));

            // Detect renamed assets if application was closed, and assets were renamed via file system
            foreach (var pair in AssetGuidManager.Paths.ToList())
            {
                var path = pair.Value;
                if (!File.Exists(path))
                {
                    var guid = pair.Key;
                    var hash = AssetGuidManager.GetHash(guid);

                    var assetOnDiskWithSameHashButNotKnownPath = assetsOnDisk.FirstOrDefault(
                        a => a.Hash == hash && !AssetGuidManager.ContainsValue(a.Path));

                    // If this asset on disk is found, update old guid to new path, since best prediction is that it was renamed
                    if (assetOnDiskWithSameHashButNotKnownPath != null)
                    {
                        AssetGuidManager.AddNewGuid(guid, assetOnDiskWithSameHashButNotKnownPath.Path, hash);
                        Logger.Log(LogType.Log, "Asset '" + assetOnDiskWithSameHashButNotKnownPath.Name + "' was recognized as renamed asset");
                    }
                }
            }

            // Detect Rename for assets in memory (while keeping existing asset references)
            foreach (var assetInMemory in Assets.ToList())
            {
                if (!File.Exists(assetInMemory.Path))
                {
                    // if known path does not exist on disk anymore but some other asset with same hash exists on disk, it must have been renamed
                    var assetWithSameHashAndNotInDbYet = assetsOnDisk.FirstOrDefault(asset =>
                                                                                     asset.Hash == assetInMemory.Hash && !GuidPathTable.ContainsValue(asset.Path));

                    if (assetWithSameHashAndNotInDbYet != null)
                    {
                        RenameAssetInternal(assetInMemory.Path, assetWithSameHashAndNotInDbYet.Path);
                        Logger.Log(LogType.Log, "Asset '" + assetInMemory.Name + "' was renamed to '" + assetWithSameHashAndNotInDbYet.Name + "'");
                    }
                    else
                    {
                        DeleteAssetInternal(assetInMemory);
                        Logger.Log(LogType.Log, "Asset was deleted: '" + assetInMemory.Name + "'");
                    }
                }
            }

            // Add new assets and detect modifications
            foreach (var assetOnDisk in assetsOnDisk)
            {
                var isHashKnown = GuidHashTable.ContainsValue(assetOnDisk.Hash);
                var isPathKnown = GuidPathTable.ContainsValue(assetOnDisk.Path);

                // We know the path, but hash has changed, must have been modified
                if (!isHashKnown && isPathKnown)
                {
                    UpdateAssetInternal(GetAsset(assetOnDisk.Path));
                    Logger.Log(LogType.Log, "Asset was modified: '" + assetOnDisk.Name + "'");
                }
                // New file added
                else if (!isPathKnown)
                {
                    AddAssetInternal(assetOnDisk);
                }
            }

            EndAssetEditing();
            Profiler.Stop("AssetManager_Refresh");

            StatusManager.Add("AssetManager", 10, new Status(null, "Asset Refresh Finished", StandardColors.Default));
            // Logger.Log(LogType.Log, "Asset refresh finished");

            RefreshFinished?.Invoke();
        }