Exemplo n.º 1
0
        internal static ProjectKey?GetFileStorageProjectKey(string path)
        {
            string descriptionFilename = System.IO.Path.Combine(path, FileStorageConfig);

            if (System.IO.File.Exists(descriptionFilename))
            {
                try
                {
                    FileStorageDescription x = JsonUtils.LoadFromFile <FileStorageDescription>(descriptionFilename);
                    return(new ProjectKey(x.HostName, x.ProjectName));
                }
                catch (Exception ex)
                {
                    ExceptionHandlers.Handle("Cannot read serialized FileStorageDescription object", ex);
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        static private void integrateInGitUI()
        {
            string scriptPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);

            try
            {
                GitExtensionsIntegrationHelper.AddCustomActions(scriptPath);
                SourceTreeIntegrationHelper.AddCustomActions(scriptPath);
            }
            catch (GitExtensionsIntegrationHelperException ex)
            {
                ExceptionHandlers.Handle("Cannot integrate mrHelper in Git Extensions", ex);
            }
            catch (SourceTreeIntegrationHelperException ex)
            {
                ExceptionHandlers.Handle("Cannot integrate mrHelper in Source Tree", ex);
            }
        }
Exemplo n.º 3
0
 private void bindingListUserGroupControls_ListChanged(object sender, ListChangedEventArgs e)
 {
     try
     {
         if (this.SelectedUserGroupIndex != null && e.PropertyDescriptor != null && e.NewIndex >= 0 && e.NewIndex < this.bindingListUserGroupControls.Count)
         {
             UserGroupControlDTO userGroupControlDTO = this.bindingListUserGroupControls[e.NewIndex];
             if (userGroupControlDTO != null)
             {
                 this.userGroupAPIs.SaveUserGroupControls(this.SelectedUserGroupIndex, userGroupControlDTO, e.PropertyDescriptor.Name);
             }
         }
     }
     catch (Exception exception)
     {
         ExceptionHandlers.ShowExceptionMessageBox(this, exception);
     }
 }
Exemplo n.º 4
0
        public ColumnMappings(GlobalEnums.MappingTaskID mappingTaskID, string excelFile, string sheetName)
        {
            InitializeComponent();
            try
            {
                this.oleDbAPIs = new OleDbAPIs(CommonNinject.Kernel.Get <IOleDbAPIRepository>(), mappingTaskID);

                this.excelFile     = excelFile;
                this.sheetName     = sheetName;
                this.mappingTaskID = mappingTaskID;

                this.Text = "Mapping for " + this.excelFile;
            }
            catch (Exception exception)
            {
                ExceptionHandlers.ShowExceptionMessageBox(this, exception);
            }
        }
Exemplo n.º 5
0
 private void GetUserGroupReports()
 {
     try
     {
         if (this.userGroupAPIs != null && this.bindingListUserGroupReports != null)
         {
             IList <UserGroupReport> userGroupReports = this.userGroupAPIs.GetUserGroupReports(this.SelectedUserGroupIndex != null ? this.SelectedUserGroupIndex.UserGroupID : 0);
             this.bindingListUserGroupReports.RaiseListChangedEvents = false;
             Mapper.Map <ICollection <UserGroupReport>, ICollection <UserGroupReportDTO> >(userGroupReports, this.bindingListUserGroupReports);
             this.bindingListUserGroupReports.RaiseListChangedEvents = true;
             this.bindingListUserGroupReports.ResetBindings();
         }
     }
     catch (Exception exception)
     {
         ExceptionHandlers.ShowExceptionMessageBox(this, exception);
     }
 }
Exemplo n.º 6
0
 private void buttonUserRemove_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.UserID > 0)
         {
             if (CustomMsgBox.Show(this, "Are you sure you want to delete " + this.comboUserID.Text + "?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == DialogResult.Yes)
             {
                 this.userAPIs.UserRemove(this.UserID);
                 this.comboUserID.ComboBox.DataSource = this.userAPIs.GetUserIndexes();
             }
         }
     }
     catch (Exception exception)
     {
         ExceptionHandlers.ShowExceptionMessageBox(this, exception);
     }
 }
Exemplo n.º 7
0
 private void bindingListUserAccessControls_ListChanged(object sender, ListChangedEventArgs e)
 {
     try
     {
         if (e.PropertyDescriptor != null && e.NewIndex >= 0 && e.NewIndex < this.bindingListUserAccessControls.Count)
         {
             UserAccessControlDTO userAccessControlDTO = this.bindingListUserAccessControls[e.NewIndex];
             if (userAccessControlDTO != null)
             {
                 this.userAPIs.SaveUserAccessControls(userAccessControlDTO.AccessControlID, userAccessControlDTO.AccessLevel, userAccessControlDTO.ApprovalPermitted, userAccessControlDTO.UnApprovalPermitted, userAccessControlDTO.VoidablePermitted, userAccessControlDTO.UnVoidablePermitted, userAccessControlDTO.ShowDiscount);
             }
         }
     }
     catch (Exception exception)
     {
         ExceptionHandlers.ShowExceptionMessageBox(this, exception);
     }
 }
Exemplo n.º 8
0
        async private Task loadBranchListAsync()
        {
            Debug.Assert(_sourceBranchTemplate != null);
            onSourceBranchListLoadStart();

            IEnumerable <Branch> branchList = null;;

            try
            {
                branchList = await _repositoryAccessor.GetBranches(_sourceBranchTemplate);
            }
            catch (RepositoryAccessorException ex)
            {
                string message = String.Format("Cannot load a list of branches by template {0}", _sourceBranchTemplate);
                ExceptionHandlers.Handle(message, ex);
            }
            onSourceBranchListLoadFinish(branchList);
        }
Exemplo n.º 9
0
 private void bindingListUserGroupReports_ListChanged(object sender, ListChangedEventArgs e)
 {
     try
     {
         if (this.SelectedUserGroupIndex != null && e.PropertyDescriptor != null && e.NewIndex >= 0 && e.NewIndex < this.bindingListUserGroupReports.Count)
         {
             UserGroupReportDTO userGroupReportDTO = this.bindingListUserGroupReports[e.NewIndex];
             if (userGroupReportDTO != null)
             {
                 this.userGroupAPIs.SaveUserGroupReports(userGroupReportDTO.UserGroupReportID, this.SelectedUserGroupIndex.UserGroupID, this.SelectedUserGroupIndex.Name, userGroupReportDTO.ReportID, userGroupReportDTO.ReportName, userGroupReportDTO.Enabled);
             }
         }
     }
     catch (Exception exception)
     {
         ExceptionHandlers.ShowExceptionMessageBox(this, exception);
     }
 }
Exemplo n.º 10
0
 public void Save()
 {
     try
     {
         if (this.myController.Save())
         {
             if (this.EscapeAfterSave)
             {
                 this.Escape();
             }
             this.Loading();
         }
     }
     catch (Exception exception)
     {
         ExceptionHandlers.ShowExceptionMessageBox(this, exception);
     }
 }
Exemplo n.º 11
0
 private void fastListIndex_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (this.ReadonlyMode)
         {
             int?selectedIndexID = this.getSelectedIndexID();
             if (selectedIndexID != null && selectedIndexID != this.baseDTO.GetID())
             {
                 this.invokeEdit(selectedIndexID);
             }
         }
     }
     catch (Exception exception)
     {
         ExceptionHandlers.ShowExceptionMessageBox(this, exception);
     }
 }
Exemplo n.º 12
0
        async Task updateDiscussions(MergeRequestKey mrk, DiscussionUpdateType type)
        {
            if (_reconnect)
            {
                return;
            }

            try
            {
                await updateDiscussionsAsync(mrk, type);
            }
            catch (OperatorException ex)
            {
                ExceptionHandlers.Handle(String.Format(
                                             "Cannot update discussions for MR: Host={0}, Project={1}, IId={2}",
                                             mrk.ProjectKey.HostName, mrk.ProjectKey.ProjectName, mrk.IId.ToString()), ex);
            }
        }
Exemplo n.º 13
0
 private void buttonUserAdmin_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.SelectedUserControlIndex != null && this.SelectedUserControlIndex.UserID > 0 && this.SelectedUserControlIndex.SecurityIdentifier != ContextAttributes.User.SecurityIdentifier)
         {
             if (CustomMsgBox.Show(this, "Are you sure you want to " + (this.SelectedUserControlIndex.IsDatabaseAdmin ? "unset" : "set") + " as admin for this user?" + "\r\n" + "\r\nUser:  "******"Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == DialogResult.Yes)
             {
                 this.userControlAPIs.UserControlSetAdmin(this.SelectedUserControlIndex.UserID, this.SelectedUserControlIndex.UserName, this.SelectedUserControlIndex.SecurityIdentifier, !this.SelectedUserControlIndex.IsDatabaseAdmin);
                 this.LoadUserControls();
             }
         }
     }
     catch (Exception exception)
     {
         ExceptionHandlers.ShowExceptionMessageBox(this, exception);
     }
 }
Exemplo n.º 14
0
 private void buttonUserToggleVoid_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.SelectedUserControlIndex != null && this.SelectedUserControlIndex.UserID > 0 && this.SelectedUserControlIndex.SecurityIdentifier != ContextAttributes.User.SecurityIdentifier)
         {
             if (CustomMsgBox.Show(this, "Are you sure you want to " + (this.SelectedUserControlIndex.InActive ? "enable" : "disable") + " this user registration?" + "\r\n" + "\r\nUser:  "******"Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == DialogResult.Yes)
             {
                 this.userControlAPIs.UserControlToggleVoid(this.SelectedUserControlIndex.UserID, this.SelectedUserControlIndex.UserName, this.SelectedUserControlIndex.SecurityIdentifier, !this.SelectedUserControlIndex.InActive);
                 this.LoadUserControls();
             }
         }
     }
     catch (Exception exception)
     {
         ExceptionHandlers.ShowExceptionMessageBox(this, exception);
     }
 }
Exemplo n.º 15
0
 private void buttonUserToggleVoid_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.SelectedUserIndex != null && this.SelectedUserIndex.UserID > 0 && !this.SelectedUserIndex.IsDatabaseAdmin)
         {
             if (CustomMsgBox.Show(this, "Are you sure you want to " + (this.SelectedUserIndex.InActive ? "enable" : "disable") + " this user registration?" + "\r\n" + "\r\nUser:  "******"\r\nAt:  " + this.SelectedUserIndex.FullyQualifiedOrganizationalUnitName, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == DialogResult.Yes)
             {
                 this.userAPIs.UserToggleVoid(this.SelectedUserIndex.UserID, !this.SelectedUserIndex.InActive);
                 this.LoadUserTrees();
             }
         }
     }
     catch (Exception exception)
     {
         ExceptionHandlers.ShowExceptionMessageBox(this, exception);
     }
 }
Exemplo n.º 16
0
 private void comboFilterTexts_TextChanged(object sender, EventArgs e)
 {
     try
     {
         IToolstripChild toolstripChild = ActiveMdiChild as IToolstripChild;
         if (toolstripChild != null)
         {
             if (sender.Equals(this.comboFilterTexts))
             {
                 toolstripChild.ApplyFilter(this.comboFilterTexts.Text);
             }
         }
     }
     catch (Exception exception)
     {
         ExceptionHandlers.ShowExceptionMessageBox(this, exception);
     }
 }
Exemplo n.º 17
0
 private void Instructions_GridUpdated(object sender, EventArgs e)
 {
     if (_mdef.Body != null)
     {
         if (Settings.Default.OptimizeAndFixIL)
         {
             // this will also call ComputeOffsets
             _mdef.Body.SimplifyMacros();
             _mdef.Body.OptimizeMacros();
         }
         else
         {
             _mdef.Body.ComputeOffsets();
         }
     }
     Instructions.Rehash();
     ExceptionHandlers.Rehash();
 }
Exemplo n.º 18
0
        private void WizardDetail_Load(object sender, EventArgs e)
        {
            try
            {
                if (this.deliveryAdviceViewModel.SalesOrderID != null)
                {
                    this.olvSalesOrderEntryDate.Width = 0; this.olvSalesOrderReference.Width = 0;
                }

                List <PendingSalesOrderDetail> pendingSalesOrderDetails = this.deliveryAdviceAPIs.GetPendingSalesOrderDetails(this.deliveryAdviceViewModel.LocationID, this.deliveryAdviceViewModel.DeliveryAdviceID, this.deliveryAdviceViewModel.SalesOrderID, this.deliveryAdviceViewModel.CustomerID, this.deliveryAdviceViewModel.ReceiverID, string.Join(",", this.deliveryAdviceViewModel.ViewDetails.Select(d => d.SalesOrderDetailID)), false);
                this.fastPendingSalesOrderDetails.SetObjects(pendingSalesOrderDetails);
                this.customTabBatch.TabPages[0].Text = "Pending " + this.fastPendingSalesOrderDetails.GetItemCount().ToString("N0") + " item" + (this.fastPendingSalesOrderDetails.GetItemCount() > 1 ? "s      " : "      ");
            }
            catch (Exception exception)
            {
                ExceptionHandlers.ShowExceptionMessageBox(this, exception);
            }
        }
Exemplo n.º 19
0
        private DiffStatistic?parseGitDiffStatistic(ILocalCommitStorage repo, MergeRequestKey mrk,
                                                    GitDiffArguments args)
        {
            void traceError(string text)
            {
                Trace.TraceError(String.Format(
                                     "[GitBasedSizeCollector] Cannot parse git diff text {0} obtained by key {3} in the repo {2} (in \"{1}\"). "
                                     + "This makes impossible to show git statistic for MR with IID {4}", text, repo.Path,
                                     String.Format("{0}/{1}", args.CommonArgs.Sha1?.ToString() ?? "N/A",
                                                   args.CommonArgs.Sha2?.ToString() ?? "N/A"),
                                     String.Format("{0}:{1}", repo.ProjectKey.HostName, repo.ProjectKey.ProjectName), mrk.IId));
            }

            IEnumerable <string> statText = null;

            try
            {
                statText = repo.Git?.ShowDiff(args);
            }
            catch (GitNotAvailableDataException ex)
            {
                ExceptionHandlers.Handle("Cannot obtain git statistic", ex);
            }

            if (statText == null || !statText.Any())
            {
                traceError(statText == null ? "\"null\"" : "(empty)");
                return(null);
            }

            int parseOrZero(string x) => int.TryParse(x, out int result) ? result : 0;

            string firstLine = statText.First();
            Match  m         = gitDiffStatRe.Match(firstLine);

            if (!m.Success || !m.Groups["files"].Success || parseOrZero(m.Groups["files"].Value) < 1)
            {
                traceError(firstLine);
                return(null);
            }

            return(new DiffStatistic(parseOrZero(m.Groups["files"].Value),
                                     parseOrZero(m.Groups["ins"].Value), parseOrZero(m.Groups["del"].Value)));
        }
Exemplo n.º 20
0
        public void LoadDiscussions()
        {
            _synchronizeInvoke?.BeginInvoke(new Action(
                                                async() =>
            {
                if (_dataCache?.DiscussionCache == null)
                {
                    Loaded?.Invoke(null);
                    return;
                }

                Trace.TraceInformation(String.Format(
                                           "[AsyncDiscussionLoader] Loading discussions. Hostname: {0}, Project: {1}, MR IId: {2}...",
                                           _mergeRequestKey.ProjectKey.HostName, _mergeRequestKey.ProjectKey.ProjectName, _mergeRequestKey.IId));

                IEnumerable <Discussion> discussions = null;
                StatusChanged?.Invoke("Loading discussions");
                try
                {
                    discussions = await _dataCache.DiscussionCache.LoadDiscussions(_mergeRequestKey);
                }
                catch (DiscussionCacheException ex)
                {
                    string message = "Cannot load discussions from GitLab";
                    ExceptionHandlers.Handle(message, ex);
                    MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    StatusChanged?.Invoke(String.Empty);
                }

                if (discussions != null)
                {
                    Trace.TraceInformation("[DiscussionsForm] Checking for new commits...");

                    StatusChanged?.Invoke("Checking for new commits");
                    await _updateGit(_mergeRequestKey, discussions);
                    StatusChanged?.Invoke(String.Empty);
                }

                Loaded?.Invoke(discussions);
            }), null);
        }
Exemplo n.º 21
0
        async private Task submitNewBodyAsync(Control noteControl, string newText)
        {
            DiscussionNote oldNote = getNoteFromControl(noteControl);

            if (oldNote == null || newText == oldNote.Body)
            {
                // TextBox.Tag is equal to TextBox.Text ==> text was not changed
                return;
            }

            if (newText.Length == 0)
            {
                MessageBox.Show("Discussion text cannot be empty", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Color       oldColor = noteControl.BackColor;
            ContextMenu oldMenu  = noteControl.ContextMenu;

            disableNoteControl(noteControl); // let's make a visual effect similar to other modifications

            DiscussionNote newNote;

            try
            {
                newNote = await _editor.ModifyNoteBodyAsync(oldNote.Id, newText);
            }
            catch (DiscussionEditorException ex)
            {
                string message = "Cannot update discussion text";
                ExceptionHandlers.Handle(message, ex);
                MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                newNote = oldNote;
            }

            if (!noteControl.IsDisposed && newNote != null)
            {
                enableNoteControl(noteControl, oldColor, oldMenu, newNote);
                setDiscussionNoteText(noteControl, newNote);
            }

            _onContentChanged(this, true);
        }
Exemplo n.º 22
0
        async protected override Task doUpdate(ILocalCommitStorage repo)
        {
            foreach (KeyValuePair <MergeRequestKey, Version> keyValuePair in collectLatestVersions(repo))
            {
                DiffStatistic?diffStat = null;
                if (!String.IsNullOrEmpty(keyValuePair.Value.Base_Commit_SHA) &&
                    !String.IsNullOrEmpty(keyValuePair.Value.Head_Commit_SHA))
                {
                    GitDiffArguments args = new GitDiffArguments
                                            (
                        GitDiffArguments.DiffMode.ShortStat,
                        new GitDiffArguments.CommonArguments
                        (
                            keyValuePair.Value.Base_Commit_SHA,
                            keyValuePair.Value.Head_Commit_SHA,
                            null, null, null
                        ),
                        null
                                            );

                    bool finished = repo?.Updater == null;
                    CommitBasedContextProvider contextProvider = new CommitBasedContextProvider(
                        new string[] { keyValuePair.Value.Head_Commit_SHA }, keyValuePair.Value.Base_Commit_SHA);
                    repo?.Updater?.RequestUpdate(contextProvider, () => finished = true);
                    await TaskUtils.WhileAsync(() => !finished);

                    try
                    {
                        if (repo?.Git != null)
                        {
                            await repo.Git.FetchAsync(args);
                        }
                        diffStat = parseGitDiffStatistic(repo, keyValuePair.Key, args);
                    }
                    catch (FetchFailedException ex)
                    {
                        ExceptionHandlers.Handle(String.Format(
                                                     "Cannot update git statistic for MR with IID {0}", keyValuePair.Key), ex);
                    }
                }
                _statistic[keyValuePair.Key] = new MergeRequestStatistic(keyValuePair.Value.Created_At, diffStat);
                Update?.Invoke();
            }
        }
Exemplo n.º 23
0
        private void buttonOKESC_Click(object sender, EventArgs e)
        {
            try
            {
                if (sender.Equals(this.buttonOK))
                {
                    this.DialogResult = DialogResult.OK;
                }

                if (sender.Equals(this.buttonESC))
                {
                    this.DialogResult = DialogResult.Cancel;
                }
            }
            catch (Exception exception)
            {
                ExceptionHandlers.ShowExceptionMessageBox(this, exception);
            }
        }
Exemplo n.º 24
0
        private void buttonItems_Click(object sender, EventArgs e)
        {
            try
            {
                //MasterMDI masterMDI = new MasterMDI(GlobalEnums.NmvnTaskID.Commodity, new Commodities());

                MasterMDI masterMDI = new MasterMDI(GlobalEnums.NmvnTaskID.BatchMaster, new BatchMasters());

                masterMDI.ShowDialog();
                masterMDI.Dispose();

                this.combexCommodityID.DataSource = this.commodityAPIs.GetCommodityBases();
                this.invokeEdit(this.batchViewModel.BatchID);
            }
            catch (Exception exception)
            {
                ExceptionHandlers.ShowExceptionMessageBox(this, exception);
            }
        }
Exemplo n.º 25
0
 internal static void MigrateDirectory(string oldPath, string newPath)
 {
     if (Directory.Exists(newPath))
     {
         DeleteDirectoryIfExists(oldPath);
     }
     else if (Directory.Exists(oldPath))
     {
         try
         {
             Directory.Move(oldPath, newPath);
         }
         catch (Exception ex) // Any exception from Directory.Move()
         {
             ExceptionHandlers.Handle(String.Format("Cannot rename directory at path {0}", oldPath), ex);
             DeleteDirectoryIfExists(oldPath);
         }
     }
 }
Exemplo n.º 26
0
        internal ByteCodeMethodBody(JavaClassImage classImage, CodeAttribute attribute)
        {
            MaxStack = attribute.MaxStack;

            // Read instructions.
            var disassembler = new ByteCodeDisassembler(new MemoryBigEndianReader(attribute.Code))
            {
                OperandResolver = new DefaultOperandResolver(classImage)
            };

            foreach (var instruction in disassembler.ReadInstructions())
            {
                Instructions.Add(instruction);
            }

            // Read exception handlers.
            foreach (var handler in attribute.ExceptionHandlers)
            {
                ExceptionHandlers.Add(new ExceptionHandler(classImage, this, handler));
            }

            // Read attributes.
            foreach (var attr in attribute.Attributes)
            {
                string name = classImage.ClassFile.ConstantPool.ResolveString(attr.NameIndex);
                switch (name)
                {
                // Local variables
                case LocalVariableTableAttribute.AttributeName:
                    var localsTable = LocalVariableTableAttribute.FromReader(new MemoryBigEndianReader(attr.Contents));
                    foreach (var info in localsTable.LocalVariables)
                    {
                        Variables.Add(new LocalVariable(classImage, this, info));
                    }
                    break;


                default:
                    ExtraAttributes.Add(name, attr.Clone());
                    break;
                }
            }
        }
Exemplo n.º 27
0
        private void MasterMdi_MdiChildActivate(object sender, EventArgs e)
        {
            try
            {
                ToolStripManager.RevertMerge(this.toolstripMain);
                IToolstripMerge mergeToolstrip = ActiveMdiChild as IToolstripMerge;
                if (mergeToolstrip != null)
                {
                    ToolStripManager.Merge(mergeToolstrip.toolstripChild, toolstripMain);
                }

                IToolstripChild toolstripChild = ActiveMdiChild as IToolstripChild;
                if (toolstripChild != null)
                {
                    toolstripChild.PropertyChanged -= new PropertyChangedEventHandler(toolstripChild_PropertyChanged);
                    toolstripChild.PropertyChanged += new PropertyChangedEventHandler(toolstripChild_PropertyChanged);

                    toolstripChild_PropertyChanged(toolstripChild, new PropertyChangedEventArgs("IsDirty"));
                }

                else
                {
                    this.toolStripSeparatorPrint.Visible = false;
                    this.buttonPrint.Visible             = false;
                    this.buttonPrintPreview.Visible      = false;
                }

                this.buttonEscape.Visible       = toolstripChild != null;
                this.separatorInputData.Visible = toolstripChild != null;

                this.labelSearchBarcode.Visible = toolstripChild != null;
                this.panelTopRight.Width        = (toolstripChild != null ? this.labelSearchBarcode.Width + 20 : 10) + this.comboSearchBarcode.Width + this.buttonSearchBarcode.Width + this.buttonReports.Width;

                if (ActiveMdiChild != null)
                {
                    ActiveMdiChild.WindowState = FormWindowState.Maximized;
                }
            }
            catch (Exception exception)
            {
                ExceptionHandlers.ShowExceptionMessageBox(this, exception);
            }
        }
        internal void SaveComparison(string baseSha, string headSha, Comparison comparison)
        {
            string comparisonCacheFilepath = getComparisonCacheFilepath(baseSha, headSha);
            string comparisonCacheDirName  = Path.GetDirectoryName(comparisonCacheFilepath);

            if (!System.IO.Directory.Exists(comparisonCacheDirName))
            {
                System.IO.Directory.CreateDirectory(comparisonCacheDirName);
            }

            try
            {
                JsonUtils.SaveToFile(comparisonCacheFilepath, comparison);
            }
            catch (Exception ex) // Any exception from JsonUtils.SaveToFile()
            {
                ExceptionHandlers.Handle("Cannot serialize Comparison object", ex);
            }
        }
Exemplo n.º 29
0
 private void buttonEscape_Click(object sender, EventArgs e)
 {
     try
     {
         IToolstripChild toolstripChild = ActiveMdiChild as IToolstripChild;
         if (toolstripChild != null)
         {
             toolstripChild.Escape();
         }
         if (this.MdiChildren.Length <= 0)
         {
             this.naviBarModuleMaster.Collapsed = false;
         }
     }
     catch (Exception exception)
     {
         ExceptionHandlers.ShowExceptionMessageBox(this, exception);
     }
 }
Exemplo n.º 30
0
        private void initializeColorScheme()
        {
            bool createColorScheme(string filename)
            {
                string filepath = Path.Combine(Directory.GetCurrentDirectory(), filename);

                try
                {
                    _colorScheme = new ColorScheme(filepath, _expressionResolver);
                    return(true);
                }
                catch (ArgumentException ex)
                {
                    ExceptionHandlers.Handle("Cannot create a color scheme", ex);
                }
                return(false);
            }

            if (comboBoxColorSchemes.SelectedIndex < 0 || comboBoxColorSchemes.Items.Count < 1)
            {
                // nothing is selected or list is empty, create an empty scheme
                _colorScheme = new ColorScheme();
            }

            // try to create a scheme for the selected item
            else if (!createColorScheme(comboBoxColorSchemes.Text))
            {
                string message = String.Format("Cannot initialize color scheme {0}",
                                               comboBoxColorSchemes.Text);
                addOperationRecord(message);

                if (comboBoxColorSchemes.SelectedIndex > 0)
                {
                    comboBoxColorSchemes.SelectedIndex = 0;
                }
                else
                {
                    _colorScheme = new ColorScheme();
                }
            }

            forEachListView(listView => listView.SetColorScheme(_colorScheme));
        }