Exemplo n.º 1
0
 private void SetAddressBoxProperties()
 {
     if (!_loading)
     {
         var domain = MemoryDomains.FirstOrDefault(d => d.Name == DomainDropDown.SelectedItem.ToString());
         if (domain != null)
         {
             AddressBox.SetHexProperties(domain.Size);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Присвоит текст adressBox(у)
 /// </summary>
 /// <param name="addressBox">объект addressBox, с которым будет работать метод</param>
 public void SetTextAddressBox(AddressBox addressBox)
 {
     if (addressBox.WebControl.Source == null)
     {
         addressBox.AccessibilityObject.Value = "about:blank";
     }
     else
     {
         addressBox.AccessibilityObject.Value = addressBox.WebControl.Source.OriginalString;
     }
 }
Exemplo n.º 3
0
 public ProgrammMethods(TabControl tabControl, WebSessionProvider webSessionProvider, Form1 form1, NotifyIcon notifyIcon1, AddressBox addressBox1, Panel splitContainerUp, Timer timer)
 {
     NOW                     = new NavigationOnWebControl();
     TCA                     = new TabControlAwesomium(tabControl, webSessionProvider, this);
     this.formGUI            = form1;
     this.notifyIcon1        = notifyIcon1;
     this.tabControl         = tabControl;
     this.webSessionProvider = webSessionProvider;
     this.addressBox1        = addressBox1;
     this.splitContainerUp   = splitContainerUp;
     this.timer              = timer;
 }
Exemplo n.º 4
0
        public Cheat GetCheat()
        {
            Cheat.COMPARISONTYPE comparisonType = Cheat.COMPARISONTYPE.NONE;
            var domain  = MemoryDomains[DomainDropDown.SelectedItem.ToString()];
            var address = AddressBox.ToRawInt().Value;

            if (address < domain.Size)
            {
                var watch = Watch.GenerateWatch(
                    MemoryDomains[DomainDropDown.SelectedItem.ToString()],
                    AddressBox.ToRawInt().Value,
                    GetCurrentSize(),
                    Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString()),
                    BigEndianCheckBox.Checked,
                    NameBox.Text
                    );

                switch (CompareTypeDropDown.SelectedItem.ToString())
                {
                case "": comparisonType = Cheat.COMPARISONTYPE.NONE; break;

                case "=": comparisonType = Cheat.COMPARISONTYPE.EQUAL; break;

                case ">": comparisonType = Cheat.COMPARISONTYPE.GREATER_THAN; break;

                case ">=": comparisonType = Cheat.COMPARISONTYPE.GREATER_THAN_OR_EQUAL; break;

                case "<": comparisonType = Cheat.COMPARISONTYPE.LESS_THAN; break;

                case "<=": comparisonType = Cheat.COMPARISONTYPE.LESS_THAN_OR_EQUAL; break;

                case "!=": comparisonType = Cheat.COMPARISONTYPE.NOT_EQUAL; break;

                default: comparisonType = Cheat.COMPARISONTYPE.NONE; break;
                }

                int?c = CompareBox.ToRawInt() == null ? null : (int?)CompareBox.ToRawInt().Value;


                return(new Cheat(
                           watch,
                           ValueBox.ToRawInt().Value,
                           CompareBox.ToRawInt() == null ? null : (int?)CompareBox.ToRawInt().Value,
                           true,
                           comparisonType
                           ));
            }
            else
            {
                MessageBox.Show(address.ToString() + " is not a valid address for the domain " + domain.Name, "Index out of range", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(Cheat.Separator);
            }
        }
Exemplo n.º 5
0
 public void TabControlSelecting(TabControlCancelEventArgs e, AddressBox addressBox) //Добавляет страницу -> выбираем или выбирает эту страницу -> задает этой странице addressBox и задает текст addressBox(а) этой страницы
 {
     if (e.TabPage.Text == "   +")
     {
         TCA.AddPage();
     }
     else
     {
         TCA.SetWebControlInAddressBox(addressBox);
         TCA.SetTextAddressBox(addressBox);
     }
 }
        /// <summary>
        /// Windows the loaded.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            var accent = Settings.Current.ToolbarBackgroundColor;

            accent.A        = 255;
            Root.Background = accent.ToBrush();
            accent.A        = 128;
            Background      = accent.ToBrush();

            AddressBox.Focus();
            AddressBox.CaretIndex = AddressBox.Text.Length;
        }
Exemplo n.º 7
0
 public NESGameGenie()
 {
     InitializeComponent();
     Closing += (o, e) =>
     {
         Global.Config.NesGGSettings.Wndx = Location.X;
         Global.Config.NesGGSettings.Wndy = Location.Y;
     };
     TopMost = Global.Config.NesGGSettings.TopMost;
     AddressBox.SetHexProperties(0x10000);
     ValueBox.SetHexProperties(0x100);
     CompareBox.SetHexProperties(0x100);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChangeEmail"/> class with the specified
        /// initial content and additional caption text.</summary>
        /// <param name="address">
        /// The initial value for the <see cref="Address"/> property.</param>
        /// <param name="caption">
        /// Additional text to display in the title bar of the dialog.</param>
        /// <exception cref="ArgumentNullOrEmptyException">
        /// <paramref name="caption"/> is a null reference or an empty string.</exception>

        public ChangeEmail(string address, string caption)
        {
            if (String.IsNullOrEmpty(caption))
            {
                ThrowHelper.ThrowArgumentNullOrEmptyException("caption");
            }

            InitializeComponent();
            Title += caption;

            // set focus on address
            AddressBox.Text = address;
            AddressBox.Focus();
        }
Exemplo n.º 9
0
        private void Reset()
        {
            string text = SearchBox.Text.Trim();

            View.DataSource = Program.Entities.Teachers
                              .Where(s => text.Length == 0 || s.Name.Contains(text))
                              .ToList();

            IdBox.Clear();
            NameBox.Clear();
            AddressBox.Clear();
            MaleButton.Checked = FemaleButton.Checked = false;
            DobBox.Value       = DateTime.Today;
            PhoneBox.Clear();
        }
Exemplo n.º 10
0
        private void DoEdit()
        {
            if (_watchList.Count == 1)
            {
                _watchList[0].Notes = NotesBox.Text;
            }

            if (_changedSize)
            {
                for (var i = 0; i < _watchList.Count; i++)
                {
                    var size = Watch.WatchSize.Byte;
                    switch (SizeDropDown.SelectedIndex)
                    {
                    case 0:
                        size = Watch.WatchSize.Byte;
                        break;

                    case 1:
                        size = Watch.WatchSize.Word;
                        break;

                    case 2:
                        size = Watch.WatchSize.DWord;
                        break;
                    }

                    _watchList[i] = Watch.GenerateWatch(
                        _watchList[i].Domain,
                        _watchList.Count == 1 ? AddressBox.ToRawInt() ?? 0 : _watchList[i].Address ?? 0,
                        size,
                        _watchList[i].Type,
                        _watchList[i].Notes,
                        _watchList[i].BigEndian
                        );
                }
            }

            if (_changedDisplayType)
            {
                _watchList.ForEach(x => x.Type = Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString()));
            }

            if (BigEndianCheckBox.CheckState != CheckState.Indeterminate)
            {
                _watchList.ForEach(x => x.BigEndian = BigEndianCheckBox.Checked);
            }
        }
Exemplo n.º 11
0
        private void SetFormToCheat()
        {
            _loading = true;
            SetSizeSelected(_cheat.Size);
            PopulateTypeDropdown();
            SetTypeSelected(_cheat.Type);
            SetDomainSelected(_cheat.Domain);

            AddressBox.SetHexProperties(_cheat.Domain.Size);

            ValueBox.ByteSize       =
                CompareBox.ByteSize =
                    _cheat.Size;

            ValueBox.Type       =
                CompareBox.Type =
                    _cheat.Type;

            ValueHexIndLabel.Text       =
                CompareHexIndLabel.Text =
                    _cheat.Type == DisplayType.Hex ? HexInd : string.Empty;

            BigEndianCheckBox.Checked = _cheat.BigEndian.Value;

            NameBox.Text    = _cheat.Name;
            AddressBox.Text = _cheat.AddressStr;
            ValueBox.Text   = _cheat.ValueStr;
            CompareBox.Text = _cheat.Compare.HasValue ? _cheat.CompareStr : String.Empty;

            if (_cheat.ComparisonType.Equals(Cheat.COMPARISONTYPE.NONE))
            {
                CompareTypeDropDown.SelectedIndex = 0;
            }
            else
            {
                CompareTypeDropDown.SelectedIndex = ((int)_cheat.ComparisonType - 1);
            }


            CheckFormState();
            if (!_cheat.Compare.HasValue)
            {
                CompareBox.Text = String.Empty;                 // Necessary hack until WatchValueBox.ToRawInt() becomes nullable
            }

            _loading = false;
        }
        /// <summary>
        /// Освободить память webControl(а), на выбранной вкладке
        /// </summary>
        /// <param name="addressBox">addressBox</param>
        public void ClearMemory(AddressBox addressBox)
        {
            Uri uri = (tabControl.TabPages[tabControl.SelectedIndex].Controls[0] as WebControl).Source;

            webSessionProvider.Views.Remove(tabControl.TabPages[tabControl.SelectedIndex].Controls[0] as WebControl); // Не обязательная строка
            tabControl.TabPages[tabControl.SelectedIndex].Controls[0].Dispose();

            WebControl webControl = new_WebControl();

            addressBox.WebControl = webControl;

            webSessionProvider.Views.Add(webControl);

            webControl.Source = uri;

            tabControl.TabPages[tabControl.SelectedIndex].Controls.Add(webControl);
        }
Exemplo n.º 13
0
        private void RamPoke_Load(object sender, EventArgs e)
        {
            _watchList = _watchList.Where(x => !x.IsSeparator).ToList();             // Weed out separators just in case

            if (_watchList.Count == 0)
            {
                ValueBox.Enabled = false;
                return;
            }

            if (InitialLocation.X > 0 || InitialLocation.Y > 0)
            {
                Location = InitialLocation;
            }

            if (_watchList.Count > 1)
            {
                bool hasMixedSizes  = _watchList.Select(x => x.Size).Distinct().Count() > 1;
                bool hasMixedTypes  = _watchList.Select(x => x.Type).Distinct().Count() > 1;
                bool hasMixedEndian = _watchList.Select(x => x.BigEndian).Distinct().Count() > 1;

                if (hasMixedSizes || hasMixedTypes || hasMixedEndian)
                {
                    UnSupportedConfiguration();
                }
            }

            AddressBox.SetHexProperties(_watchList[0].Domain.Size);
            AddressBox.Text = (_watchList.Count > 10 ? _watchList.Take(10) : _watchList)             // Hack in case an absurd amount of addresses are picked, this can be slow and create too long of a string
                              .Select(a => a.AddressString)
                              .Distinct()
                              .Aggregate((addrStr, nextStr) => $"{addrStr},{nextStr}");

            ValueBox.ByteSize = _watchList[0].Size;
            ValueBox.Type     = _watchList[0].Type;

            ValueHexLabel.Text    = _watchList[0].Type == DisplayType.Hex ? "0x" : "";
            ValueBox.Text         = _watchList[0].ValueString.Replace(" ", "");
            DomainLabel.Text      = _watchList[0].Domain.Name;
            SizeLabel.Text        = _watchList[0].Size.ToString();
            DisplayTypeLabel.Text = Watch.DisplayTypeToString(_watchList[0].Type);
            BigEndianLabel.Text   = _watchList[0].BigEndian ? "Big Endian" : "Little Endian";
            SetTitle();
        }
Exemplo n.º 14
0
        private void AddCheat_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(AddressBox.Text) && !string.IsNullOrWhiteSpace(ValueBox.Text))
            {
                var watch = Watch.GenerateWatch(
                    MemoryDomains["System Bus"],
                    AddressBox.ToRawInt().Value,
                    WatchSize.Byte,
                    Client.Common.DisplayType.Hex,
                    false,
                    GameGenieCode.Text);

                Global.CheatList.Add(new Cheat(
                                         watch,
                                         ValueBox.ToRawInt().Value,
                                         CompareBox.ToRawInt()
                                         ));
            }
        }
Exemplo n.º 15
0
        private void RamPoke_Load(object sender, EventArgs e)
        {
            _watchList = _watchList.Where(x => !x.IsSeparator).ToList();             // Weed out separators just in case

            if (_watchList.Count == 0)
            {
                ValueBox.Enabled = false;
                return;
            }

            if (InitialLocation.X > 0 || InitialLocation.Y > 0)
            {
                Location = InitialLocation;
            }

            if (_watchList.Count > 1)
            {
                var hasMixedSizes  = _watchList.Select(x => x.Size).Distinct().Count() > 1;
                var hasMixedTypes  = _watchList.Select(x => x.Type).Distinct().Count() > 1;
                var hasMixedEndian = _watchList.Select(x => x.BigEndian).Distinct().Count() > 1;

                if (hasMixedSizes || hasMixedTypes || hasMixedEndian)
                {
                    UnSupportedConfiguration();
                }
            }

            AddressBox.SetHexProperties(_watchList[0].Domain.Size);
            AddressBox.Text       = _watchList.Select(a => a.AddressString).Distinct().Aggregate((addrStr, nextStr) => addrStr + ("," + nextStr));
            ValueHexLabel.Text    = _watchList[0].Type == Watch.DisplayType.Hex ? "0x" : string.Empty;
            ValueBox.Text         = _watchList[0].ValueString.Replace(" ", string.Empty);
            DomainLabel.Text      = _watchList[0].Domain.Name;
            SizeLabel.Text        = _watchList[0].Size.ToString();
            DisplayTypeLabel.Text = Watch.DisplayTypeToString(_watchList[0].Type);
            BigEndianLabel.Text   = _watchList[0].BigEndian ? "Big Endian" : "Little Endian";
            SetTitle();

            ValueBox.ByteSize = _watchList[0].Size;
            ValueBox.Type     = _watchList[0].Type;
        }
Exemplo n.º 16
0
        private void saveBtn(object sender, RoutedEventArgs e)
        {
            try
            {
                var suppModel = new supplier
                {
                    SupplierID  = int.Parse(SuppIdBox.Text),
                    FirstName   = FirstNameBox.Text,
                    LastName    = LastNameBox.Text,
                    Address     = AddressBox.Text,
                    City        = CityBox.Text,
                    PinCode     = int.Parse(PinCodeBox.Text),
                    PhoneNumber = int.Parse(PhoneNrBox.Text),
                    Email       = EmailBox.Text,
                    DateJoin    = DateJoinPicker.SelectedDate,
                    SupplierOf  = SuppBox.Text,
                };

                SuppIdBox.Clear();
                FirstNameBox.Clear();
                LastNameBox.Clear();
                AddressBox.Clear();
                CityBox.Clear();
                PinCodeBox.Clear();
                PhoneNrBox.Clear();
                EmailBox.Clear();
                SuppBox.Clear();

                dc.suppliers.InsertOnSubmit(suppModel);
                dc.SubmitChanges();

                MessageBox.Show("Supplier has been added");
                LoadData();
                LoadWindow();
            }
            catch
            {
                MessageBox.Show("u need to fill out all fields correct");
            }
        }
Exemplo n.º 17
0
        private void DoEdit()
        {
            if (Watches.Count == 1)
            {
                Watches[0].Notes = NotesBox.Text;
            }

            if (_changedSize)
            {
                for (var i = 0; i < Watches.Count; i++)
                {
                    var size = SizeDropDown.SelectedIndex switch
                    {
                        1 => WatchSize.Word,
                        2 => WatchSize.DWord,
                        _ => WatchSize.Byte
                    };

                    Watches[i] = Watch.GenerateWatch(
                        Watches[i].Domain,
                        Watches.Count == 1 ? AddressBox.ToRawInt() ?? 0 : Watches[i].Address,
                        size,
                        Watches[i].Type,
                        Watches[i].BigEndian,
                        Watches[i].Notes);
                }
            }

            if (_changedDisplayType)
            {
                Watches.ForEach(x => x.Type = Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString()));
            }

            if (BigEndianCheckBox.CheckState != CheckState.Indeterminate)
            {
                Watches.ForEach(x => x.BigEndian = BigEndianCheckBox.Checked);
            }
        }
Exemplo n.º 18
0
        public Cheat GetCheat()
        {
            var domain  = MemoryDomains[DomainDropDown.SelectedItem.ToString()] !;
            var address = AddressBox.ToRawInt().Value;

            if (address < domain.Size)
            {
                var watch = Watch.GenerateWatch(
                    MemoryDomains[DomainDropDown.SelectedItem.ToString()],
                    AddressBox.ToRawInt().Value,
                    GetCurrentSize(),
                    Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString()),
                    BigEndianCheckBox.Checked,
                    NameBox.Text);

                var comparisonType = CompareTypeDropDown.SelectedItem.ToString() switch
                {
                    "" => Cheat.CompareType.None,
                    "=" => Cheat.CompareType.Equal,
                    ">" => Cheat.CompareType.GreaterThan,
                    ">=" => Cheat.CompareType.GreaterThanOrEqual,
                    "<" => Cheat.CompareType.LessThan,
                    "<=" => Cheat.CompareType.LessThanOrEqual,
                    "!=" => Cheat.CompareType.NotEqual,
                    _ => Cheat.CompareType.None
                };

                return(new Cheat(
                           watch,
                           ValueBox.ToRawInt().Value,
                           CompareBox.ToRawInt() == null ? null : (int?)CompareBox.ToRawInt().Value,
                           true,
                           comparisonType));
            }

            MessageBox.Show($"{address} is not a valid address for the domain {domain.Name}", "Index out of range", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            return(Cheat.Separator);
        }
Exemplo n.º 19
0
        private void saveBtn(object sender, RoutedEventArgs e)
        {
            try
            {
                var empModel = new employee
                {
                    EmployeeID  = int.Parse(EmpIdBox.Text),
                    FirstName   = FirstNameBox.Text,
                    LastName    = LastNameBox.Text,
                    Address     = AddressBox.Text,
                    City        = CityBox.Text,
                    PinCode     = int.Parse(PinCodeBox.Text),
                    PhoneNumber = int.Parse(PhoneNrBox.Text),
                    Email       = EmailBox.Text,
                    JoinDate    = DateJoinPicker.SelectedDate
                };

                EmpIdBox.Clear();
                FirstNameBox.Clear();
                LastNameBox.Clear();
                AddressBox.Clear();
                CityBox.Clear();
                PinCodeBox.Clear();
                PhoneNrBox.Clear();
                EmailBox.Clear();

                dc.employees.InsertOnSubmit(empModel);
                dc.SubmitChanges();

                MessageBox.Show("Employee has been added");
                LoadData();
                LoadWindow();
            }
            catch
            {
                MessageBox.Show("Thats not a valid action");
            }
        }
Exemplo n.º 20
0
        void CalculateCurrentDomain()
        {
            // Use IUri to parse the current domain into parts
            IUri   uri = ParseUri.Create(Browser.LocationURL);
            string domain;
            string host;

            // Get the current domain and host values
            uri.GetDomain(out domain);
            uri.GetHost(out host);
            int domainPosition = host.LastIndexOf(domain);
            int hostPosition   = Browser.LocationURL.IndexOf(host);

            if (domainPosition != -1 && domainPosition != -1)
            {
                AddressBox.Select(hostPosition + domainPosition, domain.Length);
                TrueDomain.Text = "Current Domain: " + domain;
            }
            else
            {
                TrueDomain.Text = "Current Domain: (error)";
            }
        }
Exemplo n.º 21
0
        private void SetFormToCheat()
        {
            _loading = true;
            SetSizeSelected(_cheat.Size);
            PopulateTypeDropdown();
            SetTypeSelected(_cheat.Type);
            SetDomainSelected(_cheat.Domain);

            AddressBox.SetHexProperties(_cheat.Domain.Size);

            NameBox.Text    = _cheat.Name;
            AddressBox.Text = _cheat.AddressStr;
            ValueBox.Text   = _cheat.ValueStr;
            CompareBox.Text = _cheat.Compare.HasValue ? _cheat.CompareStr : String.Empty;

            ValueBox.ByteSize       =
                CompareBox.ByteSize =
                    _cheat.Size;

            ValueBox.Type       =
                CompareBox.Type =
                    _cheat.Type;

            ValueHexIndLabel.Text       =
                CompareHexIndLabel.Text =
                    _cheat.Type == Watch.DisplayType.Hex ? HexInd : String.Empty;

            BigEndianCheckBox.Checked = _cheat.BigEndian.Value;

            CheckFormState();
            if (!_cheat.Compare.HasValue)
            {
                CompareBox.Text = String.Empty;                 // Necessary hack until WatchValueBox.ToRawInt() becomes nullable
            }

            _loading = false;
        }
Exemplo n.º 22
0
        private void SetFormToDefault()
        {
            _loading = true;
            SetSizeSelected(WatchSize.Byte);
            PopulateTypeDropdown();

            NameBox.Text = "";

            if (MemoryDomains != null)
            {
                AddressBox.SetHexProperties(MemoryDomains.SystemBus.Size);
            }

            ValueBox.ByteSize       =
                CompareBox.ByteSize =
                    WatchSize.Byte;

            ValueBox.Type       =
                CompareBox.Type =
                    DisplayType.Hex;

            ValueBox.ResetText();
            CompareBox.ResetText();

            ValueHexIndLabel.Text       =
                CompareHexIndLabel.Text =
                    HexInd;

            BigEndianCheckBox.Checked = false;

            SetTypeSelected(DisplayType.Hex);

            CheckFormState();
            CompareBox.Text = "";             // TODO: A needed hack until WatchValueBox.ToRawInt() becomes nullable
            _loading        = false;
        }
Exemplo n.º 23
0
        private void OnOK(object sender, RoutedEventArgs e)
        {
            //ServiceManager.Instance.LinphoneService.RemoveDBPassword();

            if (!_viewModel.ValidateName())
            {
                MessageBox.Show("Please enter contact name", "VATRP", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                NameBox.Focus();
                return;
            }

            _viewModel.UpdateContactAddress(false);
            if (!_viewModel.ValidateUsername(_viewModel.ContactSipUsername))
            {
                bool errorOccurred = true;
                var  errorString   = string.Empty;
                switch (_viewModel.ValidateAddress(_viewModel.ContactSipUsername))
                {
                case 1:
                    errorString = "Empty username is not allowed";
                    break;

                case 2:
                    errorString = "Calling address format is incorrect";
                    break;

                case 3:
                    errorString = "Username format is incorrect";
                    break;

                case 4:
                    errorString = "Registration host format is incorrect";
                    break;

                case 5:
                    errorString = "Port is out of range";
                    break;

                default:
                    errorOccurred = false;
                    break;
                }

                if (errorOccurred)
                {
                    MessageBox.Show(errorString, "VATRP", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                    AddressBox.Focus();
                    return;
                }
            }

            if (!string.IsNullOrEmpty(_viewModel.NewAvatarPath))
            {
                if (!string.IsNullOrEmpty(_viewModel.OriginAvatarPath))
                {
                    if (File.Exists(_viewModel.OriginAvatarPath))
                    {
                        try
                        {
                            File.Delete(_viewModel.OriginAvatarPath);
                        }
                        catch (Exception ex)
                        {
                            LOG.Warn("Failed to remove file: " + _viewModel.OriginAvatarPath + " Cause: " + ex.Message);
                        }
                    }
                }

                var avatarPath =
                    ServiceManager.Instance.BuildDataPath(string.Format("{0}{1}",
                                                                        _viewModel.ContactSipUsername, Path.GetExtension(_viewModel.NewAvatarPath)));
                try
                {
                    // just for confidence
                    if (File.Exists(avatarPath))
                    {
                        File.Delete(avatarPath);
                    }

                    File.Copy(_viewModel.NewAvatarPath, avatarPath);
                    _viewModel.AvatarChanged = true;
                }
                catch (Exception ex)
                {
                    LOG.Warn(string.Format("Failed to copy file: {0} -> {1}. Cause: {2}", _viewModel.NewAvatarPath,
                                           avatarPath, ex.Message));
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(_viewModel.OriginAvatarPath))
                {
                    var fileExt = Path.GetExtension(_viewModel.OriginAvatarPath);

                    var newAvatarPath =
                        ServiceManager.Instance.BuildDataPath(string.Format("{0}{1}",
                                                                            _viewModel.ContactSipUsername, fileExt));
                    if (newAvatarPath != _viewModel.OriginAvatarPath)
                    {
                        // rename old file
                        try
                        {
                            File.Move(_viewModel.OriginAvatarPath, newAvatarPath);
                            _viewModel.AvatarChanged = true;
                        }
                        catch (Exception ex)
                        {
                            LOG.Warn(string.Format("Failed to move file: {0} -> {1}. Cause: {2}", _viewModel.OriginAvatarPath,
                                                   newAvatarPath, ex.Message));
                        }
                    }
                }
            }

            MessageBox.Show("Contact added successfully.", "VATRP", MessageBoxButton.OK,
                            MessageBoxImage.None);

            this.DialogResult = true;
            Close();
        }
Exemplo n.º 24
0
 private void AddressBox_LostFocus(object sender, RoutedEventArgs e)
 {
     AddressBox.InvalidateProperty(TextBox.TextProperty);
 }
Exemplo n.º 25
0
 private void GotoDialog_Shown(object sender, EventArgs e)
 {
     AddressBox.Focus();
 }
Exemplo n.º 26
0
        /// <summary>
        /// Clears all fields and sets necessary enables/disables to
        /// prepare for new customer entry into database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NewCustomerButton_Click(object sender, EventArgs e)
        {
            FirstNameBox.Clear();
            LastNameBox.Clear();
            AddressBox.Clear();
            CityBox.Clear();
            StateBox.Clear();
            ZipBox.Clear();
            PhoneBox.Clear();
            EmailBox.Clear();
            CustomerSelectBox.Enabled = false;
            CancelButton.Enabled      = true;
            SaveButton.Enabled        = true;
            return;

            /*
             * // When add customer button is first clicked, display message and disable box.
             * if (CustomerSelectBox.Enabled == true)
             * {
             *  MessageBox.Show("To add a customer, fill in the fields and click Add Customer again", "Add Customer");
             *  CustomerSelectBox.Enabled = false;
             *  return;
             * }
             *
             * // Once form is in "add customer" mode, add customer normally.
             * else
             * {
             *  bool valid = true; // Boolean will be set to false if any tests fail, used to check if customer should be saved.
             *  if (FirstNameBox.Text == "" || Regex.IsMatch(FirstNameBox.Text, name))
             *  {
             *      MessageBox.Show("Please enter your first name", "First name is a required field");
             *      FirstNameBox.Focus();
             *      valid = false;
             *  }
             *  if (LastNameBox.Text == "" || Regex.IsMatch(LastNameBox.Text, name))
             *  {
             *      MessageBox.Show("Please enter your last name", "Last name is a required field");
             *      LastNameBox.Focus();
             *      valid = false;
             *  }
             *  if (AddressBox.Text == "" || Regex.IsMatch(AddressBox.Text, address))
             *  {
             *      MessageBox.Show("Please enter your address", "Address is a required field");
             *      AddressBox.Focus();
             *      valid = false;
             *  }
             *  if (CityBox.Text == "" || Regex.IsMatch(CityBox.Text, name))
             *  {
             *      MessageBox.Show("Please enter your city", "City is a required field");
             *      CityBox.Focus();
             *      valid = false;
             *  }
             *  if (StateBox.Text == "" || Regex.IsMatch(StateBox.Text, name))
             *  {
             *      MessageBox.Show("Please enter your state", "State is a required field");
             *      StateBox.Focus();
             *      valid = false;
             *  }
             *  if (ZipBox.Text == "" || Regex.IsMatch(ZipBox.Text, zip))
             *  {
             *      MessageBox.Show("Please enter your zip code", "Zip Code is a required field");
             *      ZipBox.Focus();
             *      valid = false;
             *  }
             *  if (PhoneBox.Text == "" || Regex.IsMatch(PhoneBox.Text, phone))
             *  {
             *      MessageBox.Show("Please enter your phone number", "Phone number is a required field");
             *      PhoneBox.Focus();
             *      valid = false;
             *  }
             *  if (EmailBox.Text == "" || Regex.IsMatch(EmailBox.Text, email))
             *  {
             *      MessageBox.Show("Please enter your email address", "Email is a required field");
             *      EmailBox.Focus();
             *      valid = false;
             *  }
             *
             *  // If no issues, add customer to text file and ComboBox.
             *  if (valid)
             *  {
             *      Customer tempCustomer = new Customer(FirstNameBox.Text, LastNameBox.Text, AddressBox.Text, CityBox.Text, StateBox.Text, ZipBox.Text, PhoneBox.Text, EmailBox.Text);
             *      customers.Add(tempCustomer);
             *
             *      // Close reader and inFile even if exception is thrown.
             *      // SRC:https://stackoverflow.com/questions/86766/how-to-properly-handle-exceptions-when-performing-file-io
             *      try
             *      {
             *          using (FileStream outFile = new FileStream("customers.txt", FileMode.Append, FileAccess.Write))
             *          using (StreamWriter writer = new StreamWriter(outFile))
             *          {
             *              // Write info to file.
             *              writer.WriteLine($"{FirstNameBox.Text},{LastNameBox.Text},{AddressBox.Text},{CityBox.Text},{StateBox.Text},{ZipBox.Text},{PhoneBox.Text},{EmailBox.Text}");
             *              // Clear Text Boxes.
             *              FirstNameBox.Clear();
             *              LastNameBox.Clear();
             *              AddressBox.Clear();
             *              CityBox.Clear();
             *              StateBox.Clear();
             *              ZipBox.Clear();
             *              PhoneBox.Clear();
             *              EmailBox.Clear();
             *              CustomerSelectBox.Items.Add(tempCustomer);
             *              CustomerSelectBox.Enabled = true;
             *          }
             *      }
             *      catch (FileNotFoundException)
             *      {
             *          MessageBox.Show("File 'customers.txt' not found to write.", "File Write Error");
             *      }
             *      // Catch generic I/O exceptions.
             *      catch (IOException ex)
             *      {
             *          MessageBox.Show(ex.ToString(), "Error");
             *      }
             *
             *  }
             * }
             */
        }
Exemplo n.º 27
0
        /// <summary>
        /// Clicking button checks if all fields have plausible entires (not empty or wrong format). Then
        /// updates currently selected customer with new information. Uses email as unique identifier, but
        /// does not check if email already exists. (Not sure how...)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveButton_Click(object sender, EventArgs e)
        {
            bool valid = true; // Boolean will be set to false if any tests fail, used to check if customer should be saved.

            if (FirstNameBox.Text == "" || !Regex.IsMatch(FirstNameBox.Text, name))
            {
                MessageBox.Show("Please enter your first name", "First name is a required field");
                FirstNameBox.Focus();
                valid = false;
            }
            if (LastNameBox.Text == "" || !Regex.IsMatch(LastNameBox.Text, name))
            {
                MessageBox.Show("Please enter your last name", "Last name is a required field");
                LastNameBox.Focus();
                valid = false;
            }
            if (AddressBox.Text == "" || !Regex.IsMatch(AddressBox.Text, address))
            {
                MessageBox.Show("Please enter your address", "Address is a required field");
                AddressBox.Focus();
                valid = false;
            }
            if (CityBox.Text == "" || !Regex.IsMatch(CityBox.Text, city))
            {
                MessageBox.Show("Please enter your city", "City is a required field");
                CityBox.Focus();
                valid = false;
            }
            if (StateBox.Text == "" || !Regex.IsMatch(StateBox.Text, name))
            {
                MessageBox.Show("Please enter your state", "State is a required field");
                StateBox.Focus();
                valid = false;
            }
            if (ZipBox.Text == "" || !Regex.IsMatch(ZipBox.Text, zip))
            {
                MessageBox.Show("Please enter your zip code", "Zip Code is a required field");
                ZipBox.Focus();
                valid = false;
            }
            if (PhoneBox.Text == "" || !Regex.IsMatch(PhoneBox.Text, phone))
            {
                MessageBox.Show("Please enter your phone number", "Phone number is a required field");
                PhoneBox.Focus();
                valid = false;
            }
            if (EmailBox.Text == "" || !Regex.IsMatch(EmailBox.Text, email))
            {
                MessageBox.Show("Please enter your email address", "Email is a required field");
                EmailBox.Focus();
                valid = false;
            }

            // If invalid entry, do not save.
            if (!valid)
            {
                return;
            }

            // Else
            string          ConnectionString = "server=localhost;user=root;database=book store;password="******"Insert into customer values" +
                                  $"('null','{FirstNameBox.Text}'," +
                                  $"'{LastNameBox.Text}'," +
                                  $"'{AddressBox.Text}'," +
                                  $"'{CityBox.Text}'," +
                                  $"'{StateBox.Text}'," +
                                  $"'{ZipBox.Text}'," +
                                  $"'{PhoneBox.Text}'," +
                                  $"'{EmailBox.Text}')";

                cmd.Connection = DBConnect;
                cmd.ExecuteNonQuery();
                DBConnect.Close();

                FirstNameBox.Clear();
                LastNameBox.Clear();
                AddressBox.Clear();
                CityBox.Clear();
                StateBox.Clear();
                ZipBox.Clear();
                PhoneBox.Clear();
                EmailBox.Clear();

                // Call function to update the combobox with new customer added.
                CustomerSelectBox_Click(sender, e);

                CustomerSelectBox.Enabled = true;
                SaveButton.Enabled        = false;
                MessageBox.Show("Customer added to database.");
                return;
            }
            // Else update the currently selected customer with textbox info

            // Extract first and last name into string array.
            string[] custName = new string[2];
            custName = CustomerSelectBox.Text.Split();

            cmd.CommandText = $"Update customer set" +
                              $" first='{FirstNameBox.Text}'," +
                              $"last='{LastNameBox.Text}'," +
                              $"address='{AddressBox.Text}'," +
                              $"city='{CityBox.Text}'," +
                              $"state='{StateBox.Text}'," +
                              $"zip='{ZipBox.Text}'," +
                              $"phone='{PhoneBox.Text}'," +
                              $"email='{EmailBox.Text}'" +
                              $" where first='{custName[0]}' AND last ='{custName[1]}'";
            cmd.Connection = DBConnect;
            cmd.ExecuteNonQuery();
            DBConnect.Close();
            MessageBox.Show("Customer successfully updated.");
            return;



            /*
             * SaveButton.Enabled = false;     // Disable the save button again until new customer is selected from the comboBox.
             *
             * // Rewrite the entire file, omitting the line with the email of the customer that is being updated, since email is unique.
             * // SRC: https://stackoverflow.com/questions/10371630/c-sharp-text-file-search-for-specific-word-and-delete-whole-line-of-text-that-co
             * Customer tempCustomer = (Customer)(CustomerSelectBox.SelectedItem);
             * var oldLines = File.ReadAllLines("customers.txt");
             * var newLines = oldLines.Where(line => !line.Contains(tempCustomer.email));
             * File.WriteAllLines("customers.txt", newLines);
             *
             * customers.Remove((Customer)CustomerSelectBox.SelectedItem);  // Remove old customer info from customer list.
             *
             * // Add new info to list.
             * tempCustomer = new Customer(FirstNameBox.Text, LastNameBox.Text, AddressBox.Text, CityBox.Text, StateBox.Text, ZipBox.Text, PhoneBox.Text, EmailBox.Text);
             * customers.Add(tempCustomer);
             *
             * // Close reader and inFile even if exception is thrown.
             * // SRC:https://stackoverflow.com/questions/86766/how-to-properly-handle-exceptions-when-performing-file-io
             * try
             * {
             *  using (FileStream outFile = new FileStream("customers.txt", FileMode.Append, FileAccess.Write))
             *  using (StreamWriter writer = new StreamWriter(outFile))
             *  {
             *      // Write info to file.
             *      writer.WriteLine($"{FirstNameBox.Text},{LastNameBox.Text},{AddressBox.Text},{CityBox.Text},{StateBox.Text},{ZipBox.Text},{PhoneBox.Text},{EmailBox.Text}");
             *  }
             *
             *  // Clear Text Boxes.
             *  FirstNameBox.Clear();
             *  LastNameBox.Clear();
             *  AddressBox.Clear();
             *  CityBox.Clear();
             *  StateBox.Clear();
             *  ZipBox.Clear();
             *  PhoneBox.Clear();
             *  EmailBox.Clear();
             *
             *  // Update comboBox with new info.
             *  CustomerSelectBox.Items.Remove(CustomerSelectBox.SelectedItem);
             *  CustomerSelectBox.Items.Add(tempCustomer);
             * }
             * catch (FileNotFoundException)
             * {
             *  MessageBox.Show("File 'customers.txt' not found to write.", "File Write Error");
             * }
             * // Catch generic I/O exceptions.
             * catch (IOException ex)
             * {
             *  MessageBox.Show(ex.ToString(), "Error");
             * }
             */
        }
Exemplo n.º 28
0
        void ReleaseDesignerOutlets()
        {
            if (AddressBox != null)
            {
                AddressBox.Dispose();
                AddressBox = null;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if (FullAcquisitionCostCheckBox != null)
            {
                FullAcquisitionCostCheckBox.Dispose();
                FullAcquisitionCostCheckBox = null;
            }
        }
Exemplo n.º 29
0
 private void AddressBox_Click(object sender, System.EventArgs e)
 {
     // Select all text for editing
     AddressBox.SelectAll();
 }
Exemplo n.º 30
0
        private void RamWatchNewWatch_Load(object sender, EventArgs e)
        {
            if (InitialLocation.X > 0 || InitialLocation.Y > 0)
            {
                Location = InitialLocation;
            }
            _loading = false;
            SetAddressBoxProperties();

            switch (_mode)
            {
            default:
            case Mode.New:
                SizeDropDown.SelectedItem = SizeDropDown.Items[0];
                break;

            case Mode.Duplicate:
            case Mode.Edit:
                switch (_watchList[0].Size)
                {
                case Watch.WatchSize.Byte:
                    SizeDropDown.SelectedItem = SizeDropDown.Items[0];
                    break;

                case Watch.WatchSize.Word:
                    SizeDropDown.SelectedItem = SizeDropDown.Items[1];
                    break;

                case Watch.WatchSize.DWord:
                    SizeDropDown.SelectedItem = SizeDropDown.Items[2];
                    break;
                }

                var index = DisplayTypeDropDown.Items.IndexOf(Watch.DisplayTypeToString(_watchList[0].Type));
                DisplayTypeDropDown.SelectedItem = DisplayTypeDropDown.Items[index];

                if (_watchList.Count > 1)
                {
                    NotesBox.Enabled = false;
                    NotesBox.Text    = String.Empty;

                    AddressBox.Enabled = false;
                    AddressBox.Text    = _watchList.Select(a => a.AddressString).Aggregate((addrStr, nextStr) => addrStr + ("," + nextStr));

                    BigEndianCheckBox.ThreeState = true;

                    if (_watchList.Select(s => s.Size).Distinct().Count() > 1)
                    {
                        DisplayTypeDropDown.Enabled = false;
                    }
                }
                else
                {
                    NotesBox.Text = _watchList[0].Notes;
                    AddressBox.SetFromRawInt(_watchList[0].Address ?? 0);
                }

                SetBigEndianCheckBox();
                DomainDropDown.Enabled = false;
                break;
            }
        }