Example #1
0
        /// <summary>
        /// Display the properties of the currently selected Location when invoked from the ListView
        /// </summary>
        protected void EditListLocation()
        {
            // Sanity check to ensure that only one item is selected in the list
            if (locationsList.SelectedItems.Count != 1)
            {
                return;
            }

            UltraListViewItem selectedItem = locationsList.SelectedItems[0];
            AssetGroup        location     = selectedItem.Tag as AssetGroup;

            // The parent item of the location being edited is the currently selected node in the tree
            UltraTreeNode selectedNode   = locationsTree.SelectedNodes[0];
            AssetGroup    parentLocation = selectedNode.Tag as AssetGroup;

            // Display the properties of this location
            string originalName = location.Name;

            if (EditLocation(parentLocation, location))
            {
                // Update the tree and then re-populate the list
                if (location.Name != originalName)
                {
                    UltraTreeNode childNode = FindChildNode(selectedNode, originalName);
                    if (childNode != null)
                    {
                        childNode.Text = location.Name;
                        childNode.Tag  = location;
                    }
                }
                PopulateListView(selectedNode);
            }
        }
Example #2
0
        private void addNoFilterLvi()
        {
            UltraListViewItem li = ultraListView_Filters.Items.Add(null, NoFilters);

            li.Tag = null;
            li.Appearance.ForeColor = Color.Red;
        }
Example #3
0
        ///
        /// Support Methods
        ///

        private void LoadTags()
        {
            TagList = TagsDAO.DAO.GetAllTags();
            ulvTagList.Reset();
            ulvTagList.View = UltraListViewStyle.List;
            ulvTagList.ItemSettings.Appearance.Image                 = imageList1.Images[0];
            ulvTagList.ItemSettings.SelectedAppearance.Image         = imageList1.Images[1];
            ulvTagList.ItemSettings.SelectedAppearance.FontData.Bold = DefaultableBoolean.False;
            ulvTagList.ItemSettings.SelectedAppearance.ForeColor     = Color.Black;
            ulvTagList.ItemSettings.SelectedAppearance.BackColor     = Color.MistyRose;
            //ulvTagList.ItemSettings.SelectedAppearance.BorderColor = Color.MistyRose;
            //ulvTagList.ItemSettings.SelectedAppearance.BackColor2 = SystemColors.Highlight;
            //ulvTagList.ItemSettings.SelectedAppearance.BackGradientStyle = GradientStyle.Vertical;


            ulvTagList.ItemSettings.SubItemsVisibleInToolTipByDefault = false;
            UltraListViewMainColumn mainColumn = ulvTagList.MainColumn;

            mainColumn.Text     = "Tag Name";
            mainColumn.DataType = typeof(System.String);
            /// Load 'er up
            for (int i = 0; i < TagList.Count; i++)
            {
                UltraListViewItem item = ulvTagList.Items.Add(TagList[i].ID.ToString(), TagList[i].TagName);
                //item.Tag = TagList[i];
            }
            ulvTagList.Refresh();
            bDeleteTag.Enabled = (ulvTagList.SelectedItems.Count > 0);
        }
Example #4
0
 private void ulvDETemplates_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {                   // Change this to false if you want to maintain
                         // the existing selection.
                         //bool clearExisting = false;
         Point         cursorPos = new Point(e.X, e.Y);
         UltraListView listView  = sender as UltraListView;
         // Use the UltraListView's 'ItemFromPoint' method to hit test for an
         // UltraListViewItem. Note that we specify true for the 'selectableAreaOnly'
         // parameter, so that we only get a hit when the cursor is over the text
         // or image area of the item.
         UltraListViewItem itemAtPoint = listView.ItemFromPoint(cursorPos, true);
         // If we got a reference to an item, populate the context menu
         // accordingly and return
         if (itemAtPoint != null)
         {
             //this.ulvMethodsList.ContextMenuStrip = null;
             Infragistics.Win.ISelectionManager selectionManager =
                 listView as Infragistics.Win.ISelectionManager;
             selectionManager.SelectItem(itemAtPoint, true);
             itemAtPoint.Activate();
             contextMenuStrip1.Enabled = true;
         }
         else
         {
             contextMenuStrip1.Enabled = false;
             //this.ulvMethodsList.ContextMenuStrip = cmsListViewStyle;
         }
     }
 }
Example #5
0
        /// <summary>
        /// Load data into the controls
        /// </summary>
        private void InitializeRegistryMappings()
        {
            foreach (string registryKey in _scannerConfiguration.ListRegistryKeys)
            {
                string key       = "";
                string value     = "";
                int    delimiter = registryKey.IndexOf(';');
                if (delimiter == -1)
                {
                    key = registryKey;
                }
                else
                {
                    key   = registryKey.Substring(0, delimiter);
                    value = registryKey.Substring(delimiter + 1);
                }

                // Add to the list
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = value;
                UltraListViewItem item = new UltraListViewItem(key, subItemArray);
                lvRegistryKeys.Items.Add(item);
            }
        }
Example #6
0
        /// <summary>
        /// Load the records from the input file into the list view
        ///
        /// When importing user defined data fields and their values the file should be in the following format
        ///
        /// Picklist Name		PickItem
        ///
        /// We assume that the first row will be labels but the user may elect to include it if not
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormImportPicklists_Load(object sender, EventArgs e)
        {
            // try and read the CSV file into the list view
            try
            {
                using (CSVReader csv = new CSVReader(_fromFile))
                {
                    // Read each line from the file noting that we MUST have 2 columns and 2 only
                    string[] fields;
                    while ((fields = csv.GetCSVLine()) != null)
                    {
                        if (fields.Length != 2)
                        {
                            continue;
                        }

                        // Add the 2 fields to the ListView
                        UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                        subItemArray[0]       = new UltraListViewSubItem();
                        subItemArray[0].Value = fields[1];
                        //
                        UltraListViewItem item = new UltraListViewItem(fields[0], subItemArray);
                        item.CheckState = (lvRecords.Items.Count == 0) ? CheckState.Unchecked : CheckState.Checked;
                        lvRecords.Items.Add(item);
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Failed to import the file " + _fromFile + ".  Reason: " + ex.Message, "Import Failed");
            }
        }
Example #7
0
        public FormUserLocation(AssetGroup parentLocation, AssetGroup theLocation)
        {
            InitializeComponent();

            _parentLocation = parentLocation;
            _location       = theLocation;

            // If this entry is null or the InstanceID is 0 then we are creating a new Location type
            if (_location == null)
            {
                _location           = new AssetGroup();
                _location.GroupType = AssetGroup.GROUPTYPE.userlocation;
            }

            this.Text     = (_location.GroupID == 0) ? "New Location" : "Edit Location";
            tbParent.Text = (_parentLocation == null) ? "" : _parentLocation.FullName;
            tbChild.Text  = (_location.GroupID == 0) ? "New Location" : _location.Name;

            // Add (any) IP address ranges to the list
            string[] startIpAddresses = _location.StartIP.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            string[] endIpAddresses   = _location.EndIP.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            ulvTcpRanges.BeginUpdate();
            for (int isub = 0; isub < startIpAddresses.Length; isub++)
            {
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = endIpAddresses[isub];
                UltraListViewItem item = new UltraListViewItem(startIpAddresses[isub], subItemArray);
                ulvTcpRanges.Items.Add(item);
            }
            ulvTcpRanges.EndUpdate();
        }
Example #8
0
        private void loadForms()
        {
            ulvForms.Width = 272;
            ulvForms.ViewSettingsDetails.CheckBoxStyle = CheckBoxStyle.CheckBox;
            ulvForms.View = UltraListViewStyle.Details;
            ulvForms.ItemSettings.Appearance.Image = imageList1.Images[0];
            ulvForms.ViewSettingsList.MultiColumn  = false;
            ulvForms.Height = 115;
            ulvForms.ViewSettingsDetails.SubItemColumnsVisibleByDefault = true;
            ulvForms.ViewSettingsDetails.AutoFitColumns             = AutoFitColumns.ResizeAllColumns;
            ulvForms.ItemSettings.SubItemsVisibleInToolTipByDefault = false;
            ulvForms.ItemSettings.SelectionType = SelectionType.Extended;

            UltraListViewMainColumn mainColumn = ulvForms.MainColumn;

            mainColumn.Text     = "Name";
            mainColumn.DataType = typeof(System.Int32);

            List <VWA4Common.DataObject.Formx> formsInSeries = FormDAO.DAO.GetAllBySeriesId(this.formSeries.Id);

            foreach (VWA4Common.DataObject.Formx f in FormDAO.DAO.GetAll())
            {
                UltraListViewItem i = ulvForms.Items.Add(f.Id.ToString(), f.Name);

                if (formsInSeries.Find(delegate(VWA4Common.DataObject.Formx frm) { return(frm.Id == f.Id); }) != null)
                {
                    this.ulvForms.Items[i.Index].CheckState = CheckState.Checked;
                }
            }

            this.pnlFormSeries.Controls.Add(ulvForms);
            this.ulvForms.Focus();
        }
Example #9
0
        private void AddLocation(UltraListViewItem lvi)
        {
            LocationsDAO lwDataAccess = new LocationsDAO();

            // Create the AssetGroup for this location noting that we need to add the root item name to all
            // locations created as this will be missing from the import text
            string     oldLocation = lvi.Text;
            AssetGroup newGroup    = new AssetGroup();

            newGroup.GroupType = AssetGroup.GROUPTYPE.userlocation;
            if (oldLocation == "")
            {
                newGroup.FullName = _rootName;
            }
            else
            {
                newGroup.FullName = _rootName + AssetGroup.LOCATIONDELIMITER + lvi.Text;
            }
            newGroup.StartIP = lvi.SubItems[0].Text;
            newGroup.EndIP   = lvi.SubItems[1].Text;

            // Add this group and get its database index
            newGroup.Add();

            // Now we need to add the asset (if there is one defined)
            string assetName = lvi.SubItems[2].Text;

            if (assetName != "")
            {
                Asset newAsset = new Asset();
                newAsset.LocationID = newGroup.GroupID;
                newAsset.Name       = assetName;
                newAsset.Add();
            }
        }
Example #10
0
        private void btnEditComplianceField_Click(object sender, EventArgs e)
        {
            if (lvTriggers.SelectedItems.Count != 1)
            {
                MessageBox.Show(
                    "Please select one compliance field to edit.",
                    "Compliance Report",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);

                return;
            }

            UltraListViewItem lvi = lvTriggers.SelectedItems[0];

            _complianceIndex = lvi.Index;

            if (_complianceIndex == 0)
            {
                cbBooleanValue.Enabled = false;
            }

            PopulateComplianceFields(lvi.Text);

            cbConditions.Text   = lvi.SubItems[0].Value.ToString();
            cbValuePicker.Text  = lvi.SubItems[1].Value.ToString().Replace("'", "");
            cbBooleanValue.Text = lvi.SubItems[2].Value.ToString();

            DeleteComplianceField();
            bnSaveComplianceReport.Enabled = true;
        }
        private void ulvUserData_MouseMove(object sender, MouseEventArgs e)
        {
            UltraListView listView = sender as UltraListView;

            //  If the mouse has moved outside the area in which it was pressed,
            //  start a drag operation
            if (lastMouseDown.HasValue)
            {
                Size      dragSize = SystemInformation.DragSize;
                Rectangle dragRect = new Rectangle(lastMouseDown.Value, dragSize);
                dragRect.X -= dragSize.Width / 2;
                dragRect.Y -= dragSize.Height / 2;

                if (!dragRect.Contains(e.Location))
                {
                    UltraListViewItem itemAtPoint = listView.ItemFromPoint(e.Location);

                    if (itemAtPoint != null)
                    {
                        lastMouseDown = null;
                        dragItem      = itemAtPoint;
                        listView.DoDragDrop(dragItem, DragDropEffects.Move);
                    }
                }
            }
        }
Example #12
0
        /// <summary>
        /// Edit an existing registry key mapping
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnEditKey_Click(object sender, EventArgs e)
        {
            // Get the mapping that is to be edited
            UltraListViewItem editItem = lvRegistryKeys.SelectedItems[0];
            string            key      = editItem.Text;
            string            value    = editItem.SubItems[0].Text;

            // ...and invoke a form to edit it
            FormShadedAskInput2 form = new FormShadedAskInput2("Please enter the registry key name and value name to be audited.  You should include the registry hive (e.g. HKEY_LOCAL_MACHINE)"
                                                               , "Enter Registry Key"
                                                               , "Registry Key Name:"
                                                               , "Value Name"
                                                               , key
                                                               , value
                                                               , Properties.Resources.application_serial_number_corner,
                                                               false);

            if (form.ShowDialog() == DialogResult.OK)
            {
                // Remove the existing item from the list
                int index = editItem.Index;
                lvRegistryKeys.Items.Remove(editItem);

                // ...and add in the new item
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = form.Value2Entered();
                UltraListViewItem item = new UltraListViewItem(form.Value1Entered(), subItemArray);
                lvRegistryKeys.Items.Add(item);
            }
        }
Example #13
0
        /// <summary>
        /// Called when we want to add a new registry mapping
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnAddKey_Click(object sender, EventArgs e)
        {
            FormShadedAskInput2 form = new FormShadedAskInput2("Please enter the registry key name and value name to map to the application.  Do not specify the registry hive as HKEY_LOCAL_MACHINE is assumed."
                                                               , "Enter Registry Key (beneath HKEY_LOCAL_MACHINE)"
                                                               , "Registry Key Name:", "Value Name", "", "", Properties.Resources.application_serial_number_corner
                                                               , true);

            if (form.ShowDialog() == DialogResult.OK)
            {
                // OK add the new mapping to our list
                RegistryMapping        mapping      = new RegistryMapping(form.Value1Entered(), form.Value2Entered());
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = mapping.ValueName;
                UltraListViewItem item = new UltraListViewItem(mapping.RegistryKey, subItemArray);
                item.Tag = mapping;
                lvRegistryKeys.Items.Add(item);

                // Build the mappings string
                String mappingString = BuildMappingString();

                // ..and update the configuration file
                _applicationsFile.SetString(cbApplications.SelectedItem.ToString(), mappingString, true);
            }
        }
Example #14
0
        public void LoadServers(bool showValidOnly)
        {
            // set the heading based on the selection
            if (showValidOnly)
            {
                ultraListViewSelectServer.MainColumn.Text = HeadingValidServers;
            }
            else
            {
                ultraListViewSelectServer.MainColumn.Text = HeadingAllServers;
            }

            // Get the server list from the currently loaded array without doing a refresh

            // Fill the list view.
            ultraListViewSelectServer.Items.Clear();
            foreach (Sql.RegisteredServer server in Program.gController.Repository.RegisteredServers)
            {
                if (!showValidOnly || server.LastCollectionSnapshotId > 0)
                {
                    UltraListViewItem li = ultraListViewSelectServer.Items.Add(null, server.ConnectionName);
                    li.Tag = server;
                }
            }

            if (ultraListViewSelectServer.Items.Count > 0)
            {
                ultraListViewSelectServer.SelectedItems.Clear();
                ultraListViewSelectServer.SelectedItems.Add(ultraListViewSelectServer.Items[0]);
            }
        }
Example #15
0
        /// <summary>
        /// Add a uPicklist and/or PickItem to the database
        ///
        /// </summary>
        /// <param name="lvi"></param>
        private void AddPicklist(UltraListViewItem lvi)
        {
            // Recover the data fields
            string listName = lvi.Text;
            string itemName = lvi.SubItems[0].Text;

            // Does the Picklist exist?
            PickList pickList = _listPickLists.FindPickList(listName);

            if (pickList == null)
            {
                pickList      = new PickList();
                pickList.Name = listName;
                pickList.Add();
                _listPickLists.Add(pickList);
            }

            // Does the pickitem already exist within the Picklist?
            PickItem pickItem = pickList.FindPickItem(itemName);

            if (pickItem == null)
            {
                pickItem          = new PickItem();
                pickItem.Name     = itemName;
                pickItem.ParentID = pickList.PicklistID;
                pickItem.Add();
            }
        }
Example #16
0
        private void tsmRemoveFoodType_Click(object sender, EventArgs e)
        {
            UltraListViewItem item = ulvTaggedFoodTypes.SelectedItems[0];

            TagsFoodTypeDAO.DAO.Delete(item.Key);
            LoadTaggedFoodTypes(CurrTag.ID);
        }
Example #17
0
        private void ulvPrintSeries_DragOver(object sender, DragEventArgs e)
        {
            UltraListView listView  = sender as UltraListView;
            Point         clientPos = listView.PointToClient(new Point(e.X, e.Y));

            if (this.dragItem != null)
            {
                this.dropItem = listView.ItemFromPoint(clientPos);
                //e.Effect = this.dropItem != null && this.dropItem != this.dragItem ? DragDropEffects.Move : DragDropEffects.None;
            }

            e.Effect = DragDropEffects.Move;
            int dragScrollAreaHeight = 8;

            Rectangle displayRect   = listView.DisplayRectangle;
            Rectangle topScrollArea = displayRect;

            topScrollArea.Height = (dragScrollAreaHeight * 2);

            Rectangle bottomScrollArea = displayRect;

            bottomScrollArea.Y      = bottomScrollArea.Bottom - dragScrollAreaHeight;
            bottomScrollArea.Height = dragScrollAreaHeight;

            ISelectionManager selectionManager = listView as ISelectionManager;

            if (topScrollArea.Contains(clientPos) || bottomScrollArea.Contains(clientPos))
            {
                selectionManager.DoDragScrollVertical(0);
            }
        }
Example #18
0
        private void loadFormSeries()
        {
            ulvFormSeries.Reset();
            ulvFormSeries.Width  = pnlFormSeries.Width;
            ulvFormSeries.Height = pnlFormSeries.Height;
            ulvFormSeries.View   = UltraListViewStyle.Details;
            ulvFormSeries.ItemSettings.Appearance.Image = imageList1.Images[0];

            ulvFormSeries.ViewSettingsDetails.SubItemColumnsVisibleByDefault = true;
            ulvFormSeries.ViewSettingsDetails.AutoFitColumns             = AutoFitColumns.ResizeAllColumns;
            ulvFormSeries.ItemSettings.SubItemsVisibleInToolTipByDefault = false;
            ulvFormSeries.ItemSettings.SelectionType = SelectionType.Single;

            UltraListViewMainColumn mainColumn = ulvFormSeries.MainColumn;

            mainColumn.Text     = "Form Series Name";
            mainColumn.DataType = typeof(System.Int32);

            foreach (VWA4Common.DataObject.FormSeries fs in FormSeriesDAO.DAO.GetAll())
            {
                UltraListViewItem i = ulvFormSeries.Items.Add(fs.Id.ToString(), fs.Name);
            }

            this.pnlFormSeries.Controls.Add(ulvFormSeries);
        }
Example #19
0
        private void ulvForms_MouseMove(object sender, MouseEventArgs e)
        {
            UltraListView listView = sender as UltraListView;

            //  If the mouse has moved outside the area in which it was pressed,
            //  start a drag operation
            if (!this.lastMouseDown.IsEmpty && e.Button == MouseButtons.Left)
            {
                Size      dragSize = SystemInformation.DragSize;
                Rectangle dragRect = new Rectangle(this.lastMouseDown, dragSize);
                dragRect.X -= dragSize.Width / 2;
                dragRect.Y -= dragSize.Height / 2;

                if (!dragRect.Contains(e.Location))
                {
                    UltraListViewItem itemAtPoint = listView.ItemFromPoint(e.Location);

                    if (itemAtPoint != null)
                    {
                        this.lastMouseDown = new Point();
                        this.dragItem      = itemAtPoint;
                        listView.DoDragDrop(this.dragItem, DragDropEffects.Move);
                    }
                }
            }
        }
Example #20
0
        void ulvForms_MouseDown(object sender, MouseEventArgs e)
        {
            //this.pnlPrintSeriesPanel.Visible = false;

            if (e.Button == MouseButtons.Left)
            {
                this.lastMouseDown = e.Location;
            }
            else if (e.Button == MouseButtons.Right)
            {
                Point             cursorPos   = new Point(e.X, e.Y);
                UltraListView     listView    = sender as UltraListView;
                UltraListViewItem itemAtPoint = listView.ItemFromPoint(cursorPos, true);

                if (itemAtPoint != null)
                {
                    Infragistics.Win.ISelectionManager selectionManager = listView as Infragistics.Win.ISelectionManager;
                    selectionManager.SelectItem(itemAtPoint, true);
                    itemAtPoint.Activate();
                    contextMenuStrip1.Enabled = true;
                    contextMenuStrip1.Show(listView, new Point(e.X, e.Y));
                }
                else
                {
                    contextMenuStrip1.Enabled = false;
                }
            }
            else
            {
                this.lastMouseDown = new Point();
            }
        }
Example #21
0
        protected void AddSelectedItems(UltraTreeNode parentNode)
        {
            switch (parentNode.CheckedState)
            {
            case CheckState.Checked:
            {
                if (parentNode.Key.StartsWith("Applications|"))
                {
                    if (parentNode.Key.Split('|').Length == 4)
                    {
                        parentNode.Key = parentNode.Key.Substring(0, parentNode.Key.LastIndexOf("|"));
                    }
                }

                UltraListViewItem lvi = new UltraListViewItem(parentNode.Key, null);
                //lvi.Appearance.Image = parentNode.LeftImages[0];
                lvi.Appearance.Image = GetIcon(parentNode);
                lvi.Tag = parentNode.Tag;
                lvSelectedItems.Items.Add(lvi);
            }
            break;

            case CheckState.Indeterminate:
                foreach (UltraTreeNode childNode in parentNode.Nodes)
                {
                    AddSelectedItems(childNode);
                }
                break;
            }

            return;
        }
        private void ulvUserData_DragOver(object sender, DragEventArgs e)
        {
            UltraListView listView  = sender as UltraListView;
            Point         clientPos = listView.PointToClient(new Point(e.X, e.Y));

            if (dragItem != null)
            {
                dropItem = listView.ItemFromPoint(clientPos);
                e.Effect = dropItem != null && dropItem != dragItem ? DragDropEffects.Move : DragDropEffects.None;
            }

            //  If the cursor is within {dragScrollAreaHeight} pixels
            //  of the top or bottom edges of the control, scroll
            int dragScrollAreaHeight = 8;

            Rectangle displayRect   = listView.DisplayRectangle;
            Rectangle topScrollArea = displayRect;

            topScrollArea.Height = (dragScrollAreaHeight * 2);

            Rectangle bottomScrollArea = displayRect;

            bottomScrollArea.Y      = bottomScrollArea.Bottom - dragScrollAreaHeight;
            bottomScrollArea.Height = dragScrollAreaHeight;

            ISelectionManager selectionManager = listView;

            if (topScrollArea.Contains(clientPos) || bottomScrollArea.Contains(clientPos))
            {
                selectionManager.DoDragScrollVertical(0);
            }
        }
        /// <summary>
        /// Delete an alert definition from the list
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure that you want to delete this Alert Definition?", "Confirm Delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                UltraListViewItem lvi = lvAlertDefinitions.SelectedItems[0];
                int index             = lvi.Index;
                //
                // Remove the item from the list view
                lvAlertDefinitions.Items.Remove(lvi);

                string selectedFileName = Path.Combine(Application.StartupPath, "scanners\\alertmonitors\\") + lvi.Text + ".xml";

                if (File.Exists(selectedFileName))
                {
                    File.Delete(selectedFileName);
                }

                // Select the next definition in the list if any
                if (index >= lvAlertDefinitions.Items.Count)
                {
                    index--;
                }
                if (index >= 0)
                {
                    lvAlertDefinitions.SelectedItems.Add(lvAlertDefinitions.Items[index]);
                }
            }
        }
        /// <summary>
        /// Called as we click a mouse button within the list view.  If this is the right button then we should
        /// select (any) item which the mouse is over
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ulvUserData_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                lastMouseDown = e.Location;
            }
            else
            {
                lastMouseDown = null;
            }

            UltraListView     listViewDrag = sender as UltraListView;
            UltraListViewItem itemAtPoint  = listViewDrag.ItemFromPoint(e.X, e.Y, true);

            if (itemAtPoint != null)
            {
                lastMouseDownLocation = new Point(e.X, e.Y);

                if (e.Button == MouseButtons.Right)
                {
                    ulvUserData.SelectedItems.Clear();
                    ulvUserData.SelectedItems.Add(itemAtPoint);
                }
            }
            else
            {
                lastMouseDownLocation = null;
            }
        }
        /// <summary>
        /// Refresh the list of Asset Types for the currently selected asset type category
        /// </summary>
        /// <param name="category"></param>
        private void RefreshList(UserDataCategory category)
        {
            ulvUserData.BeginUpdate();
            ulvUserData.Items.Clear();

            // Get the small icon which we will display
            Bitmap image = IconMapping.LoadIcon(category.Icon, IconMapping.Iconsize.Small);

            // Add the items to the list
            foreach (UserDataField field in category)
            {
                // Subitems are type and description
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[2];
                subItemArray[0] = new UltraListViewSubItem {
                    Value = field.TypeAsString
                };
                subItemArray[1] = new UltraListViewSubItem {
                    Value = field.Description()
                };
                //
                UltraListViewItem lvi = new UltraListViewItem(field.Name, subItemArray);
                lvi.Tag = field;
                lvi.Appearance.Image = image;
                ulvUserData.Items.Add(lvi);
            }
            ulvUserData.EndUpdate();
        }
Example #26
0
        private void bnEditIP_Click(object sender, EventArgs e)
        {
            if (tcpipListView.SelectedItems.Count == 1)
            {
                CheckState active = tcpipListView.SelectedItems[0].CheckState;

                IpAddressRangeForm ipForm = new IpAddressRangeForm(tcpipListView.SelectedItems[0].Key, (string)tcpipListView.SelectedItems[0].SubItems[0].Value);
                if (ipForm.ShowDialog() == DialogResult.OK)
                {
                    if (!tcpipListView.Items.Exists(ipForm.StartAddress))
                    {
                        tcpipListView.Items.Remove(tcpipListView.SelectedItems[0]);

                        UltraListViewItem item = tcpipListView.Items.Add(ipForm.StartAddress, ipForm.StartAddress);
                        item.SubItems[0].Value = ipForm.EndAddress;
                        item.CheckState        = active;
                    }
                    else
                    {
                        MessageBox.Show("Start IP address already exists. Range will not be added.", "Invalid IP Range", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
            }
            else if (tcpipListView.SelectedItems.Count > 1)
            {
                MessageBox.Show("Only one entry can edited at a time.", "AuditWizard", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Please select an IP range to edit.", "AuditWizard", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #27
0
        private void UpdateStats()
        {
            int count         = trackList.Items.Count;
            int countScrobble = 0;

            object[] items = trackList.Items.All;

            TimeSpan total      = new TimeSpan(0, 0, 0);
            TimeSpan toScrobble = new TimeSpan(0, 0, 0);

            try
            {
                foreach (object item in items)
                {
                    UltraListViewItem current = (UltraListViewItem)item;
                    total = total.Add(TimeSpan.Parse(current.SubItems[3].Value.ToString()));

                    toScrobble     = toScrobble.Add(new TimeSpan(TimeSpan.Parse(current.SubItems[3].Value.ToString()).Ticks *(int)current.SubItems[4].Value));
                    countScrobble += (int)current.SubItems[4].Value;
                }
            }
            catch { }

            labelStats.Text = "Total items: " + count + "   " + "Scrobbles count: " + countScrobble + "   " + "Total time: " + total.ToString() +
                              "   " + "Scrobble time: " + toScrobble.ToString();
        }
Example #28
0
        private void editFields_Click(object sender, EventArgs e)
        {
            if (trackList.SelectedItems.Count > 0)
            {
                if (!editPanel.Visible)
                {
                    editPanel.Size     = fileList.Size;
                    editPanel.Location = fileList.Location;

                    editPanel.Visible = true;

                    try
                    {
                        UltraListViewItem item = (UltraListViewItem)trackList.SelectedItems.All[0];
                        artistNew.Text = item.SubItems[1].Value.ToString();
                        albumNew.Text  = item.SubItems[2].Value.ToString();
                        trackNew.Text  = item.SubItems[0].Value.ToString();
                    }
                    catch { }
                }
                else
                {
                    editPanel.Visible = false;
                }
            }
            else
            {
                MessageBox.Show("Select something first!", "Not like this!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void ApplyImportStatus(UltraListViewItem lvImport, ImportStatusIcon statusIcon, string statusMessage)
        {
            using (logX.loggerX.InfoCall())
            {
                lvImport.SubItems[0].Value = statusMessage;
                Image image;
                switch (statusIcon)
                {
                case ImportStatusIcon.Imported:
                    image = imageList1.Images["Ok"];
                    break;

                case ImportStatusIcon.Warning:
                    image = imageList1.Images["Warning"];
                    break;

                case ImportStatusIcon.Error:
                    image = imageList1.Images["Error"];
                    break;

                case ImportStatusIcon.Importing:
                    image = imageList1.Images["Importing"];
                    break;

                default:
                    image = imageList1.Images["Undefined"];
                    break;
                }
                lvImport.Appearance.Image = image;
            }
        }
Example #30
0
        private void PopulateResultsListView(DataTable aDataTable, string aSearchType)
        {
            UltraListViewItem[] items = new UltraListViewItem[aDataTable.Rows.Count];

            lvResults.BeginUpdate();

            for (int i = 0; i < aDataTable.Rows.Count; i++)
            {
                DataRow row = aDataTable.Rows[i];
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[3];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = row[1];

                subItemArray[1]       = new UltraListViewSubItem();
                subItemArray[1].Value = aSearchType;

                subItemArray[2]       = new UltraListViewSubItem();
                subItemArray[2].Value = row[2];

                UltraListViewItem item = new UltraListViewItem(row[0], subItemArray);
                items[i] = item;
            }

            lvResults.Items.AddRange(items);
            lvResults.EndUpdate();
        }
Example #31
0
        private void addAll_Click(object sender, EventArgs e)
        {
            StartTimer();

            object[] files = fileList.Items.All;

            ArrayList errors = new ArrayList();

            foreach (object file in files)
            {
                try
                {
                    UltraListViewItem item = (UltraListViewItem)file;

                    TagLib.File tagFile = TagLib.File.Create(item.Key.ToString());

                    ArrayList subItemValues = new ArrayList();

                    subItemValues.Add(tagFile.Tag.Title);
                    subItemValues.Add(tagFile.Tag.FirstPerformer);
                    subItemValues.Add(tagFile.Tag.Album);
                    subItemValues.Add(tagFile.Properties.Duration.ToString());
                    subItemValues.Add(1);

                    UltraListViewItem track = new UltraListViewItem(tagFile.Name, subItemValues.ToArray());

                    trackList.Items.Add(track);

                }
                catch (Exception exp)
                {
                    errors.Add(((UltraListViewItem)file).Value.ToString() + " : " + exp.Message.ToString());
                }
            }
            if (errors.Count > 0)
            {
                info.Clear();
                info.AppendText("Following errors have occured:\r\n\r\n");

                foreach (string error in errors.ToArray())
                {
                    info.AppendText(error);
                    info.AppendText("\r\n");
                }

                errorPopup.Show(new Point(this.Size.Width + this.Location.X, this.Location.Y + this.Size.Height / 3));
            }

            UpdateStats();

            StopTimer();
        }
Example #32
0
        private void openCue_Click(object sender, EventArgs e)
        {
            StartTimer();

            OpenFileDialog dialog = new OpenFileDialog();
            dialog.InitialDirectory = folderTree.ActiveNode.FullPath.Replace(folderTree.ActiveNode.RootNode.FullPath + "\\", "");

            dialog.Filter = "CUE'sheet lists (*.cue)|*.cue|Text sheet Files (*.txt)|*.txt";
            dialog.Title = "Select CUE'sheet to open";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    CueSheet sheet = new CueSheet(dialog.FileName);
                    string artist = sheet.Performer;
                    string album = sheet.Title;

                    CueSharp.Track[] tracks = sheet.Tracks;

                    //TagLib.File tagFile = TagLib.File.Create(dialog.FileName);
                    //TimeSpan totalTime = new TimeSpan(tagFile.Length);

                    TimeSpan totalTime = new TimeSpan();
                    TimeSpan totalTrackTime = new TimeSpan();
                    int totalTracks = tracks.Length;

                    bool readFile = false;

                    try
                    {
                        TagLib.File tagFile = TagLib.File.Create(Path.GetDirectoryName(dialog.FileName) + "\\" + tracks[0].DataFile.Filename);
                        totalTime = tagFile.Properties.Duration;
                        readFile = true;
                    }
                    catch
                    {
                    }

                    foreach (object item in tracks)
                    {
                        try
                        {
                            CueSharp.Track track = (CueSharp.Track)item;

                            ArrayList subItemValues = new ArrayList();

                            subItemValues.Add(track.Title);
                            subItemValues.Add(track.Performer);
                            subItemValues.Add(album);

                            TimeSpan trackTime = new TimeSpan();

                            if (track.TrackNumber != totalTracks)
                            {
                                trackTime = new TimeSpan(0, tracks[track.TrackNumber].Indices[0].Minutes - track.Indices[0].Minutes, tracks[track.TrackNumber].Indices[0].Seconds - track.Indices[0].Seconds);
                            }
                            else if(readFile)
                                trackTime = new TimeSpan(0, totalTime.Minutes - totalTrackTime.Minutes, totalTime.Seconds - totalTrackTime.Seconds);
                            else trackTime = new TimeSpan(0, totalTrackTime.Minutes/totalTracks, totalTrackTime.Seconds/totalTracks);

                            totalTrackTime = totalTrackTime.Add(trackTime);

                            subItemValues.Add(trackTime.ToString());
                            subItemValues.Add(1);

                            UltraListViewItem listTrack = new UltraListViewItem("CUE'sheet item", subItemValues.ToArray());
                            trackList.Items.Add(listTrack);
                        }
                        catch (Exception exp)
                        {
                            //errors.Add(((UltraListViewItem)file).Value.ToString() + " : " + exp.Message.ToString());
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Ook!");
                }
            }

            UpdateStats();

            StopTimer();
        }
Example #33
0
        private void folderTree_AfterActivate(object sender, NodeEventArgs e)
        {
            StartTimer();

            string path = e.TreeNode.FullPath.Replace(e.TreeNode.RootNode.FullPath + "\\", "");

            if (!e.TreeNode.HasNodes)
            {
                if(Directory.Exists(path))
                {
                    try
                    {
                        foreach (string dir in Directory.GetDirectories(path))
                        {
                            UltraTreeNode node = new UltraTreeNode();
                            node.Text = dir.Substring(dir.LastIndexOf(@"\") + 1);
                            e.TreeNode.Nodes.Add(node);
                        }
                    }
                    catch (UnauthorizedAccessException) { }
                }
            }
            try
            {
                fileList.Items.Clear();
                string[] files = Directory.GetFiles(path);    //search does not allow multiple patterns

                foreach (string file in files)
                {
                    string ext = Path.GetExtension(file);

                    object[] subItemsValues = new string[] { };
                    UltraListViewItem item = new UltraListViewItem();

                    switch (ext)
                    {
                        case ".mp3":
                            subItemsValues = new string[] { "MP3" };
                            item = new UltraListViewItem(Path.GetFileName(file), subItemsValues);

                            item.Key = file;
                            fileList.Items.Add(item);
                            break;
                        case ".ogg":
                            subItemsValues = new string[] { "OGG" };
                            item = new UltraListViewItem(Path.GetFileName(file), subItemsValues);

                            item.Key = file;
                            fileList.Items.Add(item);
                            break;
                        case ".flac":
                            subItemsValues = new string[] { "FLAC" };
                            item = new UltraListViewItem(Path.GetFileName(file), subItemsValues);

                            item.Key = file;
                            fileList.Items.Add(item);
                            break;
                        case ".ape":
                            subItemsValues = new string[] { "APE" };
                            item = new UltraListViewItem(Path.GetFileName(file), subItemsValues);

                            item.Key = file;
                            fileList.Items.Add(item);
                            break;
                    }
                }
            }
            catch (Exception) {}

            StopTimer();
        }
Example #34
0
        private void fileList_ItemDoubleClick(object sender, ItemDoubleClickEventArgs e)
        {
            TagLib.File tagFile = TagLib.File.Create(e.Item.Key.ToString());

            ArrayList subItemValues = new ArrayList();

            subItemValues.Add(tagFile.Tag.Title);
            subItemValues.Add(tagFile.Tag.FirstPerformer);
            subItemValues.Add(tagFile.Tag.Album);
            subItemValues.Add(tagFile.Properties.Duration.ToString());
            subItemValues.Add(1);

            UltraListViewItem track = new UltraListViewItem(tagFile.Name, subItemValues.ToArray());

            trackList.Items.Add(track);

            UpdateStats();
        }
 private void BuildUsedFunctionList (SortedDictionary<int, Function> usedFunctions)
 {
     ulvUsedFunctions.Items.Clear();
     ulvUsedFunctions.Text = "Transition Functions";
     foreach (var orderKey in usedFunctions.Keys)
     {
         var item = new UltraListViewItem(usedFunctions[orderKey].FunctionName, null, usedFunctions[orderKey]);
         ulvUsedFunctions.Items.Add(item);
     }
 }
        private void lvAttachments_MouseMove(
            object sender,
            MouseEventArgs e)
        {
            var listView = sender as UltraListView;

            //  If the mouse has moved outside the area in which it was pressed,
            //  start a drag operation
            if (!_lastMouseDown.HasValue)
            {
                return;
            }
            Size dragSize = SystemInformation.DragSize;
            var dragRect = new Rectangle
                (
                _lastMouseDown.Value,
                dragSize);
            dragRect.X -= dragSize.Width/2;
            dragRect.Y -= dragSize.Height/2;

            if (!dragRect.Contains(e.Location))
            {
                return;
            }
            if (listView == null)
            {
                return;
            }
            UltraListViewItem itemAtPoint = listView.ItemFromPoint(e.Location);

            if (itemAtPoint == null)
            {
                return;
            }
            _lastMouseDown = null;
            _dragItem = itemAtPoint;
            listView.DoDragDrop
                (
                    _dragItem,
                    DragDropEffects.Move);
        }
 private void BuildUnusedFunctionList(IQueryable<Function> functions)
 {
     ulvUnusedFunctions.Items.Clear();
     ulvUnusedFunctions.Text = "Available Functions";
     foreach (var function in functions)
     {
         var item = new UltraListViewItem(function.FunctionName, null,function);
         ulvUnusedFunctions.Items.Add(item);
     }
 }
        private void lvAttachments_DragOver(
            object sender,
            DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.Copy;
            }
            var listView = sender as UltraListView;
            if (listView == null)
            {
                return;
            }
            Point clientPos = listView.PointToClient
                (
                    new Point
                        (
                        e.X,
                        e.Y));

            if (_dragItem != null)
            {
                _dropItem = listView.ItemFromPoint(clientPos);

                e.Effect = _dropItem != null && _dropItem != _dragItem
                               ? DragDropEffects.Move
                               : DragDropEffects.None;
            }

            //  TODO: This could be improved with a hover timer

            //  If the cursor is within {dragScrollAreaHeight} pixels
            //  of the top or bottom edges of the control, scroll
            const int dragScrollAreaHeight = 8;

            Rectangle displayRect = listView.DisplayRectangle;
            Rectangle topScrollArea = displayRect;
            topScrollArea.Height = (dragScrollAreaHeight*2);

            Rectangle bottomScrollArea = displayRect;
            bottomScrollArea.Y = bottomScrollArea.Bottom - dragScrollAreaHeight;
            bottomScrollArea.Height = dragScrollAreaHeight;

            ISelectionManager selectionManager = listView;
            if (topScrollArea.Contains(clientPos) || bottomScrollArea.Contains(clientPos))
            {
                selectionManager.DoDragScrollVertical(0);
            }
        }
        private void OnDragEnd(
            UltraListView listView,
            bool canceled)
        {
            if (isFormClosing)
            {
                return;
            }
            if (canceled == false && _data != null)
            {
                listView.BeginUpdate();

                // listView.Items.Remove((UltraListViewItem) data);
                int index = 0;
                if (listView.Items.Count > 0)
                {
                    index = listView.Items.Count;
                }
                //Create Unique GUID From Filename
                string myUniqueFileName = "";
                try
                {
                    myUniqueFileName = string.Format
                        (
                            ((string[]) (_data))[0],
                            Guid.NewGuid());
                }
                catch (Exception)
                {
                    myUniqueFileName = string.Format
                        (
                            "Image " + DateTime.Now,
                            Guid.NewGuid());
                }

                try
                {
                    using (var item = new UltraListViewItem(_data.ToString())
                                      {
                                          Tag = ((string[]) (_data))[0],
                                          Key = myUniqueFileName
                                      })
                    {
                        const int thumbSize = 256;
                        Bitmap thumbnail = WindowsThumbnailProvider.GetThumbnail
                            (
                                ((string[]) (_data))[0],
                                thumbSize,
                                thumbSize,
                                ThumbnailOptions.BiggerSizeOk);
                        if (bmp != null)
                        {
                            item.Appearance.ImageBackground = bmp;
                            item.Appearance.Image = bmp;
                        }
                        else
                        {
                            item.Appearance.ImageBackground = thumbnail;
                            item.Appearance.Image = thumbnail;
                        }
                        if (!listView.Items.Contains(myUniqueFileName))
                        {
                            listView.Items.Insert
                                (
                                    index,
                                    item);
                        }
                    }
                }
                catch (Exception)
                {
                    var b = new Bitmap((Bitmap) _data);
                    var i = (Image) b;
                    try
                    {
                        string result = ImageConverter.GetString
                            (
                                ImageConverter.ImageToBase64Byte
                                    (
                                        i,
                                        ImageFormat.Bmp));
                        try
                        {
                            listView.Items.Insert
                                (
                                    index,
                                    new UltraListViewItem(myUniqueFileName)
                                    {
                                        Tag = result
                                    });
                        }
                        catch (Exception)
                        {
                            listView.Items.Add
                                (
                                    new UltraListViewItem(myUniqueFileName)
                                    {
                                        Tag = result
                                    });
                        }

                        UltraListViewItem selected = listView.Items[index];
                        selected.Appearance.ImageBackground = i;
                        selected.Appearance.Image = b;
                    }
                    catch (Exception e)
                    {
                        //Do Nothing
                    }
                }

                listView.EndUpdate();
            }

            _dragItem = _dropItem = null;
            _lastMouseDown = null;
        }