Example #1
0
    private void OnClickLK(ButtonScript obj, object args, int param1, int param2)
    {
        SceneData ssdata = SceneData.GetData(GameManager.SceneID);

        if (ssdata.sceneType_ == SceneType.SCT_Instance)
        {
            if (CopyData.IsCopyScene(GameManager.SceneID))
            {
                MessageBoxUI.ShowMe(LanguageManager.instance.GetValue("likaifuben"), () =>
                {
                    NetConnection.Instance.exitCopy();
                });
            }
            else
            {
                NetConnection.Instance.exitTeam();
                NetConnection.Instance.exitLobby();
            }
        }
        else
        {
            NetConnection.Instance.exitTeam();
            NetConnection.Instance.exitLobby();
        }
        tipsObj.SetActive(false);
    }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            CopyData   s      = new CopyData(this, false);
            CopyStatus status = s.SendMessage("Test message 1234567890 1234567890 1234567890 1234567890", "Test Receiver");

            status = s.SendMessage("Test message A", "SpeechCristi");
        }
Example #3
0
        public void WriteOffsetRecords(BinaryWriter writer, IDBRowSerializer <T> serializer, uint recordOffset, int sparseCount)
        {
            var sparseIdLookup = new Dictionary <int, uint>(sparseCount);

            for (int i = 0; i < sparseCount; i++)
            {
                if (serializer.Records.TryGetValue(i, out var record))
                {
                    if (CopyData.TryGetValue(i, out int copyid))
                    {
                        // copy records use their parent's offset
                        writer.Write(sparseIdLookup[copyid]);
                        writer.Write(record.TotalBytesWrittenOut);
                    }
                    else
                    {
                        writer.Write(sparseIdLookup[i] = recordOffset);
                        writer.Write(record.TotalBytesWrittenOut);
                        recordOffset += (uint)record.TotalBytesWrittenOut;
                    }
                }
                else
                {
                    // unused ids are empty records
                    writer.BaseStream.Position += 6;
                }
            }
        }
    void InitChests()
    {
        childChests.Clear();

        if (chestsRoot == null)
        {
            return;
        }

        foreach (Transform child in chestsRoot)
        {
            child.gameObject.SetActiveRecursively(false);
            childChests.Add(child);
        }
        childChests.Sort(delegate(Transform a, Transform b)
        {
            // Sort by name
            return(string.Compare(a.name, b.name));
        });

        CopyData cpData = Globals.Instance.MGameDataManager.MCurrentCopyData;

        int upperLimit = Mathf.Min(childChests.Count, cpData.MCopyChestData.ChestIDList.Count);

        for (int i = 0; i < upperLimit; i++)
        {
            int id = cpData.MCopyChestData.ChestIDList[i];
            InitOneRandomChest(childChests[i], id);
        }
    }
Example #5
0
    void OnClickDoYER(ButtonScript obj, object args, int param1, int param2)
    {
        SceneData ssdata = SceneData.GetData(GameManager.SceneID);

        if (ssdata.sceneType_ == SceneType.SCT_Instance)
        {
            if (CopyData.IsCopyScene(GameManager.SceneID))
            {
                MessageBoxUI.ShowMe(LanguageManager.instance.GetValue("likaifuben"), () => {
                    NetConnection.Instance.exitCopy();
                    Prebattle.Instance.ActiveEnterScene(2);
                });
            }
        }
        else if (ssdata.sceneType_ == SceneType.SCT_GuildBattleScene)
        {
            MessageBoxUI.ShowMe(LanguageManager.instance.GetValue("likaijiazuzhan"), () => {
                Prebattle.Instance.ActiveEnterScene(2);
            });
        }
        else
        {
            Prebattle.Instance.ActiveEnterScene(2);
        }

        Hide();
    }
Example #6
0
 public void SaveData(CopyData data)
 {
     lock (this.syncLock)
     {
         this.data = data;
     }
 }
Example #7
0
        public BitmapInfo(Bitmap bitmap, CopyData copyData = CopyData.True)
        {
            Width       = bitmap.Width;
            Height      = bitmap.Height;
            Components  = Helper.GetComponentsNumber(bitmap.PixelFormat);
            PixelFormat = bitmap.PixelFormat;

            Rectangle  rect       = Rectangle.FromLTRB(0, 0, Width, Height);
            BitmapData bitmapData = bitmap.LockBits(rect,
                                                    ImageLockMode.ReadOnly, PixelFormat);

            Stride       = Math.Abs(bitmapData.Stride);
            DataByteSize = Stride * Height;
            Data         = new byte[DataByteSize];
            if (copyData == CopyData.True)
            {
                Marshal.Copy(bitmapData.Scan0, Data, 0, DataByteSize);
            }
            bitmap.UnlockBits(bitmapData);

            if (PixelFormat == PixelFormat.Format8bppIndexed)
            {
                palette = bitmap.Palette;
            }
        }
Example #8
0
 public void Copy()
 {
     CopyData.Clear();
     foreach (var item in Selection.ToList())
     {
         CopyData.Add(item);
     }
 }
Example #9
0
        /// <summary>
        /// Send DataTransport Object via Window-messages
        /// </summary>
        /// <param name="dataTransport">DataTransport with data for a running instance</param>
        private static void SendData(CopyDataTransport dataTransport)
        {
            string   appName  = Application.ProductName;
            CopyData copyData = new CopyData();

            copyData.Channels.Add(appName);
            copyData.Channels[appName].Send(dataTransport);
        }
Example #10
0
    public ShelfContainer GetRandomShelvingUnit(StockTypes selectedType = StockTypes.None)
    {
        // Check if there are shelves in the map
        if (shelvingUnits.Count == 0)
        {
            Debug.LogWarning(!isDoneLoading ? "MapManager is not done loading!" : "There are no shelves in the map!");

            return(null);
        }

        // Filter out shelves that are needed
        List <ShelfContainer> sortedShelfList = new List <ShelfContainer>();

        if (selectedType != StockTypes.None)
        {
            for (int i = 0; i < shelvingUnits.Count; i++)
            {
                ShelfContainer currentShelf = shelvingUnits[i];

                if (currentShelf.ShelfStockType == selectedType)
                {
                    sortedShelfList.Add(shelvingUnits[i]);
                }
            }
        }
        else
        {
            CopyData.CopyObjectData(shelvingUnits, sortedShelfList);
        }

        if (sortedShelfList.Count == 0)
        {
            Debug.LogWarning("There are no shelves that have this type of stock: " + selectedType.ToString());
            return(null);
        }

        // Filter out empty shelves
        List <ShelfContainer> stockedShelves = new List <ShelfContainer>();

        for (int s = 0; s < sortedShelfList.Count; s++)
        {
            ShelfContainer shelf = sortedShelfList[s];
            if (!shelf.IsEmpty())
            {
                stockedShelves.Add(shelf);
            }
        }

        if (stockedShelves.Count == 0)
        {
            Debug.Log("All shelves of " + selectedType.ToString() + " is empty!");
            return(EssentialFunctions.GetRandomFromArray(sortedShelfList));;
        }
        else
        {
            return(EssentialFunctions.GetRandomFromArray(stockedShelves));
        }
    }
    public static CopyData CreateForString(int dwData, string value, bool Unicode = false)
    {
        var result = new CopyData();

        result.dwData = (IntPtr)dwData;
        result.lpData = Unicode ? Marshal.StringToCoTaskMemUni(value) : Marshal.StringToCoTaskMemAnsi(value);
        result.cbData = value.Length + 1;
        return(result);
    }
    public static UIntPtr Send(IntPtr targetHandle, int dwData, string value, uint timeoutMs = 1000, bool Unicode = false)
    {
        var     cds = CopyData.CreateForString(dwData, value, Unicode);
        UIntPtr result;

        SendMessageTimeout(targetHandle, WM_COPYDATA, IntPtr.Zero, ref cds, SendMessageTimeoutFlags.SMTO_NORMAL, timeoutMs, out result);
        cds.Dispose();
        return(result);
    }
Example #13
0
        public CopyDataService()
        {
            this.data = null;

#if false
            Workspace.PrimaryWorkspace.WorkspaceChanged += (sender, args) =>
            {
                SaveData(null);
            };
#endif
        }
        public void SendMessageCopyDataToWindowAnsi(IntPtr hWnd, string data)
        {
            var copyData = new CopyData
            {
                dwData = IntPtr.Zero,
                cbData = data.Length + 1,
                lpData = Marshal.StringToCoTaskMemAnsi(data)
            };

            SendMessage(hWnd, 0x004A, IntPtr.Zero, ref copyData);
        }
Example #15
0
 static bool IsCopyEndId(int qid)
 {
     foreach (KeyValuePair <int, CopyData> pair in CopyData.GetData())
     {
         if (qid == pair.Value._EndID)
         {
             return(true);
         }
     }
     return(false);
 }
Example #16
0
 void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         copy = new CopyData(this);
         copy.OnDataReceived += copy_OnDataReceived;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #17
0
    void OnClickbackTeam(ButtonScript obj, object args, int param1, int param2)
    {
        int sceneid = TeamSystem.GetMyTeamLeader().sceneId_;

        if (CopyData.IsCopyScene(sceneid))
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("fubenguidui"));
            return;
        }
        NetConnection.Instance.backTeam();
//		zanshiBtn.gameObject.SetActive (true);
//		backTeamBtn.gameObject.SetActive (false);
    }
Example #18
0
        public void Clear()
        {
            IndexData      = null;
            PalletData     = null;
            ColumnMeta     = null;
            RecordsData    = null;
            ForeignKeyData = null;
            CommonData     = null;

            _Records?.Clear();
            StringTable?.Clear();
            SparseEntries?.Clear();
            CopyData?.Clear();
        }
Example #19
0
        public bool CheckApplicable(ITextBuffer subjectBuffer, CopyData copyData)
        {
            if (copyData == null)
            {
                return false;
            }

            var selection = view.Selection;
            var spans = selection.GetSnapshotSpansOnBuffer(subjectBuffer);
            if (spans.Count() != 1)
            {
                return false;
            }

            var document = subjectBuffer.CurrentSnapshot.GetRelatedDocumentsWithChanges().FirstOrDefault();
            if (document == null)
            {
                return false;
            }

            if (document.SourceCodeKind != SourceCodeKind.Regular)
            {
                return false;
            }

            var span = spans.Select(s => new TextSpan(s.Start, s.Length)).First();
            var newSpan = new TextSpan(span.Start, copyData.Text.Length);

            var newDocument = ForkNewDocument(copyData, document, span);

            // analyze in new document
            var newOffsetMap = CopyData.CreateOffsetMap(newDocument, newSpan);

            foreach (var pair in copyData)
            {
                var offset = pair.Key;
                var token = pair.Value.Item1;
                var symbol = pair.Value.Item2;

                // check whether existing symbol is same one
                if (IsSameSymbol(offset, token, symbol, newOffsetMap))
                {
                    continue;
                }

                // missing using, 
            }

            return false;
        }
Example #20
0
        public void Clear()
        {
            id_list_data   = null;
            PalletData     = null;
            ColumnMeta     = null;
            RecordsData    = null;
            refData        = null;
            ForeignKeyData = null;
            CommonData     = null;

            _Records?.Clear();
            StringTable?.Clear();
            offset_map_Entries?.Clear();
            CopyData?.Clear();
        }
Example #21
0
        public void CanCopyData()
        {
            var page = new CopyData();

            var jim   = 1301;
            var brian = 1229;
            var zygo  = 1182;

            var result = page.CopyData(jim, brian, zygo, true);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(1, result.Items.Count());
            Assert.AreEqual("Zygo", result.Vendor.VendorName);
            Assert.IsTrue(ItemRepository.GetVendorItems(result.Vendor.VendorID).Count() == 1);
        }
        public static void Send(IntPtr targetHandle, string value)
        {
            var data = new CopyData
            {
                dwData = (IntPtr)MessageId,
                lpData = Marshal.StringToCoTaskMemUni(value),
                cbData = 2 * value.Length + 1
            };

            SendMessage(targetHandle, WM_COPYDATA, IntPtr.Zero, ref data);

            Marshal.FreeCoTaskMem(data.lpData);
            data.lpData = IntPtr.Zero;
            data.cbData = 0;
        }
Example #23
0
    protected void Awake()
    {
        MActorData = new PlayerData();
        MEnemyData = new PlayerData();

        MCurrentSeaAreaData = new SeaAreaData();
        // Just for easy call
        MCurrentPortData = MCurrentSeaAreaData.MPortData;
        MCurrentCopyData = MCurrentSeaAreaData.MCurrentCopyData;

        MSeaAreaDataList = new Dictionary <int, SeaAreaData>();

        produceTeches   = new List <GameData.TechInfo>();
        warTeches       = new List <GameData.TechInfo>();
        formationTeches = new List <GameData.TechInfo>();
    }
    /// <summary>
    /// Replaces the boss.
    /// </summary>
    /// <param name='_originalModel'>
    /// _original model.
    /// </param>
    private void ReplaceBoss(GameObject _originalModel)
    {
        if (Globals.Instance.MGameDataManager == null)
        {
            return;
        }

        CopyData t_cpdata = Globals.Instance.MGameDataManager.MCurrentCopyData;
        List <CopyMonsterData.MonsterData> t_monsterList = t_cpdata.MCopyMonsterData.MMonsterDataList;

        if (t_monsterList.Count > 0)
        {
            CopyMonsterData.MonsterData t_monsterData = t_monsterList[t_monsterList.Count - 1];
            ReplaceModel(t_monsterData.ModelName, _originalModel);
        }
    }
Example #25
0
        public MainForm(CopyDataTransport dataTransport)
        {
            instance = this;
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            lang = Language.GetInstance();
            IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);

            // Make sure all hotkeys pass this window!
            HotkeyControl.RegisterHotkeyHWND(this.Handle);
            RegisterHotkeys();

            tooltip = new ToolTip();

            UpdateUI();
            InitializeQuickSettingsMenu();

            captureForm = new CaptureForm();

            // Load all the plugins
            PluginHelper.instance.LoadPlugins(this, captureForm);
            SoundHelper.Initialize();

            // Enable the Greenshot icon to be visible, this prevents Problems with the context menu
            notifyIcon.Visible = true;

            // Create a new instance of the class: copyData = new CopyData();
            copyData = new CopyData();

            // Assign the handle:
            copyData.AssignHandle(this.Handle);
            // Create the channel to send on:
            copyData.Channels.Add("Greenshot");
            // Hook up received event:
            copyData.CopyDataReceived += new CopyDataReceivedEventHandler(CopyDataDataReceived);

            if (dataTransport != null)
            {
                HandleDataTransport(dataTransport);
            }
            ClipboardHelper.RegisterClipboardViewer(this.Handle);
        }
Example #26
0
    void Start()
    {
        UIManager.SetButtonEventHandler(clostBtn.gameObject, EnumButtonEvent.OnClick, OnClickClose, 0, 0);

        Dictionary <int, CopyData> metaData = CopyData.GetData();

        foreach (var x in metaData.Values)
        {
            GameObject     objCell = Object.Instantiate(cell.gameObject) as GameObject;
            CopyOpenCellUI cellUI  = objCell.GetComponent <CopyOpenCellUI>();
            cellUI.cellData          = x;
            objCell.transform.parent = grid.transform;
            objCell.SetActive(true);
            objCell.transform.localScale = Vector3.one;
        }
        noOpenCell.transform.parent = grid.transform;
        noOpenCell.SetActive(true);
        noOpenCell.transform.localScale = Vector3.one;
    }
        private void ShowLog(object[] objs)
        {
            if (InvokeRequired)
            {
                Invoke(new DoInMainThread(ShowLog));
                return;
            }
            LogType type    = CopyData.GetLogType((int)objs[0]);
            string  message = (string)objs[1];

            if (UserManager.GetUserManager().GetCurrentUser().IsAdmin())
            {
                LogUtil.LogAdmin(LogTextBox, logFilePath, type, message);
            }
            else
            {
                LogUtil.LogTest(LogTextBox, logFilePath, type, message);
            }
        }
Example #28
0
        public async Task <IActionResult> createInstallationCopy([FromBody] CopyDataDB data)
        {
            // Write to SDDBackend
            var packageCopy = new CopyData(data.oldName, data.newName);

            try
            {
                var res = await pc.CreateCopy(packageCopy);
            }
            catch (HttpRequestException e) when(!e.Message.Contains("200"))
            {
                return(BadRequest());
            }

            // Getting data ready for database
            var inst = new Installation(data.newName, "20.52.46.188:3389", data.Subscription, data.copyMethod, data.client);

            // Check state of the installation that has been copied
            try
            {
                var instStateRes = await pc.GetStateAsync(data.oldName);

                inst.state = await instStateRes.Content.ReadAsStringAsync();
            }
            catch (HttpRequestException e) when(!e.Message.Contains("200"))
            {
                inst.state = "failed";
            }

            // Write to database
            try
            {
                await cc.CreateInstallationAsync(inst); // TODO: Check if failed
            }
            catch (Exception)
            {
                // TODO: Delete copy from SDD
                return(BadRequest());
            }

            return(Ok());
        }
Example #29
0
        private IEnumerable <IDBRow> GetCopyRows()
        {
            if (CopyData == null || CopyData.Count == 0)
            {
                yield break;
            }

            // fix temp ids
            _Records = _Records.ToDictionary(x => x.Value.Id, x => x.Value);

            foreach (var copyRow in CopyData)
            {
                IDBRow rec = _Records[copyRow.Value].Clone();
                rec.Data         = rec.Data.Clone();
                rec.Id           = copyRow.Key;
                _Records[rec.Id] = rec;
                yield return(rec);
            }

            CopyData.Clear();
        }
Example #30
0
        public async Task <IActionResult> copyJson([FromBody] CopyData data, [FromQuery] string repo = "scdfiles")
        {
            try
            {
                IActionResult actionResult = await getJson(data.oldName, repo);

                var content = actionResult as OkObjectResult;

                string jsonString = content.Value.ToString();
                jsonString = jsonString.Replace(data.oldName, data.newName);

                InstallationRoot newInstallation = JsonConvert.DeserializeObject <InstallationRoot>(jsonString);
                // create installation with a 10% chance of failing
                InstallationSim sim = simHandler.createFailedInstallationByChance(newInstallation, 10);
                await sim.runSetup();

                if (sim.status == StatusType.STATUS_FINISHED_SUCCESS)
                {
                    await GitController.CopyFile(data.newName, data.oldName, repo, jsonString);
                }
                else
                {
                    return(BadRequest("{\"status\": 400, \"message\": \"Failed to create file.\", \"installation_status\": \"" + sim.status + "\"}"));
                }
            }
            catch (NullReferenceException)
            {
                return(BadRequest("{\"status\": 400, \"message\": \"Could not find file with the given filename.\"}"));
            }
            catch (ApiValidationException)
            {
                return(BadRequest("{\"status\": 400, \"message\": \"File already exists in github repo.\"}"));
            }
            catch (Exception)
            {
                return(BadRequest("{\"status\": 400, \"message\": \"Unknown error.\"}"));
            }

            return(Ok("{\"status\": 200, \"message\": \"Success.\", \"installation_status\": \"" + StatusType.STATUS_FINISHED_SUCCESS + "\"}"));
        }
Example #31
0
    protected virtual void InitRandomChests()
    {
        // Get the position list
        Object obj = null;

        if (null != MCurrentCopyData.MCopyBasicData.ChestPointsFile)
        {
            obj = Resources.Load(MCurrentCopyData.MCopyBasicData.ChestPointsFile);
        }
        else
        {
            obj = Resources.Load("PathPoints/Copy1ChestPoints");
        }

        GameObject go = GameObject.Instantiate(obj) as GameObject;

//		AIPathPatrol pathAI = go.GetComponent<AIPathPatrol>() as AIPathPatrol;
//		_mChestPosList = new Vector3[pathAI.pathPointInfos.Length];
//		for (int i = 0; i < _mChestPosList.Length; ++i)
//		{
//			_mChestPosList[i] = pathAI.pathPointInfos[i].Position;
//		}
        GameObject.Destroy(go);

        // Must after the _mChestPosList
        CopyData copytData = Globals.Instance.MGameDataManager.MCurrentCopyData;

        //if (0 == copytData.MCopyChestData.ChestIDList.Count)
        //{
        //	Globals.Instance.MGUIManager.GetGUIWindow<GUIMain>().UpdateCopyChestShow(_mChestList.Count);
        //	return;
        //}

        foreach (int id in copytData.MCopyChestData.ChestIDList)
        {
            CreateRandomChest(id);
        }
    }
    void InitMonsterObjs()
    {
        childMonsters.Clear();

        // Hide all buildings
        foreach (Transform child in monsterRoot)
        {
            child.gameObject.SetActiveRecursively(false);
            childMonsters.Add(child);
        }
        childMonsters.Sort(delegate(Transform a, Transform b)
        {
            // Sort by name
            return(string.Compare(a.name, b.name));
        });

        CopyData cpData = Globals.Instance.MGameDataManager.MCurrentCopyData;

        CopyMonsterData.MonsterData monsterData = null;
        for (int i = 0; i < cpData.MCopyMonsterData.MMonsterDataList.Count; i++)
        {
            monsterData = cpData.MCopyMonsterData.MMonsterDataList[i];

            InitOneMonster(childMonsters[i], monsterData);

            if (i == cpData.MCopyMonsterData.MMonsterDataList.Count - 1)
            {
                if (cpData.MCopyBasicData.CopyType == 1)
                {
                    childMonsters[i].transform.localScale = new Vector3(EliteCardScale, EliteCardScale, 1.0f);
                }
                else if (cpData.MCopyBasicData.CopyType == 2)
                {
                    childMonsters[i].transform.localScale = new Vector3(BossCardScale, BossCardScale, 1.0f);
                }
            }
        }
    }
Example #33
0
    private void OnClickzh(ButtonScript obj, object args, int param1, int param2)
    {
        if (CopyData.IsCopyScene(GameManager.SceneID))
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("bunengzhaohuan"));
            return;
        }

        for (int i = 0; i < TeamSystem.GetTeamMembers().Length; i++)
        {
            if (!TeamSystem.IsTeamLeader((int)TeamSystem.GetTeamMembers()[i].instId_))
            {
                if (TeamSystem.GetTeamMembers()[i].isLeavingTeam_)
                {
                    NetConnection.Instance.teamCallMember((int)TeamSystem.GetTeamMembers()[i].instId_);
                }
            }
        }



        tipsObj.SetActive(false);
    }
Example #34
0
        /// <summary>
        /// Process a server pong message from the server.
        /// </summary>
        /// <param name="handle">server windows handle</param>
        /// <param name="copyData">received message</param>
        /// <remarks>
        /// Returns the message contents to the client application.
        /// </remarks>
        private void ProcessServerPong(IntPtr handle, ref CopyData copyData)
        {
            // debug info
            OutputDebugString("processServerPong");

            // store server application window handle
            serverHandle = handle;

            // message parsing variables
            byte[] buffer = null;
            buffer = this.GetBufferFromCopyData(ref copyData);
            int index = 0;

            // message format:
            // string: server name
            // string: server version

            // parse message
            string serverName = this.GetString(ref buffer, ref index);
            string serverVersion = this.GetString(ref buffer, ref index);

            // trigger server pong event
            this.NotifyServerPong(serverName, serverVersion);
        }
Example #35
0
        /// <summary>
        /// Process a server info message from the server.
        /// </summary>
        /// <param name="copyData">received message</param>
        private void ProcessServerInfo(ref CopyData copyData)
        {
            // debug info
            OutputDebugString("ProcessServerInfo");

            // message parsing variables
            byte[] buffer = null;
            buffer = this.GetBufferFromCopyData(ref copyData);
            int index = 0;

            // message format:
            // string: server info

            // parse message
            string msg = this.GetString(ref buffer, ref index);

            // trigger server info event
            this.NotifyServerInfo(msg);
        }
Example #36
0
        /// <summary>
        /// Process a server connection info message from the server.
        /// </summary>
        /// <param name="copyData">received message</param>
        /// <remarks>
        /// Returns the message contents to the client application by callback.
        /// </remarks>
        private void ProcessServerConnectionInfo(ref CopyData copyData)
        {
            // debug info
            OutputDebugString("processServerConnectionInfo");

            // message parsing variables
            byte[] buffer = null;
            buffer = this.GetBufferFromCopyData(ref copyData);
            int index = 0;

            // message format:
            // byte: connection type
            // byte: I2C address (for I2C connections)
            // UInt16: VID (for USB connections)
            // UInt16: PID (for USB connections)
            // string: bridge client name (for bridge connections)
            // string: bridge client version (for bridge connections)

            // parse message
            ConnectionInfo connectionInfo = new ConnectionInfo();
            byte connectionType = this.GetByte(ref buffer, ref index);
            connectionInfo.connectionType = (ConnectionType)connectionType;
            connectionInfo.i2cAddress = this.GetByte(ref buffer, ref index);

            // the original version of this message only returned the I2C address, so
            // don't try to parse the buffer if it's too short
            if (buffer.Length > 2)
            {
                connectionInfo.usbVid = this.GetUshort(ref buffer, ref index);
                connectionInfo.usbPid = this.GetUshort(ref buffer, ref index);
                connectionInfo.bridgeName = this.GetString(ref buffer, ref index);
                connectionInfo.bridgeVersion = this.GetString(ref buffer, ref index);
            }
            else
            {
                connectionInfo.usbVid = 0;
                connectionInfo.usbPid = 0;
                connectionInfo.bridgeName = string.Empty;
                connectionInfo.bridgeVersion = string.Empty;
            }

            // trigger server connection info event
            this.NotifyServerConnectionInfo(connectionInfo);
        }
Example #37
0
        /// <summary>
        /// Process an object message message from the server.
        /// </summary>
        /// <param name="copyData">received message</param>
        /// <remarks>
        /// Returns the message contents to the client application.
        /// </remarks>
        private void ProcessObjectMessage(ref CopyData copyData)
        {
            // debug info
            OutputDebugString("processObjectMessage");

            // get message contents
            byte[] buffer = null;
            buffer = this.GetBufferFromCopyData(ref copyData);

            // trigger object message event
            this.NotifyObjectMessage(ref buffer);
        }
Example #38
0
        /// <summary>
        /// Process a chip save config confirm message from the server.
        /// </summary>
        /// <param name="copyData">received message</param>
        /// <remarks>
        /// Returns the message contents to the client application.
        /// </remarks>
        private void ProcessChipSaveConfigConfirm(ref CopyData copyData)
        {
            // debug info
            OutputDebugString("processChipSaveConfigConfirm");

            // message parsing variables
            byte[] buffer = null;
            buffer = this.GetBufferFromCopyData(ref copyData);
            int index = 0;

            // message format:
            // byte: flag: operation succeeded

            // parse message
            byte operationSucceeded = this.GetByte(ref buffer, ref index);

            // parse operation success/failure from message payload
            bool operationSucceededFlag = false;
            if (operationSucceeded == 0)
            {
                operationSucceededFlag = true;
            }

            // trigger chip save config confirm event
            this.NotifyChipSaveConfigConfirm(operationSucceededFlag);
        }
Example #39
0
        /// <summary>
        /// Process a chip object table message from the server.
        /// </summary>
        /// <param name="copyData">received message</param>
        /// <remarks>
        /// Returns the message contents to the client application by callback.
        /// </remarks>
        private void ProcessChipObjectTable(ref CopyData copyData)
        {
            // debug info
            OutputDebugString("processChipObjectTable");

            // message parsing variables
            byte[] buffer = null;
            buffer = this.GetBufferFromCopyData(ref copyData);
            int index = 0;

            // message format:
            // byte: flag: operation succeeded
            // then: multiple instances of the following:
            //       ushort: object type
            //       ushort: object start position
            //       ushort: object size
            //       ushort: number of object instances
            //       ushort: number of report IDs per instance

            // parse message
            byte operationSucceeded = this.GetByte(ref buffer, ref index);

            // parse operation success/failure from message payload
            bool operationSucceededFlag = false;
            if (operationSucceeded == 0)
            {
                operationSucceededFlag = true;
            }

            // calculate number of object table elements in the received data
            int bufferSize = buffer.Length;
            int numObjectTableElements = (bufferSize - 1) / ObjectTableElement.OBJECT_TABLE_ELEMENT_SIZE;

            // create object table
            ObjectTableElement[] objectTable = new ObjectTableElement[numObjectTableElements];

            // parse object table from message
            for (int i = 0; i < numObjectTableElements; i++)
            {
                // build object table element
                ObjectTableElement objectTableElement = new ObjectTableElement();
                objectTableElement.type = this.GetUshort(ref buffer, ref index);
                objectTableElement.start_position = this.GetUshort(ref buffer, ref index);
                objectTableElement.size = this.GetUshort(ref buffer, ref index);
                objectTableElement.instances = this.GetUshort(ref buffer, ref index);
                objectTableElement.num_report_ids_per_instance = this.GetUshort(ref buffer, ref index);

                // save object table element
                objectTable[i] = objectTableElement;
            }

            // trigger chip object table event
            this.NotifyChipObjectTable(operationSucceededFlag, ref objectTable);
        }
Example #40
0
        private void frmMain_Load(object sender, System.EventArgs e)
        {
            Global.ConnectionLog = new CEventLogEngine( Global.m_CurrentDirectory + "connection.log");
            Global.ConnectionLog.Enabled = false; // Set to true to have all NNTP trafic logged to connection.log

            if( !System.IO.Directory.Exists( Global.m_CurrentDirectory + "Cache"))
                System.IO.Directory.CreateDirectory( Global.m_CurrentDirectory + "Cache");

            if( !System.IO.Directory.Exists( Global.m_CurrentDirectory + "Download"))
                System.IO.Directory.CreateDirectory( Global.m_CurrentDirectory + "Download");

            Decoder.DecodeQueue = new ArrayQueue();
            Decoder.DecoderThread = new System.Threading.Thread( new System.Threading.ThreadStart( Decoder.Decode));
            Decoder.DecoderThread.Priority = System.Threading.ThreadPriority.Lowest;
            Decoder.DecoderThread.Name = "Decoder";
            Decoder.DecoderThread.Start();

            Global.m_Options = new OptionValues(false, true, 15, false, true, 5, true, 6, false, false, "", "", false, false, Global.m_CurrentDirectory);
            if(!LoadOptions(Global.m_CurrentDirectory + "options.xml"))
                frmMain.LogWriteError(Global.m_CurrentDirectory + "options.xml failed to load");

            m_ServerManager = new ServerManager();
            if(!m_ServerManager.LoadServers(Global.m_CurrentDirectory + "servers.xml"))
                frmMain.LogWriteError(Global.m_CurrentDirectory + "servers.xml failed to load");

            if(System.IO.File.Exists(Global.m_CurrentDirectory + "nzb-o-matic.xml"))
                ImportNZB(Global.m_CurrentDirectory + "nzb-o-matic.xml");

            if( Global.m_Options.ConnectOnStart)
            {
                frmMain.LogWriteInfo("Connect on startup enabled.");
                Connect();
            }

            foreach(string str in Global.Args)
            {
                frmMain.LogWriteInfo("Startup parameter: " + str);
                if(str == "/start")
                {
                    frmMain.LogWriteInfo("Connect on startup switch detected.");
                    Connect();
                }
                if(str == "/exit")
                {
                    frmMain.LogWriteInfo("Exit on completion switch detected.");
                    Global.m_ExitComplete = true;
                    Menu_Main_Options_Exit.Checked = true;
                }
                if(str.EndsWith(".nzb"))
                {
                    ImportNZB(str);
                }
            }

            copydata = new CopyData();
            copydata.AssignHandle(this.Handle);
            copydata.Channels.Add("NZBImport");
            copydata.DataReceived += new DataReceivedEventHandler(copydata_DataReceived);

            UpdateServers();

            frmMain.LogWriteInfo(Global.Name + " succesfully started.");
            frmMain.LogWriteInfo("Version: " + Global.Version);
        }
Example #41
0
        /// <summary>
        /// Process a chip debug data message from the server.
        /// </summary>
        /// <param name="copyData">received message</param>
        private void ProcessChipDebugData(ref CopyData copyData)
        {
            // debug info
            OutputDebugString("ProcessChipDebugData");

            byte[] buffer = null;
            buffer = this.GetBufferFromCopyData(ref copyData);

            // trigger chip debug data event
            this.NotifyChipDebugData(ref buffer);
        }
Example #42
0
        /// <summary>
        /// Process a chip attach message from the server.
        /// </summary>
        /// <param name="copyData">received message</param>
        /// <remarks>
        /// Returns the message contents to the client application.
        /// </remarks>
        private void ProcessChipAttach(ref CopyData copyData)
        {
            // debug info
            OutputDebugString("processChipAttach");

            // get message contents
            byte[] buffer = null;
            buffer = this.GetBufferFromCopyData(ref copyData);

            // expected data = family_id etc from chip info block

            // trigger chip attach event
            this.NotifyChipAttach(ref buffer);
        }
Example #43
0
 private static extern IntPtr SendMessage(IntPtr hwnd, int wMsg, int wParam, ref CopyData lParam);
Example #44
0
        private static Document ForkNewDocument(CopyData copyData, Document document, TextSpan span)
        {
            // here we assume paste data is what is copied before.
            // we will check this assumption when things are actually pasted.
            var newText = document.GetTextAsync().Result.ToString().Remove(span.Start, span.Length).Insert(span.Start, copyData.Text);

            // fork solution
            return document.WithText(SourceText.From(newText));
        }
Example #45
0
 public void Apply(ITextBuffer buffer, CopyData copyData)
 {
     throw new NotImplementedException();
 }
Example #46
0
        /// <summary>
        /// Get the payload from a Windows WM_COPYDATA message.
        /// </summary>
        /// <param name="copyData">Windows WM_COPYDATA message</param>
        /// <returns>The message contents as a Byte array.</returns>
        protected byte[] GetBufferFromCopyData(ref CopyData copyData)
        {
            // the structure cbData field contains the number of bytes in the message data
            int bufferSize = copyData.cbData;

            // get a buffer containing the message data
            byte[] buffer = new byte[bufferSize];
            System.Runtime.InteropServices.Marshal.Copy(copyData.lpData, buffer, 0, bufferSize);

            return buffer;
        }
Example #47
0
        /// <summary>
        /// Process a chip debug stop confirm message from the server.
        /// </summary>
        /// <param name="copyData">received message</param>
        private void ProcessChipDebugStopConfirm(ref CopyData copyData)
        {
            // debug info
            OutputDebugString("ProcessChipDebugStopConfirm");

            // message parsing variables
            byte[] buffer = null;
            buffer = this.GetBufferFromCopyData(ref copyData);
            int index = 0;

            // message format:
            // byte: debug stop status

            // parse message
            ChipDebugStopStatus chipDebugStopStatus = (ChipDebugStopStatus)this.GetByte(ref buffer, ref index);

            // trigger chip debug sopt confirm event
            this.NotifyChipDebugDataStopConfirm(chipDebugStopStatus);
        }
Example #48
0
        public static void Main(string[] args)
        {
            if(Environment.CurrentDirectory != Application.StartupPath)
                Environment.CurrentDirectory = Application.StartupPath;

            Console.WriteLine("Creating loader.");

            m_RunMutex = new Mutex(true, "NZB-O-Matic Mutex");
            if(!m_RunMutex.WaitOne(0, false))
            {
                Console.WriteLine("Instance of NZB-O-Matic already running!");
                CopyData cd = new CopyData();
                cd.Channels.Add("NZBImport");
                foreach(string str in args)
                    if(str.EndsWith(".nzb"))
                        cd.Channels["NZBImport"].Send(str);
                cd.Channels.Remove("NZBImport");
                return;
            }

            do
            {
                try
                {
                    //reset variables
                    m_Update = false;
                    m_Restart = false;

                    //setup appdomain
                    AppDomainSetup setup = new AppDomainSetup();
                    setup.ApplicationName = "NZB-O-MaticPlus";
                    setup.ApplicationBase = Environment.CurrentDirectory;
                    setup.ShadowCopyDirectories = Environment.CurrentDirectory;
                    setup.ShadowCopyFiles = "true";

                    //create appdomain
                    m_AppDomain = AppDomain.CreateDomain("Engine Domain", null, setup);
                    //create remoteloader in appdomain
                    m_RemoteLoader = (RemoteLoader)m_AppDomain.CreateInstanceFromAndUnwrap(System.IO.Path.GetFileName(Application.ExecutablePath), "Loader.RemoteLoader");
                    //load assembly in to remoteloader
                    m_RemoteLoader.LoadAssembly("Engine");
                    //create instance of engine in remoteloader
                    m_RemoteLoader.Create();
                    //get name and version from engine
                    m_Name = m_RemoteLoader.Name;
                    m_Version = m_RemoteLoader.Version;
                    //start engine in remoteloader
                    m_RemoteLoader.Start(args);
                    //get variables after engine exits
                    m_Restart = m_RemoteLoader.Restart;
                    m_Update = m_RemoteLoader.Update;
                }
                catch(Exception e)
                {
                    Console.WriteLine(e);
                }

                if(m_Update)
                {
                    frmUpdate m_UpdateForm = new frmUpdate();
                    Application.Run(m_UpdateForm);
                    m_UpdateForm.Dispose();
                }
            } while(m_Restart);

            Console.WriteLine("Exiting program.");
        }
Example #49
0
        private void frmMain_Load(object sender, System.EventArgs e)
        {
            try
            {
                Global.m_DataDirectory = Environment.GetEnvironmentVariable("appdata") + @"\nomp\";
                if (Global.m_DataDirectory == @"\nomp\") throw new ArgumentNullException();
            }
            catch
            {
                Global.m_DataDirectory = Global.m_CurrentDirectory;
            }
            Global.m_CacheDirectory = Global.m_DataDirectory + @"\Cache\";

            try
            {
                RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders");
                string str = (string)rk.GetValue("Personal");
                if (str == null ) throw new ArgumentNullException();
                Global.m_DownloadDirectory = str + @"\download\";
            }
            catch
            {
                Global.m_DownloadDirectory = Global.m_CurrentDirectory + @"\download\";
            }

            Global.ConnectionLog = new CEventLogEngine( Global.m_DataDirectory + "connection.log");
            Global.ConnectionLog.Enabled = false; // Set to true to have all NNTP trafic logged to connection.log

            if( !System.IO.Directory.Exists( Global.m_CacheDirectory))
                System.IO.Directory.CreateDirectory( Global.m_CacheDirectory);

            if( !System.IO.Directory.Exists( Global.m_DownloadDirectory))
                System.IO.Directory.CreateDirectory( Global.m_DownloadDirectory);

            Decoder.DecodeQueue = new ArrayQueue();
            Decoder.DecoderThread = new System.Threading.Thread( new System.Threading.ThreadStart( Decoder.Decode));
            Decoder.DecoderThread.Priority = System.Threading.ThreadPriority.Lowest;
            Decoder.DecoderThread.Name = "Decoder";
            Decoder.DecoderThread.Start();

            Global.m_Options = new OptionValues(false, true, 15, false, true, 5, true, 6, false, false, "", "", false, false, Global.m_CurrentDirectory, false);
            if(!LoadOptions(Global.m_DataDirectory + "options.xml"))
            {
            if(!LoadOptions(Global.m_CurrentDirectory + "options.xml"))
                frmMain.LogWriteError(Global.m_CurrentDirectory + "options.xml failed to load");

            }
            m_ServerManager = new ServerManager();
            if(!m_ServerManager.LoadServers(Global.m_DataDirectory + "servers.xml"))
            {
            if(!m_ServerManager.LoadServers(Global.m_CurrentDirectory + "servers.xml"))
                frmMain.LogWriteError(Global.m_CurrentDirectory + "servers.xml failed to load");

            }
            if(System.IO.File.Exists(Global.m_DataDirectory + "nzb-o-matic.xml"))
                ImportNZB(Global.m_DataDirectory + "nzb-o-matic.xml");

            if( Global.m_Options.ConnectOnStart)
            {
                frmMain.LogWriteInfo("Connect on startup enabled.");
                Connect();
            }

            foreach(string str in Global.Args)
            {
                frmMain.LogWriteInfo("Startup parameter: " + str);
                if(str == "/start")
                {
                    frmMain.LogWriteInfo("Connect on startup switch detected.");
                    Connect();
                }
                if(str == "/exit")
                {
                    frmMain.LogWriteInfo("Exit on completion switch detected.");
                    Global.m_ExitComplete = true;
                    Menu_Main_Options_Exit.Checked = true;
                }
                if(str.EndsWith(".nzb"))
                {
                    ImportNZB(str);
                }
            }

            copydata = new CopyData();
            copydata.AssignHandle(this.Handle);
            copydata.Channels.Add("NZBImport");
            copydata.DataReceived += new DataReceivedEventHandler(copydata_DataReceived);

            UpdateServers();

            frmMain.LogWriteInfo(Global.Name + " succesfully started.");
            frmMain.LogWriteInfo("Version: " + Global.Version);
        }