Esempio n. 1
0
        /// @brief scff_Interprocess用に変換
        public scff_interprocess.Message ToInterprocess(int bound_width, int bound_height, bool force_null_layout)
        {
            scff_interprocess.Message output = new scff_interprocess.Message();

            output.timestamp = this.Timestamp;
            if (force_null_layout)
            {
                output.layout_type = (Int32)scff_interprocess.LayoutType.kNullLayout;
            }
            else
            {
                output.layout_type = (Int32)this.LayoutType;
            }
            output.layout_element_count = this.LayoutElementCount;

            // Listの前から順番に書き込む
            const int kMaxComplexLayoutElements = scff_interprocess.Interprocess.kMaxComplexLayoutElements;

            output.layout_parameters = new scff_interprocess.LayoutParameter[kMaxComplexLayoutElements];
            for (int i = 0; i < kMaxComplexLayoutElements; i++)
            {
                if (i < this.LayoutParameters.Count)
                {
                    output.layout_parameters[i] = this.LayoutParameters[i].ToInterprocess(bound_width, bound_height);
                }
                else
                {
                    // C#はインスタンスは勝手にゼロクリアされる
                    output.layout_parameters[i] = new scff_interprocess.LayoutParameter();
                }
            }

            return(output);
        }
  //-------------------------------------------------------------------
  // Message
  //-------------------------------------------------------------------

  void Send(bool show_message, bool force_null_layout) {
    if (entries_.Count == 0) {
      // 書き込み先が存在しない
      if (show_message) {
        MessageBox.Show("No process to send message.");
      }
      return;
    }

    viewmodel.Entry current_entry = (viewmodel.Entry)entries_.Current;

    try {
      /// @warning DWORD->int変換!オーバーフローの可能性あり
      Process.GetProcessById((int)current_entry.ProcessID);
    } catch {
      // プロセスが存在しない場合
      if (show_message) {
        MessageBox.Show("Cannot find process(" + current_entry.ProcessID + ").");
      }
      return;
    }

    // Messageを変換
    scff_interprocess.Message interprocess_message =
        message_.ToInterprocess(current_entry.SampleWidth, current_entry.SampleHeight, force_null_layout);
    
    // 共有メモリにアクセス
    interprocess_.InitMessage(current_entry.ProcessID);
    interprocess_.SendMessage(interprocess_message);
  }
        /// @brief scff_Interprocess用に変換
        public scff_interprocess.Message ToInterprocess(int bound_width, int bound_height, bool force_null_layout)
        {
            scff_interprocess.Message output = new scff_interprocess.Message();

            output.timestamp = this.Timestamp;
            if (force_null_layout) {
              output.layout_type = (Int32)scff_interprocess.LayoutType.kNullLayout;
            } else {
              output.layout_type = (Int32)this.LayoutType;
            }
            output.layout_element_count = this.LayoutElementCount;

            // Listの前から順番に書き込む
            const int kMaxComplexLayoutElements = scff_interprocess.Interprocess.kMaxComplexLayoutElements;
            output.layout_parameters = new scff_interprocess.LayoutParameter[kMaxComplexLayoutElements];
            for (int i = 0; i < kMaxComplexLayoutElements; i++) {
              if (i < this.LayoutParameters.Count) {
            output.layout_parameters[i] = this.LayoutParameters[i].ToInterprocess(bound_width, bound_height);
              } else {
            // C#はインスタンスは勝手にゼロクリアされる
            output.layout_parameters[i] = new scff_interprocess.LayoutParameter();
              }
            }

            return output;
        }
        /// @brief Interprocessで利用可能な構造体に変換
        public static scff_interprocess.Message ToInterprocess(Message input, int bound_width, int bound_height)
        {
            scff_interprocess.Message output = new scff_interprocess.Message();

            output.timestamp = input.Timestamp;
            output.layout_type = (Int32)input.LayoutType;
            output.layout_element_count = input.LayoutElementCount;

            // Listの前から順番に書き込む
            const int kMaxComplexLayoutElements = scff_interprocess.Interprocess.kMaxComplexLayoutElements;
            output.layout_parameters = new scff_interprocess.LayoutParameter[kMaxComplexLayoutElements];
            for (int i = 0; i < kMaxComplexLayoutElements; i++) {
              if (i < input.LayoutParameters.Count) {
            output.layout_parameters[i] = LayoutParameterFactory.ToInterprocess(
            input.LayoutParameters[i], bound_width, bound_height);
              } else {
            // C#はインスタンスは勝手にゼロクリアされる
            output.layout_parameters[i] = new scff_interprocess.LayoutParameter();
              }
            }

            return output;
        }