Exemple #1
0
 public override void OnClick()
 {
     if (this.QueryUI == null || this.QueryUI.IsDisposed)
     {
         this.QueryUI = new SimpleStat();
         this.QueryUI.FormBorderStyle = FormBorderStyle.FixedDialog;
         this.QueryUI.MinimizeBox     = false;
         this.QueryUI.MaximizeBox     = false;
         this.QueryUI.TopMost         = true;
         this.QueryUI.MapControl      = (IMapControl3)_context.MapControl;
         this.QueryUI.PPipeCfg        = _plugin.PipeConfig;
         this.QueryUI.MContext        = this._context;
         this.QueryUI.Closing        += new CancelEventHandler(this.QueryUI_Closing);
         this.QueryUI.Show();
     }
     else if (!this.QueryUI.Visible)
     {
         this.QueryUI.AutoFlash();
         this.QueryUI.Show();
         if (this.QueryUI.WindowState == FormWindowState.Minimized)
         {
             this.QueryUI.WindowState = FormWindowState.Normal;
         }
     }
 }
        public override void Update(long gameTime, NamelessGame namelessGame)
        {
            foreach (IEntity entity in RegisteredEntities)
            {
                Damage     damage = entity.GetComponentOfType <Damage>();
                SimpleStat health = entity.GetComponentOfType <Stats>().Health;
                health.Value -= damage.DamageValue;
                if (health.Value <= health.MinValue)
                {
                    namelessGame.Commander.EnqueueCommand(new DeathCommand(entity));
                }

                entity.RemoveComponentOfType <Damage>();
            }
        }
Exemple #3
0
        private void CommitWriteTransaction()
        {
            if (g_bExtraSafe)
            {
                if (!IOConnection.FileExists(m_iocTemp))
                {
                    throw new FileNotFoundException(m_iocTemp.Path +
                                                    MessageService.NewLine + KLRes.FileSaveFailed);
                }
            }

            bool bMadeUnhidden = UrlUtil.UnhideFile(m_iocBase.Path);

#if !KeePassUAP
            // 'All' includes 'Audit' (SACL), which requires SeSecurityPrivilege,
            // which we usually don't have and therefore get an exception;
            // trying to set 'Owner' or 'Group' can result in an
            // UnauthorizedAccessException; thus we restore 'Access' (DACL) only
            const AccessControlSections acs = AccessControlSections.Access;

            bool   bEfsEncrypted = false;
            byte[] pbSec         = null;
#endif
            DateTime?  otCreation = null;
            SimpleStat sStat      = null;

            bool bBaseExists = IOConnection.FileExists(m_iocBase);
            if (bBaseExists && m_iocBase.IsLocalFile())
            {
                // FileAttributes faBase = FileAttributes.Normal;
                try
                {
#if !KeePassUAP
                    FileAttributes faBase = File.GetAttributes(m_iocBase.Path);
                    bEfsEncrypted = ((long)(faBase & FileAttributes.Encrypted) != 0);
                    try { if (bEfsEncrypted)
                          {
                              File.Decrypt(m_iocBase.Path);
                          }
                    }                                                                           // For TxF
                    catch (Exception) { Debug.Assert(false); }
#endif
                    otCreation = File.GetCreationTimeUtc(m_iocBase.Path);
                    sStat      = SimpleStat.Get(m_iocBase.Path);
#if !KeePassUAP
                    // May throw with Mono
                    FileSecurity sec = File.GetAccessControl(m_iocBase.Path, acs);
                    if (sec != null)
                    {
                        pbSec = sec.GetSecurityDescriptorBinaryForm();
                    }
#endif
                }
                catch (Exception) { Debug.Assert(NativeLib.IsUnix()); }

                // if((long)(faBase & FileAttributes.ReadOnly) != 0)
                //	throw new UnauthorizedAccessException();
            }

            if (!TxfMove())
            {
                if (bBaseExists)
                {
                    IOConnection.DeleteFile(m_iocBase);
                }
                IOConnection.RenameFile(m_iocTemp, m_iocBase);
            }
            else
            {
                Debug.Assert(pbSec != null);
            }                                                 // TxF success => NTFS => has ACL

            try
            {
                // If File.GetCreationTimeUtc fails, it may return a
                // date with year 1601, and Unix times start in 1970,
                // so testing for 1971 should ensure validity;
                // https://msdn.microsoft.com/en-us/library/system.io.file.getcreationtimeutc.aspx
                if (otCreation.HasValue && (otCreation.Value.Year >= 1971))
                {
                    File.SetCreationTimeUtc(m_iocBase.Path, otCreation.Value);
                }

                if (sStat != null)
                {
                    SimpleStat.Set(m_iocBase.Path, sStat);
                }

#if !KeePassUAP
                if (bEfsEncrypted)
                {
                    try { File.Encrypt(m_iocBase.Path); }
                    catch (Exception) { Debug.Assert(false); }
                }

                // File.SetAccessControl(m_iocBase.Path, secPrev);
                // Directly calling File.SetAccessControl with the previous
                // FileSecurity object does not work; the binary form
                // indirection is required;
                // https://sourceforge.net/p/keepass/bugs/1738/
                // https://msdn.microsoft.com/en-us/library/system.io.file.setaccesscontrol.aspx
                if ((pbSec != null) && (pbSec.Length != 0))
                {
                    FileSecurity sec = new FileSecurity();
                    sec.SetSecurityDescriptorBinaryForm(pbSec, acs);

                    File.SetAccessControl(m_iocBase.Path, sec);
                }
#endif
            }
            catch (Exception) { Debug.Assert(false); }

            if (bMadeUnhidden)
            {
                UrlUtil.HideFile(m_iocBase.Path, true);
            }
        }