Ejemplo n.º 1
0
        /// <summary>
        /// Begins loading routines for the specified fileReference, which is expected to point to a valid model.
        /// This function takes a delegate which will correctly load the file pointed to by the FileReference,
        /// and another delegate which will create a correct <see cref="IRenderable"/> object from the resulting
        /// object.
        /// </summary>
        /// <param name="fileReference">A <see cref="FileReference"/> which points to the desired file.</param>
        /// <param name="referenceLoadingRoutine">A delegate which correctly loads the desired file, returning a generic type T.</param>
        /// <param name="createRenderableDelegate">A delegate which accepts a generic type T and returns a renderable object.</param>
        /// <param name="associatedControlPage">The control page which the file is associated with, that is, the one with relevant controls.</param>
        /// <typeparam name="T">The type of model to load.</typeparam>
        private void BeginLoadingFile <T>(
            FileReference fileReference,
            DataLoadingDelegates.LoadReferenceDelegate <T> referenceLoadingRoutine,
            DataLoadingDelegates.CreateRenderableDelegate <T> createRenderableDelegate,
            ControlPage associatedControlPage)
        {
            Log.Info($"Loading \"{fileReference.FilePath}\".");

            this.StatusSpinner.Active = true;

            string modelName = fileReference.Filename;
            uint   modelStatusMessageContextID = this.MainStatusBar.GetContextId($"itemLoad_{modelName}");
            uint   modelStatusMessageID        = this.MainStatusBar.Push(modelStatusMessageContextID,
                                                                         $"Loading \"{modelName}\"...");

            Task.Factory.StartNew(() => referenceLoadingRoutine(fileReference))
            .ContinueWith(modelLoadTask => createRenderableDelegate(modelLoadTask.Result, fileReference), this.UIThreadScheduler)
            .ContinueWith(createRenderableTask => this.RenderingEngine.SetRenderTarget(createRenderableTask.Result), this.UIThreadScheduler)
            .ContinueWith
            (
                result =>
            {
                this.StatusSpinner.Active = false;
                this.MainStatusBar.Remove(modelStatusMessageContextID, modelStatusMessageID);
                EnableControlPage(associatedControlPage);
            },
                this.UIThreadScheduler
            );
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 初始化字典,内含键值对,键为page名的字符串,名为对应的page对象
        /// </summary>
        private void InitDictionary()
        {
            this._dicPage = new Dictionary <string, Page>();

            string strPagName = "PAGE_HOME";
            Page   objPage    = new HomePage();

            objPage.DataContext = this._viewViewModel;
            this._dicPage.Add(strPagName, objPage);

            strPagName          = "PAGE_CONNECT";
            objPage             = new ConnectPage();
            objPage.DataContext = this._viewViewModel;
            this._dicPage.Add(strPagName, objPage);

            strPagName          = "PAGE_CONTROL";
            objPage             = new ControlPage();
            objPage.DataContext = this._viewViewModel;
            this._dicPage.Add(strPagName, objPage);

            strPagName          = "PAGE_UPDATE";
            objPage             = new UpdatePage();
            objPage.DataContext = this._viewViewModel;
            this._dicPage.Add(strPagName, objPage);

            strPagName          = "PAGE_CALIBRATION";
            objPage             = new CalibrationPage();
            objPage.DataContext = this._viewViewModel;
            this._dicPage.Add(strPagName, objPage);

            strPagName          = "PAGE_SETUP";
            objPage             = new SetupPage();
            objPage.DataContext = this._viewViewModel;
            this._dicPage.Add(strPagName, objPage);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Disables the specified control page.
        /// </summary>
        /// <param name="pageToDisable">pageToEnable.</param>
        private void DisableControlPage(ControlPage pageToDisable)
        {
            if (Enum.IsDefined(typeof(ControlPage), pageToDisable))
            {
                switch (pageToDisable)
                {
                case ControlPage.Image:
                {
                    this.RenderAlphaCheckButton.Sensitive = false;
                    this.RenderRedCheckButton.Sensitive   = false;
                    this.RenderGreenCheckButton.Sensitive = false;
                    this.RenderBlueCheckButton.Sensitive  = false;
                    break;
                }

                case ControlPage.Model:
                {
                    this.RenderBoundsCheckButton.Sensitive    = false;
                    this.RenderWireframeCheckButton.Sensitive = false;
                    break;
                }

                case ControlPage.Animation:
                {
                    break;
                }

                case ControlPage.Audio:
                {
                    break;
                }
                }
            }
        }
Ejemplo n.º 4
0
 public KeyToken(ControlPage page, KeyCode key, KeyCode[] combo = null)
 {
     this.key = key;
     if (combo != null)
     {
         keyCombo = new KeyCombo(combo);
     }
     this.page = page;
 }
Ejemplo n.º 5
0
        public async Task NavigateToControlPage()
        {
            var controlPage = new ControlPage
            {
                BindingContext = app.Container.Resolve <IControlPageViewModel>()
            };

            await SwitchPageAsync(controlPage);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Enables the specified control page and brings it to the front. If the <paramref name="pageToEnable"/>
        /// parameter is <see cref="ControlPage.None"/>, this is interpreted as disabling all pages.
        /// </summary>
        /// <param name="pageToEnable">pageToEnable.</param>
        private void EnableControlPage(ControlPage pageToEnable)
        {
            if (pageToEnable == ControlPage.None)
            {
                foreach (ControlPage otherPage in Enum.GetValues(typeof(ControlPage)))
                {
                    DisableControlPage(otherPage);
                }

                return;
            }

            if (Enum.IsDefined(typeof(ControlPage), pageToEnable))
            {
                // Set the page
                this.ItemControlNotebook.Page = (int)pageToEnable;

                // Disable the other pages
                foreach (ControlPage otherPage in Enum.GetValues(typeof(ControlPage)))
                {
                    if (otherPage == pageToEnable)
                    {
                        continue;
                    }

                    DisableControlPage(otherPage);
                }


                switch (pageToEnable)
                {
                case ControlPage.Image:
                {
                    this.RenderAlphaCheckButton.Sensitive = true;
                    this.RenderRedCheckButton.Sensitive   = true;
                    this.RenderGreenCheckButton.Sensitive = true;
                    this.RenderBlueCheckButton.Sensitive  = true;
                    break;
                }

                case ControlPage.Model:
                {
                    break;
                }

                case ControlPage.Animation:
                {
                    break;
                }

                case ControlPage.Audio:
                {
                    break;
                }
                }
            }
        }
Ejemplo n.º 7
0
 public void SetActivePage(ControlPage page)
 {
     if (page == currentActivePage)
     {
         return;
     }
     prevPage          = currentActivePage;
     currentActivePage = page;
     OnPageActivation?.Invoke(currentActivePage);
 }
Ejemplo n.º 8
0
        public override UserControl GetControlPage()
        {
            var page = new ControlPage();

            page.DataContext = viewModel;

            // Allow parent to define width/height
            page.Width  = double.NaN;
            page.Height = double.NaN;

            return(page);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Disables the specified control page.
        /// </summary>
        /// <param name="pageToDisable">pageToEnable.</param>
        private void DisableControlPage(ControlPage pageToDisable)
        {
            switch (pageToDisable)
            {
            case ControlPage.Image:
            {
                this.RenderAlphaCheckButton.Sensitive = false;
                this.RenderRedCheckButton.Sensitive   = false;
                this.RenderGreenCheckButton.Sensitive = false;
                this.RenderBlueCheckButton.Sensitive  = false;
                break;
            }

            case ControlPage.Model:
            {
                this.RenderBoundsCheckButton.Sensitive    = false;
                this.RenderWireframeCheckButton.Sensitive = false;
                this.RenderDoodadsCheckButton.Sensitive   = false;

                this.ModelVariationListStore.Clear();
                this.ModelVariationComboBox.Sensitive = false;
                break;
            }

            case ControlPage.Animation:
            {
                break;
            }

            case ControlPage.Audio:
            {
                break;
            }

            case ControlPage.None:
            {
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(pageToDisable));
            }
            }
        }
Ejemplo n.º 10
0
        private void ChkPin_Click(object sender, RoutedEventArgs e)
        {
            if (chkPin.IsChecked == true)
            {
                var Name = ControlPage.SelectTweakName();
                if (Name == null)
                {
                    chkPin.IsChecked = false;
                    return;
                }

                chkPin.ToolTip = Name;

                App.presets.PinProg(progSet.guid, Name);
            }
            else
            {
                App.presets.UnPinProg(progSet.guid);
            }
        }
Ejemplo n.º 11
0
        IEnumerator GateKeeperRoutine()
        {
            Debug.LogFormat("#KEYMASTER# the Gatekeeper awaits the Keymaster");
            var list = new List <KeyToken>();

            while (true)
            {
                foreach (var attrib in pageSelectionControl)
                {
                    if (attrib.AllowTrigger())
                    {
                        Debug.LogFormat("#KEYMASTER# {0}| acivated control page method: {1}", this, attrib.label);
                        attrib.action?.Invoke();
                    }
                }

                if (prevPage != currentActivePage)
                {
                    list = null;
                    if (currentActivePage != ControlPage.None)
                    {
                        keyCommandMap.TryGetValue(currentActivePage, out list);
                    }
                    prevPage = currentActivePage;
                }

                if (list != null)
                {
                    foreach (var item in list)
                    {
                        if (item.AllowTrigger())
                        {
                            Debug.LogFormat("#KEYMASTER# {0}| invoking method {1} for label {2}", this, item.action?.Method.Name, item.label);
                            item.action?.Invoke();
                        }
                    }
                }

                yield return(null);
            }
        }
Ejemplo n.º 12
0
        ControlPage ShowByPage(DisplayHelper dh, ControlPage page)
        {
            if (page != dh.page)
            {
                page = dh.page;
                Color c = GUI.backgroundColor;
                GUI.backgroundColor = buttonColor;
                if (GUILayout.Button(string.Format("Page: \t{0}", page), GUILayout.Height(20)))
                {
                    showPage[page] = !showPage[page];
                }
                if (!showPage[page])
                {
                    GUI.backgroundColor = c;
                    return(page);
                }
                c = GUI.contentColor;
                GUI.contentColor = Color.magenta;
                GUILayout.BeginHorizontal();
                GUILayout.Label("Label", GUILayout.ExpandWidth(true), GUILayout.Width(300));
                GUILayout.Label("Key", GUILayout.ExpandWidth(true), GUILayout.Width(300));
                GUILayout.Label("Type", GUILayout.ExpandWidth(true), GUILayout.Width(300));

                GUILayout.EndHorizontal();
                GUI.contentColor = c;
            }
            if (!showPage[page])
            {
                return(page);
            }


            GUILayout.BeginHorizontal();
            GUILayout.Label(dh.label, GUILayout.ExpandWidth(true), GUILayout.Width(300));
            GUILayout.Label(string.Format("{0} {1}", dh.key.ToString(), dh.combo), GUILayout.ExpandWidth(true), GUILayout.Width(300));
            GUILayout.Label(dh.type, GUILayout.ExpandWidth(true), GUILayout.Width(300));
            GUILayout.EndHorizontal();
            return(page);
        }
Ejemplo n.º 13
0
        private async void MenuItem_Clicked_1(object sender, EventArgs e)
        {
            //rename
            File   file    = (sender as MenuItem).BindingContext as File;
            string newName = await DisplayPromptAsync("Rename " + file.FileType.ToString(), "New name");

            string response;

            if (file.FileType == FileType.File)
            {
                response = SendAndReceive("MOVE_FILE:" + file.FullName + "|" + GetFullName(directory, newName));
            }
            else
            {
                response = SendAndReceive("MOVE_FOLDER:" + file.FullName + "|" + GetFullName(directory, newName));
            }
            if (response != Codes.Success.ToString())
            {
                await DisplayAlert("Exception ocurred", response.Remove(0, Codes.Error.ToString().Length), ControlPage.GetCancelButtonText());
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Loads and displays the specified fileReference in the UI, which is expected to point to a valid object.
        /// This function takes a delegate which will correctly load the file pointed to by the FileReference,
        /// and another delegate which will create a correct <see cref="IRenderable"/> object from the resulting
        /// object.
        /// </summary>
        /// <param name="gamePage">The game page that the renderable originated from.</param>
        /// <param name="fileReference">A <see cref="FileReference"/> which points to the desired file.</param>
        /// <param name="referenceLoadingRoutine">A delegate which correctly loads the desired file, returning a generic type T.</param>
        /// <param name="createRenderableDelegate">A delegate which accepts a generic type T and returns a renderable object.</param>
        /// <param name="associatedControlPage">The control page which the file is associated with, that is, the one with relevant controls.</param>
        /// <param name="ct">A cancellation token for this operation.</param>
        /// <typeparam name="T">The type of object to load.</typeparam>
        private async Task DisplayRenderableFile <T>(
            GamePage gamePage,
            FileReference fileReference,
            DataLoadingDelegates.LoadReferenceDelegate <T> referenceLoadingRoutine,
            DataLoadingDelegates.CreateRenderableDelegate <T> createRenderableDelegate,
            ControlPage associatedControlPage,
            CancellationToken ct)
        {
            if (fileReference == null)
            {
                throw new ArgumentNullException(nameof(fileReference));
            }

            Log.Info($"Loading \"{fileReference.FilePath}\".");

            this.StatusSpinner.Active = true;

            string modelName = fileReference.Filename;
            uint   modelStatusMessageContextID = this.MainStatusBar.GetContextId($"itemLoad_{modelName}");
            uint   modelStatusMessageID        = this.MainStatusBar.Push
                                                 (
                modelStatusMessageContextID,
                $"Loading \"{modelName}\"..."
                                                 );

            try
            {
                T item = await Task.Run
                         (
                    () => referenceLoadingRoutine(fileReference),
                    ct
                         );

                IRenderable renderable = await Task.Factory.StartNew
                                         (
                    () => createRenderableDelegate(item, fileReference, gamePage.Version),
                    ct,
                    TaskCreationOptions.None,
                    this.UiThreadScheduler
                                         );

                if (renderable != null)
                {
                    ct.ThrowIfCancellationRequested();

                    // Replace the renderable on the UI thread
                    await Task.Factory.StartNew
                    (
                        () => this.RenderingEngine.SetRenderTarget(renderable),
                        ct,
                        TaskCreationOptions.None,
                        this.UiThreadScheduler
                    );

                    EnableControlPage(associatedControlPage);
                }
            }
            catch (OperationCanceledException)
            {
                Log.Info($"Cancelled loading of {fileReference.Filename}");
            }
            finally
            {
                this.StatusSpinner.Active = false;
                this.MainStatusBar.Remove(modelStatusMessageContextID, modelStatusMessageID);
            }
        }
Ejemplo n.º 15
0
        private async void MenuItem_Clicked(object sender, EventArgs e)
        {
            //delete
            File file = (sender as MenuItem).BindingContext as File;

            if (await DisplayAlert("U sure 'bout that?", "Do you really want to delete this " + file.FileType.ToString() + "?", "Yes", "No") == false)
            {
                return;
            }
            string response;

            if (file.FileType == FileType.File)
            {
                response = SendAndReceive("DELETE_FILE:" + file.FullName);
            }
            else
            {
                response = SendAndReceive("DELETE_FOLDER:" + file.FullName);
            }
            if (response != Codes.Success.ToString())
            {
                await DisplayAlert("Exception ocurred", response.Remove(0, Codes.Error.ToString().Length), ControlPage.GetCancelButtonText());
            }
            Update();
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Enables the specified control page and brings it to the front. If the <paramref name="pageToEnable"/>
        /// parameter is <see cref="ControlPage.None"/>, this is interpreted as disabling all pages.
        /// </summary>
        /// <param name="pageToEnable">pageToEnable.</param>
        private void EnableControlPage(ControlPage pageToEnable)
        {
            if (pageToEnable == ControlPage.None)
            {
                foreach (ControlPage otherPage in Enum.GetValues(typeof(ControlPage)))
                {
                    DisableControlPage(otherPage);
                }

                return;
            }

            if (Enum.IsDefined(typeof(ControlPage), pageToEnable))
            {
                // Set the page
                this.ItemControlNotebook.Page = (int)pageToEnable;

                // Disable the other pages
                foreach (ControlPage otherPage in Enum.GetValues(typeof(ControlPage)))
                {
                    if (otherPage == pageToEnable)
                    {
                        continue;
                    }

                    DisableControlPage(otherPage);
                }

                switch (pageToEnable)
                {
                case ControlPage.Image:
                {
                    RenderableImage image = this.RenderingEngine.RenderTarget as RenderableImage;
                    if (image == null)
                    {
                        return;
                    }

                    this.MipCountLabel.Text = image.MipCount.ToString();

                    this.RenderAlphaCheckButton.Sensitive = true;
                    this.RenderRedCheckButton.Sensitive   = true;
                    this.RenderGreenCheckButton.Sensitive = true;
                    this.RenderBlueCheckButton.Sensitive  = true;

                    image.RenderAlphaChannel = this.RenderAlphaCheckButton.Active;
                    image.RenderRedChannel   = this.RenderRedCheckButton.Active;
                    image.RenderGreenChannel = this.RenderGreenCheckButton.Active;
                    image.RenderBlueChannel  = this.RenderBlueCheckButton.Active;
                    break;
                }

                case ControlPage.Model:
                {
                    this.RenderBoundsCheckButton.Sensitive    = true;
                    this.RenderWireframeCheckButton.Sensitive = true;
                    RenderableWorldModel wmo = this.RenderingEngine.RenderTarget as RenderableWorldModel;
                    if (wmo != null)
                    {
                        wmo.ShouldRenderBounds    = this.RenderBoundsCheckButton.Active;
                        wmo.ShouldRenderWireframe = this.RenderWireframeCheckButton.Active;
                    }

                    RenderableGameModel mdx = this.RenderingEngine.RenderTarget as RenderableGameModel;
                    if (mdx != null)
                    {
                        mdx.ShouldRenderBounds = this.RenderBoundsCheckButton.Active;
                    }

                    break;
                }

                case ControlPage.Animation:
                {
                    break;
                }

                case ControlPage.Audio:
                {
                    break;
                }
                }
            }
        }
Ejemplo n.º 17
0
        void OnGUI()
        {
            Color c = GUI.backgroundColor;

            if (assignments == null || assignments.Length == 0)
            {
                style.normal.textColor = Color.white;
                EditorGUILayout.LabelField("no keys found", style);
                if (GUILayout.Button(new GUIContent("repopulate tokens from codebase")))
                {
                    EditorUtilities.PopulateKeyVault();
                    keyVault = EditorUtilities.GetKeyVault();
                    Init();
                }
                return;
            }

            ControlPage page = ControlPage.None;

            GUILayout.BeginVertical(style);
            GUI.backgroundColor = buttonColor;
            EditorGUILayout.LabelField("Select Layout Type", GUILayout.Width(150));
            viewType = (ViewType)EditorGUILayout.EnumPopup(viewType, GUILayout.Width(100));

            if (GUILayout.Button(new GUIContent("repopulate tokens from codebase")))
            {
                EditorUtilities.PopulateKeyVault();
                keyVault = EditorUtilities.GetKeyVault();
                Init();
            }

            GUI.backgroundColor = c;
            GUILayout.EndVertical();
            EditorGUILayout.Separator();
            EditorGUILayout.BeginVertical(style);


            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, true);
            if (viewType == ViewType.Page)
            {
                assignments = assignments
                              .OrderBy(a => a.page)
                              .ThenBy(a => a.key)
                              .ToArray();
                for (int i = 0; i < assignments.Length; i++)
                {
                    page = ShowByPage(assignments[i], page);
                }
            }
            else if (viewType == ViewType.Key)
            {
                assignments = assignments
                              .OrderBy(a => a.key)
                              .ToArray();
                ShowByKey(assignments);
            }
            else if (viewType == ViewType.Type)
            {
                assignments = assignments
                              .OrderBy(a => a.type)
                              .ToArray();
                ShowByType(assignments);
            }
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
        }
Ejemplo n.º 18
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            SendData("START_PROCESS:" + ProcessEntry.Text + "|" + ArgumentsEntry.Text);
            string str = ReceiveData();

            if (str == Codes.Success.ToString())
            {
            }
            else
            {
                DisplayAlert("Exception occured", str.Replace(Codes.Error.ToString(), ""), ControlPage.GetCancelButtonText());
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Loads and displays the specified fileReference in the UI, which is expected to point to a valid object.
        /// This function takes a delegate which will correctly load the file pointed to by the FileReference,
        /// and another delegate which will create a correct <see cref="IRenderable"/> object from the resulting
        /// object.
        /// </summary>
        /// <param name="fileReference">A <see cref="FileReference"/> which points to the desired file.</param>
        /// <param name="referenceLoadingRoutine">A delegate which correctly loads the desired file, returning a generic type T.</param>
        /// <param name="createRenderable">A delegate which accepts a generic type T and returns a renderable object.</param>
        /// <param name="associatedControlPage">The control page which the file is associated with, that is, the one with relevant controls.</param>
        /// <param name="ct">A cancellation token for this operation.</param>
        /// <typeparam name="T">The type of object to load.</typeparam>
        private async Task DisplayRenderableFile <T>(FileReference fileReference, LoadReference <T> referenceLoadingRoutine, CreateRenderable <T> createRenderable, ControlPage associatedControlPage, CancellationToken ct)
        {
            if (fileReference == null)
            {
                throw new ArgumentNullException(nameof(fileReference));
            }

            Log.Info($"Loading \"{fileReference.FilePath}\".");

            this.StatusSpinner.Active = true;

            string modelName = fileReference.Filename;
            uint   modelStatusMessageContextID = this.MainStatusBar.GetContextId($"itemLoad_{modelName}");
            uint   modelStatusMessageID        = this.MainStatusBar.Push
                                                 (
                modelStatusMessageContextID,
                $"Loading \"{modelName}\"..."
                                                 );

            try
            {
                T item = await Task.Run
                         (
                    () => referenceLoadingRoutine(fileReference),
                    ct
                         );

                IRenderable renderable = await Task.Factory.StartNew
                                         (
                    () => createRenderable(item, fileReference),
                    ct
                                         );

                if (renderable != null)
                {
                    ct.ThrowIfCancellationRequested();

                    this.ViewportWidget.MakeCurrent();
                    this.ViewportWidget.AttachBuffers();
                    renderable.Initialize();

                    // Replace the renderable on the UI thread
                    await Task.Factory.StartNew
                    (
                        () => this.RenderingEngine.SetRenderTarget(renderable),
                        ct,
                        TaskCreationOptions.None,
                        this.UiThreadScheduler
                    );

                    EnableControlPage(associatedControlPage);

                    if (renderable is IModelInfoProvider infoProvider)
                    {
                        this.PolyCountLabel.Text   = infoProvider.PolygonCount.ToString();
                        this.VertexCountLabel.Text = infoProvider.VertexCount.ToString();
                    }
                }
            }
            catch (OperationCanceledException)
            {
                Log.Info($"Cancelled loading of {fileReference.Filename}");
            }
            finally
            {
                this.StatusSpinner.Active = false;
                this.MainStatusBar.Remove(modelStatusMessageContextID, modelStatusMessageID);
            }
        }
Ejemplo n.º 20
0
        public MainWindow()
        {
            InitializeComponent();
            AppConfigManager app = new AppConfigManager();
            var style            = (Style)this.TryFindResource("ViewUCStyle");
            var mainPage         = new MainPage();

            mainPage.Style = style;
            mainPageGrid.Children.Add(mainPage);

            var signalSettingPage = new SignalSettingPage();

            signalSettingPage.Style = style;
            signalSettingPageGrid.Children.Add(signalSettingPage);

            var resultAdjudgeSettingPage = new ResultAdjudgeSettingPage();

            resultAdjudgeSettingPage.Style = style;
            resultAdjudgeSettingPageGrid.Children.Add(resultAdjudgeSettingPage);

            var controlPage = new ControlPage();

            controlPage.Style = style;
            controlPageGrid.Children.Add(controlPage);

            var resultPage = new ResultPage();

            resultPage.Style = style;
            resultPageGrid.Children.Add(resultPage);

            var vm = new MainWindowVM();

            vm.Init();
            vm.AddCommands(this);

            vm.PageNameAndVMDic.Add(MainWindowVM.MAIN_PAGE, mainPage.VM);
            vm.PageNameAndVMDic.Add(MainWindowVM.SIGNAL_SETTING_PAGE, signalSettingPage.VM);
            vm.PageNameAndVMDic.Add(MainWindowVM.RESULT_ADJUDGE_SETTING_PAGE, resultAdjudgeSettingPage.VM);
            vm.PageNameAndVMDic.Add(MainWindowVM.CONTROL_PAGE, controlPage.VM);
            vm.PageNameAndVMDic.Add(MainWindowVM.RESULT_PAGE, resultPage.VM);

            vm.InitObservers();

            VM = vm;
            this.InitCommandBindings();
            this.DataContext = VM;

            var deviceEnumerator = new MMDeviceEnumerator();

            foreach (var d in deviceEnumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active))
            {
                if (d.FriendlyName.Contains(app.GetAppValue("CardDevicesOne")))
                {
                    d.AudioEndpointVolume.MasterVolumeLevelScalar = Convert.ToInt32(app.GetAppValue("CardDevicesOneVolume")) / 100.0f;
                }
                if (d.FriendlyName.Contains(app.GetAppValue("CardDevicesTwo")))
                {
                    d.AudioEndpointVolume.MasterVolumeLevelScalar = Convert.ToInt32(app.GetAppValue("CardDevicesTwoVolume")) / 100.0f;
                }
            }



            try
            {
                ISerial serialPort = new SerialPortEx(TesterConfig.Instance.GetApplicationCom);
                //serialPort.Wirte("ff", 1);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, "程序启动时写入ff失败");
                throw;
            }



            //aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

            //aTimer.Interval = 1000;    // 1秒 = 1000毫秒
            //aTimer.Start();
            HistoryTimer hisTimer = new HistoryTimer();
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Enables the specified control page and brings it to the front. If the <paramref name="pageToEnable"/>
        /// parameter is <see cref="ControlPage.None"/>, this is interpreted as disabling all pages.
        /// </summary>
        /// <param name="pageToEnable">pageToEnable.</param>
        private void EnableControlPage(ControlPage pageToEnable)
        {
            if (pageToEnable == ControlPage.None)
            {
                foreach (ControlPage otherPage in Enum.GetValues(typeof(ControlPage)))
                {
                    DisableControlPage(otherPage);
                }

                return;
            }

            // Set the page
            this.ItemControlNotebook.Page = (int)pageToEnable;

            // Disable the other pages
            foreach (ControlPage otherPage in Enum.GetValues(typeof(ControlPage)))
            {
                if (otherPage == pageToEnable)
                {
                    continue;
                }

                DisableControlPage(otherPage);
            }

            switch (pageToEnable)
            {
            case ControlPage.Image:
            {
                RenderableImage image = this.RenderingEngine.RenderTarget as RenderableImage;
                if (image == null)
                {
                    return;
                }

                this.MipCountLabel.Text = image.MipCount.ToString();

                this.RenderAlphaCheckButton.Sensitive = true;
                this.RenderRedCheckButton.Sensitive   = true;
                this.RenderGreenCheckButton.Sensitive = true;
                this.RenderBlueCheckButton.Sensitive  = true;

                image.RenderAlphaChannel = this.RenderAlphaCheckButton.Active;
                image.RenderRedChannel   = this.RenderRedCheckButton.Active;
                image.RenderGreenChannel = this.RenderGreenCheckButton.Active;
                image.RenderBlueChannel  = this.RenderBlueCheckButton.Active;
                break;
            }

            case ControlPage.Model:
            {
                this.RenderBoundsCheckButton.Sensitive    = true;
                this.RenderWireframeCheckButton.Sensitive = true;
                this.RenderDoodadsCheckButton.Sensitive   = true;

                this.ModelVariationComboBox.Sensitive = true;

                RenderableWorldModel wmo = this.RenderingEngine.RenderTarget as RenderableWorldModel;
                if (wmo != null)
                {
                    wmo.ShouldRenderBounds    = this.RenderBoundsCheckButton.Active;
                    wmo.ShouldRenderWireframe = this.RenderWireframeCheckButton.Active;
                    wmo.ShouldRenderDoodads   = this.RenderDoodadsCheckButton.Active;

                    var doodadSetNames = wmo.GetDoodadSetNames().ToList();
                    this.ModelVariationListStore.Clear();
                    for (int i = 0; i < doodadSetNames.Count; ++i)
                    {
                        this.ModelVariationListStore.AppendValues(doodadSetNames[i], i);
                    }

                    this.ModelVariationComboBox.Active      = 0;
                    this.ModelVariationComboBox.Sensitive   = this.RenderDoodadsCheckButton.Active;
                    this.RenderDoodadsCheckButton.Sensitive = true;
                }

                RenderableGameModel mdx = this.RenderingEngine.RenderTarget as RenderableGameModel;
                if (mdx != null)
                {
                    mdx.ShouldRenderBounds    = this.RenderBoundsCheckButton.Active;
                    mdx.ShouldRenderWireframe = this.RenderWireframeCheckButton.Active;

                    var skinVariations = mdx.GetSkinVariations().ToList();
                    this.ModelVariationListStore.Clear();
                    foreach (var variation in skinVariations)
                    {
                        var firstTextureName = variation.TextureVariation1.Value;
                        if (!string.IsNullOrEmpty(firstTextureName))
                        {
                            this.ModelVariationListStore.AppendValues(variation.TextureVariation1.Value, variation.ID);
                        }
                    }

                    this.ModelVariationComboBox.Active      = 0;
                    this.ModelVariationComboBox.Sensitive   = true;
                    this.RenderDoodadsCheckButton.Sensitive = false;
                }

                break;
            }

            case ControlPage.Animation:
            {
                break;
            }

            case ControlPage.Audio:
            {
                break;
            }

            case ControlPage.None:
            {
                break;
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(pageToEnable));
            }
            }
        }
Ejemplo n.º 22
0
        private async void ToolbarItem_Clicked(object sender, EventArgs e)
        {
            string action = await DisplayActionSheet("Add", "Cancel", null, "Create folder", "Upload file");

            switch (action)
            {
            case "Create folder":
                string name = await DisplayPromptAsync("Create folder", "Folder name:");

                string response = Request("CREATE_FOLDER:" + GetFullName(directory, name));
                if (response != Codes.Success.ToString())
                {
                    await DisplayAlert("Exception ocurred", response.Remove(Codes.Error.ToString().Length), ControlPage.GetCancelButtonText());
                }
                Update();
                break;

            case "Upload file":
                try
                {
                    App.DontDisconnect = true;
                    FileData fileData = await CrossFilePicker.Current.PickFile();

                    App.DontDisconnect = false;
                    if (fileData == null)
                    {
                        return;     // user canceled file picking
                    }
                    if (Codes.FromString(Request("FILE_EXISTS:" + GetFullName(directory, fileData.FileName))).ToBool())
                    {
                        if (!await DisplayAlert("File already exists", "A file with the same name already exists in this folder, do you wish to overwrite it?", "Overwrite", "Cancel"))
                        {
                            return;
                        }
                    }
                    SendData("UPLOAD_FILE_TO:" + GetFullName(directory, fileData.FileName));
                    if (ReceiveData() != Codes.True.ToString())
                    {
                        return;
                    }
                    socket.Send(fileData.DataArray);
                    string str = ReceiveData();
                    if (str != Codes.Success.ToString())
                    {
                        await DisplayAlert("Exception ocurred", str.Remove(0, "Error".Length), "ok");

                        return;
                    }
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("Exception choosing file: " + ex.ToString());
                }
                break;

            default:
                //await DisplayAlert("Feature not implemented", "Sorry, but this feature is not yet implemented.", ControlPage.GetCancelButtonText());
                break;
            }
            Update();
        }