Exemple #1
0
        private void Button_Click_4(object sender, RoutedEventArgs e) // Delete selected student
        {
            var selectedIndex = List.SelectedIndex;

            if (students.studentlist[selectedIndex].isHead == "+")
            {
                var rez = students.studentlist[selectedIndex].group;
                rez.head     = null;
                rez.headName = "-";
            }
            students.studentlist.Remove(students.studentlist[selectedIndex]);

            NameBox.Clear();
            SurnameBox.Clear();
            Middlename.Clear();
            YearBox.Clear();
            FileNameTextBox.Clear();
            GroupCombo.SelectedIndex    = -1;
            OldGroupCombo.SelectedIndex = -1;

            List.Items.Refresh();

            mark.marks.Clear();
            Table.ItemsSource = mark.marks;
            Table.Items.Refresh();

            AddButton.IsEnabled    = true;
            HeadCheck.IsChecked    = false;
            ChangeButton.IsEnabled = false;
            DeleteButton.IsEnabled = false;
        }
Exemple #2
0
 private void ClearForm()
 {
     TitleTextBox.Clear();
     FileNameTextBox.Clear();
     AuthorTextBox.Clear();
     AlbumTextBox.Clear();
 }
        public Edit(Output output)
        {
            InitializeComponent();

            foreach (string fileNameReplacement in AttributeHelper.GetAttributeReplacements())
            {
                MenuItem item = new MenuItem();
                item.Header = new TextBlock()
                {
                    Text = fileNameReplacement
                };
                item.Tag    = fileNameReplacement;
                item.Click += FileNameReplacementItem_Click;
                FileNameReplacementList.Items.Add(item);
            }

            NameTextBox.Text     = output.Name;
            FileNameTextBox.Text = output.FileName;

            FileFormatComboBox.ItemsSource   = FileHelper.GetFileFormats();
            FileFormatComboBox.SelectedValue = output.FileFormatID;

            EditFileNameCheckBox.IsChecked = output.EditFileName;

            NameTextBox.TextChanged             += ValidateData;
            FileFormatComboBox.SelectionChanged += ValidateData;
            ValidateData(null, null);

            FileNameTextBox.Focus();
        }
Exemple #4
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            string fileName = FileNameTextBox.Text;

            if (string.IsNullOrWhiteSpace(fileName))
            {
                MessageBox.Show("Please enter a file name for the image", "Missing name", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            foreach (char item in Path.GetInvalidFileNameChars())
            {
                if (fileName.Contains(item.ToString()))
                {
                    MessageBox.Show("Invalid file name.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }

            BitmapEncoder encoder   = new PngBitmapEncoder();
            BitmapSource  bitmapSrc = MandelbrotImage.Source as BitmapSource;

            encoder.Frames.Add(BitmapFrame.Create(bitmapSrc));

            using (var filestream = new FileStream($"{fileName}.png", FileMode.Create))
            {
                encoder.Save(filestream);
                MessageBox.Show($"Saved image {fileName}.png to bin.", "Success!");
                FileNameTextBox.Clear();
            }
        }
Exemple #5
0
        } // архивация бекапа БД

        private void FileArhiveBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(FileNameTextBox.Text))
                {
                    MessageBox.Show("Выберете Файл!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    FileNameTextBox.Focus();
                    return;
                }

                String sourcePath = FileNameTextBox.Text;
                using (ZipFile zip = ZipFile.Read(sourcePath))
                {
                    zip.ExtractAll(@"C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Backup", ExtractExistingFileAction.DoNotOverwrite);
                }

                Server   srv = new Server("DESKTOP-EPNEITS");
                Database db  = default(Database);
                db = srv.Databases["Rating"];

                int recoverymod;
                recoverymod = (int)db.DatabaseOptions.RecoveryModel;

                BackupDeviceItem bdi = default(BackupDeviceItem);
                bdi = new BackupDeviceItem("Rating " + DateTime.Now.ToString("yyyy-MM-dd") + " Backup", DeviceType.File);

                Restore rs = new Restore();

                rs.NoRecovery = true;

                rs.Devices.Add(bdi);

                rs.Database = "Rating";

                // rs.SqlRestore(srv);

                db = srv.Databases["Rating"];

                rs.Devices.Remove(bdi);

                rs.NoRecovery = false;

                db.RecoveryModel = (RecoveryModel)recoverymod;

                db.Alter();

                MessageBox.Show("Восстановление данных прошло успешно!");
            }
            catch
            {
                MessageBox.Show("Данный файл не является архивом, либо не относиться к текущей базе данных!");
            }
        } // Восстановление архива
        private void FileNameReplacementItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item = (MenuItem)sender;

            int selectionStart = FileNameTextBox.SelectionStart;

            FileNameTextBox.Text = FileNameTextBox.Text.Substring(0, FileNameTextBox.SelectionStart) + item.Tag.ToString() + FileNameTextBox.Text.Substring(FileNameTextBox.SelectionStart, FileNameTextBox.Text.Length - FileNameTextBox.SelectionStart);

            FileNameTextBox.SelectionStart = selectionStart + item.Tag.ToString().Length;
            FileNameTextBox.Focus();
        }
Exemple #7
0
        public Send(string fileName)
        {
            InitializeComponent();

            FileNameTextBox.Text = fileName;

            FileNameTextBox.TextChanged += ValidateData;
            ValidateData(null, null);

            FileNameTextBox.SelectAll();
            FileNameTextBox.Focus();
        }
Exemple #8
0
        public void MultipleFilesDownload()
        {
            FileNameTextBox.SendKeys("dotNetFx45_Full_setup.exe;directx_Jun2010_redist.exe");
            ServerAddressTextBox.SendKeys("https://download.microsoft.com");
            StartButton.Click();

            Thread.Sleep(TimeSpan.FromSeconds(5)); // Wait for files to download

            var lastLog = GetLastLog();
            var status  = lastLog.Split(',')[1].Trim();

            Assert.AreEqual("Status Code: 200", status);
        }
 private void LoadAndHashFile(string path)
 {
     try
     {
         _fileContents = System.IO.File.ReadAllBytes(path);
     }
     catch (Exception ex)
     {
         string msg = "The file cannot be read.\nSystem Message:\n  " + ex.Message;
         MessageBox.Show(msg, "File Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         FileNameTextBox.Focus();
         return;
     }
     _fileHash = new SHA1CryptoServiceProvider().ComputeHash(_fileContents);
 }
Exemple #10
0
        private void StopRecording(object obj)
        {
            _pendingSave = _recorder.Stop();

            var defaultFileName = DateTime.Now.ToString("yyyy-MM-dd hh-mm-ss");

            Dispatcher.BeginInvoke(delegate()
            {
                FileNameTextBox.Text = defaultFileName;
                FileNameTextBox.Focus();
                FileNameTextBox.SelectAll();

                ToggleVisibility();
                RecordButton.Content = "Start Recording";
            });
        }
        private void Browse_Click_1(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
            openFileDialog.Filter           = "All Files(*.dll)|*.dll;";
            openFileDialog.Multiselect      = true;
            if (openFileDialog.ShowDialog() == true)
            {
                FileNameTextBox.Clear();
                foreach (var file in openFileDialog.FileNames)
                {
                    string fileName = System.IO.Path.GetFileName(file);
                    FileNameTextBox.Text += fileName + ";" + Environment.NewLine;
                    System.IO.File.Copy(file, @"C:\Automation\AppData\TestBuilds\" + BuildDefinition + "\\" + fileName, true);
                }
            }
        }
Exemple #12
0
        private void Button_Click_6(object sender, RoutedEventArgs e)
        {
            NameBox.Clear();
            SurnameBox.Clear();
            Middlename.Clear();
            YearBox.Clear();
            GroupCombo.SelectedIndex    = -1;
            OldGroupCombo.SelectedIndex = -1;
            FileNameTextBox.Clear();

            mark.marks.Clear();
            Table.ItemsSource = mark.marks;
            Table.Items.Refresh();

            AddButton.IsEnabled    = true;
            HeadCheck.IsChecked    = false;
            ChangeButton.IsEnabled = false;
            DeleteButton.IsEnabled = false;
        }
Exemple #13
0
        private void OpenFileButton_OnClick(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new Microsoft.Win32.OpenFileDialog();

            openFileDialog.Filter = "All texture files (*.*)|*.*";
            openFileDialog.Title  = "Select texture file";

            if (!string.IsNullOrEmpty(BaseFolder) && System.IO.Directory.Exists(BaseFolder))
            {
                openFileDialog.InitialDirectory = BaseFolder;
            }


            if ((openFileDialog.ShowDialog() ?? false) && !string.IsNullOrEmpty(openFileDialog.FileName))
            {
                TextureCheckBox.SetCurrentValue(System.Windows.Controls.Primitives.ToggleButton.IsCheckedProperty, true);
                FileNameTextBox.SetCurrentValue(TextBox.TextProperty, openFileDialog.FileName);

                LoadCurrentTexture();
            }
        }
Exemple #14
0
        /// <summary>
        /// Displays the FIT file.
        /// </summary>
        private void DisplayFitFile()
        {
            ClearDisplay();
            if (fitFile != null)
            {
                // display the file name
                FileNameTextBox.Text = fitFile.FileName;
                FileNameTextBox.Focus();
                FileNameTextBox.Select(FileNameTextBox.Text.Length, 0);

                // display the record summary
                NumRecordsLabel.Content  = fitFile.Records.Count.ToString();
                NumLengthsLabel.Content  = fitFile.Lengths.Count.ToString();
                NumLapsLabel.Content     = fitFile.Laps.Count.ToString();
                NumSessionsLabel.Content = fitFile.Sessions.Count.ToString();
                FitRecord last = fitFile.Records[fitFile.Records.Count - 1];
                TimeLabel.Content     = (last.Timestamp - fitFile.Records[0].Timestamp).ToString();
                DistanceLabel.Content = (last.Distance ?? 0).ToString("0.#");
                FitRecordSummary summary = fitFile.Records.Summary;
                AverageCadenceLabel.Content   = summary.AveCadence.ToString("0");
                AverageHeartRateLabel.Content = summary.AveHeartRate.ToString("0");
                AveragePowerLabel.Content     = summary.AvePower.ToString("0");
                AverageSpeedLabel.Content     = summary.AveSpeed.ToString("0.#");
                MaxCadenceLabel.Content       = summary.MaxCadence.ToString();
                MaxHeartRateLabel.Content     = summary.MaxHeartRate.ToString();
                MaxPowerLabel.Content         = summary.MaxPower.ToString();
                MaxSpeedLabel.Content         = summary.MaxSpeed.ToString("0.#");

                // display the data grids
                FileIDDataGrid.ItemsSource      = GetNonNullPropertiesValues(typeof(FitFileID), fitFile.FileID);
                DeviceInfoDataGrid.ItemsSource  = fitFile.DeviceInfos;
                UserProfileDataGrid.ItemsSource = GetNonNullPropertiesValues(typeof(FitUserProfile), fitFile.UserProfile);
                ActivityDataGrid.ItemsSource    = GetNonNullPropertiesValues(typeof(FitActivity), fitFile.Activity);
                SessionsDataGrid.ItemsSource    = fitFile.Sessions;
                LapsDataGrid.ItemsSource        = fitFile.Laps;
                LengthsDataGrid.ItemsSource     = fitFile.Lengths;
                RecordsDataGrid.ItemsSource     = fitFile.Records;
                MessagesDataGrid.ItemsSource    = fitFile.Messages;
            }
        }
Exemple #15
0
        /// <summary>
        /// Открытие диалогового окна с выбором пути.
        /// Путь записывается в поле FileNameTextBox (доступно только для чтения и служит для подтверждения прикрепления файла).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BrowseButton_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            bool?result = dlg.ShowDialog();

            if (result == true)
            {
                try
                {
                    MyPic.Source = new BitmapImage(new Uri(dlg.FileName, UriKind.RelativeOrAbsolute));

                    FileNameTextBox.Text = dlg.FileName;
                    SendButton.IsEnabled = true;
                }
                catch (Exception)
                {
                    MyPic.Source = new BitmapImage();

                    FileNameTextBox.Clear();
                    SendButton.IsEnabled = false;
                    _ = MessageBox.Show("Загруженный файл не является изображением! Выберите корректный файл.", "Ошибка!");
                }
            }
        }
Exemple #16
0
        /// <summary>
        /// Отправление данных.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SendButton_Click(object sender, RoutedEventArgs e)
        {
            if (client != null)
            {
                if (client.Connected)
                {
                    string path;

                    try
                    {
                        path = FileNameTextBox.Text;

                        if (FirstLastNameBox.Text != string.Empty &&
                            UniversityBox.Text != string.Empty &&
                            PhoneBox.Text != string.Empty &&
                            path != string.Empty)                                                                   // условия для запуска обработки и отправки данных
                        {
                            UserInfo user = new UserInfo(FirstLastNameBox.Text, UniversityBox.Text, PhoneBox.Text); // получение и подготовка данных

                            if (File.Exists(path))
                            {
                                PrepareData(user, path);

                                byte[] info        = Encoding.ASCII.GetBytes(packetSerialize.Length.ToString());
                                bool   isConnected = Send(info); // отправка информации о размере (или об отключении)

                                if (isConnected)
                                {
                                    if (client.Connected)
                                    {
                                        isConnected = Send(packetSerialize);

                                        if (isConnected)
                                        {
                                            WriteStatus("\nОжидание ответа...");

                                            Task receiveTask = Task.Factory.StartNew(Receive);

                                            FirstLastNameBox.IsEnabled = false;
                                            FirstLastNameBox.Clear();
                                            UniversityBox.IsEnabled = false;
                                            UniversityBox.Clear();
                                            PhoneBox.IsEnabled = false;
                                            PhoneBox.Clear();
                                            FileNameTextBox.Clear();
                                            browseButton.IsEnabled = false;
                                            SendButton.IsEnabled   = false;
                                            MyPic.Visibility       = Visibility.Hidden;
                                            MyPic.Visibility       = Visibility.Hidden;
                                        }
                                    }
                                    else
                                    {
                                        WriteStatus("\n\nСоединение было разорвано!");
                                        ConnectButton.Content = "Подключиться";

                                        Shutdown();
                                    }
                                }
                            }
                            else
                            {
                                _ = MessageBox.Show("Текущий путь до файла не корректен, либо файл отсуствует!", "Ошибка!");
                            }
                        }
                        else
                        {
                            _ = MessageBox.Show("Заполните все поля ввода данных!", "Ошибка!");
                        }
                    }
                    catch (Exception)
                    {
                        _ = MessageBox.Show("Неизвестная ошибка!", "Ошибка!");
                    }
                }
                else // отсутствие подключения
                {
                    _ = MessageBox.Show("Проблема с соединением. Попробуйте переподключиться.", "Ошибка!");
                    ConnectButton.Content = "Подключиться";
                }
            }
            else
            {
                _ = MessageBox.Show("Сначала необходимо подключиться!", "Ошибка!");
            }
        }
        private void LoadCurrentTexture()
        {
            if (this.DXDevice == null)
            {
                return;
            }

            bool hasChanges = false;


            if (_textureMapInfo != null)
            {
                if (_textureMapInfo.ShaderResourceView != null)
                {
                    _textureMapInfo.ShaderResourceView.Dispose();
                }

                if (_textureMapInfo.SamplerState != null)
                {
                    _textureMapInfo.SamplerState.Dispose();
                }

                Material.TextureMaps.Remove(_textureMapInfo);

                _textureMapInfo = null;

                hasChanges = true;
            }

            FileNameTextBox.ClearValue(ForegroundProperty);
            FileNameTextBox.ToolTip = null;


            if (TextureCheckBox.IsChecked ?? false)
            {
                var fileName = FileNameTextBox.Text;

                if (!string.IsNullOrEmpty(fileName))
                {
                    if (BaseFolder != null && !System.IO.Path.IsPathRooted(fileName))
                    {
                        fileName = System.IO.Path.Combine(BaseFolder, fileName);
                    }

                    if (!System.IO.File.Exists(fileName))
                    {
                        FileNameTextBox.Foreground = Brushes.Red;
                        FileNameTextBox.ToolTip    = fileName + " does not exist!";
                        return;
                    }


                    var isBaseColor = (TextureMapType == TextureMapTypes.BaseColor ||
                                       TextureMapType == TextureMapTypes.Albedo ||
                                       TextureMapType == TextureMapTypes.DiffuseColor);

                    // To load a texture from file, you can use the TextureLoader.LoadShaderResourceView (this supports loading standard image files and also loading dds files).
                    // This method returns a ShaderResourceView and it can also set a textureInfo parameter that defines some of the properties of the loaded texture (bitmap size, dpi, format, hasTransparency).
                    TextureInfo textureInfo;
                    var         shaderResourceView = Ab3d.DirectX.TextureLoader.LoadShaderResourceView(this.DXDevice.Device,
                                                                                                       fileName,
                                                                                                       loadDdsIfPresent: true,
                                                                                                       convertTo32bppPRGBA: isBaseColor,
                                                                                                       generateMipMaps: true,
                                                                                                       textureInfo: out textureInfo);

                    // Only 2D textures are supported
                    if (shaderResourceView.Description.Dimension != ShaderResourceViewDimension.Texture2D)
                    {
                        MessageBox.Show("Invalid texture dimension: " + shaderResourceView.Description.Dimension.ToString());
                        TextureCheckBox.IsChecked = false;

                        return;
                    }

                    _textureMapInfo = new TextureMapInfo(TextureMapType, shaderResourceView, null, fileName);
                    Material.TextureMaps.Add(_textureMapInfo);


                    var physicallyBasedMaterial = Material as PhysicallyBasedMaterial;
                    if (isBaseColor && physicallyBasedMaterial != null)
                    {
                        // Get recommended BlendState based on HasTransparency and HasPreMultipliedAlpha values.
                        // Possible values are: CommonStates.Opaque, CommonStates.PremultipliedAlphaBlend or CommonStates.NonPremultipliedAlphaBlend.
                        var recommendedBlendState = this.DXDevice.CommonStates.GetRecommendedBlendState(textureInfo.HasTransparency, textureInfo.HasPremultipliedAlpha);

                        physicallyBasedMaterial.BlendState      = recommendedBlendState;
                        physicallyBasedMaterial.HasTransparency = textureInfo.HasTransparency;
                    }


                    if (CurrentMaskColor == Colors.Black)
                    {
                        CurrentMaskColor = Colors.White;
                    }

                    if (CurrentFilterValue <= 0.01)
                    {
                        CurrentFilterValue = 1.0f;
                    }

                    hasChanges = true;
                }
            }


            if (hasChanges)
            {
                OnMapSettingsChanged();
            }
        }
Exemple #18
0
        private void Button_Click_3(object sender, RoutedEventArgs e) // Change information
        {
            if (String.IsNullOrWhiteSpace(NameBox.Text) || String.IsNullOrWhiteSpace(SurnameBox.Text) || String.IsNullOrWhiteSpace(Middlename.Text) || String.IsNullOrWhiteSpace(YearBox.Text))
            {
                MessageBox.Show("Please, fill all fields", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (NameBox.Text.Length > 16 || SurnameBox.Text.Length > 16 || Middlename.Text.Length > 16)
            {
                MessageBox.Show("Name, Surname and Middlename must not contain more than 16 letters ", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (Convert.ToInt32(YearBox.Text) > 2017 || Convert.ToInt32(YearBox.Text) < 1950)
            {
                MessageBox.Show("In the year selection field number should be between 1950 to 2017", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                YearBox.Clear();
                return;
            }

            if (GroupCombo.SelectedItem != null && GroupCombo.SelectedItem == OldGroupCombo.SelectedItem)
            {
                MessageBox.Show("Old group and current group must be different", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                GroupCombo.SelectedItem    = null;
                OldGroupCombo.SelectedItem = null;
                return;
            }

            var selectedIndex = List.SelectedIndex;

            students.studentlist[selectedIndex].Name       = NameBox.Text;
            students.studentlist[selectedIndex].Surname    = SurnameBox.Text;
            students.studentlist[selectedIndex].Middlename = Middlename.Text;
            students.studentlist[selectedIndex].Year       = Convert.ToInt32(YearBox.Text);

            if (GroupCombo.SelectedItem == null)
            {
                students.studentlist[selectedIndex].group_number = "-";
                students.studentlist[selectedIndex].groupHeading = "-";
                students.studentlist[selectedIndex].isHead       = "-";
                students.studentlist[selectedIndex].group        = null;
            }
            else
            {
                students.studentlist[selectedIndex].group_number = GroupCombo.Text;
                var rez = (Group)GroupCombo.SelectedItem;

                if (HeadCheck.IsChecked == true)
                {
                    if (students.studentlist[selectedIndex].groupHeading != Convert.ToString(rez.Number))
                    {
                        if (rez != students.studentlist[selectedIndex].group)
                        {
                            if (students.studentlist[selectedIndex].isHead == "+")
                            {
                                var rez1 = students.studentlist[selectedIndex].group;
                                rez1.headName = "-";
                                rez1.head     = null;
                            }
                        }

                        if (rez.head == null)
                        {
                            students.studentlist[selectedIndex].isHead       = "+";
                            students.studentlist[selectedIndex].group_number = Convert.ToString(rez.Number);
                            students.studentlist[selectedIndex].groupHeading = students.studentlist[selectedIndex].group_number;
                            students.studentlist[selectedIndex].group        = rez;

                            rez.headName = students.studentlist[selectedIndex].Surname + " " + students.studentlist[selectedIndex].Name;
                            rez.head     = students.studentlist[selectedIndex];
                        }
                        else
                        {
                            students.studentlist[selectedIndex].group_number = Convert.ToString(rez.Number);
                            students.studentlist[selectedIndex].isHead       = "-";
                            students.studentlist[selectedIndex].groupHeading = "-";
                            students.studentlist[selectedIndex].group        = rez;
                            MessageBox.Show("This group already has a head. This student was not appointed head", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                    }
                    else
                    {
                        rez.headName = students.studentlist[selectedIndex].Surname + " " + students.studentlist[selectedIndex].Name;
                    }
                }
                else
                {
                    if (rez.head == students.studentlist[selectedIndex])
                    {
                        rez.head     = null;
                        rez.headName = "-";
                    }
                    students.studentlist[selectedIndex].isHead       = "-";
                    students.studentlist[selectedIndex].groupHeading = "-";
                }
                students.studentlist[selectedIndex].group = (Group)GroupCombo.SelectedItem;
            }

            if (students.studentlist[selectedIndex].isHead == "+")
            {
                students.studentlist[selectedIndex].groupHeading = students.studentlist[selectedIndex].group_number;
            }
            else
            {
                students.studentlist[selectedIndex].groupHeading = "-";
            }

            if (OldGroupCombo.SelectedItem == null)
            {
                students.studentlist[selectedIndex].old_group_number = "-";
            }
            else
            {
                students.studentlist[selectedIndex].old_group_number = OldGroupCombo.Text;
            }

            students.studentlist[selectedIndex].oldGroup = (Group)OldGroupCombo.SelectedItem;

            if (students.studentlist[selectedIndex].studentPhoto != null)
            {
                if ("file:///" + FileNameTextBox.Text != Convert.ToString(students.studentlist[selectedIndex].studentPhoto.UriSource))
                {
                    if (FileNameTextBox.Text != "")
                    {
                        BitmapImage StudentPhoto = new BitmapImage();
                        StudentPhoto.BeginInit();
                        StudentPhoto.UriSource   = new Uri(FileNameTextBox.Text, UriKind.Absolute);
                        StudentPhoto.CacheOption = BitmapCacheOption.OnLoad;
                        StudentPhoto.EndInit();
                        students.studentlist[selectedIndex].studentPhoto = StudentPhoto;
                        students.studentlist[selectedIndex].photoPath    = Convert.ToString(students.studentlist[selectedIndex].studentPhoto.UriSource);
                    }
                }
            }

            students.studentlist[selectedIndex].marks = new List <Student.struct_marks>(mark.marks);
            List.Items.Refresh();

            NameBox.Clear();
            SurnameBox.Clear();
            Middlename.Clear();
            YearBox.Clear();
            FileNameTextBox.Clear();
            GroupCombo.SelectedIndex    = -1;
            OldGroupCombo.SelectedIndex = -1;

            mark.marks.Clear();
            Table.ItemsSource = mark.marks;
            Table.Items.Refresh();

            AddButton.IsEnabled    = true;
            HeadCheck.IsChecked    = false;
            ChangeButton.IsEnabled = false;
            DeleteButton.IsEnabled = false;
        }
Exemple #19
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     //Application.Current.MainWindow = this;
     FileNameTextBox.Focus();
 }
Exemple #20
0
        private void LoadCurrentTexture()
        {
            if (this.Device == null)
            {
                return;
            }

            bool hasChanges = false;


            if (_textureMapInfo != null)
            {
                if (_textureMapInfo.ShaderResourceView != null)
                {
                    _textureMapInfo.ShaderResourceView.Dispose();
                }

                if (_textureMapInfo.SamplerState != null)
                {
                    _textureMapInfo.SamplerState.Dispose();
                }

                Material.TextureMaps.Remove(_textureMapInfo);

                _textureMapInfo = null;

                hasChanges = true;
            }

            FileNameTextBox.ClearValue(ForegroundProperty);
            FileNameTextBox.ToolTip = null;


            if (TextureCheckBox.IsChecked ?? false)
            {
                var fileName = FileNameTextBox.Text;

                if (!string.IsNullOrEmpty(fileName))
                {
                    if (BaseFolder != null && !System.IO.Path.IsPathRooted(fileName))
                    {
                        fileName = System.IO.Path.Combine(BaseFolder, fileName);
                    }

                    if (!System.IO.File.Exists(fileName))
                    {
                        FileNameTextBox.Foreground = Brushes.Red;
                        FileNameTextBox.ToolTip    = fileName + " does not exist!";
                        return;
                    }


                    var convertTo32bppPRGBA = (TextureMapType == TextureMapTypes.BaseColor ||
                                               TextureMapType == TextureMapTypes.Albedo ||
                                               TextureMapType == TextureMapTypes.DiffuseColor);

                    var shaderResourceView = Ab3d.DirectX.TextureLoader.LoadShaderResourceView(this.Device, fileName, loadDdsIfPresent: false, convertTo32bppPRGBA: convertTo32bppPRGBA);

                    // Only 2D textures are supported
                    if (shaderResourceView.Description.Dimension != ShaderResourceViewDimension.Texture2D)
                    {
                        MessageBox.Show("Invalid texture dimension: " + shaderResourceView.Description.Dimension.ToString());
                        TextureCheckBox.IsChecked = false;

                        return;
                    }

                    _textureMapInfo = new TextureMapInfo(TextureMapType, shaderResourceView, null, fileName);
                    Material.TextureMaps.Add(_textureMapInfo);


                    if (CurrentMaskColor == Colors.Black)
                    {
                        CurrentMaskColor = Colors.White;
                    }

                    if (CurrentFilterValue <= 0.01)
                    {
                        CurrentFilterValue = 1.0f;
                    }

                    hasChanges = true;
                }
            }


            if (hasChanges)
            {
                OnMapSettingsChanged();
            }
        }
Exemple #21
0
 private void FileNameTextBox_GotFocus(object sender, RoutedEventArgs e)
 {
     FileNameTextBox.SelectAll();
 }
 public void SelectAll()
 {
     FileNameTextBox.SelectAll();
 }