예제 #1
0
 /// <summary>
 /// Opens a media file from the specified path.
 /// </summary>
 /// <param name="path">A path to the media file.</param>
 /// <param name="options">The decoder settings.</param>
 /// <returns>The opened <see cref="MediaFile"/>.</returns>
 public static MediaFile Open(string path, MediaOptions options)
 {
     try
     {
         var container = InputContainer.LoadFile(path, options);
         return(new MediaFile(container, options));
     }
     catch (DirectoryNotFoundException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new Exception("Failed to open the media file", ex);
     }
 }
예제 #2
0
 private void Update()
 {
     //use new input system for console toggle (fixes some keyboard layouts)
     if (Keyboard.current.backquoteKey.wasPressedThisFrame)
     {
         CommandManager.RunCommand("toggleconsole", null);
         return;
     }
     if (Keyboard.current.escapeKey.wasPressedThisFrame)
     {
         CommandManager.RunCommand("togglemenu", null);
         return;
     }
     InputContainer.ResetKeypressState();
     RunBinds(Cvar.Boolean("console_open") || Globals.menuopen.Boolean);
 }
예제 #3
0
        public static void ConvertCoordinateUnitList(string settingFilePath)
        {
            // 設定ファイル読み込み
            SettingFileData settingFileData = InputContainer.LoadSettingFile(settingFilePath);

            // 座標リスト読み込み
            List <CoordinateListFileData> coordinateList = InputContainer.LoadCoordinateListFileData(settingFileData.CoordinateListFilePath);

            // 座標リストフォーマット検査
            InputContainer.ValidateCoordinateList(coordinateList, settingFileData.CoordinateListFilePath);

            // 座標単位変換
            List <CoordinateListFileData> result = OutputContainer.ConvertCoordinateUnit(coordinateList);

            // 変換後の座標リスト出力
            OutputContainer.ExportCoordinateList(result, settingFileData.ExportFolderPath);
        }
예제 #4
0
        private void UpdateTableAndGrid(List <IData> finalData, InputContainer container, DataGridView grid)
        {
            var where = !string.IsNullOrWhiteSpace(container.Where) ? Tokenizer.ParseWhere(container.Where) : new List <Where>();

            try
            {
                var resultTable = new DataTable();
                if (container.ColumnsMap.FirstOrDefault().Key.ToLower() == "links")
                {
                    var res = where.Count > 0 ? Tokenizer.FilterDataArray(finalData.ConvertAll(x => (Links)x), where) : finalData.ConvertAll(x => (Links)x);
                    resultTable = HtmlHelper.ConvertToDataTable(res, container);
                }
                if (container.ColumnsMap.FirstOrDefault().Key.ToLower() == "headers")
                {
                    var res = where.Count > 0 ? Tokenizer.FilterDataArray(finalData.ConvertAll(x => (Headers)x), where) : finalData.ConvertAll(x => (Headers)x);
                    resultTable = HtmlHelper.ConvertToDataTable(res, container);
                }

                grid.DataSource = resultTable;
                if (container.SaveFormat == "csv")
                {
                    //Thanks to vc 74 https://stackoverflow.com/questions/4959722/c-sharp-datatable-to-csv
                    var sb = new StringBuilder();

                    var columnNames = resultTable.Columns.Cast <DataColumn>().Select(column => column.ColumnName);
                    sb.AppendLine(string.Join(",", columnNames));

                    foreach (DataRow row in resultTable.Rows)
                    {
                        var fields = row.ItemArray.Select(field => field.ToString());
                        sb.AppendLine(string.Join(",", fields));
                    }

                    File.WriteAllText(container.SavePath, sb.ToString());
                }
                tabControl1.TabPages[0].VerticalScroll.Enabled = true;
                tabControl1.TabPages[0].Controls.Add(grid);
                grid.Width  = grid.Parent.Width;
                grid.Height = grid.Parent.Bottom;
                tabControl1.Refresh();
            }
            catch (Exception)
            {
                container.Errors.Add("Current method provided doesn't exist!");
            }
        }
예제 #5
0
        public Game(Canvas canvas)
        {
            this.canvas  = canvas;
            isRunning    = true;
            unitFactory  = new UnitFactory(canvas);
            stateFactory = new RoundStateFactory();
            Score.getInstance();
            inputHandler = new InputHandler(this, InputContainer.getInstance());

            //create rounds
            createRounds();

            bw = new BackgroundWorker();
            bw.ProgressChanged      += bw_ProgressChanged;
            bw.WorkerReportsProgress = true;
            bw.DoWork += bw_DoWork;
            stopwatch  = new Stopwatch();
            bw.RunWorkerAsync();
        }
예제 #6
0
        private void CreateGateSettings(InputContainer componentMenu)
        {
            foreach (Type t in gateTypes)
            {
                ParameterInfo[] paras = { };
                foreach (var cs in t.GetConstructors())
                {
                    if (paras.Length < cs.GetParameters().Length)
                    {
                        paras = cs.GetParameters();
                    }
                }

                InputContainer temp   = new InputContainer();
                List <Iinput>  inputs = new List <Iinput>();
                int            oldY   = CurrentY;
                foreach (var para in paras)
                {
                    if (typeof(int).IsAssignableFrom(para.ParameterType))
                    {
                        Point start = new Point(X + Padding, CurrentY);
                        temp.Add(new Label(new Text(para.Name, Color.Black), start));

                        int textLength = (int)InputController.DefaultFont.MeasureString(para.Name).X;
                        int textHeight = (int)InputController.DefaultFont.MeasureString(para.Name).Y;
                        int x          = start.X + Padding + textLength;
                        int width      = X + Width - x - Padding;
                        var input      = new NumberSelector(new Rectangle(x, start.Y, width, textHeight), 1, 99, textHeight, 10);
                        temp.Add(input);
                        inputs.Add(input);

                        CurrentY += textHeight + Padding;

                        temp.Active = false;
                        temp.DeFocus();
                    }
                }
                CurrentY = oldY;
                Containers[t.FullName] = temp;
                Inputs.Add(temp, inputs);
            }
            componentMenu.Add(Containers.Values);
        }
예제 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StreamInfo"/> class.
        /// </summary>
        /// <param name="stream">The video stram.</param>
        /// <param name="container">The input container.</param>
        internal unsafe StreamInfo(AVStream *stream, InputContainer container)
        {
            var codec = stream->codec;

            Metadata     = new ReadOnlyDictionary <string, string>(FFDictionary.ToDictionary(stream->metadata));
            CodecName    = ffmpeg.avcodec_get_name(codec->codec_id);
            CodecId      = FormatCodecId(codec->codec_id);
            Index        = stream->index;
            IsInterlaced = codec->field_order != AVFieldOrder.AV_FIELD_PROGRESSIVE &&
                           codec->field_order != AVFieldOrder.AV_FIELD_UNKNOWN;
            FrameSize   = new Size(codec->width, codec->height);
            PixelFormat = codec->pix_fmt;
            TimeBase    = stream->time_base;
            RFrameRate  = stream->r_frame_rate;
            FrameRate   = RFrameRate.ToDouble();
            Duration    = TimeSpan.FromTicks(container.Pointer->duration * 10);
            var start = stream->start_time.ToTimeSpan(stream->time_base);

            StartTime  = start == TimeSpan.MinValue ? TimeSpan.Zero : start;
            FrameCount = Duration.ToFrameNumber(RFrameRate);
            Chapters   = ParseChapters(container);
        }
예제 #8
0
        public override void OnSetAction()
        {
            // The title appears in the control center
            base.TitleId = "Constr.SplitCurve";

            CurveInput curveInput = null;

            if (theCurve == null)
            {
                curveInput = new CurveInput("Constr.SplitCurve.Curve");
                curveInput.MouseOverCurvesEvent += new CurveInput.MouseOverCurvesDelegate(OnMouseOverCurves);
            }

            IntInput numberInput = new IntInput("Constr.SplitCurve.Count");

            numberInput.SetIntEvent += new IntInput.SetIntDelegate(OnSetNumber);
            numberInput.SetMinMax(2, 100, false);
            numberInput.GetIntEvent += new IntInput.GetIntDelegate(OnGetNumber);

            MultipleChoiceInput modeInput = new MultipleChoiceInput("Constr.SplitCurve.Mode", "Constr.SplitCurve.Mode.Values");

            // |prozentual|Längen
            modeInput.SetChoiceEvent += new MultipleChoiceInput.SetChoiceDelegate(OnSetMode);

            distances = new InputContainer("Constr.SplitCurve.Distances");
            RefreshDistances();

            if (theCurve == null)
            {
                base.SetInput(curveInput, numberInput, modeInput, distances);
            }
            else
            {
                base.SetInput(numberInput, modeInput, distances);
            }
            base.OnSetAction();
            Recalc();
        }
예제 #9
0
    protected new void Update()
    {
        if (m_gamePaused || !m_alive)
        {
            return;
        }

        inputs = InputContainer.instance;

        if (inputs.fire.down || inputs.fire.pressed)
        {
            // Fire at opponents
            m_emitter.FireProjectile(Vector2.up, 0.1f);
        }

        if (!m_gameSlowed && (inputs.slowTime.down || inputs.slowTime.pressed))
        {
            Debug.Log("Calling slow down time!");
            // Slow down game time
            StartCoroutine(SlowDownTimer.RunSlowDownTimer());
        }

        MoveEntity();
    }
예제 #10
0
 public InputHandler(Game game, InputContainer inputContainer)
 {
     this.inputContainer = inputContainer;
     this.game           = game;
 }
예제 #11
0
    private string buildInputPackage(KeyCode key, Device device)
    {
        KeyEvent keyEvent = new KeyEvent();
        keyEvent.mAction = 0;
        keyEvent.mDeviceId = device.id;
        keyEvent.mDownTime = 0;
        keyEvent.mFlags = 0;
        keyEvent.mRepeatCount = 0;
        keyEvent.mKeyCode = OuyaControllerMapping.findButton((int)key, OuyaInputManager.GetControllerType(device.name));
        keyEvent.mMetaState = 0;
        keyEvent.mScanCode = 0;
        keyEvent.mSource = 0;
        keyEvent.mSeq = 0;
        keyEvent.mEventTime = 0;
        keyEvent.mDownTime = 0;
        keyEvent.mRecycled = false;

        MotionEvent motionEvent = new MotionEvent();

        InputContainer inputContainer = new InputContainer();
        inputContainer.KeyEvent = keyEvent;
        inputContainer.MotionEvent = motionEvent;
        inputContainer.DeviceId = device.id;
        inputContainer.DeviceName = device.name;

        string jsonData = JsonMapper.ToJson(inputContainer);
        return jsonData;
    }
예제 #12
0
 public void Register(InputBase input)
 {
     InputContainer.Register(input);
     input.ActionsGraph = this;
     input.OnRegister();
 }
예제 #13
0
 public void RemoveInput(string inputName)
 {
     InputContainer.Remove(inputName);
 }
예제 #14
0
 public void doAction(Game game)
 {
     InputContainer.getInstance().Add(new ShootInput(game, UnitContainer.getInstance().objects));
 }
예제 #15
0
 public virtual void UnloadContent()
 {
     inputContainer = null;
     content.Unload();
 }
예제 #16
0
        }                                             //Not abstract, is optional

        public virtual void Initialize()
        {
            inputContainer = new InputContainer();
        }
예제 #17
0
 //------------------------Constructors------------------------
 public Menu(ContentManager content, string menuID)
 {
     this.content        = new ContentManager(content.ServiceProvider, content.RootDirectory);
     this.MenuID         = menuID;
     this.inputContainer = new InputContainer();
 }
예제 #18
0
        void ReleaseDesignerOutlets()
        {
            if (CommentButtonRightConstraint != null)
            {
                CommentButtonRightConstraint.Dispose();
                CommentButtonRightConstraint = null;
            }

            if (Input != null)
            {
                Input.Dispose();
                Input = null;
            }

            if (InputBoxBottomConstraint != null)
            {
                InputBoxBottomConstraint.Dispose();
                InputBoxBottomConstraint = null;
            }

            if (InputBoxHieghtConstraint != null)
            {
                InputBoxHieghtConstraint.Dispose();
                InputBoxHieghtConstraint = null;
            }

            if (InputBoxTopRuler != null)
            {
                InputBoxTopRuler.Dispose();
                InputBoxTopRuler = null;
            }

            if (InputContainer != null)
            {
                InputContainer.Dispose();
                InputContainer = null;
            }

            if (InputRightConstraint != null)
            {
                InputRightConstraint.Dispose();
                InputRightConstraint = null;
            }

            if (ItemTable != null)
            {
                ItemTable.Dispose();
                ItemTable = null;
            }

            if (Send != null)
            {
                Send.Dispose();
                Send = null;
            }

            if (TableBottomConstraint != null)
            {
                TableBottomConstraint.Dispose();
                TableBottomConstraint = null;
            }
        }
예제 #19
0
 public MessagesBox(InputContainer input)
 {
     this.Inputs = input;
 }
예제 #20
0
        //------------------------------------------------------------
        //------------------------Constructors------------------------
        //------------------------------------------------------------

        public MessagesBox(TextureField BackgroundTexture)
        {
            Bounds = BackgroundTexture.Bounds;
            Inputs = new InputContainer(BackgroundTexture.Bounds.Location);
            Inputs.Add(BackgroundTexture, true);
        }
        /// <summary>
        /// 后台主要处理过程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BackgroundWorker_OnDoWork(object sender, DoWorkEventArgs e)
        {
            #region 初始化处理
            //清空容器中上一次的数据
            resultList.Clear();
            dicOverWidthLocation.Clear();
            IsError = false;
            //UI参数
            InputContainer container = (InputContainer)e.Argument;

            //工作簿 BUG
            IXLWorkbook  wbTrans = null;
            IXLWorksheet wsTrans = null;
            try
            {
                wbTrans = new XLWorkbook(container.FilePath);
                wsTrans = wbTrans.Worksheet(1);
            }
            catch (Exception)
            {
                OpenWindowsUtils.OpenMyMessageBox(false, "文件已被其它程序占用,请关闭占用该文件的程序", "The file has been occupied by other programs.", this);
            }
            //sheet

            #endregion

            #region 数据入队
            try
            {
                QueueUtis.JoinDataQueue(wsTrans, dataQueues, Argument.TargetColumn, threadCount);
            }
            catch (Exception)
            {
                //数据有误,结束本次检查,
                resultList.Clear();
                Dispatcher.Invoke(delegate()
                {
                    MDataGrid.ItemsSource = null;
                });
                //UI方式 非正常关闭处理
                if (Argument.FilePath == null)
                {
                    Dispatcher.Invoke(delegate()
                    {
                        OpenWindowsUtils.OpenMyMessageBox(false, "译文不正确,存在空值", "There is a null value", this);
                        IsError = true;
                    });
                    return;
                }
                //控制台 非正常关闭处理
                else
                {
                    if (Argument.FilePath != null)
                    {
                        ConsoleClose(false);
                    }
                }
            }
            #endregion

            #region 处理数据
            //显示
            HiddenOrDisplay(btnTest, false);

            //启动线程
            for (int i = 0; i < threadCount; i++)
            {
                Thread thread = new Thread(new ParameterizedThreadStart(DataQueueThreadStart));
                thread.Start(dataQueues[i]);
            }
            #endregion

            #region  等待数据处理完毕

            AutoResetEvent.WaitAll(autoResetEvent);

            #endregion

            #region 数据显示
            //隐藏
            HiddenOrDisplay(btnTest, true);
            //排序
            SortList(resultList);
            Dispatcher.Invoke(delegate()
            {
                MDataGrid.ItemsSource = null;
                MDataGrid.ItemsSource = resultList;
            });
            #endregion

            #region 数据输出 xml、json  还有excel文件(标记超长宽度的位置)
            //1 输出路径获取
            string baseDiretory = string.Empty;
            if (Argument.OutPutDiretory != null && Directory.Exists(Argument.OutPutDiretory))
            {
                baseDiretory            = Argument.OutPutDiretory;
                Argument.OutPutDiretory = baseDiretory;
            }
            //默认文件输出路径
            else
            {
                baseDiretory = AppDomain.CurrentDomain.BaseDirectory;
            }

            //2 输出
            if (Argument.OutPutType != null)
            {
                try
                {
                    OutPutOperator.GetJsonOrXmlResult(resultList, baseDiretory, Argument.OutPutType);
                }
                catch (Exception)
                {
                    if (Argument.FilePath != null)
                    {
                        //文件输出出错
                        Console.WriteLine((int)StatusCode.code.WriteError);
                    }
                    else
                    {
                        OpenWindowsUtils.OpenMyMessageBox(false, "文件输出出错", "File output error", this);
                    }
                }
            }
            //若输出类型未指定 默认文件类型json
            else
            {
                OutPutOperator.OutPutToJSON(resultList, Path.Combine(baseDiretory, "result.json"));
            }

            //输出excel
            var t1 = dicOverWidthLocation;
            PaintCellColorOfDic(dicOverWidthLocation, wsTrans, XLColor.PastelRed);
            wbTrans.SaveAs(Path.Combine(baseDiretory, "输出结果.xlsx"));
            #endregion

            #region 控制台正常关闭处理
            if (Argument.FilePath != null)
            {
                ConsoleClose(true);
            }
            #endregion
        }
예제 #22
0
 public void RegisterPipe(string sourceInput, string pipeName)
 {
     InputContainer.RegisterPipe(sourceInput, pipeName);
 }
예제 #23
0
 public void AddInputToAction(KeyCode key, InputContainer inputContiner)
 {
     InputToActions.Add(key, inputContiner);
 }
예제 #24
0
        private void CreateGateButtons(InputContainer componentMenu, GameMenu gameMenu)
        {
            List <TextureField> icons = new List <TextureField>();

            ButtonTexture bt = new ButtonTexture(
                InputController.DefaultTexture,
                new Color(50, 50, 50),
                new Color(100, 100, 100),
                new Color(75, 75, 75),
                new Color(95, 115, 255)
                );
            int buttonSize = (Width - (ButtonPrRow + 1) * BPadding) / ButtonPrRow;
            int offsetY    = 0;

            for (int i = 0; i < gateTypes.Count; i++)
            {
                Type gateType = gateTypes[i];
                int  offsetX  = (i % ButtonPrRow);
                offsetX = offsetX * buttonSize + offsetX * BPadding;
                offsetY = (i / ButtonPrRow);
                offsetY = offsetY * buttonSize + offsetY * BPadding;

                Rectangle bounds     = new Rectangle(X + BPadding + offsetX, Y + BPadding + offsetY, buttonSize, buttonSize);
                Rectangle iconBounds = bounds;
                iconBounds.Inflate(-4, -4);

                Texture2D texture;
                if (gameMenu.GateTextureMap.ContainsKey(gateType.FullName))
                {
                    texture = gameMenu.GateTextureMap[gateType.FullName];
                }
                else
                {
                    texture = InputController.DefaultTexture;
                }

                TextureField icon = new TextureField(iconBounds, texture, Color.White);
                Button       temp = new Button(bounds, bt, new Text("", Color.White));
                temp.ID = gateType.FullName;

                icons.Add(icon);
                group.Add(temp, false);
            }



            group.BeforeSelectedButtonChange += (object sender, ButtonEventArgs e) =>
            {
                if (group.SelectedButton != null)
                {
                    Containers[group.SelectedButton.ID].Active = false;
                    Containers[group.SelectedButton.ID].DeFocus();
                }

                if (!Selected)
                {
                    OnActive?.Invoke();
                }
            };

            group.AfterSelectedButtonChange += (object sender, ButtonEventArgs e) =>
            {
                Containers[e.Button.ID].Active = true;
                Containers[e.Button.ID].Focus();
            };

            componentMenu.Add(group);
            componentMenu.Add(icons);
            CurrentY = offsetY + buttonSize + BPadding;
        }