public void OpenNote(string a_filePath, string a_fileName, string a_course)
        {
            // Check to see if note is already open
            foreach (TabPage page in mainTabControl.TabPages)
            {
                if (page.Text == string.Format("[{0}] {1}", a_course, a_fileName))
                {
                    mainTabControl.SelectedTab = page;
                    return;
                }
            }

            CustomRichTextBox newBox = new CustomRichTextBox();

            newBox.Font = new Font(newBox.Font.FontFamily, 10.5f, FontStyle.Regular);
            newBox.LoadFile(a_filePath);
            newBox.Size          = template_rtb.Size;
            newBox.Location      = template_rtb.Location;
            newBox.HideSelection = false;
            newBox.ReadOnly      = true;

            // Create new tab, make sure all TabPage values are srt to null
            CustomTab newTab = new CustomTab("", "", "", null);

            newTab.Text = string.Format("[{0}] {1}", a_course, a_fileName);
            newTab.Controls.Add(newBox);

            mainTabControl.TabPages.Add(newTab);

            ResizeTabControlAndChildren();
        }
        /// <summary>
        /// Sets the label for the specified custom tab.
        /// </summary>
        /// <param name="tab"></param>
        /// <param name="label"></param>
        public void SetCustomTabLabel(CustomTab tab, string label)
        {
            // If it doesn't have access then execute the same function on the UI thread, otherwise just run it.
            if (!Application.Current.Dispatcher.CheckAccess())
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() => SetCustomTabLabel(tab, label)));
                return;
            }

            switch (tab)
            {
            case CustomTab.Tab1:
                App.MainWindow.CustomTab1Label.Content      = label;
                App.Settings.AvalonSettings.CustomTab1Label = label;
                break;

            case CustomTab.Tab2:
                App.MainWindow.CustomTab2Label.Content      = label;
                App.Settings.AvalonSettings.CustomTab2Label = label;
                break;

            case CustomTab.Tab3:
                App.MainWindow.CustomTab3Label.Content      = label;
                App.Settings.AvalonSettings.CustomTab3Label = label;
                break;
            }
        }
        private void ResizeTabControlAndChildren()
        {
            int folderBoxWidth = foldersGroupBox.Width;

            // Get new width
            int newWidth = (Size.Width - mainTabControl.Location.X) - (folderBoxWidth + 40);

            mainTabControl.Width = newWidth;

            // Get new height
            int newHeight = (Size.Height - mainTabControl.Location.Y) - 70;

            mainTabControl.Height = newHeight;

            foreach (TabPage tab in mainTabControl.TabPages)
            {
                CustomTab cTab = (CustomTab)tab;

                foreach (Control ctrl in cTab.Controls)
                {
                    if (ctrl.GetType() == typeof(CustomRichTextBox))
                    {
                        ctrl.Width  = newWidth - 13;
                        ctrl.Height = newHeight - 35;
                    }
                }
            }
        }
Exemple #4
0
 public async Task <SaveResponseDto> Add(CustomTab customTab)
 {
     return(new SaveResponseDto
     {
         SaveSuccessful = await _customTabRepository.AddAsync(customTab) != null,
         RecordId = customTab.Id
     });
 }
Exemple #5
0
        public async Task <SaveResponseDto> UpdateAsync(CustomTab customTab)
        {
            var response = await _customTabRepository.UpdateAsync(customTab, customTab.Id);

            return(new SaveResponseDto
            {
                SaveSuccessful = response != null,
                SavedEntityId = customTab.Id
            });
        }
        // Default ctor
        public MainPageViewModel()
        {
            CustomTabsInfo = new CustomTabsConfigModel();
            CustomTabsInfo.ConfigModelName = "New Test Model";

            CustomTab _customTab = new CustomTab();

            _customTab.Header       = "Test 1 Tab";
            _customTab.TabIsVisible = true;
            //_customTab.TaskCollection = new TaskCollection();

            //UtilitiesTask _task = new UtilitiesTask();
            //_task.TaskTitle = "Task 1";
            //_task.ButtonLabel = "Task 1 Button";
            //_task.ButtonType = "SQL";

            //_customTab.TaskCollection.TaskList.Add(_task);

            //_task = new UtilitiesTask();
            //_task.TaskTitle = "Task 2";
            //_task.ButtonLabel = "Task 2 Button";
            //_task.ButtonType = "Crystal";

            //_customTab.TaskCollection.TaskList.Add(_task);
            CustomTabsInfo.CustomTabCollection.Add(_customTab);

            _customTab              = new CustomTab();
            _customTab.Header       = "Test 2 Tab";
            _customTab.TabIsVisible = true;
            //_task = new UtilitiesTask();
            //_customTab.TaskCollection = new TaskCollection();
            //_customTab.TaskCollection.TaskList.Add(_task);
            CustomTabsInfo.CustomTabCollection.Add(_customTab);


            _customTab              = new CustomTab();
            _customTab.Header       = "Test 3 Tab";
            _customTab.TabIsVisible = true;
            //_task = new UtilitiesTask();
            //_customTab.TaskCollection = new TaskCollection();
            //_customTab.TaskCollection.TaskList.Add(_task);
            CustomTabsInfo.CustomTabCollection.Add(_customTab);


            this.Model = CustomTabsInfo;
            BeginEdit();

            // DEBUG: Associate with IsDirtyInfo
            AssociateProperties(m => m.ConfigModelName, vm => vm.IsDirtyInfo);
            AssociateProperties(m => m.CustomTabCollection, vm => vm.IsDirtyInfo);

            // Handle PropertyChanged event (debugging)
            //Model.PropertyChanged += OnModelPropertyChanged;
        }
Exemple #7
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            ((CustomTab)(mainTabControl.SelectedTab)).Save();
            if (string.IsNullOrEmpty(MainNoteDirectory))
            {
                MessageBox.Show("You need to set a MainNoteDirectory before saving. (File -> Preferences)", "Error", MessageBoxButtons.OK);
                return;
            }

            CustomTab selectedTab = (CustomTab)mainTabControl.SelectedTab;

            selectedTab.Save();
        }
        /// <summary>
        /// Sets the visibility of the specified custom tab.
        /// </summary>
        /// <param name="tab"></param>
        /// <param name="visible"></param>
        public void SetCustomTabVisible(CustomTab tab, bool visible)
        {
            // If it doesn't have access then execute the same function on the UI thread, otherwise just run it.
            if (!Application.Current.Dispatcher.CheckAccess())
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() => SetCustomTabVisible(tab, visible)));
                return;
            }

            switch (tab)
            {
            case CustomTab.Tab1:
                App.MainWindow.CustomTab1.Visibility = visible.ToVisibleOrCollapse();
                break;

            case CustomTab.Tab2:
                App.MainWindow.CustomTab2.Visibility = visible.ToVisibleOrCollapse();
                break;

            case CustomTab.Tab3:
                App.MainWindow.CustomTab3.Visibility = visible.ToVisibleOrCollapse();
                break;
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (AfflictionsTab != null)
            {
                AfflictionsTab.Dispose();
                AfflictionsTab = null;
            }

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

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

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

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

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

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

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

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

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

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

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

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

            if (TopView != null)
            {
                TopView.Dispose();
                TopView = null;
            }
        }
Exemple #10
0
        private void OpenTab(string a_path = "NULL")
        {
            CustomRichTextBox newBox = new CustomRichTextBox();

            newBox.OnLineNumberChanged += Event_OnActiveTextBoxLineChanged;
            newBox.Font          = new Font(newBox.Font.FontFamily, 10.5f, FontStyle.Regular);
            newBox.Size          = template_rtb.Size;
            newBox.Location      = template_rtb.Location;
            newBox.HideSelection = false;

            if (a_path == "NULL")
            {
                using (NewTabDetailsForm form = new NewTabDetailsForm(mLoadedSemesters.ToArray())) {
                    DialogResult result = form.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        // Create new tab, make sure all TabPage values are set to null
                        CustomTab newTab = new CustomTab(form.Semester, form.Course, form.ClassType, MainNoteDirectory + form.Semester + "\\" + form.Course + "\\Notes\\" + string.Format("{0}-{1}-{2}_{3}.rtf", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, form.ClassType));
                        newTab.Text = string.Format("[{0}] {1}", form.Course,
                                                    string.Format("{0}-{1}-{2}_{3}.rtf", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, form.ClassType));
                        newTab.Controls.Add(newBox);

                        mainTabControl.TabPages.Add(newTab);

                        mainTabControl.SelectedIndex = mainTabControl.TabPages.Count - 1;

                        // If the tab that was just added is the only tab (TabPages.Count == 1)
                        if (mainTabControl.TabPages.Count == 1)
                        {
                            foreach (Control ctrl in mainTabControl.SelectedTab.Controls)
                            {
                                if (ctrl.GetType() == typeof(CustomRichTextBox))
                                {
                                    activeRichTextBox = (CustomRichTextBox)ctrl;
                                    CustomConsole.Log("Set the child of CustomTab with id: " + ((CustomTab)mainTabControl.SelectedTab).mTabId + " to the active CustomRichTextBox");
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                string[] splitFileName = a_path.Split('\\');

                string temp_semester = splitFileName[splitFileName.Length - 4];

                string[] classTypeSplit = splitFileName[splitFileName.Length - 1].Split('_');
                string   temp_classtype = classTypeSplit[1].Split('.')[0];
                string   temp_course    = splitFileName[splitFileName.Length - 3];

                newBox.LoadFile(a_path);

                // Create new tab, make sure all TabPage values are srt to null
                CustomTab newTab = new CustomTab(temp_semester, temp_course, temp_classtype, a_path);
                newTab.Text = string.Format("[{0}] {1}", temp_course, splitFileName[splitFileName.Length - 1]);
                newTab.Controls.Add(newBox);

                mainTabControl.TabPages.Add(newTab);

                CustomConsole.Log("Opened file to edit: " + a_path);

                // If the tab that was just added is the only tab (TabPages.Count == 1)
                if (mainTabControl.TabPages.Count == 1)
                {
                    foreach (Control ctrl in mainTabControl.SelectedTab.Controls)
                    {
                        if (ctrl.GetType() == typeof(CustomRichTextBox))
                        {
                            activeRichTextBox = (CustomRichTextBox)ctrl;
                            CustomConsole.Log("Set the child of CustomTab with id: " + ((CustomTab)mainTabControl.SelectedTab).mTabId + " to the active CustomRichTextBox");
                        }
                    }
                }
            }
        }