private void ExtraAction(PowerAction action)
        {
            switch (action)
            {
            case PowerAction.PowerUp:
            case PowerAction.PowerDown:
                var powerUpOrDownFrag = new PowerUpDownFragment(Presenter.Balances[_walletPager.CurrentItem], action);
                powerUpOrDownFrag.SetTargetFragment(this, WalletFragmentPowerUpOrDownRequestCode);
                ((BaseActivity)Activity).OpenNewContentFragment(powerUpOrDownFrag);
                break;

            case PowerAction.CancelPowerDown:
                var alertAction = new ActionAlertDialog(Activity, string.Format(AppSettings.LocalizationManager.GetText(LocalizationKeys.CancelPowerDownAlert), Presenter.Balances[_walletPager.CurrentItem].ToWithdraw.ToBalanceValueString()),
                                                        string.Empty, AppSettings.LocalizationManager.GetText(LocalizationKeys.Yes),
                                                        AppSettings.LocalizationManager.GetText(LocalizationKeys.No), AutoLinkAction);
                alertAction.AlertAction += () =>
                {
                    var userInfo = Presenter.Balances[_walletPager.CurrentItem].UserInfo;
                    if (string.IsNullOrEmpty(userInfo.ActiveKey))
                    {
                        var intent = new Intent(Activity, typeof(ActiveSignInActivity));
                        intent.PutExtra(ActiveSignInActivity.ActiveSignInUserName, userInfo.Login);
                        intent.PutExtra(ActiveSignInActivity.ActiveSignInChain, (int)userInfo.Chain);
                        StartActivityForResult(intent, ActiveSignInActivity.ActiveKeyRequestCode);
                        return;
                    }

                    CancelPowerDown();
                };
                alertAction.Show();
                break;
            }
        }
        private void OKBtn_Click(object sender, EventArgs e)
        {
            if (TraitBox.Checked)
            {
                fAction = null;
            }
            else
            {
                if (fAction == null)
                {
                    fAction = new PowerAction();
                }

                if (AtWillBtn.Checked)
                {
                    fAction.Use = BasicAttackBtn.Checked ? PowerUseType.Basic : PowerUseType.AtWill;
                }

                if (EncounterBtn.Checked)
                {
                    fAction.Use      = PowerUseType.Encounter;
                    fAction.Recharge = RechargeBox.Text;
                }

                if (DailyBtn.Checked)
                {
                    fAction.Use = PowerUseType.Daily;
                }

                fAction.Action        = (ActionType)ActionBox.SelectedItem;
                fAction.Trigger       = TriggerBox.Text;
                fAction.SustainAction = (ActionType)SustainBox.SelectedItem;
            }
        }
Beispiel #3
0
 private void OKBtn_Click(object sender, EventArgs e)
 {
     if (this.TraitBox.Checked)
     {
         this.fAction = null;
         return;
     }
     if (this.fAction == null)
     {
         this.fAction = new PowerAction();
     }
     if (this.AtWillBtn.Checked)
     {
         this.fAction.Use = (this.BasicAttackBtn.Checked ? PowerUseType.Basic : PowerUseType.AtWill);
     }
     if (this.EncounterBtn.Checked)
     {
         this.fAction.Use      = PowerUseType.Encounter;
         this.fAction.Recharge = this.RechargeBox.Text;
     }
     if (this.DailyBtn.Checked)
     {
         this.fAction.Use = PowerUseType.Daily;
     }
     this.fAction.Action        = (ActionType)this.ActionBox.SelectedItem;
     this.fAction.Trigger       = this.TriggerBox.Text;
     this.fAction.SustainAction = (ActionType)this.SustainBox.SelectedItem;
 }
Beispiel #4
0
        public static void Set(PowerAction action)
        {
            switch (action)
            {
            case PowerAction.Lock:
                RunDll32("user32.dll, LockWorkStation");
                break;

            case PowerAction.Restart:
                Shutdwon("/r");
                break;

            case PowerAction.Logout:
                Shutdwon("/l");
                break;

            case PowerAction.Shutdown:
                Shutdwon("/s");
                break;

            case PowerAction.Hybernate:
                Shutdwon("/h");
                break;

            case PowerAction.Sleep:
                Shutdwon("powrprof.dll, SetSuspendState 0, 1, 0");
                break;
            }
        }
Beispiel #5
0
 public PowerUpDownModel(Common.BalanceModel model, PowerAction powerAction)
     : base(model.UserInfo)
 {
     From         = model.UserInfo.Login;
     To           = model.UserInfo.Login;
     Value        = model.Value;
     CurrencyType = model.CurrencyType;
     PowerAction  = powerAction;
 }
        private void InitiallizeCollections()
        {
            var schemes = PowerManagement.GetPowerSchemes();

            // Create clones of the list of schemes to use for charging, discharging, and active scheme menus
            PowerSchemes            = new ObservableCollection <PowerScheme>(schemes.Clone());
            DischargingPowerSchemes = new ObservableCollection <PowerScheme>(ActivateScheme(schemes.Clone(), Settings.Default.DischargingScheme));
            ChargingPowerSchemes    = new ObservableCollection <PowerScheme>(ActivateScheme(schemes.Clone(), Settings.Default.ChargingScheme));

            PowerActions = new ObservableCollection <PowerAction>(PowerAction.GetActions());
        }
Beispiel #7
0
        private void ActionBtn_Click(object sender, EventArgs e)
        {
            PowerAction     action          = this.fPower.Action ?? new PowerAction();
            PowerActionForm powerActionForm = new PowerActionForm(action);

            if (powerActionForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.fPower.Action = powerActionForm.Action;
                this.update_action();
                this.update_advice();
            }
        }
Beispiel #8
0
 protected void AreEqual(PowerAction mp, PowerAction ddi, string name)
 {
     if (mp == null)
     {
         Assert.IsNull(ddi, "Action not null " + name);
         return;
     }
     Assert.IsNotNull(ddi, "Missing action for " + name);
     Assert.AreEqual(mp.Action, ddi.Action, "Invalid action Type for " + name);
     Assert.AreEqual(mp.Recharge, ddi.Recharge);
     Assert.AreEqual(mp.SustainAction, ddi.SustainAction);
     Assert.AreEqual(mp.Trigger, ddi.Trigger);
     Assert.AreEqual(mp.Use, ddi.Use, "Invalid use for action " + name);
     Assert.AreEqual(mp.ToString(), ddi.ToString());
 }
 protected void AreEqual(PowerAction mp, PowerAction ddi, string name)
 {
     if (mp == null)
     {
         Assert.IsNull(ddi, "Action not null " + name);
         return;
     }
     Assert.IsNotNull(ddi, "Missing action for " + name);
     Assert.AreEqual(mp.Action, ddi.Action, "Invalid action Type for " + name);
     Assert.AreEqual(mp.Recharge, ddi.Recharge);
     Assert.AreEqual(mp.SustainAction, ddi.SustainAction);
     Assert.AreEqual(mp.Trigger, ddi.Trigger);
     Assert.AreEqual(mp.Use, ddi.Use,"Invalid use for action " + name);
     Assert.AreEqual(mp.ToString(), ddi.ToString());
 }
Beispiel #10
0
        private void ActionBtn_Click(object sender, EventArgs e)
        {
            PowerAction pa = fPower.Action;

            if (pa == null)
            {
                pa = new PowerAction();
            }

            PowerActionForm dlg = new PowerActionForm(pa);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                fPower.Action = dlg.Action;
                update_action();
                update_advice();
            }
        }
Beispiel #11
0
        //--------------------------------------------------------------------------------------------
        public bool RestartPort(int port, PowerAction action)
        {
            //if (port < 1 || port > 8)
               //{
               //     throw new Exception("Invalid port range.");
               //}

               //string immediateRebootPort1  = "HX=hr&HX2=hr&OutCtl=68000000&OutCtl=c9000000&OutCtl=2d010000&OutCtl=91010000&OutCtl=f5010000&OutCtl=59020000&OutCtl=bd020000&OutCtl=21030000";
               //string immediateRebootPort2  = "HX=hr&HX2=hr&OutCtl=65000000&OutCtl=cc000000&OutCtl=2d010000&OutCtl=91010000&OutCtl=f5010000&OutCtl=59020000&OutCtl=bd020000&OutCtl=21030000";
               //switch (action)
               //{
               //     case PowerAction.ImmediateReboot:
               //          return PostData(immediateRebootPort1);

               //     case PowerAction.DelayedReboot:
               //          return PostData(immediateRebootPort2);

               //     default:
               //          throw new Exception("The action you chose has not been impletmented.");
               //}

               return PostData("admin\r\nivycrest\r\n1\r\n" + port.ToString() + "\r\n1\r\n3\r\nYES\r\n");
               return false;
        }
Beispiel #12
0
 // when a powerup is "played," adds the event undergone to events
 public void WhenPlayed(PowerAction action)
 {
     Played += action;
 }
        private void GetActionType(PowerAction powerAction, string temp)
        {
            string potentielTrigger = string.Empty;

            if (temp.ToLower().StartsWith("standard"))
            {
                powerAction.Action = ActionType.Standard;
                potentielTrigger   = temp.Substring("standard".Length);
            }
            if (temp.ToLower().StartsWith("move"))
            {
                powerAction.Action = ActionType.Move;
                potentielTrigger   = temp.Substring("move".Length);
            }
            if (temp.ToLower().StartsWith("minor"))
            {
                powerAction.Action = ActionType.Minor;
                potentielTrigger   = temp.Substring("minor".Length);
            }
            if (temp.ToLower().StartsWith("immediate interrupt"))
            {
                powerAction.Action = ActionType.Interrupt;
                potentielTrigger   = temp.Substring("immediate interrupt".Length);
            }
            if (temp.ToLower().StartsWith("immediate reaction"))
            {
                powerAction.Action = ActionType.Reaction;
                potentielTrigger   = temp.Substring("immediate reaction".Length);
            }
            if (temp.ToLower().StartsWith("opportunity"))
            {
                powerAction.Action = ActionType.Opportunity;
                potentielTrigger   = temp.Substring("opportunity".Length);
            }
            if (temp.ToLower().StartsWith("free"))
            {
                powerAction.Action = ActionType.Free;
                potentielTrigger   = temp.Substring("free".Length);
            }
            if (temp.ToLower().StartsWith("none"))
            {
                powerAction.Action = ActionType.None;
                potentielTrigger   = temp.Substring("none".Length);
            }
            if (temp.ToLower().StartsWith("no action"))
            {
                powerAction.Action = ActionType.None;
                potentielTrigger   = temp.Substring("no action".Length);
            }
            if (temp.StartsWith("when "))
            {
                powerAction.Action = ActionType.Reaction;
                potentielTrigger   = temp;
            }
            if (temp == "")
            {
                powerAction.Action = ActionType.None;
            }
            if (!String.IsNullOrEmpty(potentielTrigger))
            { //trigger can already be set
                powerAction.Trigger = potentielTrigger;
            }
            powerAction.Trigger = CleanExtraComma(powerAction.Trigger);
            if (powerAction.Trigger.StartsWith(","))
            {
                powerAction.Trigger = powerAction.Trigger.Substring(1).Trim();
            }
        }
Beispiel #14
0
 public void DoPowerAction(PowerAction action)
 {
     Win32.DoExitWin((int)action);
 }
Beispiel #15
0
 //--------------------------------------------------------------------------------------------
 public bool RestartAllPorts(PowerAction action)
 {
     string immediateRebootAll = "HX=hr&HX2=hr&C2=733839f5b26682cabd0fbafc5d7c7f18&master_ctrl=4";
        return PostData("admin\r\nivycrest\r\n1\r\n1\r\n1\r\n3\r\nYES\r\n");
 }
Beispiel #16
0
 // when a powerup is "played," adds the event undergone to events
 public void WhenPlayed(PowerAction action)
 {
     Played += action;
 }
Beispiel #17
0
 public PowerManipulationViewController(WalletPresenter presenter, PowerAction action)
 {
     _walletPresenter = presenter;
     _powerAction     = action;
 }
Beispiel #18
0
 public PowerElement(Identifier identifier, PowerAction action) : this(identifier)
 {
     _overridenAction = action;
 }
Beispiel #19
0
        public async Task <OperationResult <VoidResponse> > TryPowerUpOrDown(BalanceModel balance, PowerAction powerAction)
        {
            var model = new PowerUpDownModel(balance, powerAction);

            return(await TryRunTask <PowerUpDownModel, VoidResponse>(PowerDownOrDown, OnDisposeCts.Token, model));
        }
Beispiel #20
0
        public PowerActionForm(PowerAction action)
        {
            InitializeComponent();

            Application.Idle += new EventHandler(Application_Idle);

            RechargeBox.Items.Add(PowerAction.RECHARGE_2);
            RechargeBox.Items.Add(PowerAction.RECHARGE_3);
            RechargeBox.Items.Add(PowerAction.RECHARGE_4);
            RechargeBox.Items.Add(PowerAction.RECHARGE_5);
            RechargeBox.Items.Add(PowerAction.RECHARGE_6);

            Array actions = Enum.GetValues(typeof(ActionType));

            foreach (ActionType a in actions)
            {
                ActionBox.Items.Add(a);
                SustainBox.Items.Add(a);
            }

            if (action != null)
            {
                fAction = action.Copy();
            }

            if (fAction != null)
            {
                fAction = action.Copy();

                TraitBox.Checked = false;

                switch (fAction.Use)
                {
                case PowerUseType.AtWill:
                    AtWillBtn.Checked      = true;
                    BasicAttackBtn.Checked = false;
                    break;

                case PowerUseType.Basic:
                    AtWillBtn.Checked      = true;
                    BasicAttackBtn.Checked = true;
                    break;

                case PowerUseType.Encounter:
                    EncounterBtn.Checked = true;
                    RechargeBox.Text     = fAction.Recharge;
                    break;

                case PowerUseType.Daily:
                    DailyBtn.Checked = true;
                    break;
                }

                ActionBox.SelectedItem  = fAction.Action;
                TriggerBox.Text         = fAction.Trigger;
                SustainBox.SelectedItem = fAction.SustainAction;
            }
            else
            {
                TraitBox.Checked = true;

                AtWillBtn.Checked       = true;
                BasicAttackBtn.Checked  = false;
                ActionBox.SelectedItem  = ActionType.Standard;
                SustainBox.SelectedItem = ActionType.None;
            }
        }
Beispiel #21
0
 public PowerUpDownFragment(BalanceModel balance, PowerAction action)
 {
     _balance     = balance;
     _powerAction = action;
 }
Beispiel #22
0
        public PowerActionForm(PowerAction action)
        {
            this.InitializeComponent();
            Application.Idle += new EventHandler(this.Application_Idle);
            this.RechargeBox.Items.Add("Recharges on 2-6");
            this.RechargeBox.Items.Add("Recharges on 3-6");
            this.RechargeBox.Items.Add("Recharges on 4-6");
            this.RechargeBox.Items.Add("Recharges on 5-6");
            this.RechargeBox.Items.Add("Recharges on 6");
            foreach (ActionType value in Enum.GetValues(typeof(ActionType)))
            {
                this.ActionBox.Items.Add(value);
                this.SustainBox.Items.Add(value);
            }
            if (action != null)
            {
                this.fAction = action.Copy();
            }
            if (this.fAction == null)
            {
                this.TraitBox.Checked        = true;
                this.AtWillBtn.Checked       = true;
                this.BasicAttackBtn.Checked  = false;
                this.ActionBox.SelectedItem  = ActionType.Standard;
                this.SustainBox.SelectedItem = ActionType.None;
                return;
            }
            this.fAction          = action.Copy();
            this.TraitBox.Checked = false;
            switch (this.fAction.Use)
            {
            case PowerUseType.Encounter:
            {
                this.EncounterBtn.Checked = true;
                this.RechargeBox.Text     = this.fAction.Recharge;
                break;
            }

            case PowerUseType.AtWill:
            {
                this.AtWillBtn.Checked      = true;
                this.BasicAttackBtn.Checked = false;
                break;
            }

            case PowerUseType.Basic:
            {
                this.AtWillBtn.Checked      = true;
                this.BasicAttackBtn.Checked = true;
                break;
            }

            case PowerUseType.Daily:
            {
                this.DailyBtn.Checked = true;
                break;
            }
            }
            this.ActionBox.SelectedItem  = this.fAction.Action;
            this.TriggerBox.Text         = this.fAction.Trigger;
            this.SustainBox.SelectedItem = this.fAction.SustainAction;
        }
Beispiel #23
0
        public async Task <AssetPowerStateDto> UpdatePowerStateAsync(Guid assetId, PowerAction state)
        {
            var asset = await _assetService.GetAssetAsync(assetId);

            if (asset.Model.MountType == "blade")
            {
                return(await SetBladePowerStatus(asset, state));
            }

            var pduPorts = asset.PowerPorts
                           .Where(o => o.PduPort != null)
                           .GroupBy(o => o.PduPort.Pdu.ToString())
                           .ToDictionary(d => d.Key,
                                         d => d.Select(o => o.PduPort.Number)
                                         .ToList());
            var powerStates = new List <AssetPowerPortStateDto>();

            foreach (var kvp in pduPorts)
            {
                // data is pdu: (hpdu-rtp1-A01L) (rack address + pdunumber + (LorR)
                // port: number
                // v: on, off
                foreach (var port in kvp.Value)
                {
                    var requestData = new Dictionary <String, String>
                    {
                        { "pdu", kvp.Key },
                        { "port", port.ToString() },
                        { "v", state.ToString().ToLower() }
                    };

                    if (state.ToString().ToLower().Equals("cycle"))
                    {
                        requestData.Remove("v");
                        requestData.Add("v", "off");
                        var d = new FormUrlEncodedContent(requestData);
                        var r = await Client.PostAsync("/power.php", d);

                        await Task.Delay(2000);

                        // Two seconds after sending the power off signal, send power on
                        requestData.Remove("v");
                        requestData.Add("v", "on");
                    }

                    var data     = new FormUrlEncodedContent(requestData);
                    var response = await Client.PostAsync("/power.php", data);

                    Console.WriteLine(response);

                    // Translate the action that was taken on the asset into a current power state
                    var powerState = PowerState.Off;
                    if (state == PowerAction.On || state == PowerAction.Cycle)
                    {
                        powerState = PowerState.On;
                    }

                    var powerPortState = new AssetPowerPortStateDto()
                    {
                        Port   = kvp.Key.ToString(),
                        Status = powerState
                    };

                    powerStates.Add(powerPortState);
                }
            }
            var ret = new AssetPowerStateDto()
            {
                Id         = assetId,
                PowerPorts = powerStates
            };

            //GetChassisPower();
            return(ret);
        }
Beispiel #24
0
 public PowerActionEventArgs(Game g, PowerAction a)
 {
     Game   = g;
     Action = a;
 }
Beispiel #25
0
        private void Browser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            if (e.Url.Scheme == "power")
            {
                if (e.Url.LocalPath == "info")
                {
                    e.Cancel = true;

                    PowerInfoForm dlg = new PowerInfoForm(fPower);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        fPower.Name     = dlg.PowerName;
                        fPower.Keywords = dlg.PowerKeywords;

                        update_statblock();
                    }
                }

                if (e.Url.LocalPath == "action")
                {
                    e.Cancel = true;

                    PowerAction     action = fPower.Action;
                    PowerActionForm dlg    = new PowerActionForm(action);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        fPower.Action = dlg.Action;

                        refresh_examples();
                        update_statblock();
                    }
                }

                if (e.Url.LocalPath == "prerequisite")
                {
                    e.Cancel = true;

                    DetailsForm dlg = new DetailsForm(fPower.Condition, "Power Prerequisite", null);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        fPower.Condition = dlg.Details;
                        update_statblock();
                    }
                }

                if (e.Url.LocalPath == "range")
                {
                    e.Cancel = true;

                    PowerRangeForm dlg = new PowerRangeForm(fPower);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        fPower.Range = dlg.PowerRange;
                        update_statblock();
                    }
                }

                if (e.Url.LocalPath == "attack")
                {
                    e.Cancel = true;

                    PowerAttack attack = fPower.Attack;
                    if (attack == null)
                    {
                        attack = new PowerAttack();
                    }

                    int             level = (fCreature != null) ? fCreature.Level : 0;
                    IRole           role  = (fCreature != null) ? fCreature.Role : null;
                    PowerAttackForm dlg   = new PowerAttackForm(attack, fFromFunctionalTemplate, level, role);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        fPower.Attack = dlg.Attack;

                        refresh_examples();
                        update_statblock();
                    }
                }

                if (e.Url.LocalPath == "clearattack")
                {
                    e.Cancel = true;

                    fPower.Attack = null;

                    refresh_examples();
                    update_statblock();
                }

                if (e.Url.LocalPath == "details")
                {
                    e.Cancel = true;

                    PowerDetailsForm dlg = new PowerDetailsForm(fPower.Details, fCreature);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        fPower.Details = dlg.Details;
                        update_statblock();
                    }
                }

                if (e.Url.LocalPath == "desc")
                {
                    e.Cancel = true;

                    DetailsForm dlg = new DetailsForm(fPower.Description, "Power Description", null);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        fPower.Description = dlg.Details;
                        update_statblock();
                    }
                }
            }

            if (e.Url.Scheme == "details")
            {
                if (e.Url.LocalPath == "refresh")
                {
                    e.Cancel = true;

                    refresh_examples();
                    update_statblock();
                }

                try
                {
                    int index = int.Parse(e.Url.LocalPath);
                    e.Cancel = true;

                    fPower.Details = fExamples[index];
                    fExamples.RemoveAt(index);

                    if (fExamples.Count == 0)
                    {
                        refresh_examples();
                    }

                    update_statblock();
                }
                catch
                {
                    // Not a number
                }
            }
        }