Exemple #1
0
        public static void ScriptedKeyItem(Client client, KeyItem keyItem, int slot)
        {
            switch (keyItem.ItemID)
            {
            case 1839:     // Costume box
            {
                Messenger.SendAvailableCostumes(client);
            }
            break;

            case 1842:     // Drif-Flute
            {
                if (client.Player.Map.Indoors || client.Player.Map.MapType != Enums.MapType.Standard)
                {
                    var story   = new Story();
                    var segment = StoryBuilder.BuildStory();
                    StoryBuilder.AppendSaySegment(segment, "It's probably a bad idea to use that here.", client.Player.GetActiveRecruit().Species, 0, 0);
                    segment.AppendToStory(story);
                    StoryManager.PlayStory(client, story);

                    return;
                }

                if (client.Player.OutlawRole == Enums.OutlawRole.Outlaw && IsOutlawPlayerInRange(client, 30, Enums.OutlawRole.Hunter))
                {
                    Messenger.StoryMessage(client, "It's not safe to use that now! A hunter is nearby!");

                    return;
                }

                Messenger.SendAvailableFlyPoints(client);
            }
            break;
            }
        }
Exemple #2
0
 public Key(KeyItem item, KeyBundle bundle, AzureKeyVault vault)
 {
     _vault     = vault;
     _rsaParams = bundle.Key.ToRSAParameters();
     Name       = item.Identifier.Name;
     Version    = item.Identifier.Version;
 }
Exemple #3
0
 public static void ReportKeyItemCollected(KeyItem itemCollected)
 {
     if (OnKeyItemCollected != null)
     {
         OnKeyItemCollected(itemCollected);
     }
 }
Exemple #4
0
        public static IMaze GeneratePreBuildMaze()
        {
            var keyForFourthRoom = new KeyItem("Key 4", 10);
            var keyForFinalRoom  = new KeyItem("Key 7", 50);

            var first   = new Room();
            var second  = new Room();
            var third   = new Room(new IItem[] { keyForFourthRoom });
            var fourth  = new Room();
            var fifth   = new Room();
            var sixth   = new Room(new IItem[] { keyForFinalRoom });
            var seventh = new Room();

            first.AddDoorTo(second);
            second.AddDoorTo(third);
            second.AddDoorTo(fourth, keyForFourthRoom);
            third.AddDoorTo(second);
            fourth.AddDoorTo(fifth);
            fifth.AddDoorTo(sixth);
            fifth.AddDoorTo(seventh, keyForFinalRoom);
            sixth.AddDoorTo(fifth);

            var allRooms = new IRoom[]
            {
                first,
                second,
                third,
                fourth,
                fifth,
                sixth,
                seventh
            };

            return(new Maze(allRooms, first, seventh));
        }
Exemple #5
0
 private void New_Click(object sender, RoutedEventArgs e)
 {
     if (containerTabControl.SelectedItem == keysTabItem)
     {
         KeyItem key = new KeyItem();
         key.Id   = Settings.ContainerInner.NextKeyNumber;
         key.Name = string.Format("Key {0}", Settings.ContainerInner.NextKeyNumber);
         Settings.ContainerInner.NextKeyNumber++;
         key.ActiveKeyset = true;
         key.KeysetId     = 1;
         key.Sln          = 1;
         key.KeyTypeAuto  = true;
         key.KeyTypeTek   = false;
         key.KeyTypeKek   = false;
         key.KeyId        = 1;
         key.AlgorithmId  = 0x84;
         key.Key          = BitConverter.ToString(KeyGenerator.GenerateVarKey(32).ToArray()).Replace("-", string.Empty);
         Settings.ContainerInner.Keys.Add(key);
     }
     else if (containerTabControl.SelectedItem == groupsTabItem)
     {
         Container.GroupItem group = new Container.GroupItem();
         group.Id   = Settings.ContainerInner.NextGroupNumber;
         group.Name = string.Format("Group {0}", Settings.ContainerInner.NextGroupNumber);
         Settings.ContainerInner.NextGroupNumber++;
         group.Keys = new List <int>();
         Settings.ContainerInner.Groups.Add(group);
     }
 }
Exemple #6
0
        public static IList <HistogramItem> GetDateHistogram <T>(this KeyItem item,
                                                                 Expression <Func <T, Object> > fieldGetter)
        {
            var histogramItem = item.DateHistogram(GetName(fieldGetter));

            return(histogramItem.Items);
        }
    override protected void DoCreate()
    {
        tabBar             = new TabBar <string>(new SwitchList <string>(), TabBar <string> .DefaultStringOf);
        tabBar.Text        = Name;
        tabBar.CloseClick += OnCloseClick;
        Controls.Add(tabBar);

        KeyMap  frameKeyMap = new KeyMap();
        KeyItem escape      = new KeyItem(Keys.Escape, null,
                                          new KeyAction("&View\\File tree\\Cancel renaming", DoCancel, null, false));

        frameKeyMap.AddItem(escape);
        frameKeyMap.AddItem(new KeyItem(Keys.Enter, null,
                                        new KeyAction("&View\\File tree\\Complete renaming", DoComplete, null, false)));

        KeyMap beforeKeyMap = new KeyMap();

        beforeKeyMap.AddItem(escape);

        textBox = new MulticaretTextBox();
        textBox.KeyMap.AddBefore(beforeKeyMap);
        textBox.KeyMap.AddAfter(KeyMap);
        textBox.KeyMap.AddAfter(frameKeyMap, 1);
        textBox.KeyMap.AddAfter(DoNothingKeyMap, -1);
        textBox.FocusedChange += OnTextBoxFocusedChange;
        Controls.Add(textBox);

        tabBar.MouseDown += OnTabBarMouseDown;
        InitResizing(tabBar, null);
    }
Exemple #8
0
 protected void OnKeyPickup(KeyItem key)
 {
     if (KeyPickup != null)
     {
         KeyPickup.Invoke(key);
     }
 }
Exemple #9
0
        public ActionResult DeleteStaffOrganisation(Guid?staffCode, FormCollection form)
        {
            var model = GetUpdatedModel();

            //Set flags false
            SetFlagsFalse(model);

            //Establish which staff organisation to remove
            Guid StaffOrganisationValue = Guid.Empty;

            foreach (string KeyItem in form)
            {
                if (KeyItem.StartsWith("ApplicationStaffAdmin::DeleteStaffOrganisation"))
                {
                    StaffOrganisationValue = Guid.Parse(KeyItem.Substring(47));
                    break;
                }
            }

            var StaffOrganisationItem = model.StaffOrganisationList.Single(x => x.Code == StaffOrganisationValue);

            model.StaffOrganisationList.Remove(StaffOrganisationItem);

            DetermineIsDirty(model);
            return(View(model));
        }
Exemple #10
0
 public static void ReportKeyItemInPosition(KeyItem key)
 {
     if (OnKeyItemCollected != null)
     {
         OnKeyInPosition(key);
     }
 }
        public ISprite CreateKeyItem(Vector2 startingPos, bool kept, bool resetKept)
        {
            IItem add = new KeyItem(spriteBatch, textures["key"], startingPos, kept, resetKept);

            RoomItems.Instance.AddItem(add);
            return(add);
        }
        private IAggregation GetKeyedBucketItem(JsonReader reader, JsonSerializer serializer)
        {
            reader.Read();
            var key = reader.Value;

            reader.Read();
            var property = reader.Value as string;

            if (property == "from" || property == "to")
            {
                return(GetRangeAggregation(reader, serializer, key.ToString()));
            }


            var keyItem = new KeyItem();

            keyItem.Key = key.ToString();
            reader.Read();             //doc_count;
            var docCount = reader.Value as long?;

            keyItem.DocCount = docCount.GetValueOrDefault(0);
            reader.Read();

            var nextProperty = reader.Value as string;

            if (nextProperty == "score")
            {
                return(GetSignificantTermItem(reader, serializer, keyItem));
            }


            keyItem.Aggregations = this.GetNestedAggregations(reader, serializer);
            return(keyItem);
        }
    private void Awake()
    {
        //情報取得
        _playerObject     = GameObject.Find("Player");
        _playerController = _playerObject.GetComponentInChildren <PlayerController>();

        _initialEquipmentObject = GameObject.Find("FlashLight");
        _initialEquipment       = _initialEquipmentObject.GetComponent <Item>();

        _enemyObject = GameObject.Find("Enemy_tutorial");
        _enemyBrain  = _enemyObject.GetComponentInChildren <ChangeTargetPoint>();

        _barrier = GameObject.Find("Barriers");

        _lampObject = GameObject.Find("Lamp_C");

        _lightEffectObject = GameObject.Find("Flash");
        _lightEffect       = _lightEffectObject.GetComponent <Light>();

        _tranquilizerObject = GameObject.Find("Tranquilizer");
        _tranquilizer       = _tranquilizerObject.GetComponent <Tranquilizer>();

        _keyItemObject = GameObject.Find("KeyItem");
        _keyItem       = _keyItemObject.GetComponent <KeyItem>();
    }
Exemple #14
0
        private void ProcessKeyItemUse(KeyItem keyItem)
        {
            string message;

            switch (keyItem.UseAction)
            {
            case KeyItem.UseActionType.OPENLOCATION:
                message = _gameMap.OpenLocationsByItem(keyItem.Id);
                CurrentLocationInformation = keyItem.UseMessage;
                break;

            case KeyItem.UseActionType.DAMAGE:
                OnPlayerDies(keyItem.UseMessage);
                break;

            case KeyItem.UseActionType.GIVENPC:
                message = keyItem.UseMessage;
                _player.UpdateMissionStatus();
                _player.RemoveGameItemQuantityFromInventory(_currentGameItem);
                break;

            default:
                break;
            }
        }
Exemple #15
0
    public void SelectChoice(int stage, int choice)
    {
        choice = ConvertChoice(stage, choice);
        KeyItem[] items = new KeyItem[0];
        if (stage <= 0)
        {
            items = vehicleItems;
        }
        else if (stage == 1)
        {
            items = sceneItems;
        }
        else if (stage >= 2)
        {
            items = roadItems;
        }

        for (int i = 0; i < items.Length; i++)
        {
            if (i == choice)
            {
                items[i].isActive = true;
            }
            else
            {
                items[i].isActive = false;
            }
        }
    }
Exemple #16
0
 public void ConfirmPurchase(KeyItem itemAsset)
 {
     PlayerManager.playerData.SetMoney(PlayerManager.playerData.GetMoney() - itemAsset.GetPrice());
     PlayerManager.playerData.SetKeyItemBoughtById(itemAsset.GetID(), true);
     yesButton.onClick.RemoveAllListeners();
     DeselectItem();
     UpdateUI();
 }
Exemple #17
0
 // Token: 0x0600044E RID: 1102 RVA: 0x0001C68C File Offset: 0x0001A88C
 private void btnKeyEntry_Click(object sender, EventArgs e)
 {
     if (hotkey.Hotkey != Keys.None)
     {
         var item = new KeyItem(hotkey.Hotkey);
         listKeys.Items.Add(item);
         toolTip1.Hide(label5);
     }
 }
 public Transform AddKey(KeyItem key)
 {
     keys.Add(key);
     if (keys.Count == 1)
     {
         return(transform);
     }
     return(keys[keys.Count - 2].transform);
 }
Exemple #19
0
 private void btnKeyEntry_Click(object sender, EventArgs e)
 {
     if (this.hotkey.Hotkey != Keys.None)
     {
         KeyItem item = new KeyItem(this.hotkey.Hotkey);
         this.listKeys.Items.Add(item);
         this.toolTip1.Hide(this.label5);
     }
 }
Exemple #20
0
        /// <summary>
        ///     Load the form and set up the choices
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SetShortcutKeyForm_Load(object sender, EventArgs e)
        {
            // set the tooltip
            tooltip.SetToolTip(advancedTextbox, strings._SetShortcutKeyForm_advancedTextbox_tooltip);

            // load the key list
            keyCombo.Items.Clear();
            KeyItem selected = null;

            keyCombo.Items.Add("None");
            foreach (WinAPI.VirtualKeyCode vk in Enum.GetValues(typeof(WinAPI.VirtualKeyCode)))
            {
                if (vk >= WinAPI.VirtualKeyCode.VK_SPACE)
                {
                    var item = new KeyItem(vk);
                    keyCombo.Items.Add(item);
                    if (Hotkey != null && Hotkey.Key == vk)
                    {
                        selected = item;
                    }
                }
            }

            if (selected != null)
            {
                keyCombo.SelectedItem = selected;
            }
            else
            {
                keyCombo.SelectedIndex = 0;
            }

            // set the modifiers
            if (Hotkey != null)
            {
                shiftToggle.Checked = (Hotkey.Modifiers & WinAPI.KeyModifiers.Shift) != 0;
                ctrlToggle.Checked  = (Hotkey.Modifiers & WinAPI.KeyModifiers.Control) != 0;
                altToggle.Checked   = (Hotkey.Modifiers & WinAPI.KeyModifiers.Alt) != 0;

                notifyRadioButton.Enabled = true;
                notifyRadioButton.Checked = Hotkey.Action == HotKey.HotKeyActions.Notify;
                //
                injectRadioButton.Enabled = true;
                injectRadioButton.Checked = Hotkey.Action == HotKey.HotKeyActions.Inject;
                injectTextbox.Enabled     = injectRadioButton.Checked;
                injectTextbox.Text        = injectRadioButton.Checked ? Hotkey.Window : string.Empty;
                //
                pasteRadioButton.Enabled = true;
                pasteRadioButton.Checked = Hotkey.Action == HotKey.HotKeyActions.Copy;
                //
                advancedRadioButton.Enabled = true;
                advancedRadioButton.Checked = Hotkey.Action == HotKey.HotKeyActions.Advanced;
                advancedTextbox.Enabled     = advancedRadioButton.Checked;
                advancedTextbox.Text        = advancedRadioButton.Checked ? Hotkey.Advanced : string.Empty;
            }
        }
        public KeySender(PaneHotKeys KeyItems)
        {
            // Store the hotkeys.
            HotKeys    = KeyItems;
            KeyStrings = new List <string>();

            // Name of OBS Window.
            ProcName       = ConfigurationManager.AppSettings.Get("OBSWindowName");
            ServiceAppType = ConfigurationManager.AppSettings.Get("StreamServiceSW");

            // Find the refocus value.
            bool.TryParse(ConfigurationManager.AppSettings.Get("ForceRefocus").ToLower(), out ForceFocusOBS);

            // Check for null.
            if (string.IsNullOrEmpty(ServiceAppType))
            {
                throw new Exception("PLEASE SPECIFY SERVICE APP TYPE (OBS, XPLIT, ETC)");
            }
            if (string.IsNullOrEmpty(ProcName))
            {
                throw new Exception("PLEASE SPECIFY THE OBS WINDOW NAME AND RESTART THIS APP");
            }

            // Pull in the SendAttempts and SendDelayTime
            if (!int.TryParse(ConfigurationManager.AppSettings.Get("KeySendCount"), out SendAttempts))
            {
                SendAttempts = 2;   // Default send count.
            }
            if (!int.TryParse(ConfigurationManager.AppSettings.Get("SendDelayValue"), out SendDelayTime))
            {
                SendDelayTime = 50; // Default delay time.
            }
            // Make sure we don't have some absurd value here.
            uint CheckNegativeSendAttempts  = (uint)SendAttempts;
            uint CheckNegativeSendDelayTime = (uint)SendDelayTime;

            // Negative value check.
            SendAttempts  = (int)CheckNegativeSendAttempts;
            SendDelayTime = (int)CheckNegativeSendDelayTime;

            // Gigantic number check
            if (SendAttempts >= 5)
            {
                SendAttempts = 5;
            }
            if (SendDelayTime >= 500)
            {
                SendAttempts = 500;
            }

            // Convert the list of ConsoleKey items into string items.
            foreach (var KeyItem in HotKeys.HotKeysList)
            {
                KeyStrings.Add(KeyItem.ToString());
            }
        }
Exemple #22
0
    public override void Accept(Visitor visitor)
    {
        KeyItem keyItem = GetComponent <KeyItem>();

        if (keyItem != null)
        {
            AddKey(keyItem.GetKeyType());
        }
        Destroy(gameObject, 0.1f);
    }
Exemple #23
0
        public void ScrapKeyPress(object sender, ScrapKeyPressEventArgs e)
        {
            KeyItem item = this.keyBook.FindKeyItem(e.key);

            if (item != null)
            {
                ScrapBase scrap = (ScrapBase)sender;
                item.ParentStyle.Apply(ref scrap);
            }
        }
Exemple #24
0
 protected override void InitializeView(IClientController clientController, ICrossViewManager crossViewManager)
 {
     KeyItems                             = new ObservableCollection <KeyItem>();
     _currentKeyItem                      = new KeyItem();
     _liveKeyloggerCommand                = clientController.Commander.GetCommand <LiveKeyloggerCommand>();
     _liveKeyloggerCommand.KeyDown       += LiveKeyloggerCommandOnKeyUpDown;
     _liveKeyloggerCommand.KeyUp         += LiveKeyloggerCommandOnKeyUpDown;
     _liveKeyloggerCommand.StringDown    += LiveKeyloggerCommandOnStringDown;
     _liveKeyloggerCommand.WindowChanged += LiveKeyloggerCommandOnWindowChanged;
 }
 public void AddToKeyItemBag(KeyItem newKeyItem)
 {
     if (keyItemBag.TryGetValue(newKeyItem.keyItemName.ToString(), out KeyItem curKeyItme))
     {
         Debug.Log("WTF YOU HAVE A DUP");
     }
     else
     {
         keyItemBag.Add(newKeyItem.keyItemName, newKeyItem);
     }
 }
Exemple #26
0
 public static bool HasKeyItem(KeyItem requiredItem)
 {
     foreach (KeyItem item in m_keyItems)
     {
         if (item.name == requiredItem.name)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #27
0
 public bool TestKey(KeyItem tryKey)
 {
     if (key.Equals(tryKey))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #28
0
        private string BuildKeyItemHeader(int responseID)
        {
            DialogResponse response  = GetResponseByID(GetCurrentPageName(), responseID);
            int            keyItemID = (int)response.CustomData;
            KeyItem        entity    = _keyItem.GetKeyItemByID(keyItemID);

            string header = _color.Green("Key Item: ") + entity.Name + "\n\n";

            header += _color.Green("Description: ") + entity.Description + "\n";

            return(header);
        }
Exemple #29
0
 public void OnKeyItemCOllected(KeyItem key)
 {
     for (int i = 0; i < currKeyItems.Count; i++)
     {
         if (currKeyItems[i] == key)
         {
             keyItems[i].DOColor(Color.white, 0.5f);
             keyItems[i].rectTransform.DOScale(Vector3.one * 1.5f, 0.5f);
             StartCoroutine(ReturnKeyItemIcon(keyItems[i]));
         }
     }
 }
Exemple #30
0
    private KeyItem GetKeyOrCreate(string name)
    {
        KeyItem item = keys.Find(x => x.name == name);

        if (item == null)
        {
            item = new KeyItem(name);
            keys.Add(item);
        }

        return(item);
    }
Exemple #31
0
 public void removeKeyItem(int index)
 {
     KeyItem empty = new KeyItem();
     keyItemsList [index] = empty;
     slots [index] = empty;
 }
		public IList<KeyItem> GetKeysForEncryption()
		{
			var crypto = new PgpCrypto(new CryptoContext());
			var keys = new List<KeyItem>();

			foreach (PgpPublicKey key in crypto.GetPublicKeyUserIdsForEncryption())
			{
				foreach (string user in key.GetUserIds())
				{
					var match = Regex.Match(user, @"<(.*)>");
					if (!match.Success)
						continue;

					var k = new KeyItem();
					k.Key = match.Groups[1].Value;
					k.KeyDisplay = user;

					var fingerprint = key.GetFingerprint();
					k.KeyId =
						fingerprint[fingerprint.Length - 4].ToString("X2") +
						fingerprint[fingerprint.Length - 3].ToString("X2") +
						fingerprint[fingerprint.Length - 2].ToString("X2") +
						fingerprint[fingerprint.Length - 1].ToString("X2");

					if (key.GetValidSeconds() != 0)
						k.Expiry = key.CreationTime.AddSeconds(key.GetValidSeconds()).ToShortDateString();

					keys.Add(k);
				}
			}

			return keys;
		}
 private IAggregation GetSignificantTermItem(JsonReader reader, JsonSerializer serializer, KeyItem keyItem)
 {
     reader.Read();
     var score = reader.Value as double?;
     reader.Read();
     reader.Read();
     var bgCount = reader.Value as long?;
     var significantTermItem = new SignificantTermItem()
     {
         Key = keyItem.Key,
         DocCount = keyItem.DocCount,
         BgCount = bgCount.GetValueOrDefault(0),
         Score = score.GetValueOrDefault(0)
     };
     reader.Read();
     significantTermItem.Aggregations = this.GetNestedAggregations(reader, serializer);
     return significantTermItem;
 }
 private Key MapVaultKeyToLocalKey(KeyItem vaultKey)
 {
    return new Key(vaultKey.Kid);
 }
Exemple #35
0
 public bool HasKeyitem(KeyItem item)
 {
     return HasKeyItem(_InstanceID, (uint)item);
 }
		internal KeyListViewItem(string txt, KeyItem keyItem): base(txt)
		{
			KeyItem = keyItem;

			SubItems.Add(new ListViewItem.ListViewSubItem(this, keyItem.Expiry));
			SubItems.Add(new ListViewItem.ListViewSubItem(this, keyItem.KeyId));
		}
        private IAggregation GetKeyedBucketItem(JsonReader reader, JsonSerializer serializer)
        {
            reader.Read();
            var key = reader.Value as string;
            reader.Read();
            var property = reader.Value as string;
            if (property == "from" || property == "to")
                return GetRangeAggregation(reader, serializer, key);

            var keyItem = new KeyItem();
            keyItem.Key = key;
            reader.Read(); //doc_count;
            var docCount = reader.Value as long?;
            keyItem.DocCount = docCount.GetValueOrDefault(0);
            reader.Read();

            var nextProperty = reader.Value as string;
            if (nextProperty == "score")
            {
                return GetSignificantTermItem(reader, serializer, keyItem);
            }

            keyItem.Aggregations = this.GetNestedAggregations(reader, serializer);
            return keyItem;
        }
		/// <summary>
		/// Load the form and set up the choices
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void SetShortcutKeyForm_Load(object sender, EventArgs e)
		{
			// set the tooltip
			tooltip.SetToolTip(advancedTextbox, strings._SetShortcutKeyForm_advancedTextbox_tooltip);

			// load the key list
			keyCombo.Items.Clear();
			KeyItem selected = null;
			keyCombo.Items.Add("None");
			foreach (WinAPI.VirtualKeyCode vk in Enum.GetValues(typeof(WinAPI.VirtualKeyCode)))
			{
				if (vk >= WinAPI.VirtualKeyCode.VK_SPACE)
				{
					var item = new KeyItem(vk);
					keyCombo.Items.Add(item);
					if (Hotkey != null && Hotkey.Key == vk)
					{
						selected = item;
					}
				}
			}
			if (selected != null)
			{
				keyCombo.SelectedItem = selected;
			}
			else
			{
				keyCombo.SelectedIndex = 0;
			}

			// set the modifiers
			if (this.Hotkey != null)
			{
				shiftToggle.Checked = ((this.Hotkey.Modifiers & WinAPI.KeyModifiers.Shift) != 0);
				ctrlToggle.Checked = ((this.Hotkey.Modifiers & WinAPI.KeyModifiers.Control) != 0);
				altToggle.Checked = ((this.Hotkey.Modifiers & WinAPI.KeyModifiers.Alt) != 0);

				this.notifyRadioButton.Enabled = true;
				this.notifyRadioButton.Checked = (this.Hotkey.Action == HotKey.HotKeyActions.Notify);
				//
				this.injectRadioButton.Enabled = true;
				this.injectRadioButton.Checked = (this.Hotkey.Action == HotKey.HotKeyActions.Inject);
				this.injectTextbox.Enabled = this.injectRadioButton.Checked;
				this.injectTextbox.Text = (this.injectRadioButton.Checked == true ? this.Hotkey.Window : string.Empty);
				//
				this.pasteRadioButton.Enabled = true;
				this.pasteRadioButton.Checked = (this.Hotkey.Action == HotKey.HotKeyActions.Copy);
				//
				this.advancedRadioButton.Enabled = true;
				this.advancedRadioButton.Checked = (this.Hotkey.Action == HotKey.HotKeyActions.Advanced);
				this.advancedTextbox.Enabled = this.advancedRadioButton.Checked;
				this.advancedTextbox.Text = (this.advancedRadioButton.Checked == true ? this.Hotkey.Advanced : string.Empty);
			}

		}
Exemple #39
0
        // 创建指定记录的检索点集合
        // parameters:
        //		domData	记录数据dom 不能为null
        //		strRecordID	记录id 不能为null或空
        //		strLang	语言版本
        //		strStyle	风格,暂没有用上
        //		nKeySize	检索点尺寸
        //		keys	out参数,返回生成的检索点集合
        //		strError	out参数,出错信息
        // return:
        //		-1	出错
        //		0	成功
        public int BuildKeys(XmlDocument domData,
            string strRecordID,
            string strLang,
//             string strStyle,
            int nKeySize,
            out KeyCollection keys,
            out string strError)
        {
            strError = "";
            keys = new KeyCollection();

            if (this.dom == null)
                return 0;

            if (domData == null)
            {
                strError = "BuildKeys()调用错误,domData参数不能为null。";
                Debug.Assert(false, strError);
                return -1;
            }

            // Debug.Assert(strRecordID != null && strRecordID != "", "BuildKeys()调用错误,strRecordID参数不能为null或为空。");

            if (String.IsNullOrEmpty(strLang) == true)
            {
                strError = "BuildKeys()调用错误,strLang参数不能为null。";
                Debug.Assert(false, strError);
                return -1;
            }

            /*
            if (String.IsNullOrEmpty(strStyle) == true)
            {
                strError = "BuildKeys()调用错误,strStyle参数不能为null。";
                Debug.Assert(false, strError);
                return -1;
            }
             * */

            if (nKeySize < 0)
            {
                strError = "BuildKeys()调用错误,nKeySize参数不能小于0。";
                Debug.Assert(false, strError);
                return -1;
            }

            int nRet = 0;

            // 找到所有<key>节点
            // TODO: <key> 是否有明确的位置? 那样就可以避免 // 查找。或者预先缓存起来
            XmlNodeList keyList = dom.SelectNodes("//key");

            XPathNavigator nav = domData.CreateNavigator();

        CREATE_CACHE:
            // 创建Cache
            if (m_exprCache.Count == 0 && keyList.Count > 0)
            {
                for (int i = 0; i < keyList.Count; i++)
                {
                    XmlNode nodeKey = keyList[i];

                    XmlElement nodeXPath = (XmlElement)nodeKey.SelectSingleNode("xpath");
                    if (nodeXPath == null)
                        continue;

                    string strScriptAttr = nodeXPath.GetAttribute("scripting");

                    if (String.Compare(strScriptAttr, "on", true) == 0)
                        continue;

                    string strXPath = nodeXPath.InnerText.Trim();
                    if (string.IsNullOrEmpty(strXPath) == true)
                        continue;

                    // strNstableName 如果为 null 表示属性不存在
                    string strNstableName = DomUtil.GetAttrDiff(nodeXPath, "nstable");

                    XmlNamespaceManager nsmgr = (XmlNamespaceManager)this.tableNsClient[nodeXPath];
#if DEBUG
                    if (nsmgr != null)
                    {
                        Debug.Assert(strNstableName != null, "如果具备名字空间对象,表明<xpath>元素应该有 'nstable' 属性。");
                    }
                    else
                    {
                        Debug.Assert(strNstableName == null, "如果不具备名字空间对象,表明<xpath>元素必须没有定义 'nstable' 属性。");
                    }
#endif

                    XPathExpression expr = nav.Compile(strXPath);
                    if (nsmgr != null)
                        expr.SetContext(nsmgr);

                    m_exprCache[nodeXPath] = expr;
                }
            }

            string strKey = "";
            string strKeyNoProcess = "";
            string strFromName = "";
            string strFromValue = "";
            string strSqlTableName = "";
            string strNum = "";

            for (int i = 0; i < keyList.Count; i++)
            {
                XmlElement nodeKey = (XmlElement)keyList[i];

                strKey = "";
                strKeyNoProcess = "";
                strFromName = "";
                strFromValue = "";
                strSqlTableName = "";
                strNum = "";

                // TODO: 用 GetElementsByTagName 优化
                XmlNode nodeFrom = nodeKey.SelectSingleNode("from");
                if (nodeFrom != null)
                    strFromValue = nodeFrom.InnerText.Trim(); // 2012/2/16

                // 找不到<key>下级的<table>节点,就应该报错
                XmlNode nodeTable = nodeKey.SelectSingleNode("table");
                if (nodeTable == null)
                {
                    strError = "<key>下级未定义<table>节点。";
                    return -1;
                }

                TableInfo tableInfo = (TableInfo)this.tableTableInfoClient[nodeTable];
                Debug.Assert(tableInfo != null, "从Hashtable里取出的tabInfo不可能为null。");



                strSqlTableName = tableInfo.SqlTableName.Trim();

                // 根据语言版本获得来源名称
                strFromName = tableInfo.GetCaption(strLang);


                // 所有的检索点字符串
                List<string> aKey = new List<string>();


                XmlNode nodeXpath = nodeKey.SelectSingleNode("xpath");
                string strScriptAttr = "";
                if (nodeXpath != null)
                    strScriptAttr = DomUtil.GetAttr(nodeXpath, "scripting");

                
                if (String.Compare(strScriptAttr, "on", true) == 0)
                {
                    // 执行脚本得到检索点
                    //aKey.Add("abc");

                    //string strOutputString = "";
                    List<String> OutputStrings = null;
                    string strFunctionName = nodeXpath.InnerText.Trim();     // 2012/2/16
                    nRet = this.DoScriptFunction(domData,
                        strFunctionName,
                        "", //strInputString
                        // out strOutputString,
                        out OutputStrings,
                        out strError);
                    if (nRet == -1)
                        return -1;

                    // 2007/1/23
                    if (OutputStrings != null)
                    {
                        for (int j = 0; j < OutputStrings.Count; j++)
                        {
                            if (String.IsNullOrEmpty(OutputStrings[j]) == false)
                            {
                                aKey.Add(OutputStrings[j]);
                                // nCount++;
                            }
                        }
                    }

                }
                else
                {
                    string strXpath = "";
                    if (nodeXpath != null)
                        strXpath = nodeXpath.InnerText.Trim(); // 2012/2/16

                    string strNstableName = DomUtil.GetAttrDiff(nodeXpath, "nstable");
#if NO
                    XmlNamespaceManager nsmgr = (XmlNamespaceManager)this.tableNsClient[nodeXpath];
#if DEBUG
                    if (nsmgr != null)
                    {
                        Debug.Assert(strNstableName != null, "此时应该没有定义'nstable'属性。");
                    }
                    else
                    {
                        Debug.Assert(strNstableName == null, "此时必须没有定义'nstable'属性。");
                    }
#endif

                    XPathExpression expr = nav.Compile(strXpath);   // TODO 可以优化
                    if (nsmgr != null)
                        expr.SetContext(nsmgr);
#endif
                    // 2012/7/20优化
                    XPathExpression expr = (XPathExpression)m_exprCache[nodeXpath];

                    if (expr == null)
                    {
                        this.m_exprCache.Clear();
                        goto CREATE_CACHE;  // TODO: 如何预防死循环?
                    }

                    string strMyKey = "";

                    if (expr.ReturnType == XPathResultType.Number)
                    {
                        strMyKey = nav.Evaluate(expr).ToString();//Convert.ToString((int)(nav.Evaluate(expr)));
                        aKey.Add(strMyKey);
                    }
                    else if (expr.ReturnType == XPathResultType.Boolean)
                    {
                        strMyKey = Convert.ToString((bool)(nav.Evaluate(expr)));
                        aKey.Add(strMyKey);
                    }
                    else if (expr.ReturnType == XPathResultType.String)
                    {
                        strMyKey = (string)(nav.Evaluate(expr));
                        aKey.Add(strMyKey);
                    }
                    else if (expr.ReturnType == XPathResultType.NodeSet)
                    {
                        // ????????xpath命中多个节点时,是否创建多个key
                        XPathNodeIterator iterator = null;
                        try
                        {
                            iterator = nav.Select(expr);
                        }
                        catch (Exception ex)
                        {
                            string strTempNstableName = "";
                            if (strNstableName == null)
                                strTempNstableName = "null";
                            else
                                strTempNstableName = "'" + strNstableName + "'";
                            strError = "用路径'" + strXpath + "'选节点时出错," + ex.Message + " \r\n使用的名字空间表名为" + strTempNstableName + "。";
                            return -1;
                        }

                        if (iterator != null)
                        {
                            while (iterator.MoveNext())
                            {
                                XPathNavigator navigator = iterator.Current;
                                strMyKey = navigator.Value;
                                if (strMyKey == "")
                                    continue;

                                aKey.Add(strMyKey);
                            }
                        }
                    }
                    else
                    {
                        throw (new Exception("XPathExpression的ReturnType为'" + expr.ReturnType.ToString() + "'无效"));
                    }
                }


                for (int j = 0; j < aKey.Count; j++)
                {
                    strKey = aKey[j];
                    //???????注意,如果key内容为空,是否也应该算作一个key呢?
                    if (strKey == "")
                    	continue;

                    strKeyNoProcess = strKey;
                    strNum = "-1";

                    List<string> outputKeys = new List<string>();
                    if (tableInfo.nodeConvertKeyString != null)
                    {
                        nRet = ConvertKeyWithStringNode(domData,
                            strKey,
                            tableInfo.nodeConvertKeyString,
                            out outputKeys,
                            out strError);
                        if (nRet == -1)
                            return -1;
                    }
                    else
                    {
                        outputKeys = new List<string>();
                        outputKeys.Add(strKey);
                    }

                    for (int k = 0; k < outputKeys.Count; k++)
                    {
                        string strOneKey = outputKeys[k];
                        //根据自身的配置进行处理,得到num
                        if (tableInfo.nodeConvertKeyNumber != null)
                        {
                            nRet = ConvertKeyWithNumberNode(
                                domData,
                                strOneKey,
                                tableInfo.nodeConvertKeyNumber,
                                out strNum,
                                out strError);
                            if (nRet == -1)
                                return -1;
                            if (nRet == 1)
                            {
                                // 2010/9/27
                                strOneKey = strError + " -- " + strOneKey;
                                strNum = "-1";
                            }

                            // 2010/11/20
                            if (String.IsNullOrEmpty(strNum) == true)
                                continue;
                        }

                        if (strOneKey.Length > nKeySize)
                            strOneKey = strOneKey.Substring(0, nKeySize);
                        if (strNum.Length >= 20)
                            strNum = strNum.Substring(0, 19);

                        KeyItem keyItem = new KeyItem(strSqlTableName,
                            strOneKey,
                            strFromValue,
                            strRecordID,
                            strNum,
                            strKeyNoProcess,
                            strFromName);

                        keys.Add(keyItem);
                    }
                }
            }


            return 0;
        }
		public IList<KeyItem> GetKeysForSigning()
		{
			var crypto = new PgpCrypto(new CryptoContext());
			var keys = new List<KeyItem>();

			foreach (var key in crypto.GetPublicKeyUserIdsForSign())
			{
				var match = Regex.Match(key, @"<(.*)>");
				if (!match.Success)
					continue;

				var k = new KeyItem();
				k.Key = match.Groups[1].Value;
				k.KeyDisplay = key;

				keys.Add(k);
			}

			return keys;
		}