void vc_BreakInqueve(VisualCopy sender) { try { //Dont ask for if(InQueve) becose this ask was made in VisualCopy class //before RaiseBreakInQuevve was called. Configuration.Main.RemoveFromQueve(sender, false); } catch (Exception ex) { MessageBox.Show(Error.GetErrorLog(ex.Message, "NeathCopy", "ContainerWindow", "vc_BreakInqueve")); } }
/// <summary> /// Remove the specific visualCopy from ths listbox container. /// </summary> /// <param name="sender"></param> public void Remove(VisualCopy vc) { try { ManipulateListBox(vc, ListManipulation.Remove); if (listbox1.Items.Count == 0) { listbox1.Dispatcher.Invoke(new Action(Close), null); } } catch (Exception ex) { MessageBox.Show(Error.GetErrorLog(ex.Message, "NeathCopy", "ContainerWindow", "Remove")); } }
void vc_AfterCancel(VisualCopy sender) { try { //Try to play sound Configuration.Main.PLaySoundAfterOperation(Configuration.Main.PlaySound_After_Cancel , Configuration.Main.Cancell_Sound); //Remove from listBox Remove(sender); //Remove from VisualCopy queve if below. Configuration.Main.RemoveFromQueve(sender, true); } catch (Exception ex) { MessageBox.Show(Error.GetErrorLog(ex.Message, "NeathCopy", "ContainerWindow", "vc_AfterCancel")); } }
/// <summary> /// Add a new VisualCopy to this instance. Do not start it. /// </summary> /// <returns></returns> public VisualCopy AddNew() { try { var vc = new VisualCopy(); vc.Id = VisualsCopysHandler.VisualsCopys.Count() + 1; //VisualCopy eventsv vc.BreakInqueve += vc_BreakInqueve; vc.AfterCancel += vc_AfterCancel; vc.Finish += vc_Finish; ManipulateListBox(vc, ListManipulation.Add); return(vc); } catch (Exception ex) { MessageBox.Show(Error.GetErrorLog(ex.Message, "NeathCopy", "ContainerWindow", "AddNew")); return(null); } }
private void ManipulateListBox(VisualCopy vc, ListManipulation listManipulation) { try { // Wait until it is safe to enter. mut.WaitOne(); if (listManipulation == ListManipulation.Add) { listbox1.Dispatcher.Invoke(() => { listbox1.Items.Add(vc); }); } else if (listManipulation == ListManipulation.Remove) { listbox1.Dispatcher.Invoke(() => { listbox1.Items.Remove(vc); }); } // Release the Mutex. mut.ReleaseMutex(); } catch (Exception ex) { MessageBox.Show(Error.GetErrorLog(ex.Message, "NeathCopy", "ContainerWindow", "ManipulateListBox")); } }