Exemple #1
0
 public virtual void InitSys()
 {
     resSvc   = ResourcesService.Instance;
     audioSvc = AudioService.Instance;
     netSvc   = NetService.Instance;
     timerSvc = TimerService.Instance;
 }
        public override void Initialize()
        {
            // Load background
            ResourcesService resources = game.services.Get <ResourcesService>(ServicesDefinition.Resources);

            title    = resources.Load <SpriteFont>(Constants.fontTitle);
            overview = resources.Load <Texture2D>(Constants.textureOverview);

            // Listen to mouse events
            ControlsGameplayManager gpControls = game.gameplays.Get <ControlsGameplayManager>(GameplaysDefinition.Controls);

            gpControls.OnMouseMove  += new ControlsGameplayManager.OnMouseMoveDelegate(OnMouseMove);
            gpControls.OnMouseClick += new ControlsGameplayManager.OnMouseClickDelegate(OnMouseClick);

            // Register the overview actions
            BackgroundGameplayManager gpBackground = game.gameplays.Get <BackgroundGameplayManager>(GameplaysDefinition.Background);
            InteractiveObject         viewTop      = new InteractiveObject();

            viewTop.ActivationZone = new Rectangle(10, (int)(0.5f * (Constants.windowHeight - 0.4f * overview.Height)), (int)(overview.Width * 0.4f), (int)(overview.Height * 0.133f));
            viewTop.OnAction      += () => { gpBackground.BackgroundMode = BackgroundMode.Aerial; };
            interactives.Add(viewTop);

            InteractiveObject viewOverview = new InteractiveObject();

            viewOverview.ActivationZone = new Rectangle(viewTop.ActivationZone.X, viewTop.ActivationZone.Y + viewTop.ActivationZone.Height, viewTop.ActivationZone.Width, viewTop.ActivationZone.Height);
            viewOverview.OnAction      += () => { gpBackground.BackgroundMode = BackgroundMode.Overview; };
            interactives.Add(viewOverview);

            InteractiveObject viewBottom = new InteractiveObject();

            viewBottom.ActivationZone = new Rectangle(viewTop.ActivationZone.X, viewOverview.ActivationZone.Y + viewTop.ActivationZone.Height, viewTop.ActivationZone.Width, viewTop.ActivationZone.Height);
            viewBottom.OnAction      += () => { gpBackground.BackgroundMode = BackgroundMode.Underground; };
            interactives.Add(viewBottom);
        }
Exemple #3
0
        public IActionResult ResourceDepartureInsert([FromHeader] string Token, [FromBody] ResourceMovimentation data)
        {
            try
            {
                UserDataHandler authUser = new AuthService(_context).GetUserByToken(Token);

                if (authUser != null)
                {
                    bool departureCheck = new ResourcesService(_context).ResourceDepartureCheck(data);
                    if (departureCheck)
                    {
                        new ResourcesService(_context).InsertResourceDeparture(data, authUser.Id);

                        return(Ok("Saída de recurso cadastrada com sucesso."));
                    }
                    else
                    {
                        return(BadRequest("Você não pode retirar essa quantidade!"));
                    }
                }
                else
                {
                    return(Unauthorized("Token inválido."));
                }
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Exemple #4
0
        public IActionResult GetResourceDepartures([FromHeader] string Token)
        {
            try
            {
                UserDataHandler authUser = new AuthService(_context).GetUserByToken(Token);

                if (authUser != null)
                {
                    var resourceDepartures = new ResourcesService(_context).GetResourceDepartures();

                    if (!resourceDepartures.Any())
                    {
                        return(BadRequest("Não há saídas de recursos."));
                    }
                    return(Ok(resourceDepartures));
                }
                else
                {
                    return(Unauthorized("Token inválido."));
                }
            }
            catch (System.Exception)
            {
                throw;
            }
        }
        public NotificationsService(
            StorageService storageService,
            SystemStatusService systemStatusService,
            ResourcesService resourcesService,
            PythonEngineService pythonEngineService,
            MessageBusService messageBusService,
            SystemService systemService,
            ILoggerFactory loggerFactory)
        {
            _storageService    = storageService ?? throw new ArgumentNullException(nameof(storageService));
            _resourcesService  = resourcesService ?? throw new ArgumentNullException(nameof(resourcesService));
            _messageBusService = messageBusService ?? throw new ArgumentNullException(nameof(messageBusService));
            _systemService     = systemService ?? throw new ArgumentNullException(nameof(systemService));

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            _logger = loggerFactory.CreateLogger <NotificationsService>();

            pythonEngineService.RegisterSingletonProxy(new NotificationsPythonProxy(this));

            if (systemStatusService == null)
            {
                throw new ArgumentNullException(nameof(systemStatusService));
            }
            systemStatusService.Set("notifications.count", () =>
            {
                lock (_notifications)
                {
                    return(_notifications.Count);
                }
            });
        }
Exemple #6
0
        /// <summary>
        /// Estrae Grit
        /// Ritorna il Path dell'eseguibile
        /// </summary>
        /// <returns></returns>
        private String ExtractGrit()
        {
            ResourcesService rs = new ResourcesService(System.Reflection.Assembly.GetExecutingAssembly());
            SystemService    ss = SM.Get <SystemService>();


            String TmpPath = ss.CombinePaths(Path.GetTempPath(), "grit");


            FilePlus fp       = rs.GetObject <FilePlus>("Template_Util.GRIT.grit.exe");
            String   GritPath = ss.CombinePaths(TmpPath, "grit.exe");

            fp.Folder    = TmpPath;
            fp.Name      = "grit";
            fp.Extension = ".exe";
            fp.Save();

            fp           = rs.GetObject <FilePlus>("Template_Util.GRIT.FreeImage.dll");
            fp.Folder    = TmpPath;
            fp.Name      = "FreeImage";
            fp.Extension = ".dll";
            fp.Save();

            fp           = rs.GetObject <FilePlus>("Template_Util.GRIT.licence-mit.txt");
            fp.Folder    = TmpPath;
            fp.Name      = "licence-mit";
            fp.Extension = ".txt";
            fp.Save();

            return(GritPath);
        }
        private async void DeleteFlyoutItem_OnClick(object sender, RoutedEventArgs e)
        {
            if (sender is MenuFlyoutItem flyout)
            {
                var resource = new ResourcesService();
                var database = DatabaseService.Instance;
                var item     = (GroupItem)flyout.DataContext;

                var deleteFileDialog = new ContentDialog
                {
                    Title   = $"{resource.GetResourceValue("EntityDeleteActionButton")} {item.Text} ?",
                    Content = database.IsRecycleBinEnabled
                        ? resource.GetResourceValue("GroupRecyclingConfirmation")
                        : resource.GetResourceValue("GroupDeletingConfirmation"),
                    PrimaryButtonText = resource.GetResourceValue("EntityDeleteActionButton"),
                    CloseButtonText   = resource.GetResourceValue("EntityDeleteCancelButton")
                };

                var result = await deleteFileDialog.ShowAsync();

                // Delete the file if the user clicked the primary button.
                // Otherwise, do nothing.
                if (result == ContentDialogResult.Primary)
                {
                    item.Parent.Children.Remove(item);
                    // TODO: refresh treeview
                    if (database.IsRecycleBinEnabled)
                    {
                        database.RecyleBinGroup.AddGroup(item.Group, true);
                    }
                }
            }
        }
Exemple #8
0
            public TestSetup()
            {
                var dataContext = new FakeDataContext();

                ResourceStringsRepository = new Repository <ResourceString>(dataContext);
                CacheMock         = new TestCacheManager().CacheMock;
                ResourcesService  = new ResourcesService(CacheMock.Object, ResourceStringsRepository);
                TestLoggerFactory = null;
            }
Exemple #9
0
        public override void Initialize()
        {
            // Load sound effect
            ResourcesService resources = game.services.Get <ResourcesService>(ServicesDefinition.Resources);

            windSound          = resources.Load <SoundEffect>(Constants.soundWind).CreateInstance();
            windSound.IsLooped = true;
            windSound.Volume   = intensity;
            windSound.Play();
        }
        public override void Initialize()
        {
            // Load background
            ResourcesService resources = game.services.Get <ResourcesService>(ServicesDefinition.Resources);

            forest = resources.Load <Texture2D>(Constants.textureForest);
            ground = resources.Load <Texture2D>(Constants.textureGround);
            grass  = resources.Load <Texture2D>(Constants.textureGrass);
            water  = resources.Load <Texture2D>(Constants.textureWater);
        }
Exemple #11
0
        public void GetResourceById_ThrowsEntityNotFound_WhenResourceDoesNotExist()
        {
            var nonExistingId    = Guid.NewGuid();
            var resourcesService = new ResourcesService(resourceRepoMock.Object);

            Assert.ThrowsException <EntityNotFoundException>(() =>
            {
                resourcesService.GetResourceById(nonExistingId.ToString());
            });
        }
Exemple #12
0
        public void GetResourceById_ThrowsException_WhenResourceIdHasInvalidValue()
        {
            var resourcesService = new ResourcesService(resourceRepoMock.Object);

            var badId = "ljkhgfgd fhjlikh jguygf";

            Assert.ThrowsException <Exception>(() =>
            {
                resourcesService.GetResourceById(badId);
            });
        }
Exemple #13
0
        public override void Initialize()
        {
            // Load music
            ResourcesService resources  = game.services.Get <ResourcesService>(ServicesDefinition.Resources);
            Song             background = resources.Load <Song>(Constants.musicForest);

            // Play music in loop
            MediaPlayer.Volume      = 0.4f;
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(background);
        }
 /// <summary>
 /// 根据课程id获取资源文件
 /// </summary>
 /// <param name="context"></param>
 public void FindByCourseId(HttpContext context)
 {
     var zwJson = new ZwJson();
     ResourcesService resourcesService = new ResourcesService(_session);
     var id = context.Request.Params["id"];
     var resources = resourcesService.FindByCourseId(new Model.Course() { Id = id });
     zwJson.Data = resources;
     zwJson.IsSuccess = true;
     zwJson.JsExecuteMethod = "Ajax_FindByCourseId";
     context.Response.Write(_jss.Serialize(zwJson));
 }
        public void CardsDatabaseTest_EnsureAllCardsHaveImages()
        {
            ResourcesService resService = new ResourcesService();

            foreach (Card card in CardsDatabase.Default.Cards)
            {
                Assert.IsNotNull(new CardInstance(card).BackgroundColor, card.Name);
                Assert.IsNotNull(new CardInstance(card).ForegroundColor, card.Name);
                Assert.IsNotNull(new CardInstance(card).RarityColor, card.Name);

                Uri imageUri = new Uri(card.ImageName, UriKind.RelativeOrAbsolute);
                Assert.IsTrue(resService.ResourceExists(imageUri), card.Name);
            }
        }
Exemple #16
0
        public override void Initialize()
        {
            // Bind the rendering callbacks
            treeGenerator.onExecute += new Generator.OnExecuteDelegate(this.OnDrawBranch);

            // First generation
            Generate();

            // Load texture
            ResourcesService resources = game.services.Get <ResourcesService>(ServicesDefinition.Resources);

            leaf   = resources.Load <Texture2D>(Constants.textureLeaf);
            branch = resources.Load <Texture2D>(Constants.textureBranch);
            cell   = resources.Load <Texture2D>(Constants.textureCell);
        }
Exemple #17
0
        protected void DrawRoot(UndergroundCell cell, Direction direction)
        {
            // Get the objects we need for the rendering
            ResourcesService          resources    = game.services.Get <ResourcesService>(ServicesDefinition.Resources);
            BackgroundGameplayManager gpBackground = game.gameplays.Get <BackgroundGameplayManager>(GameplaysDefinition.Background);

            // Draw the child root
            {
                // Get the texture matching the cell
                Texture2D tex = resources.Load <Texture2D>($"textures/roots/root-in-{cell.Size}");

                // Get the center of the rendering
                Vector2 center   = new Vector2(0.5f * tex.Width, 0.5f * tex.Height);
                Vector2 offset   = new Vector2(0.5f * (Constants.windowHeight * Constants.windowRatio), (float)(gpBackground.GroundLevel + 0.433f * Constants.cellWidth));
                Vector2 position = undergroundGrid.GetPosition(cell.X, cell.Y, offset, Constants.cellWidth);
                float   rotation = undergroundGrid.GetAngle(direction);

                // Render the root
                spriteBatch.Draw(tex, position, null, Color.White, rotation, center, (float)Constants.cellWidth / (float)tex.Width, SpriteEffects.None, 0f);
            }

            // Draw the parent root
            {
                // Get the texture matching the cell
                Texture2D tex = resources.Load <Texture2D>($"textures/roots/root-out-{cell.Size}");

                // Get the parent cell
                UndergroundCell  parent      = null;
                Tuple <int, int> coordinates = undergroundGrid.GetNeighbourCoordinates(cell, undergroundGrid.GetOppositeDirection(direction));
                if (undergroundGrid.IsCellCreated(coordinates.Item1, coordinates.Item2))
                {
                    parent = undergroundGrid[coordinates.Item1, coordinates.Item2];
                }
                if (parent != null)
                {
                    // Get the center of the rendering
                    Vector2 center   = new Vector2(0.5f * tex.Width, 0.5f * tex.Height);
                    Vector2 offset   = new Vector2(0.5f * (Constants.windowHeight * Constants.windowRatio), (float)(gpBackground.GroundLevel + 0.433f * Constants.cellWidth));
                    Vector2 position = undergroundGrid.GetPosition(parent.X, parent.Y, offset, Constants.cellWidth);
                    float   rotation = undergroundGrid.GetAngle(undergroundGrid.GetOppositeDirection(direction));

                    // Render the root
                    spriteBatch.Draw(tex, position, null, Color.White, rotation, center, (float)Constants.cellWidth / (float)tex.Width, SpriteEffects.None, 0f);

                    Console.WriteLine($"Draw parent {coordinates.Item1},{coordinates.Item2} with size {cell.Size}");
                }
            }
        }
Exemple #18
0
        public HueColorPicker()
        {
            InitializeComponent();
            ResourcesService rs  = new ResourcesService(System.Reflection.Assembly.GetExecutingAssembly());
            BitmapImage      img = rs.GetObject <BitmapImage>("ExtendCSharpWPF.Resource.HueRing.png");

            canvas.Background = new ImageBrush(img);


            SelectionCircle        = new Ellipse();
            SelectionCircle.Stroke = System.Windows.Media.Brushes.Black;
            SelectionCircle.Fill   = System.Windows.Media.Brushes.Transparent;
            SelectionCircle.HorizontalAlignment = HorizontalAlignment.Center;
            SelectionCircle.VerticalAlignment   = VerticalAlignment.Center;
            canvas.Children.Add(SelectionCircle);
        }
Exemple #19
0
        private void ImportFormatComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var resources = new ResourcesService();
            var comboBox  = sender as ComboBox;

            switch (comboBox?.SelectedIndex)
            {
            case 0:
                Model.ImportFormat = new CsvImportFormat();
                Model.ImportFileExtensionFilter = ".csv";
                Model.ImportFormatHelp          = resources.GetResourceValue("NewImportFormatHelpCSV");
                break;

            default:
                Model.ImportFormat = new NullImportFormat();
                break;
            }
        }
Exemple #20
0
        public void GetResourceById_Returns_ResourceWhenExists()
        {
            Exception throwException   = null;
            var       resourcesService = new ResourcesService(resourceRepoMock.Object);
            Resource  resource         = null;

            try
            {
                resource = resourcesService.GetResourceById(existingResourceGuid.ToString());
            }
            catch (Exception e)
            {
                throwException = e;
            }

            Assert.IsNull(throwException, $"Exception was thrown");
            Assert.IsNotNull(resource);
        }
Exemple #21
0
    private void Init()
    {
        //服务模块初始化
        //NetService net = GetComponent<NetService>();
        //net.InitSvc();
        ResourcesService res = GetComponent <ResourcesService>();

        res.InitSvc();
        AudioService audio = GetComponent <AudioService>();

        audio.InitSvc();
        TimerService timer = GetComponent <TimerService>();

        timer.InitSvc();
        //业务系统初始化
        LoginSystem login = GetComponent <LoginSystem>();

        login.InitSys();
        //进入登录场景并加载相应UI
        login.EnterLogin();
    }
Exemple #22
0
        private async void OnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs)
        {
            // Save the argument exception because it's cleared on first access
            var exception     = unhandledExceptionEventArgs.Exception;
            var realException =
                exception is TargetInvocationException &&
                exception.InnerException != null
                    ? exception.InnerException
                    : exception;

            var database = DatabaseService.Instance;
            var resource = new ResourcesService();

            if (realException is SaveException)
            {
                unhandledExceptionEventArgs.Handled = true;
                await MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("MessageDialogSaveErrorTitle"),
                                                           realException.InnerException.Message,
                                                           resource.GetResourceValue("MessageDialogSaveErrorButtonSaveAs"),
                                                           resource.GetResourceValue("MessageDialogSaveErrorButtonDiscard"),
                                                           async command =>
                {
                    var savePicker = new FileSavePicker
                    {
                        SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
                        SuggestedFileName      = $"{database.Name} - copy"
                    };
                    savePicker.FileTypeChoices.Add(resource.GetResourceValue("MessageDialogSaveErrorFileTypeDesc"),
                                                   new List <string> {
                        ".kdbx"
                    });

                    var file = await savePicker.PickSaveFileAsync();
                    if (file != null)
                    {
                        database.Save(file);
                    }
                }, null);
            }
        }
 /// <summary>
 /// 删除资源文件
 /// </summary>
 /// <param name="context"></param>
 public void DelRecources(HttpContext context)
 {
     ZwJson zwJson = new ZwJson();
     ResourcesService resourcesService = new ResourcesService(session);
     var name = context.Request.Params["name"];
     var courseid = context.Request.Params["courseid"];
     var type = context.Request.Params["type"];
     var pathAll = "";
     switch (type)
     {
         case "课程列表":
             pathAll = _filepath + courseid + @"\" + name;
             break;
         case "视频列表":
             pathAll = _video + courseid + @"\" + name;
             break;
         case "flashPdf":
             pathAll = _flash + courseid + @"\" + name;
             break;
     }
     try
     {
         resourcesService.DeleteByName(new Resources()
         {
             Name = name,
             Flag = type
         });
         zwJson.IsSuccess = true;
         zwJson.JsExecuteMethod = "ajax_DelRecources";
         File.Delete(pathAll);
         context.Response.Write(_jss.Serialize(zwJson));
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #24
0
 public Resources(ResourcesService service)
 {
     _service = service;
 }
 /// <summary>
 /// 保存课程资源文件
 /// </summary>
 /// <param name="context"></param>
 public void SaveFile(HttpContext context)
 {
     ZwJson zwJson = new ZwJson();
     ResourcesService resourcesService = new ResourcesService(session);
     HttpPostedFile file = context.Request.Files["Filedata"];
     var courseid = context.Request.Params["id"];
     var type = context.Request.Params["type"];
     Resources resources = new Resources();
     if (file == null) return;
     var pathAll = "";
     var httppath = "";
     var pathDirectory = "";
     switch (type)
     {
         case "课程列表":
             pathAll = _filepath + courseid + @"\" + file.FileName;
             httppath = "/CourseFile/" + courseid + @"\" + file.FileName;
             pathDirectory = _filepath + courseid;
             break;
         case "视频列表":
             pathAll = _video + courseid + @"\" + file.FileName;
             httppath = "/OlFile/" + courseid + @"\" + file.FileName;
             pathDirectory = _video + courseid;
             break;
         case "flashPdf":
             pathAll = _flash + courseid + @"\" + file.FileName;
             httppath = "/FlashFile/" + courseid + @"\" + file.FileName;
             pathDirectory = _flash + courseid;
             break;
     }
     var url = UrlHelper.Resolve(httppath);
     int size = file.ContentLength / 1024;
     var flag = file.ContentLength % 1024;
     if (flag > 0)
     {
         size++;
     }
     resources.FileSize = size.ToString(CultureInfo.InvariantCulture);
     resources.Flag = type;
     resources.Name = file.FileName;
     resources.FileType = file.FileName.Split('.')[file.FileName.Split('.').Length - 1];
     resources.FilePath = url;
     resources.CreateDt = DateTime.Now;
     resources.Course = new Model.Course()
     {
         Id = courseid
     };
     if (!Directory.Exists(pathDirectory))
     {
         Directory.CreateDirectory(pathDirectory);
     }
     if (File.Exists(pathAll))
     {
         resourcesService.DeleteByName(resources);
     }
     resources.Id = Guid.NewGuid().ToString();
     resourcesService.Save(resources);
     file.SaveAs(pathAll);
     //zwJson.IsSuccess = true;
     //zwJson.JsExecuteMethod = "ajax_SaveFile";
     //context.Response.Write(_jss.Serialize(zwJson));
 }
 /// <summary>
 /// 获取资源文件
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public string GetResources(HttpContext context)
 {
     ResourcesService resourcesService = new ResourcesService(session);
     var list = resourcesService.Get();
     SessionFactory.CloseSession();
     var str = "Hello";
     return str;
 }
Exemple #27
0
 static ResourceHelper()
 {
     ResourceLoader.GetStringInternal = key => ResourcesService.Get(key);
 }
 public ResourcesServiceAdapter(ResourcesService resourcesService)
 {
     this.resourcesService = resourcesService;
 }
Exemple #29
0
 public ReportService()
 {
     Report           = new Reports();
     _resourceService = new ResourcesService();
     _facilityService = new FacilityService();
 }
Exemple #30
0
        private void StartPart2(string mutexName, string[] remainingArgs)
        {
            IAnimationService animationService;

            Memory.Initialize();
            CultureInfo info = AppSettings.Instance.UI.Language.Value;

            Thread.CurrentThread.CurrentUICulture     = info;
            CultureInfo.DefaultThreadCurrentUICulture = info;
            AppSettings.Instance.UI.Language.Value    = info;
            PdnResources.Culture = info;
            AppSettings.Instance.UI.ErrorFlagsAtStartup.Value = AppSettings.Instance.UI.ErrorFlags.Value;
            UIUtil.IsGetMouseMoveScreenPointsEnabled          = AppSettings.Instance.UI.EnableSmoothMouseInput.Value;
            if (!OS.VerifyFrameworkVersion(4, 6, 0, OS.FrameworkProfile.Full))
            {
                string message = PdnResources.GetString("Error.FXRequirement");
                MessageBoxUtil.ErrorBox(null, message);
                string fxurl = "http://www.microsoft.com/en-us/download/details.aspx?id=40773";
                () => ShellUtil.LaunchUrl2(null, fxurl).Eval <bool>().Observe();
            }
            else if (!OS.VerifyWindowsVersion(6, 1, 1))
            {
                string str4 = PdnResources.GetString("Error.OSRequirement");
                MessageBoxUtil.ErrorBox(null, str4);
            }
            else if (!Processor.IsFeaturePresent(ProcessorFeature.SSE))
            {
                string str5 = PdnResources.GetString("Error.SSERequirement");
                MessageBoxUtil.ErrorBox(null, str5);
            }
            else
            {
                string str;
                if (MultithreadedWorkItemDispatcher.IsSingleThreadForced && PdnInfo.IsFinalBuild)
                {
                    throw new PaintDotNet.InternalErrorException("MultithreadedWorkItemDispatcher.IsSingleThreadForced shouldn't be true for Final builds!");
                }
                if (RefTrackedObject.IsFullRefTrackingEnabled && PdnInfo.IsFinalBuild)
                {
                    throw new PaintDotNet.InternalErrorException("Full ref tracking should not be enabled for non-expiring builds!");
                }
                PaintDotNet.Base.AssemblyServices.RegisterProxies();
                PaintDotNet.Core.AssemblyServices.RegisterProxies();
                PaintDotNet.Framework.AssemblyServices.RegisterProxies();
                ObjectRefProxy.CloseRegistration();
                remainingArgs = TryRemoveArg(remainingArgs, "/showCrashLog=", out str);
                if (!string.IsNullOrWhiteSpace(str))
                {
                    DialogResult?nullable = null;
                    try
                    {
                        string fullPath = Path.GetFullPath(str);
                        if (File.Exists(fullPath))
                        {
                            nullable = new DialogResult?(CrashManager.ShowCrashLogDialog(fullPath));
                        }
                    }
                    catch (Exception exception)
                    {
                        try
                        {
                            MessageBox.Show(exception.ToString(), null, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        }
                        catch (Exception exception2)
                        {
                            Environment.FailFast(null, exception2);
                        }
                    }
                    DialogResult?nullable2 = nullable;
                    DialogResult oK        = DialogResult.OK;
                    if ((((DialogResult)nullable2.GetValueOrDefault()) == oK) ? nullable2.HasValue : false)
                    {
                        string[] args = new string[] { "/sleep=1000" };
                        StartNewInstance(null, false, args);
                    }
                }
                else
                {
                    string str2;
                    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Startup.OnCurrentDomainUnhandledException);
                    Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, true);
                    Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, false);
                    Application.ThreadException += new ThreadExceptionEventHandler(Startup.OnApplicationThreadException);
                    this.canUseCrashDialog       = true;
                    remainingArgs = TryRemoveArg(remainingArgs, "/test", out str2);
                    if (str2 != null)
                    {
                        PdnInfo.IsTestMode = true;
                    }
                    SingleInstanceManager disposeMe = new SingleInstanceManager(mutexName);
                    animationService = null;
                    try
                    {
                        DirectWriteFactory.DefaultDirectWriteSettingsController defaultDirectWriteSettingsController;
                        DrawingContext.DefaultDrawingContextSettingsController  defaultDrawingContextSettingsController;
                        IDisposable               updatesServiceShutdown;
                        IUpdatesServiceHost       updatesServiceHost;
                        PdnSynchronizationContext pdnSyncContext;
                        if (!disposeMe.IsFirstInstance)
                        {
                            disposeMe.FocusFirstInstance();
                            foreach (string str7 in remainingArgs)
                            {
                                disposeMe.SendInstanceMessage(str7, 30);
                            }
                            disposeMe.Dispose();
                            disposeMe = null;
                        }
                        else
                        {
                            CleanupService.Initialize();
                            ResourcesService.Initialize();
                            UserFilesService.Initialize();
                            UserPalettesService.Initialize();
                            animationService           = AnimationService.Initialize();
                            animationService.IsEnabled = true;
                            Document.Initialize(PdnInfo.Version);
                            Layer.Initialize(PdnResources.GetString("Layer.BackgroundLayer.DefaultName"));
                            Effect.SetDefaultServiceProviderValueFactory(effect => new ServiceProviderForEffects());
                            defaultDirectWriteSettingsController = DirectWriteFactory.GetDefaultSettingsController();
                            defaultDirectWriteSettingsController.DefaultCulture = AppSettings.Instance.UI.Language.Value;
                            AppSettings.Instance.UI.Language.ValueChangedT     += (sender, e) => (defaultDirectWriteSettingsController.DefaultCulture = e.NewValue);
                            AeroColors.CurrentScheme = AppSettings.Instance.UI.AeroColorScheme.Value;
                            AppSettings.Instance.UI.AeroColorScheme.ValueChangedT += (sender, e) => (AeroColors.CurrentScheme = e.NewValue);
                            defaultDrawingContextSettingsController = DrawingContext.GetDefaultSettingsController();
                            defaultDrawingContextSettingsController.DefaultTextAntialiasMode = AppSettings.Instance.UI.DefaultTextAntialiasMode.Value;
                            AppSettings.Instance.UI.DefaultTextAntialiasMode.ValueChangedT  += delegate(object sender, ValueChangedEventArgs <TextAntialiasMode> e) {
                                defaultDrawingContextSettingsController.DefaultTextAntialiasMode = e.NewValue;
                                foreach (Form form in Application.OpenForms)
                                {
                                    form.PerformLayoutRecursiveDepthFirst("TextAntialiasMode");
                                    form.Invalidate(true);
                                }
                            };
                            defaultDrawingContextSettingsController.DefaultTextRenderingMode = AppSettings.Instance.UI.DefaultTextRenderingMode.Value;
                            AppSettings.Instance.UI.DefaultTextRenderingMode.ValueChangedT  += delegate(object sender, ValueChangedEventArgs <TextRenderingMode> e) {
                                defaultDrawingContextSettingsController.DefaultTextRenderingMode = e.NewValue;
                                foreach (Form form in Application.OpenForms)
                                {
                                    form.PerformLayoutRecursiveDepthFirst("TextRenderingMode");
                                    form.Invalidate(true);
                                }
                            };
                            PaintDotNet.IndirectUI.ControlInfo.Initialize(Assembly.GetExecutingAssembly());
                            PdnBaseForm.SetStaticHelpRequestedHandler(delegate(object sender, HelpEventArgs e) {
                                HelpService.Instance.ShowHelp(sender as IWin32Window);
                                e.Handled = true;
                            });
                            Control control = new Control();
                            SynchronizationContext current = SynchronizationContext.Current;
                            PdnSynchronizationContextController controller = PdnSynchronizationContext.Install(new WaitForMultipleObjectsExDelegate(WaitHelper.WaitForMultipleObjectsEx), new SleepExDelegate(WaitHelper.SleepEx));
                            pdnSyncContext         = controller.Instance;
                            this.mainForm          = new MainForm(remainingArgs);
                            updatesServiceHost     = this.mainForm.CreateUpdatesServiceHost();
                            updatesServiceShutdown = null;
                            EventHandler initUpdatesOnShown = null;
                            initUpdatesOnShown = delegate(object sender, EventArgs e) {
                                this.mainForm.Shown   -= initUpdatesOnShown;
                                updatesServiceShutdown = UpdatesService.Initialize(updatesServiceHost);
                            };
                            this.mainForm.Shown += initUpdatesOnShown;
                            this.mainForm.SingleInstanceManager = disposeMe;
                            disposeMe = null;
                            int num        = (int)Math.Floor((double)8.3333333333333339);
                            int intervalMs = (int)Math.Floor((double)50.0);
                            using (AnimationTimerUpdateThread timerThread = new AnimationTimerUpdateThread(intervalMs, false))
                            {
                                < > c__DisplayClass20_1 class_3;
Exemple #31
0
        private static void Main()
        {
            Validate.CheckIfFirstTimeRunning();

            if (IsAnotherInstanceOfThisProgramRunning(Assembly.GetEntryAssembly()?.GetName().Name))
            {
                MessageBox.Show(
                    Resources.Program_Main_Only_one_instance_of_Clipboard_Helper_RegEx_can_be_running_at_the_same_time__This_instance_will_be_closed_,
                    "Clipboard Helper RegEx", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }


            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
            Application.ThreadException += ApplicationOnThreadException;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //The program is initiated in this class. The different presenters handle all the user input from the views so the program
            //behaves correctly.

            //User controls
            var settingsArea = new TableLayoutPanel {
                Dock = DockStyle.Fill
            };
            var settingsLeft = new GroupBox {
                Dock = DockStyle.Left
            };
            var settingsRight = new GroupBox {
                Dock = DockStyle.Fill
            };
            var settingsMenuLeft = new ViewUserSettingsLeftMenu {
                Dock = DockStyle.Fill
            };
            var settingsRightAppearance = new ViewUserSettingsRightAppearance {
                Dock = DockStyle.Fill
            };
            var settingsRightAutoShownTabs = new ViewUserSettingsRightAutoShownTabs
            {
                Dock = DockStyle.Fill
            };
            var settingsRightManuallyShownTabs = new ViewUserSettingsRightManuallyShownTabs
            {
                Dock = DockStyle.Fill
            };
            var settingsDownButtons = new ViewUserSettingsDownButtons {
                Dock = DockStyle.Bottom
            };
            var settingsAdvanced = new ViewUserSettingsRightAdvanced {
                Dock = DockStyle.Fill
            };
            var settingsHelp = new ViewUserSettingsRightHelp {
                Dock = DockStyle.Fill
            };
            var mainSplCont = new ViewMainSplCont {
                Dock = DockStyle.Fill
            };
            var mainSplContPanelUpTabs = new ViewMainSplContPanelUpTabs {
                Dock = DockStyle.Fill
            };
            var mainSplContPanelDown = new ViewMainSplContPanelDown {
                Dock = DockStyle.Fill
            };

            //Built-in Visual Studio settings
            ISettingsService settings = new SettingsService();

            //Not built-in Visual Studio settings
            ISettingsServiceXmlSerialization settingsServiceXmlSerialization = new SettingsServiceXmlSerialization();

            //Built-in Visual Studio resources
            IResourcesService resources = new ResourcesService();

            //Other classes
            var validate = new Validate(settingsRightManuallyShownTabs, settingsRightAutoShownTabs, settingsServiceXmlSerialization);
            var pasting  = new Pasting();
            var fileData = new FileData();

            //Views
            var viewAbout        = new ViewAbout();
            var viewMain         = new ViewMain(mainSplCont, mainSplContPanelUpTabs, mainSplContPanelDown);
            var viewMin          = new ViewMin();
            var viewUserSettings = new ViewUserSettings(settingsArea, settingsDownButtons, settingsLeft,
                                                        settingsRight, settingsMenuLeft);
            var viewDialog = new ViewDialog();

            //Presenters
            var unused1 = new PresenterAbout(viewAbout, resources);
            var unused2 = new PresenterMain(
                viewMain,
                viewMin,
                viewUserSettings,
                viewAbout,
                settings,
                resources,
                mainSplContPanelUpTabs,
                settingsDownButtons,
                pasting);
            var unused3 = new PresenterMainSplCont(mainSplCont, viewMain);
            var unused4 = new PresenterMainSplContPanelUpTabs(
                mainSplContPanelUpTabs,
                viewMain,
                viewMin,
                settings,
                pasting,
                mainSplContPanelDown,
                settingsServiceXmlSerialization,
                settingsDownButtons);
            var unused5 = new PresenterMainSplContPanelDown(mainSplContPanelDown);
            var unused6 = new PresenterMin(viewMin, viewMain, resources);
            var unused7 = new PresenterUserSettings(
                viewUserSettings,
                resources);
            var unused8 = new PresenterUserSettingsLeftMenu(
                settingsMenuLeft,
                viewUserSettings,
                settingsRightAppearance,
                settingsRightAutoShownTabs,
                settingsRightManuallyShownTabs,
                settingsAdvanced,
                settingsHelp);
            var unused9 = new PresenterUserSettingsRightAppearance(
                settingsRightAppearance,
                settings,
                settingsDownButtons,
                viewMain,
                validate,
                viewDialog);
            var unused10 = new PresenterUserSettingsRightAutoShownTabs(
                settingsRightAutoShownTabs,
                viewDialog,
                viewUserSettings,
                settingsDownButtons,
                settingsServiceXmlSerialization,
                mainSplContPanelUpTabs);
            var unused11 = new PresenterUserSettingsRightManuallyShownTabs(
                settingsRightManuallyShownTabs,
                viewDialog,
                viewUserSettings,
                settingsDownButtons,
                settingsServiceXmlSerialization);
            var unused12 = new PresenterUserSettingsDownButtons(
                settingsDownButtons,
                viewUserSettings,
                settings);
            var unused13 = new PresenterUserSettingsRightAdvanced(
                settingsAdvanced,
                viewDialog,
                settings,
                settingsRightAutoShownTabs,
                settingsServiceXmlSerialization,
                settingsRightManuallyShownTabs,
                validate,
                fileData);
            var unused14 = new PresenterDialog(viewDialog);
            var unused15 = new PresenterUserSettingsRightHelp(
                settingsHelp);

            Application.Run(viewMain);

            //Disposing
            settingsRightAppearance.Dispose();
            settingsRightAutoShownTabs.Dispose();
            settingsRightManuallyShownTabs.Dispose();
            settingsAdvanced.Dispose();
            settingsHelp.Dispose();
            viewAbout.Dispose();
            viewMain.Dispose();
            viewMin.Dispose();
            viewUserSettings.Dispose();
            viewDialog.Dispose();
            unused2.Dispose();
            unused4.Dispose();
            unused5.Dispose();
            unused6.Dispose();
            unused13.Dispose();
        }