Beispiel #1
0
        private void AddBranche(TreeViewItem tvi, MenuItem mnu)
        {
            foreach (var c in mnu.Items)
            {
                MenuItem m = c as MenuItem;
                if (m != null)
                {
                    TreeViewItem stvi = new TreeViewItem();

                    ShortCutInfo sci = (from a in _allMenuItems where a.MenuName == m.Name select a).FirstOrDefault();
                    if (sci == null)
                    {
                        sci = new ShortCutInfo(m.Name);
                        _allMenuItems.Add(sci);
                    }
                    stvi.Tag    = sci;
                    stvi.Header = m.Header;
                    tvi.Items.Add(stvi);

                    if (m.Items.Count > 0)
                    {
                        stvi.IsExpanded = true;
                        AddBranche(stvi, m);
                    }
                }
            }
        }
Beispiel #2
0
        public DialogResult ShowDialog(ShortCutInfo item, IWin32Window owner = null)
        {
            this.ShortCutInfo = item ?? new ShortCutInfo {
                Name = context.AppInfo.AppName
            };
            this.txtName.Text = this.ShortCutInfo.Name;
            if (this.ShortCutInfo.TargetDir != null)
            {
                this.cmbTargetDir.SelectedItem = this.ShortCutInfo.TargetDir;
            }
            else
            {
                if (this.cmbTargetDir.Items.Count > 0)
                {
                    this.cmbTargetDir.SelectedIndex = 0;
                }
            }
            if (this.ShortCutInfo.Target != null)
            {
                this.cmbTarget.SelectedItem = this.ShortCutInfo.Target;
            }
            this.txtArgs.Text = this.ShortCutInfo.Args;

            if (owner != null)
            {
                return(this.ShowDialog(owner));
            }
            else
            {
                return(this.ShowDialog());
            }
        }
Beispiel #3
0
    public List <ShortCutInfo> LoadShortCutInfo()
    {
        List <ShortCutInfo> shortCutInfos = new List <ShortCutInfo>();
        string    sql = "select * from shortcut_information where user_id=" + GameConfig.UserId + " order by shortcut_id";
        DataTable dt  = MysqlHelper.ExecuteTable(sql, CommandType.Text, null);

        if (dt.Rows.Count > 0)
        {
            foreach (DataRow dr in dt.Rows)
            {
                ShortCutInfo shortCutInfo = new ShortCutInfo();
                shortCutInfo.ShortCutID = int.Parse(dr["shortcut_id"].ToString());
                if (dr["skill_id"] == DBNull.Value)
                {
                    shortCutInfo.SkillID = -1;
                }
                else
                {
                    shortCutInfo.SkillID = int.Parse(dr["skill_id"].ToString());
                }
                shortCutInfos.Add(shortCutInfo);
            }
        }
        return(shortCutInfos);
    }
Beispiel #4
0
        //TODO:初始化快捷键上面的技能数据,不包含等级等数据
        public SkillFullInfo(int skId, int index)
        {
            var sinfo = ShortCutInfo.CreateBuilder();

            sinfo.Index  = index;
            sinfo.BaseId = skId;
            sinfo.Type   = 0;
            shortInfo    = sinfo.BuildPartial();

            skillData = Util.GetSkillData(skId, 1);
        }
Beispiel #5
0
        public ShortCutAssignmentWindow()
        {
            InitializeComponent();

            _allMenuItems = new List <ShortCutInfo>();
            if (!string.IsNullOrEmpty(Core.Settings.Default.MainWindowShortCutKeyAssignment))
            {
                string[] lines = Core.Settings.Default.MainWindowShortCutKeyAssignment.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string l in lines)
                {
                    //Shift|Control|Alt|Windows|MenuName|Key
                    string[] parts = l.Split(new char[] { '|' }, 6);
                    if (parts.Length == 6)
                    {
                        ShortCutInfo sci = new ShortCutInfo(parts[4]);
                        sci.Shift    = bool.Parse(parts[0]);
                        sci.Control  = bool.Parse(parts[1]);
                        sci.Alt      = bool.Parse(parts[2]);
                        sci.Windows  = bool.Parse(parts[3]);
                        sci.ShortKey = parts[5];
                        _allMenuItems.Add(sci);
                    }
                }
            }

            Menu mainMenu = Core.ApplicationData.Instance.MainWindow.mainMenu;

            foreach (var c in mainMenu.Items)
            {
                MenuItem m = c as MenuItem;
                if (m != null)
                {
                    TreeViewItem tvi = new TreeViewItem();

                    ShortCutInfo sci = (from a in _allMenuItems where a.MenuName == m.Name select a).FirstOrDefault();
                    if (sci == null)
                    {
                        sci = new ShortCutInfo(m.Name);
                        _allMenuItems.Add(sci);
                    }
                    tvi.Tag    = sci;
                    tvi.Header = m.Header;
                    treeView.Items.Add(tvi);

                    if (m.Items.Count > 0)
                    {
                        tvi.IsExpanded = true;
                        AddBranche(tvi, m);
                    }
                }
            }

            keyAssignment.Visibility = System.Windows.Visibility.Hidden;
        }
Beispiel #6
0
        private void treeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            ShortCutInfo sci = null;

            if (treeView.SelectedItem != null)
            {
                TreeViewItem tvi = treeView.SelectedItem as TreeViewItem;
                if (tvi != null)
                {
                    sci = tvi.Tag as ShortCutInfo;
                }
            }
            keyAssignment.Visibility = (sci != null && !string.IsNullOrEmpty(sci.MenuName)) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;

            DataContext = sci;
        }
        public IEnumerator SetSkillShortCut(int skId, int index)
        {
            var packet = new KBEngine.PacketHolder();
            var b      = CGModifyShortcutsInfo.CreateBuilder();

            b.IdAdd = true;
            var shortInfo = ShortCutInfo.CreateBuilder();

            shortInfo.Index   = index;
            shortInfo.IndexId = index;
            shortInfo.BaseId  = skId;
            shortInfo.Type    = 0;
            b.SetShortCutInfo(shortInfo);

            yield return(StartCoroutine(KBEngine.Bundle.sendSimple(this, b, packet)));

            //var ret = packet.packet.protoBody as GCModifyShortcutsInfo;
            SetShortSkillData(skId, index);
        }
Beispiel #8
0
        public static void GetShortCuts(KBEngine.Packet packet)
        {
            var au    = GCLoadShortcutsInfo.CreateBuilder();
            var pinfo = ServerData.Instance.playerInfo;

            if (pinfo.HasSkill)
            {
                var defaultSlot = GetShortCutsInfo();
                int ind         = 0;
                foreach (var sk in defaultSlot)
                {
                    if (sk != 0)
                    {
                        var sh = ShortCutInfo.CreateBuilder();
                        sh.Index  = ind;
                        sh.BaseId = sk;
                        au.AddShortCutInfo(sh);
                    }
                    ind++;
                }
            }
            ServerBundle.SendImmediate(au, packet.flowId);
        }
Beispiel #9
0
        /// <summary>
        /// 默认前4种技能占用 1 2 3 4 的槽
        /// 当有技能设置了槽 则使用该技能占用 特定槽
        /// </summary>
        static void PushSkillShortcutsInfo()
        {
            var au    = GCPushShortcutsInfo.CreateBuilder();
            var pinfo = ServerData.Instance.playerInfo;

            if (pinfo.HasSkill)
            {
                var defaultSlot = GetShortCutsInfo();
                var ind         = 0;
                foreach (var sk in defaultSlot)
                {
                    if (sk != 0)
                    {
                        var sh = ShortCutInfo.CreateBuilder();
                        sh.Index  = ind;
                        sh.BaseId = sk;
                        au.AddShortCutInfo(sh);
                    }
                    ind++;
                }
            }
            ServerBundle.SendImmediatePush(au);
        }
Beispiel #10
0
 //TODO:快捷键技能的信息 需要通过ShortCutInfo和普通的SkillInfo 来初始化 获得技能的等级信息
 //TODO:根据快捷键信息 初始化技能信息 或者 使用道具药品的信息
 public SkillFullInfo(ShortCutInfo sh)
 {
     shortInfo = sh;
     skillData = Util.GetSkillData(sh.BaseId, 1);
     //Pos = sh.Index;
 }
        public ShortCutAssignmentWindow()
        {
            InitializeComponent();

            _allMenuItems = new List<ShortCutInfo>();
            if (!string.IsNullOrEmpty(Core.Settings.Default.MainWindowShortCutKeyAssignment))
            {
                string[] lines = Core.Settings.Default.MainWindowShortCutKeyAssignment.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string l in lines)
                {
                    //Shift|Control|Alt|Windows|MenuName|Key
                    string[] parts = l.Split(new char[] { '|' }, 6);
                    if (parts.Length == 6)
                    {
                        ShortCutInfo sci = new ShortCutInfo(parts[4]);
                        sci.Shift = bool.Parse(parts[0]);
                        sci.Control = bool.Parse(parts[1]);
                        sci.Alt = bool.Parse(parts[2]);
                        sci.Windows = bool.Parse(parts[3]);
                        sci.ShortKey = parts[5];
                        _allMenuItems.Add(sci);
                    }
                }
            }

            Menu mainMenu = Core.ApplicationData.Instance.MainWindow.mainMenu;
            foreach (var c in mainMenu.Items)
            {
                MenuItem m = c as MenuItem;
                if (m != null)
                {
                    TreeViewItem tvi = new TreeViewItem();

                    ShortCutInfo sci = (from a in _allMenuItems where a.MenuName == m.Name select a).FirstOrDefault();
                    if (sci == null)
                    {
                        sci = new ShortCutInfo(m.Name);
                        _allMenuItems.Add(sci);
                    }
                    tvi.Tag = sci;
                    tvi.Header = m.Header;
                    treeView.Items.Add(tvi);

                    if (m.Items.Count > 0)
                    {
                        tvi.IsExpanded = true;
                        AddBranche(tvi, m);
                    }
                }
            }

            keyAssignment.Visibility = System.Windows.Visibility.Hidden;
        }
        private void AddBranche(TreeViewItem tvi, MenuItem mnu)
        {
            foreach (var c in mnu.Items)
            {
                MenuItem m = c as MenuItem;
                if (m != null)
                {
                    TreeViewItem stvi = new TreeViewItem();

                    ShortCutInfo sci = (from a in _allMenuItems where a.MenuName == m.Name select a).FirstOrDefault();
                    if (sci == null)
                    {
                        sci = new ShortCutInfo(m.Name);
                        _allMenuItems.Add(sci);
                    }
                    stvi.Tag = sci;
                    stvi.Header = m.Header;
                    tvi.Items.Add(stvi);

                    if (m.Items.Count > 0)
                    {
                        stvi.IsExpanded = true;
                        AddBranche(stvi, m);
                    }
                }
            }
        }