示例#1
0
 /// <summary>
 /// Initializes '_proxy', fills the listbox.
 /// </summary>
 /// <param name="tmp">Host.</param>
 /// <param name="userId">Id of user.</param>
 /// <param name="itemsId">Id of item.</param>
 /// <param name="data">Items type.</param>
 public WordsPrintFilter(EngServRef.EngServiceClient tmp, int userId, int itemsId, EngServRef.ServerData data) : this()
 {
     _proxy = tmp;
     user   = userId;
     item   = itemsId;
     type   = data;
 }
示例#2
0
        /// <summary>
        /// Initializes '_proxy' and sets default rating.
        /// </summary>
        /// <param name="tmp">Host to be initialized.</param>
        /// <param name="id">Id of item.</param>
        /// <param name="userId">Id of user.</param>
        /// <param name="stars">The number of stars.</param>
        /// <param name="data">Type of item.</param>
        public EditRating(EngServRef.EngServiceClient tmp, int id, int userId, int?stars, EngServRef.ServerData data) : this()
        {
            _proxy = tmp;

            this.id = id;
            user    = userId;
            count   = stars == null? 0: Convert.ToInt32(stars);
            mark    = count;
            type    = data;

            foreach (Image item in wrRating.Children)
            {
                item.ToolTip = count;
                item.Opacity = (count >= Convert.ToInt32(item.Tag)) ? 1 : 0.2;
            }
        }
示例#3
0
        //Initialize '_proxy'. Requires the users id.
        public EditAvatar(EngServRef.EngServiceClient tmp, int id) : this()
        {
            _proxy  = tmp;
            this.id = id;

            string path = _proxy.GetItemProperty(id, EngServRef.ServerData.User, EngServRef.PropertyData.Imgpath) ?? "Wolf.png";

            if (path == "Wolf.png")
            {
                FormData.SetImage("pack://*****:*****@"Temp\Avatars\{path}"))
                {
                    FormData.SetImage($@"pack://siteoforigin:,,,/Temp\Avatars\{path}", imDrag);
                }
                else
                {
                    MessageBox.Show("Your avatar can not be found!", "Something went wrong", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
示例#4
0
        //Initialize '_proxy'. Requires the users id.
        public EditRole(EngServRef.EngServiceClient tmp, int id) : this()
        {
            _proxy  = tmp;
            this.id = id;
            int roleId = Convert.ToInt32(_proxy.GetItemProperty(id, EngServRef.ServerData.User, EngServRef.PropertyData.Role));

            role = _proxy.GetItemProperty(roleId, EngServRef.ServerData.Role, EngServRef.PropertyData.Name);
            lUsername.Content = _proxy.GetItemProperty(id, EngServRef.ServerData.User, EngServRef.PropertyData.Name);

            List <int> lst = new List <int>(_proxy.GetItems(EngServRef.ServerData.Role));
            int        i   = 0;

            foreach (int item in lst)
            {
                cmbRole.Items.Add(new TextBlock {
                    Text = _proxy.GetItemProperty(item, EngServRef.ServerData.Role, EngServRef.PropertyData.Name), FontSize = 12, Foreground = Brushes.Black
                });
                if (item == roleId)
                {
                    cmbRole.SelectedIndex = i;
                }
                i++;
            }
        }
 //Initialize '_proxy'. Requires the users id.
 public EditPassword(EngServRef.EngServiceClient tmp, int id) : this()
 {
     _proxy  = tmp;
     this.id = id;
 }
示例#6
0
 /// <summary>
 /// Initialize form for editting.
 /// </summary>
 /// <param name="tmp">Host.</param>
 /// <param name="wordsName">Word.</param>
 /// <param name="userId">Id of user.</param>
 public AddWord(EngServRef.EngServiceClient tmp, int word, int?userId) : this(tmp, userId)
 {
     name     = _proxy.GetItemProperty(word, EngServRef.ServerData.Word, EngServRef.PropertyData.Name);
     wordsId  = word;
     editForm = true;
 }
示例#7
0
 /// <summary>
 /// Add a word for video or book.
 /// </summary>
 /// <param name="tmp">Host.</param>
 /// <param name="wordsName">Word.</param>
 /// <param name="userId">Id of user.</param>
 /// <param name="itemId">Items id.</param>
 /// <param name="type">Items type.</param>
 public AddWord(EngServRef.EngServiceClient tmp, string wordsName, int?userId, int?itemId, EngServRef.ServerData type) : this(tmp, userId)
 {
     name = wordsName;
     item = itemId;
     data = type;
 }
示例#8
0
 /// <summary>
 /// Initializes '_proxy'.
 /// </summary>
 /// <param name="tmp">Host.</param>
 /// <param name="userId">Id of user.</param>
 public AddWord(EngServRef.EngServiceClient tmp, int?userId) : this()
 {
     _proxy = tmp;
     user   = Convert.ToInt32(userId);
 }
示例#9
0
 //Initialize '_proxy'. Requires the users id.
 public EditUsername(EngServRef.EngServiceClient tmp, int id) : this()
 {
     _proxy  = tmp;
     this.id = id;
 }
示例#10
0
 /// <summary>
 /// 'Edit' form. Hides rating, fills fields.
 /// </summary>
 /// <param name="tmp">Host.</param>
 /// <param name="id">Video id.</param>
 public AddVideo(EngServRef.EngServiceClient tmp, int id, EngServRef.ServerData type) : this()
 {
     _proxy = tmp;
     video  = id;
 }
示例#11
0
 /// <summary>
 /// Initializes '_proxy', fills the listboxes.
 /// </summary>
 /// <param name="tmp">Host.</param>
 /// <param name="userId">Id of user.</param>
 public AddVideo(EngServRef.EngServiceClient tmp, int?userId) : this()
 {
     _proxy = tmp;
     user   = userId;
     FillCategories();
 }
示例#12
0
        //Add a new video.
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            int?year = null;

            if (txtYear.Text != "")
            {
                year = Convert.ToInt32(txtYear.Text);
            }
            int edit = 0;

            if (txtPath.Text == "")
            {
                MessageBox.Show("Choose file!", "No file chosen", MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }

            Task.Run(new Action(() => {
                Dispatcher.Invoke(new Action(() =>
                {
                    stMain.Visibility = Visibility.Collapsed;

                    if (video == null)
                    {
                        int?id = _proxy.AddVideo(txtName.Text, txtDesc.Text == "" ? null : txtDesc.Text, txtPath.Text, txtSubs.Text, "WolfV.png", chCopy.IsChecked == true ? false : true, mark, user, year, DateTime.Now);
                        if (id == null)
                        {
                            MessageBox.Show("Something went wrong.", "Operation denied", MessageBoxButton.OK, MessageBoxImage.Stop);
                            stMain.Visibility = Visibility.Visible;
                            return;
                        }
                        edit = Convert.ToInt32(id);

                        if (lPath.Content.ToString() != "...")
                        {
                            if (!_proxy.Upload(File.ReadAllBytes(lPath.Content.ToString()), $"{edit}{Path.GetExtension(lPath.Content.ToString())}", EngServRef.FilesType.VideosImages))
                            {
                                MessageBox.Show("This file is too large!\nPlease choose another file.", "Unable to upload", MessageBoxButton.OK, MessageBoxImage.Stop);
                                _proxy.RemoveItem(edit, EngServRef.ServerData.Video);
                                stMain.Visibility = Visibility.Visible;
                                return;
                            }
                            _proxy.EditData(edit, $"{edit}{Path.GetExtension(lPath.Content.ToString())}", EngServRef.ServerData.Video, EngServRef.PropertyData.Imgpath);
                        }
                        if (chCopy.IsChecked == true)
                        {
                            try
                            {
                                if (!_proxy.Upload(File.ReadAllBytes(txtPath.Text), $"{edit}{Path.GetExtension(txtPath.Text)}", EngServRef.FilesType.Videos))
                                {
                                    MessageBox.Show("This file is too large!\nPlease choose another file.", "Unable to upload", MessageBoxButton.OK, MessageBoxImage.Stop);
                                    _proxy.RemoveItem(edit, EngServRef.ServerData.Video);
                                    stMain.Visibility = Visibility.Visible;
                                    return;
                                }
                                _proxy.EditData(edit, $"{edit}{Path.GetExtension(txtPath.Text)}", EngServRef.ServerData.Video, EngServRef.PropertyData.Path);
                            }
                            catch (OutOfMemoryException)
                            {
                                MessageBox.Show("This file is too large!\nPlease choose another file.", "Unable to upload", MessageBoxButton.OK, MessageBoxImage.Stop);
                                _proxy = new EngServRef.EngServiceClient();
                                _proxy.RemoveItem(edit, EngServRef.ServerData.Video);
                                stMain.Visibility = Visibility.Visible;
                                return;
                            }
                        }
                        if (txtSubs.Text != "")
                        {
                            if (!_proxy.Upload(File.ReadAllBytes(txtSubs.Text), $"{edit}{Path.GetExtension(txtSubs.Text)}", EngServRef.FilesType.Subtitles))
                            {
                                MessageBox.Show("This file is too large!\nPlease choose another file.", "Unable to upload", MessageBoxButton.OK, MessageBoxImage.Stop);
                                _proxy.RemoveItem(edit, EngServRef.ServerData.Video);
                                stMain.Visibility = Visibility.Visible;
                                return;
                            }
                            _proxy.EditData(edit, $"{edit}{Path.GetExtension(txtSubs.Text)}", EngServRef.ServerData.Video, EngServRef.PropertyData.SubPath);
                        }
                    }
                    else
                    {
                        edit = Convert.ToInt32(video);

                        string path = _proxy.GetItemProperty(Convert.ToInt32(video), EngServRef.ServerData.Video, EngServRef.PropertyData.Path);
                        if (txtPath.Text != path && chCopy.IsChecked == true)
                        {
                            if (!_proxy.Upload(File.ReadAllBytes(txtPath.Text), $"{edit}{Path.GetExtension(txtPath.Text)}", EngServRef.FilesType.Videos))
                            {
                                MessageBox.Show("This file is too large!\nPlease choose another file.", "Unable to upload", MessageBoxButton.OK, MessageBoxImage.Stop);
                                stMain.Visibility = Visibility.Visible;
                                return;
                            }
                            _proxy.EditData(edit, $"{edit}{Path.GetExtension(txtPath.Text)}", EngServRef.ServerData.Video, EngServRef.PropertyData.Path);
                        }
                        else if (txtPath.Text == path && txtPath.Text.Contains(":") && chCopy.IsChecked == true)
                        {
                            if (!File.Exists(txtPath.Text))
                            {
                                MessageBox.Show("This file does not exist!", "Wrong", MessageBoxButton.OK, MessageBoxImage.Stop);
                                stMain.Visibility = Visibility.Visible;
                                return;
                            }
                            if (!_proxy.Upload(File.ReadAllBytes(txtPath.Text), $"{edit}{Path.GetExtension(txtPath.Text)}", EngServRef.FilesType.Videos))
                            {
                                MessageBox.Show("This file is too large!\nPlease choose another file.", "Unable to upload", MessageBoxButton.OK, MessageBoxImage.Stop);
                                stMain.Visibility = Visibility.Visible;
                                return;
                            }
                            _proxy.EditData(edit, $"{edit}{Path.GetExtension(txtPath.Text)}", EngServRef.ServerData.Video, EngServRef.PropertyData.Path);
                        }
                        else if (chCopy.IsChecked == false)
                        {
                            _proxy.EditData(edit, txtPath.Text, EngServRef.ServerData.Video, EngServRef.PropertyData.Path);
                        }
                        string subs = _proxy.GetItemProperty(Convert.ToInt32(video), EngServRef.ServerData.Video, EngServRef.PropertyData.SubPath);
                        if (txtSubs.Text != subs)
                        {
                            if (!File.Exists(txtSubs.Text))
                            {
                                MessageBox.Show("This file does not exist!", "Wrong", MessageBoxButton.OK, MessageBoxImage.Stop);
                                stMain.Visibility = Visibility.Visible;
                                return;
                            }
                            if (!_proxy.Upload(File.ReadAllBytes(txtSubs.Text), $"{edit}{Path.GetExtension(txtSubs.Text)}", EngServRef.FilesType.Subtitles))
                            {
                                MessageBox.Show("This file is too large!\nPlease choose another file.", "Unable to upload", MessageBoxButton.OK, MessageBoxImage.Stop);
                                stMain.Visibility = Visibility.Visible;
                                return;
                            }
                            _proxy.EditData(edit, $"{edit}{Path.GetExtension(txtSubs.Text)}", EngServRef.ServerData.Video, EngServRef.PropertyData.SubPath);
                        }
                        if (lPath.Content.ToString() != "...")
                        {
                            FormData.EditVideos.Add(edit);
                            string file = $"{edit}{Path.GetExtension(lPath.Content.ToString())}";
                            if (!_proxy.Upload(File.ReadAllBytes(lPath.Content.ToString()), file, EngServRef.FilesType.VideosImages))
                            {
                                MessageBox.Show("This file is too large!\nPlease choose another file.", "Unable to upload", MessageBoxButton.OK, MessageBoxImage.Stop);
                                stMain.Visibility = Visibility.Visible;
                                return;
                            }
                            _proxy.EditData(edit, file, EngServRef.ServerData.Video, EngServRef.PropertyData.Imgpath);
                        }
                        _proxy.EditData(edit, chCopy.IsChecked != true ? "True" : null, EngServRef.ServerData.Video, EngServRef.PropertyData.IsAbsolute);
                        _proxy.EditData(edit, txtYear.Text == "" ? null : txtYear.Text, EngServRef.ServerData.Video, EngServRef.PropertyData.Year);
                        _proxy.RemoveFullItemData(edit, EngServRef.ServerData.VideoCategory);
                        _proxy.EditData(edit, txtName.Text, EngServRef.ServerData.Video, EngServRef.PropertyData.Name);
                        _proxy.EditData(edit, txtDesc.Text == "" ? null : txtDesc.Text, EngServRef.ServerData.Video, EngServRef.PropertyData.Description);
                    }

                    foreach (CheckBox item in lstCategory.Items)
                    {
                        if (item.IsChecked == true)
                        {
                            _proxy.AddItemDataAsync(edit, Convert.ToInt32(item.Tag), EngServRef.ServerData.VideoCategory);
                        }
                    }
                    Close();
                }));
            }));
        }
示例#13
0
 /// <summary>
 /// Initialize form for editting.
 /// </summary>
 /// <param name="tmp">Host.</param>
 /// <param name="grammar">Rules id.</param>
 public AddGrammar(EngServRef.EngServiceClient tmp, int grammar) : this(tmp)
 {
     grammarId    = grammar;
     txtName.Text = _proxy.GetItemProperty(grammar, EngServRef.ServerData.Grammar, EngServRef.PropertyData.Name);
 }
示例#14
0
 /// <summary>
 /// Initializes '_proxy'.
 /// </summary>
 /// <param name="tmp">Host.</param>
 /// <param name="userId">Id of user.</param>
 public AddGrammar(EngServRef.EngServiceClient tmp) : this()
 {
     _proxy = tmp;
 }