Esempio n. 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            trayIcon.Icon = Icon;
            Width = settings.FormWidth;
            Height = settings.FormHeight;

            ResetSearchBarTimer();
            LoadPlaylists();

            showingPlaylist = GetPlaylist(settings.StartupPlaylist) ?? library;
            playingPlaylist = showingPlaylist;

            SetSongGridViewStyle();

            UpdateShowingPlaylist();
            songGridView.AutoGenerateColumns = false;
            songGridView.Columns["Length"].DefaultCellStyle.Format = Song.LengthFormat;

            columnSettings = ColumnSettings.Load(ColumnSettingsPath)
                ?? ColumnSettings.Load(DefaultColumnSettingsPath) ?? new ColumnSettings(songGridView.Columns);

            //Sets the columns
            foreach (ColumnSetting cs in columnSettings.SettingList)
            {
                songGridView.Columns[cs.Name].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                songGridView.Columns[cs.Name].DisplayIndex = cs.DisplayIndex;
                songGridView.Columns[cs.Name].Visible = cs.Visible;
                songGridView.Columns[cs.Name].Width = cs.Width;
                songGridView.Columns[cs.Name].SortMode = DataGridViewColumnSortMode.Automatic;
            }

            SetPlaylistGridView();

            playlistGridView.ClearSelection();
            // Select proper playlist in gridview
            foreach (DataGridViewRow row in playlistGridView.Rows)
                if ((row.DataBoundItem as PlaylistBase).Name == settings.StartupPlaylist)
                    row.Cells[0].Selected = true;

            shuffleQueue.Source = GetPlaylist(settings.Shufflequeue_SourcePlaylistName);
            shuffleQueue.Populate();
            UpdateTrayIconText();
            SetTrayIconContextMenu();
            SetStatusStrip();
            UpdateShowingPlaylist();
            volumeTrackBar.Value = settings.Volume;
        }
Esempio n. 2
0
 private void columnHeaderContextMenu_Click(object sender, EventArgs e)
 {
     MenuItem senderItem = sender as MenuItem;
     songGridView.Columns[senderItem.Name].Visible = !songGridView.Columns[senderItem.Name].Visible;
     columnSettings = new ColumnSettings(songGridView.Columns);
 }
Esempio n. 3
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Stop playback & timers
            searchBarTimer.Stop();
            searchBarTimer.Dispose();
            searchLibraryTimer?.Stop();
            searchLibraryTimer?.Dispose();

            trayIcon.Dispose();
            musicPlayer.Dispose();

            // Save settings
            SaveFormDimensions();

            settings.StartupPlaylist = showingPlaylist.Name;
            if (settings.StartupPlaylist == "Search Results")
                settings.StartupPlaylist = library.Name;

            settings.Volume = volumeTrackBar.Value;
            settings.DeviceVolume = musicPlayer.DeviceVolume;

            settings.Save(SettingsPath);

            // Save data grid column settings
            columnSettings = new ColumnSettings(songGridView.Columns);
            columnSettings.Save(ColumnSettingsPath);

            // Saving of playlists is done after the form has closed (program.cs)
        }
Esempio n. 4
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            settings.FormWidth = this.Width;
            settings.FormHeight = this.Height;
            settings.StartupPlaylist = showingPlaylist.Name;
            settings.Save(SETTINGSPATH);

            columnSettings = new ColumnSettings(songGridView.Columns);
            columnSettings.Save(COLUMNSETTINGSPATH);

            foreach (IPlaylist pl in playlists)
                pl.Save();

            searchBarTimer.Stop();
            searchBarTimer.Dispose();
            if (searchLibraryTimer != null)
            {
                searchLibraryTimer.Stop();
                searchLibraryTimer.Dispose();
            }
            trayIcon.Dispose();
            musicPlayer.Dispose();
        }
Esempio n. 5
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.trayIcon.Icon = ((System.Drawing.Icon)(this.Icon));
            this.Width = settings.FormWidth;
            this.Height = settings.FormHeight;

            ResetSearchBarTimer();
            LoadPlaylists();

            showingPlaylist = GetPlaylist(settings.StartupPlaylist);
            if (showingPlaylist == null)
                showingPlaylist = library;
            playingPlaylist = showingPlaylist;

            SetSongGridViewStyle();

            UpdateShowingPlaylist(true);
            songGridView.AutoGenerateColumns = false;
            songGridView.Columns["Length"].DefaultCellStyle.Format = Song.LengthFormat;

            columnSettings = ColumnSettings.Load(COLUMNSETTINGSPATH);
            if (columnSettings == null)
                columnSettings = ColumnSettings.Load(DEFAULTCOLUMNSETTINGSPATH);
            if (columnSettings == null)
                columnSettings = new ColumnSettings(songGridView.Columns);

            //Sets the columns
            foreach (ColumnSetting cs in columnSettings.SettingList)
            {
                songGridView.Columns[cs.Name].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                songGridView.Columns[cs.Name].DisplayIndex = cs.DisplayIndex;
                songGridView.Columns[cs.Name].Visible = cs.Visible;
                songGridView.Columns[cs.Name].Width = cs.Width;
                songGridView.Columns[cs.Name].SortMode = DataGridViewColumnSortMode.Automatic;
            }

            SetPlaylistGridView();
            PopulateShuffleQueue();
            UpdateTrayIconText();
            SetTrayIconContextMenu();
            SetStatusStrip();
        }
        /// <summary>
        /// Load column setting.
        /// </summary>
        /// <param name="columnSetting">Column setting.</param>
        /// <param name="actualProperties">Data grid item properties.</param>
        /// <param name="isDetails">Is details items.</param>
        private void _LoadColumnSetting(ColumnSettings columnSetting, 
            ICollection<DataGridItemPropertyBase> actualProperties, bool isDetails)
        {
            string key = columnSetting.SettingsKey;
            foreach (DataGridItemProperty property in actualProperties)
            {
                string formatString = COLUMNS_SETTINGS_NAMES_FORMAT_STRING;
                if (isDetails)
                {
                    formatString = ROUTE_INFO_SETTINGS_NAME + formatString;
                }

                if (String.Format(formatString, property.Name).Equals(key))
                {
                    _settingRepository.Settings.Add(key, columnSetting);
                }
            }
        }
Esempio n. 7
0
        private void btnResetColumns_Click(object sender, RoutedEventArgs e)
        {
            List <ColumnInfo> defaultColumns = ColumnSettings.GetDefaultSettings().MyModsColumns;

            ApplyColumnSettings(defaultColumns);
        }
Esempio n. 8
0
 public void SaveSettings()
 {
     Settings.Instance.MemoryListViewColumns = ColumnSettings.SaveSettings(listMemory);
 }
        public TokenProperties(IWithToken obj)
        {
            InitializeComponent();

            listPrivileges.ListViewItemSorter = new SortedListViewComparer(listPrivileges);
            GenericViewMenu.AddMenuItems(copyMenuItem.MenuItems, listPrivileges, null);
            listPrivileges.ContextMenu = menuPrivileges;

            if (obj == null)
            {
                return;
            }

            _object = obj;

            try
            {
                using (TokenHandle thandle = _object.GetToken(TokenAccess.Query))
                {
                    // "General"
                    try
                    {
                        textUser.Text         = thandle.User.GetFullName(true);
                        textUserSID.Text      = thandle.User.StringSid;
                        textOwner.Text        = thandle.Owner.GetFullName(true);
                        textPrimaryGroup.Text = thandle.PrimaryGroup.GetFullName(true);
                    }
                    catch (Exception ex)
                    {
                        textUser.Text = "(" + ex.Message + ")";
                    }

                    try
                    {
                        textSessionID.Text = thandle.SessionId.ToString();
                    }
                    catch (Exception ex)
                    {
                        textSessionID.Text = "(" + ex.Message + ")";
                    }

                    try
                    {
                        TokenElevationType type = thandle.ElevationType;

                        switch (type)
                        {
                        case TokenElevationType.Default:
                            this.textElevated.Text = "N/A";
                            break;

                        case TokenElevationType.Full:
                            this.textElevated.Text = "True";
                            break;

                        case TokenElevationType.Limited:
                            this.textElevated.Text = "False";
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        textElevated.Text = "(" + ex.Message + ")";
                    }

                    // Determine if the token has a linked token.
                    if (OSVersion.HasUac)
                    {
                        try
                        {
                            TokenHandle linkedToken = thandle.LinkedToken;

                            if (linkedToken != null)
                            {
                                linkedToken.Dispose();
                            }
                            else
                            {
                                buttonLinkedToken.Visible = false;
                            }
                        }
                        catch
                        {
                            buttonLinkedToken.Visible = false;
                        }
                    }
                    else
                    {
                        buttonLinkedToken.Visible = false;
                    }

                    try
                    {
                        bool virtAllowed = thandle.IsVirtualizationAllowed;
                        bool virtEnabled = thandle.IsVirtualizationEnabled;

                        if (virtEnabled)
                        {
                            textVirtualized.Text = "Enabled";
                        }
                        else if (virtAllowed)
                        {
                            textVirtualized.Text = "Disabled";
                        }
                        else
                        {
                            textVirtualized.Text = "Not Allowed";
                        }
                    }
                    catch (Exception ex)
                    {
                        textVirtualized.Text = "(" + ex.Message + ")";
                    }

                    try
                    {
                        using (TokenHandle tokenSource = _object.GetToken(TokenAccess.QuerySource))
                        {
                            var source = tokenSource.Source;

                            textSourceName.Text = source.SourceName.TrimEnd('\0', '\r', '\n', ' ');

                            long luid = source.SourceIdentifier.QuadPart;

                            textSourceLUID.Text = "0x" + luid.ToString("x");
                        }
                    }
                    catch (Exception ex)
                    {
                        textSourceName.Text = "(" + ex.Message + ")";
                    }

                    // "Advanced"
                    try
                    {
                        var statistics = thandle.Statistics;

                        textTokenType.Text          = statistics.TokenType.ToString();
                        textImpersonationLevel.Text = statistics.ImpersonationLevel.ToString();
                        textTokenId.Text            = "0x" + statistics.TokenId.ToString();
                        textAuthenticationId.Text   = "0x" + statistics.AuthenticationId.ToString();
                        textMemoryUsed.Text         = Utils.FormatSize(statistics.DynamicCharged);
                        textMemoryAvailable.Text    = Utils.FormatSize(statistics.DynamicAvailable);
                    }
                    catch (Exception ex)
                    {
                        textTokenType.Text = "(" + ex.Message + ")";
                    }

                    try
                    {
                        Sid[] groups = thandle.Groups;

                        _groups = new TokenGroupsList(groups);

                        foreach (var group in groups)
                        {
                            group.Dispose();
                        }

                        _groups.Dock = DockStyle.Fill;
                        tabGroups.Controls.Add(_groups);
                    }
                    catch (Exception ex)
                    {
                        tabGroups.Text = "(" + ex.Message + ")";
                    }

                    try
                    {
                        var privileges = thandle.Privileges;

                        foreach (Privilege t in privileges)
                        {
                            this.AddPrivilege(t);
                        }
                    }
                    catch (Exception ex)
                    {
                        tabPrivileges.Text = "(" + ex.Message + ")";
                    }
                }
            }
            catch (Exception ex)
            {
                tabControl.Visible = false;

                Label errorMessage = new Label
                {
                    Text = ex.Message
                };

                this.Padding = new Padding(15, 10, 0, 0);
                this.Controls.Add(errorMessage);
            }

            if (!OSVersion.HasUac)
            {
                labelElevated.Enabled       = false;
                textElevated.Enabled        = false;
                textElevated.Text           = string.Empty;
                labelVirtualization.Enabled = false;
                textVirtualized.Enabled     = false;
                textVirtualized.Text        = string.Empty;
            }

            if (tabControl.TabPages[Settings.Instance.TokenWindowTab] != null)
            {
                tabControl.SelectedTab = tabControl.TabPages[Settings.Instance.TokenWindowTab];
            }

            ColumnSettings.LoadSettings(Settings.Instance.PrivilegeListColumns, listPrivileges);
            listPrivileges.AddShortcuts();
        }
Esempio n. 10
0
 public void SetColumnSettings(string columnName, bool visible,
         string headerText, int width, HorizontalAlign hAlign, string formatString)
 {
     ColumnSettings colSetting = new ColumnSettings();
     colSetting.HeaderText = headerText;
     colSetting.Visible = visible;
     colSetting.Width = width;
     colSetting.HorizontalAlign = hAlign;
     colSetting.FormatString = formatString;
     this.editableGrid.ColumnsSettings[columnName] = colSetting;
 }