예제 #1
0
        public void LoadRequest(string path, string data)
        {
            string shortpath = path.Substring(path.LastIndexOf("/kcsapi/") + 8);

            try {
                Utility.Logger.Add(1, "Request を受信しました : " + shortpath);

                SystemEvents.UpdateTimerEnabled = false;


                var parsedData = new Dictionary <string, string>();
                data = HttpUtility.UrlDecode(data);

                foreach (string unit in data.Split("&".ToCharArray()))
                {
                    string[] pair = unit.Split("=".ToCharArray());
                    parsedData.Add(pair[0], pair[1]);
                }


                APIList.OnRequestReceived(shortpath, parsedData);
                RequestReceived(shortpath, parsedData);
            } catch (Exception ex) {
                ErrorReporter.SendErrorReport(ex, "Request の受信中にエラーが発生しました。", shortpath, data);
            } finally {
                SystemEvents.UpdateTimerEnabled = true;
            }
        }
예제 #2
0
        public void LoadResponse(string path, string data)
        {
            string shortpath = path.Substring(path.LastIndexOf("/kcsapi/") + 8);

            try
            {
                Utility.Logger.Add(1, "Recieved response:" + shortpath);

                SystemEvents.UpdateTimerEnabled = false;


                var json = DynamicJson.Parse(data.Substring(7));                        //remove "svdata="

                int result = (int)json.api_result;
                if (result != 1)
                {
                    if (result == 201)
                    {
                        Utility.Logger.Add(3,
                                           "Error code 201 was received. It may be triggered by macro detection " +
                                           "or by starting KanColle from another device.");
                    }
                    else
                    {
                        throw new InvalidOperationException($"Error code {result} was received from the server.");
                    }
                }


                if (shortpath == "api_get_member/ship2")
                {
                    ResponseReceived(shortpath, json);
                    APIList.OnResponseReceived(shortpath, json);
                }
                else if (json.IsDefined("api_data"))
                {
                    ResponseReceived(shortpath, json.api_data);
                    APIList.OnResponseReceived(shortpath, json.api_data);
                }
                else
                {
                    ResponseReceived(shortpath, null);
                    APIList.OnResponseReceived(shortpath, null);
                }
            }
            catch (Exception ex)
            {
                ErrorReporter.SendErrorReport(ex,
                                              "There was an error while receiving the response.",
                                              shortpath, data);
            }
            finally
            {
                SystemEvents.UpdateTimerEnabled = true;
            }
        }
예제 #3
0
 public APIBase this[string key] {
     get {
         if (APIList.ContainsKey(key))
         {
             return(APIList[key]);
         }
         else
         {
             return(null);
         }
     }
 }
예제 #4
0
    private APIList GetApiListFromElement(XElement element)
    {
        APIList _list = new APIList();

        _list._ApiTypes = new List <APIType>();
        foreach (XElement xElement in element.Elements())
        {
            APIType api = GetApiTypeFromElement(xElement);
            _list._ApiTypes.Add(api);
        }
        return(_list);
    }
예제 #5
0
        public void LoadResponse(string path, string data)
        {
            string shortpath = path.Substring(path.LastIndexOf("/kcsapi/") + 8);

            try
            {
                Utility.Logger.Add(1, "Responseを受信しました : " + shortpath);

                SystemEvents.UpdateTimerEnabled = false;


                var json = DynamicJson.Parse(data.Substring(7));                        //remove "svdata="

                int result = (int)json.api_result;
                if (result != 1)
                {
                    throw new InvalidOperationException("猫を検出しました。(エラーコード: " + result + ")");
                }


                if (shortpath == "api_get_member/ship2")
                {
                    ResponseReceived(shortpath, json);
                    APIList.OnResponseReceived(shortpath, json);
                }
                else if (json.IsDefined("api_data"))
                {
                    ResponseReceived(shortpath, json.api_data);
                    APIList.OnResponseReceived(shortpath, json.api_data);
                }
                else
                {
                    ResponseReceived(shortpath, null);
                    APIList.OnResponseReceived(shortpath, null);
                }
            }
            catch (Exception ex)
            {
                ErrorReporter.SendErrorReport(ex, "Responseの受信中にエラーが発生しました。", shortpath, data);
            }
            finally
            {
                SystemEvents.UpdateTimerEnabled = true;
            }
        }
예제 #6
0
        public void LoadResponse(string path, string data)
        {
            string shortpath = path.Substring(path.LastIndexOf("/kcsapi/") + 8);

            try {
                //Utility.Logger.Add( 1, LoggerRes.RecievedResponse + shortpath );

                SystemEvents.UpdateTimerEnabled = false;


                var json = DynamicJson.Parse(data.Substring(7));                                //remove "svdata="

                int result = (int)json.api_result;
                if (result != 1)
                {
                    var ex = new ArgumentException(LoggerRes.ResponseHadErrorCode + result);
                    Utility.ErrorReporter.SendErrorReport(ex, LoggerRes.ResponseHadErrorCode);
                    throw ex;
                }


                if (shortpath == "api_get_member/ship2")
                {
                    APIList.OnResponseReceived(shortpath, json);
                }
                else if (json.IsDefined("api_data"))
                {
                    APIList.OnResponseReceived(shortpath, json.api_data);
                }
                else
                {
                    APIList.OnResponseReceived(shortpath, null);
                }
            } catch (Exception ex) {
                ErrorReporter.SendErrorReport(ex, LoggerRes.ResponseError, shortpath, data);
            } finally {
                SystemEvents.UpdateTimerEnabled = true;
            }
        }
예제 #7
0
        private void setClipboard(string text)
        {
            System.Windows.Forms.Clipboard.SetText(text);

            if (this.ForehWnd != IntPtr.Zero)
            {
                this.contextMenuStrip1.Hide();

                APIList.SetActiveWindow(this.ForehWnd);
                Thread.Sleep(50);

                //貼付処理
                //SendKeys.Send("^V");
                var VK_CONTROL        = 0x11;
                var KEYEVENTF_KEYDOWN = 0x0;
                var KEYEVENTF_KEYUP   = 0x2;
                APIList.keybd_event((byte)VK_CONTROL, (byte)0, (uint)KEYEVENTF_KEYDOWN, (UIntPtr)0);
                APIList.keybd_event((byte)Keys.V, (byte)0, (uint)KEYEVENTF_KEYDOWN, (UIntPtr)0);
                Thread.Sleep(50);
                APIList.keybd_event((byte)Keys.V, (byte)0, (uint)KEYEVENTF_KEYUP, (UIntPtr)0);
                APIList.keybd_event((byte)VK_CONTROL, (byte)0, (uint)KEYEVENTF_KEYUP, (UIntPtr)0);
            }
        }
예제 #8
0
파일: SkyBot.cs 프로젝트: hitmen047/SkyBot
        public void DisableAPI(APIList id)
        {
            IConnectionAPI api = APIs.Find(x => (x.ID == id && x.Status != APIStatus.Disabled));

            api?.Disconnect();
        }
예제 #9
0
파일: SkyBot.cs 프로젝트: hitmen047/SkyBot
        public void EnableAPI(APIList id)
        {
            IConnectionAPI api = APIs.Find(x => (x.ID == id && x.Status == APIStatus.Disabled));

            api?.Connect(this);
        }
예제 #10
0
        private void keyboardHook1_KeyboardHooked(object sender, HongliangSoft.Utilities.Gui.KeyboardHookedEventArgs e)
        {
            //デバッグで実行するには デバッグ VS ホスティングプロセスを有効にする のチェックを外す
            if (e.KeyCode == this.PopupShortcutKey ||
                (this.PopupShortcutKeySub.HasValue == true && e.KeyCode == this.PopupShortcutKeySub.Value)
                )
            {
                if (e.UpDown == HongliangSoft.Utilities.Gui.KeyboardUpDown.Down)
                {
                    up_time = DateTime.Now;
                }
                else if (e.UpDown == HongliangSoft.Utilities.Gui.KeyboardUpDown.Up)
                {
                    DateTime now = DateTime.Now;

                    TimeSpan ts = now - up_time;
                    //down upの時間(押しっぱなしの場合は無視する) doubleClickTimeの流用は微妙かも・・
                    if (ts.TotalMilliseconds > doubleClickTime)
                    {
                        return;
                    }

                    //左ShiftKey ダブルクリック
                    ts        = now - prev_time;
                    prev_time = now;

                    if (ts.TotalMilliseconds <= doubleClickTime)
                    {
                        //すでに開いている場合は無視
                        if (isContextMenuStripOpen == true)
                        {
                            return;
                        }

                        //フォーカス位置の取得
                        this.ForehWnd = APIList.GetForegroundWindow();
                        var   current = APIList.GetCurrentThreadId();
                        var   target  = APIList.GetWindowThreadProcessId(this.ForehWnd, IntPtr.Zero);
                        Point p;
                        APIList.AttachThreadInput(current, target, true);
                        APIList.GetCaretPos(out p);
                        var fWnd = APIList.GetFocus();
                        APIList.ClientToScreen(fWnd, out p);
                        APIList.AttachThreadInput(current, target, false);

                        //ダブルクリック処理
                        var task = Task.Factory.StartNew(
                            () =>
                        {
                            this.Invoke(
                                (MethodInvoker)(() =>
                            {
                                Thread.Sleep(200);

                                //APIList.SetTopMost(this.Handle);
                                this.contextMenuStrip1.Show(p.X, p.Y);

                                this.contextMenuStrip1.Focus();
                                APIList.SetForegroundWindow(this.contextMenuStrip1.Handle);

                                if (this.contextMenuStrip1.Items.Count > 0)
                                {
                                    this.contextMenuStrip1.Items[0].Select();
                                }
                            }
                                                )
                                );
                        }
                            );
                    }
                }
            }
            else if (e.UpDown == HongliangSoft.Utilities.Gui.KeyboardUpDown.Up && e.KeyCode == Keys.Escape)
            {
                //キャンセルの処理
                if (isContextMenuStripOpen == true)
                {
                    this.contextMenuStrip1.Close();
                }
            }
            else
            {
                //ダブルクリックの間に違うキーが押された場合は一旦キャンセル
                up_time = DateTime.MinValue;
            }
        }
예제 #11
0
        private void OnClipBoardChanged(object sender, ClipboardEventArgs args)
        {
            if (Clipboard.ContainsText(System.Windows.Forms.TextDataFormat.Text))
            {
                var clipText = "";
                clipText = (String)System.Windows.Forms.Clipboard.GetData(System.Windows.Forms.DataFormats.StringFormat);

                using (MemoryStream ms = (MemoryStream)System.Windows.Forms.Clipboard.GetData("Csv"))
                {
                    //★特別処理★Excelからのコピー (改行がある場合ダブルコーテーションが追加されるので削除する)
                    //こちらの処理を入れない場合は一旦wordに貼り付けてコピー
                    if (ms != null)
                    {
                        if (clipText.Contains("\n") && clipText.StartsWith(@""""))
                        {
                            clipText = clipText.Replace(@"""""", "\t¶\t");
                            clipText = clipText.Replace(@"""", "");
                            clipText = clipText.Replace("\t¶\t", @"""");
                        }
                    }
                }

                var item = getClipTextItem(clipText);

                if (item == null)
                {
                    return;
                }

                Point p = new Point(0, 0);

                APIList.GetCursorPos(out p);

                try
                {
                    if (this.contextMenuStrip1.Items.Count > 0 && this.contextMenuStrip1.Items[0].Tag != null)
                    {
                        if ((String)(this.contextMenuStrip1.Items[0].Tag) == (String)clipText)
                        {
                            if (Properties.Settings.Default.SameWordAlert == true)
                            {
                                //キャレットの位置が違ったら(マウスの位置で判定しているのでカーソル移動の時は無視される(公認バグ?))
                                if ((oldPoint.X != p.X || oldPoint.Y != p.Y))
                                {
                                    this.Activate();
                                    MessageBox.Show("同じデータが追加されました。");
                                    //this.notifyIcon1.BalloonTipText = "同じデータが追加されました。";
                                    //this.notifyIcon1.ShowBalloonTip(100);
                                }
                            }

                            return;
                        }
                    }
                }
                finally
                {
                    oldPoint = p;
                }

                this.contextMenuStrip1.Items.Insert(0, item);

                //履歴数を超えた場合の削除処理
                int MaxCountData = Properties.Settings.Default.RirekiCount;
                if (this.ClipboardHistoryCount > MaxCountData)
                {
                    for (int index = this.contextMenuStrip1.Items.Count - 1; index >= MaxCountData; index--)
                    {
                        if (this.contextMenuStrip1.Items[index].Tag != null)
                        {
                            this.contextMenuStrip1.Items.RemoveAt(index);
                        }
                    }
                }

                //検索用の履歴
                int MaxSerchCountData = Properties.Settings.Default.ALLRirekiCount;

                if (this.ALLClipData.Contains(clipText) == false)
                {
                    this.ALLClipData.Insert(0, clipText);
                    if (this.ALLClipData.Count > MaxSerchCountData)
                    {
                        for (int index = this.ALLClipData.Count - 1; index >= MaxSerchCountData; index--)
                        {
                            this.ALLClipData.RemoveAt(index);
                        }
                    }
                }
            }
        }