private MainWindowViewModel()
        {
            mainWindowState        = MainWindowState.Instance;
            titleBarEventsHandlers = TitleBarEventsHandlers.Instance;

            mainWindowState.StateChanged += StateChanged;
        }
示例#2
0
        private void SetState(MainWindowState state)
        {
            message.TextChanged    -= Message_TextChanged;
            message.Text            = state.Message;
            message.SelectionStart  = state.SelectionStart;
            message.SelectionLength = 0;
            message.TextChanged    += Message_TextChanged;

            submit.Command   = state.Save;
            emoji.Command    = state.Help;
            settings.Command = state.Settings;

            suggestionList.ItemConfirmed -= OnSuggestionConfirmed;
            suggestionList.ItemsSource    = state.Suggestions;
            suggestionList.ItemConfirmed += OnSuggestionConfirmed;

            if (state.Focus)
            {
                message.Focus();
            }
            if (state.Close)
            {
                Close();
            }

            InputBindings.Clear();
            InputBindings.Add(new KeyBinding(state.Save, new KeyGesture(Key.S, ModifierKeys.Control)));

            if (!state.HasUserEdited)
            {
                InputBindings.Add(new KeyBinding(escape, new KeyGesture(Key.Escape)));
            }
        }
示例#3
0
        private void ShowOrHidePanels(MainWindowState _state)
        {
            switch (_state)
            {
            case MainWindowState.NoANN:
                MainPanel.Visibility  = Visibility.Collapsed;
                UpperPanel.Visibility = Visibility.Collapsed;
                LowerPanel.Visibility = Visibility.Collapsed;
                break;

            default:
                MainPanel.Visibility  = Visibility.Visible;
                UpperPanel.Visibility = Visibility.Visible;
                LowerPanel.Visibility = Visibility.Visible;
                if (RNA is Kohonen)
                {
                    this.Title = "ADReNA - Rede Neural de Kohonen";
                    labelNetworkType.Content = "Kohonen";
                }
                else     // is backpropagation
                {
                    this.Title = "ADReNA - Rede Neural de Backpropagation";
                    labelNetworkType.Content = "Backpropagation";
                }
                break;
            }
        }
示例#4
0
        private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            ShowLoading(false);

            if (e.Error != null)
            {
                State = MainWindowState.LoadedTrainingSet;
                MessageBox.Show("O seguinte erro ocorreu: " + e.Error.Message);
            }
            else
            {
                State = MainWindowState.TrainedANN;
                ClearRNAOutputs();

                if (RNA is Kohonen)
                {
                    MessageBox.Show("RNA Treinada com Sucesso!");
                }
                else //is Backpropagation
                {
                    labelIterationCount.Visibility = System.Windows.Visibility.Visible;
                    labelIterationCount.Content    = "Número de iterações feitas: " + ((Backpropagation)RNA).GetIterationNumber().ToString();
                    MessageBox.Show("RNA Treinada com Sucesso em " + ((Backpropagation)RNA).GetIterationNumber().ToString() + " iterações!");
                }
            }
        }
示例#5
0
        private void NewRNA()
        {
            State       = MainWindowState.RawANN;
            TrainingSet = null;
            LastSaved   = null;

            if (RNA is Kohonen)
            {
                lblErrorRate.Visibility          = Visibility.Collapsed;
                txtErrorRate.Visibility          = Visibility.Collapsed;
                lblNeighborhoodRadius.Visibility = Visibility.Visible;
                txtNeighborhoodRadius.Visibility = Visibility.Visible;

                txtNeighborhoodRadius.Text = Convert.ToString(((Kohonen)RNA).GetNeighborhoodRadius());
                txtLearningRate.Text       = Convert.ToString(((Kohonen)RNA).GetLearningRate());
                txtIterationNumber.Text    = Convert.ToString(((Kohonen)RNA).GetIterationNumber());
            }
            else // is Backpropagation
            {
                lblErrorRate.Visibility          = Visibility.Visible;
                txtErrorRate.Visibility          = Visibility.Visible;
                lblNeighborhoodRadius.Visibility = Visibility.Collapsed;
                txtNeighborhoodRadius.Visibility = Visibility.Collapsed;

                txtErrorRate.Text       = Convert.ToString(((Backpropagation)RNA).GetErrorRate());
                txtLearningRate.Text    = Convert.ToString(((Backpropagation)RNA).GetLearningRate());
                txtIterationNumber.Text = Convert.ToString(((Backpropagation)RNA).GetMaxIterationNumber());
            }
        }
示例#6
0
        private void SetControlEnable(MainWindowState state)
        {
            switch (state)
            {
            case MainWindowState.New:
            {
                this.DatabaseTypeList.IsEnabled          = true;
                this.SelectDatabaseTypeButton.Visibility = Visibility.Visible;
                this.MainTab.Visibility                     = Visibility.Hidden;
                this.MainTabTable.Visibility                = Visibility.Hidden;
                this.MainTabStoredProcedure.Visibility      = Visibility.Hidden;
                this.MainTabUserDefinedTableType.Visibility = Visibility.Hidden;
                this.m0100.IsEnabled = false;
                this.m0200.IsEnabled = false;
                this.m0300.IsEnabled = false;
            }
            break;

            case MainWindowState.SchemaLoaded:
            {
                this.DatabaseTypeList.IsEnabled          = false;
                this.SelectDatabaseTypeButton.Visibility = Visibility.Hidden;
                this.MainTab.Visibility                     = Visibility.Visible;
                this.MainTabTable.Visibility                = Visibility.Visible;
                this.MainTabStoredProcedure.Visibility      = Visibility.Visible;
                this.MainTabUserDefinedTableType.Visibility = Visibility.Visible;
                this.m0100.IsEnabled = true;
                this.m0200.IsEnabled = true;
                this.m0300.IsEnabled = true;
            }
            break;

            default: throw new InvalidOperationException();
            }
        }
示例#7
0
        private void SetChooseMode()
        {
            _windowState = MainWindowState.None;

            ChoosePanelVisibility = Visibility.Visible;
            PathPanelVisibility   = Visibility.Collapsed;
            _progressBarManager.SetVisibility(Visibility.Collapsed);
        }
示例#8
0
        private void SetProgressMode()
        {
            _windowState = MainWindowState.ProgressPanel;

            _progressBarManager.SetVisibility(Visibility.Visible);
            PathPanelVisibility   = Visibility.Collapsed;
            ChoosePanelVisibility = Visibility.Collapsed;
        }
示例#9
0
        private void SaveState(Window window)
        {
            var state = new MainWindowState {
                Placement = NativeMethods.GetPlacement(window)
            };

            _settingsService.Save("MainWindowState", state);
        }
示例#10
0
 public void SetState(MainWindowState state)
 {
     EffekseerNativePINVOKE.MainWindow_SetState(swigCPtr, MainWindowState.getCPtr(state));
     if (EffekseerNativePINVOKE.SWIGPendingException.Pending)
     {
         throw EffekseerNativePINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#11
0
        private void SetPathMode(MainWindowState state)
        {
            _windowState = state;

            PathPanelVisibility = Visibility.Visible;
            _progressBarManager.SetVisibility(Visibility.Collapsed);
            ChoosePanelVisibility = Visibility.Collapsed;
        }
示例#12
0
        private void btnLoadTrainingSet_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName   = "Treinamento";
            dlg.DefaultExt = ".json";
            dlg.Filter     = "Arquivos JSON (.json)|*.json";
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                string  filename   = dlg.FileName;
                bool    importable = false;
                bool    error      = true;
                DataSet imported   = new DataSet();

                try
                {
                    imported = ADReNA_API.Util.Import.DataSet(filename);
                    error    = false;
                }
                catch
                {
                    MessageBox.Show("Impossível carregar arquivo!");
                }

                if (!error)
                {
                    if (RNA is Kohonen)
                    {
                        if (imported.inputSize == ((Kohonen)RNA).inputLayerSize && imported.outputSize == 0)
                        {
                            importable = true;
                        }
                    }
                    else
                    {
                        if (imported.inputSize == ((Backpropagation)RNA).inputLayerSize && imported.outputSize == ((Backpropagation)RNA).outputLayerSize)
                        {
                            importable = true;
                        }
                    }

                    if (importable)
                    {
                        TrainingSet = imported;
                        if (State == MainWindowState.RawANN)
                        {
                            State = MainWindowState.LoadedTrainingSet;
                        }
                        MessageBox.Show("Conjunto de treinamento carregado com sucesso!");
                    }
                    else
                    {
                        MessageBox.Show("Não foi possível importar o conjunto de treinamento! Conjuntos de treinamento devem ser compatíveis com a RNA em questão.");
                    }
                }
            }
        }
示例#13
0
        public static bool Initialize(string title, MainWindowState state, bool isSRGBMode, bool isOpenGLMode)
        {
            bool ret = EffekseerNativePINVOKE.MainWindow_Initialize(title, MainWindowState.getCPtr(state), isSRGBMode, isOpenGLMode);

            if (EffekseerNativePINVOKE.SWIGPendingException.Pending)
            {
                throw EffekseerNativePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#14
0
 private void btnEditTrainingSet_Click(object sender, RoutedEventArgs e)
 {
     View.NewTrainingSet w = NewTrainingSetScreen();
     w.SetTrainingSet(TrainingSet);
     w.ShowDialog();
     if (TrainingSet != null && State == MainWindowState.RawANN)
     {
         State = MainWindowState.LoadedTrainingSet;
     }
 }
示例#15
0
        public MainWindowState GetState()
        {
            MainWindowState ret = new MainWindowState(EffekseerNativePINVOKE.MainWindow_GetState(swigCPtr), true);

            if (EffekseerNativePINVOKE.SWIGPendingException.Pending)
            {
                throw EffekseerNativePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#16
0
        private void OpenFile(object parameter)
        {
            State = MainWindowState.Work;
            var openFileDlg = new OpenFileDialog();

            if (openFileDlg.ShowDialog() == true)
            {
                FilePath = openFileDlg.FileName;
            }
            State = MainWindowState.Idle;
        }
示例#17
0
 public MainWindow()
 {
     InitializeComponent();
     Data           = DataLayer.GetInstance();
     CurrentControl = new InsertStudent()
     {
         Margin = new Thickness(0, 0, 0, 0),
     };
     MainGrid.Children.Add(CurrentControl);
     State = MainWindowState.InsertStudent;
 }
示例#18
0
        public MainWindowViewModel()
        {
            _linkExtractor           = new LinkExtractor();
            _cancellationTokenSource = new CancellationTokenSource();

            UrlData = new ObservableCollection <BaseUrlInfo>();

            AnalyzeUrlCommand = new BaseCommand(AnalyzeUrl);
            OpenFileCommand   = new BaseCommand(OpenFile);
            CloseAppCommand   = new BaseCommand(CloseApp);
            State             = MainWindowState.Idle;
        }
示例#19
0
 private void notifyIcon_DoubleClick(object sender, EventArgs e)
 {
     if (WindowState1 == MainWindowState.Visible)
     {
         Activate();
     }
     else
     {
         WindowState1 = MainWindowState.Visible;
         Show();
     }
 }
示例#20
0
 private void ToolStripMenuItem_ActivateMainWindow_Click(object sender, EventArgs e)
 {
     if (WindowState1 == MainWindowState.Visible)
     {
         WindowState1 = MainWindowState.Hidden;
         Hide();
     }
     else
     {
         WindowState1 = MainWindowState.Visible;
         Show();
     }
 }
示例#21
0
        public void SetState(string path, MainWindowState mainWindowState)
        {
            SetProgressMode();

            PathValue = path;

            Task task = UpdateFilesList(mainWindowState);

            if (task != null)
            {
                task.ContinueWith(t => DispatcherInvoke(() => SetPathMode(mainWindowState)));
            }
        }
示例#22
0
        private Task UpdateFilesList(MainWindowState transitionState)
        {
            switch (transitionState)
            {
            case MainWindowState.Folder:
                return(_filesListManager.UpdateFileRecords(PathValue, FileSearchType.Folder));

            case MainWindowState.ZipFile:
                return(_filesListManager.UpdateFileRecords(PathValue, FileSearchType.Zip));

            default:
                throw new ArgumentException("Unknown UpdateFilesList argument.");
            }
        }
示例#23
0
        private async void AnalyzeUrl(object parameter)
        {
            if (string.IsNullOrEmpty(_filePath))
            {
                return;
            }

            State = MainWindowState.Work;
            UrlData.Clear();

            try
            {
                UrlCount = File.ReadAllLines(_filePath).Count();
                var urls = File.ReadAllLines(_filePath).ToList();

                await Task.Factory.StartNew(() =>
                {
                    for (int i = 0; i < urls.Count; i++)
                    {
                        try
                        {
                            BaseUrlInfo baseUrlInfo;
                            if (_linkExtractor.TryGetUrl(out baseUrlInfo, urls[i], 1000, _cancellationTokenSource.Token))
                            {
                                Application.Current.Dispatcher.Invoke(() =>
                                {
                                    UrlData.Add(baseUrlInfo);
                                    CurrentUrlState = i + 1;
                                });
                            }
                        }
                        catch (Exception ex)
                        {
                            var exc = ex;
                        }
                    }
                }, _cancellationTokenSource.Token);
            }
            catch
            {
            }

            State = MainWindowState.Idle;
        }
示例#24
0
        private void FilesList_MouseDoubleClick(object sender, MainWindowState currentState, string rootFoler)
        {
            // Workaround for MVVM double click functionality
            // TODO: Imlement MVVM double click approach
            DataGridRow gridRow        = (DataGridRow)sender;
            FileRecord  selectedRecord = (FileRecord)gridRow.Item;

            if (selectedRecord != null)
            {
                if (currentState == MainWindowState.Folder)
                {
                    FilesHelper.OpenFileExplorer(rootFoler, selectedRecord.FilePath);
                }
                else
                {
                    WindowHelper.ShowError("Open file location is only possible in the Folder mode.");
                }
            }
        }
示例#25
0
        private void btnLoadLearn_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName   = "Aprendizado";
            dlg.DefaultExt = ".json";
            dlg.Filter     = "Arquivos JSON (.json)|*.json";
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                string filename = dlg.FileName;
                bool   error    = true;

                try
                {
                    ADReNA_API.Util.Import.KnowledgeBase(RNA, filename);
                    error = false;
                }
                catch
                {
                    MessageBox.Show("Não foi possível importar o aprendizado da RNA! O aprendizao deve ser compatível com a RNA em questão.");
                }

                if (!error)
                {
                    State = MainWindowState.TrainedANN;
                    if (TrainingSet == null)
                    {
                        if (RNA is Kohonen)
                        {
                            TrainingSet = new DataSet(((Kohonen)RNA).GetInputLayerSize());
                        }
                        else if (RNA is Backpropagation)
                        {
                            TrainingSet = new DataSet(((Backpropagation)RNA).GetInputLayerSize(), ((Backpropagation)RNA).GetOutputLayerSize());
                        }
                    }
                    labelIterationCount.Visibility = System.Windows.Visibility.Collapsed;
                    MessageBox.Show("Aprendizado carregado com sucesso!");
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            ChangeStateCommandBinding = new CommandBinding(ChangeState);
            SaveAsCommandBinding = new CommandBinding(ApplicationCommands.SaveAs);
            SaveAsCommandBinding.Executed += SaveAsCommandBindingExecuted;
            OpenCommandBinding = new CommandBinding(ApplicationCommands.Open);
            OpenCommandBinding.Executed += OpenCommandBindingExecuted;
            CommandBindings.Add(ChangeStateCommandBinding);
            CommandBindings.Add(SaveAsCommandBinding);
            CommandBindings.Add(OpenCommandBinding);

            mainWindowState = new MainWindowSelecting(this);
            //hydroObjectGraph = new HydroObjectGraph();
            //elementDictionary = new Dictionary<FrameworkElement, HydroObject>();
            Transform = new TranslateTransform();
            HydroDocument = new HydroDocument();
            elementDataDic = new Dictionary<FrameworkElement, ElementData>();
        }
        private void SwitchState(MainWindowState newState)
        {
            if (state != newState)
            {
                state = newState;

                switch (state)
                {
                case MainWindowState.Minimal:
                    mainWorkspace.Margin            = new Thickness(0);
                    this.mainWindow.DocumentName    = StringResources.Title;
                    this.mainWindow.ApplicationName = string.Empty;
                    break;

                case MainWindowState.Active:
                    ribbon.ApplicationMenu = _applicationMenu;
                    break;
                }
            }
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            State = MainWindowState.Active;

            BindingOperations.SetBinding(this, MainWindow.IsKeyTipModeActiveProperty, new Binding()
            {
                Source = ribbon,
                Path   = new PropertyPath("IsKeyTipModeActive")
            });

            Image icon = Template.FindName("PART_ApplicationIcon", this) as Image;

            if (icon != null)
            {
                icon.Width  = 0;
                icon.Height = 0;
            }
        }
示例#29
0
        public IUserControlProxy Create(MainWindowState state)
        {
            switch (state)
            {
            case MainWindowState.Robots:
            {
                var vm      = kernel.Get <IRobotSectionViewModel>();
                var control = new RobotSectionControl();
                control.DataContext = vm;
                return(control.AsProxy());
            }

            case MainWindowState.Programs:
            {
                var vm      = kernel.Get <IProgramSectionViewModel>();
                var control = new ProgramSectionControl();
                control.DataContext = vm;
                return(control.AsProxy());
            }
            }

            return(UserControlProxy.NullProxy);
        }
示例#30
0
        public MainWindow()
        {
            InitializeComponent();

            MainWindowState = new MainWindowState
            {
                IsGeneratingArray        = false,
                IsSavingFile             = false,
                IsLoadingFile            = false,
                IsLinearSearching        = false,
                IsBinarySearching        = false,
                IsInterchangeSorting     = false,
                IsBubbleSorting          = false,
                IsInterpolationSearching = false,
                IsSelectionSorting       = false,
                IsInsertionSorting       = false,
                IsHeapSorting            = false,
                IsQuickSorting           = false,
                IsMergeSorting           = false
            };
            DataContext = MainWindowState;

            CreateOutputFolder();
        }
示例#31
0
 private void SetControlEnable(MainWindowState state)
 {
     switch (state)
     {
         case MainWindowState.New:
             {
                 this.DatabaseTypeList.IsEnabled = true;
                 this.SelectDatabaseTypeButton.Visibility = Visibility.Visible;
                 this.MainTab.Visibility = Visibility.Hidden;
                 this.MainTabTable.Visibility = Visibility.Hidden;
                 this.MainTabStoredProcedure.Visibility = Visibility.Hidden;
                 this.MainTabUserDefinedTableType.Visibility = Visibility.Hidden;
                 this.m0100.IsEnabled = false;
                 this.m0200.IsEnabled = false;
                 this.m0300.IsEnabled = false;
             }
             break;
         case MainWindowState.SchemaLoaded:
             {
                 this.DatabaseTypeList.IsEnabled = false;
                 this.SelectDatabaseTypeButton.Visibility = Visibility.Hidden;
                 this.MainTab.Visibility = Visibility.Visible;
                 this.MainTabTable.Visibility = Visibility.Visible;
                 this.MainTabStoredProcedure.Visibility = Visibility.Visible;
                 this.MainTabUserDefinedTableType.Visibility = Visibility.Visible;
                 this.m0100.IsEnabled = true;
                 this.m0200.IsEnabled = true;
                 this.m0300.IsEnabled = true;
             }
             break;
         default: throw new InvalidOperationException();
     }
 }
 protected override void LeaveState(MainWindowState newState)
 {
     base.LeaveState(newState);
     SelectedElement = null;
 }
示例#33
0
 private void btnTrain_Click(object sender, RoutedEventArgs e)
 {
     ShowLoading(true);
     State = MainWindowState.TrainingANN;
     backgroundWorker.RunWorkerAsync();
 }
            /// <summary>
            /// Overrided method should not remove 'base.LeaveState' unless you know what you're doing.
            /// </summary>
            /// <param name="newState"></param>
            protected virtual void LeaveState(MainWindowState newState)
            {
                DrawingCanvas.MouseMove -= OnDrawingCanvasMouseMove;
                DrawingCanvas.MouseLeftButtonDown -= OnDrawingCanvasMouseLeftButtonDown;
                DrawingCanvas.MouseLeftButtonUp -= OnDrawingCanvasMouseLeftButtonUp;

                container.ChangeStateCommandBinding.Executed -= OnChangeState;
                container.ChangeStateCommandBinding.CanExecute -= CanChangeState;
                container.SaveAsCommandBinding.CanExecute -= CanChangeState;
                container.OpenCommandBinding.CanExecute -= CanChangeState;
            }
 protected override void LeaveState(MainWindowState newState)
 {
     base.LeaveState(newState);
     if (!IsCreating)
     {
         if (!(newState is MainWindowReconnecting))
         {
             container.RemoveHydroElement(element);
             originalElement.Visibility = Visibility.Visible;
         }
         else
             container.RemoveHydroElement(originalElement);
     }
     else
     {
         if (!(newState is MainWindowSettingFirstPPipeNode))
             container.RemoveHydroElement(element);
     }
 }