Example #1
0
        public decimal ValidateVoidVoucher(string ticketNumber, int userNo, ref int?nResult)
        {
            decimal dAmount = 0;

            try
            {
                // is tis printed ticket
                if (VoucherHelper.IsTISPrintedTicketPrefix(ticketNumber))
                {
                    // if the tis printed ticket available in local db
                    bool isTISTicketAvailable = VoucherHelper.IsTISPrintedTicket(ticketNumber);
                    if (!isTISTicketAvailable)
                    {
                        // wait worst case 10 secs to get the response from TIS
                        int    count   = 10;
                        string message = "Waiting for receiving data from TIS...";
                        WPFExtensions.ShowAsyncDialog(null, message, null, 1, count,
                                                      (o) =>
                        {
                            IAsyncProgress2 o2 = o as IAsyncProgress2;

                            // failure case - hit the tis communication interface and get the ticket
                            try
                            {
                                o2.UpdateStatusProgress(5, message);
                                VoucherHelper.SendTISRedeemTicketQuery(ticketNumber, userNo);
                                o2.UpdateStatusProgress(10, message);
                            }
                            catch (Exception ex)
                            {
                                ExceptionManager.Publish(ex);
                            }
                        });
                    }
                }

                // Success/failure case - ok proceed with voiding
                foreach (var obj in this.ValidateVoidVoucher(ticketNumber, ref nResult))
                {
                    dAmount = Convert.ToDecimal(obj.iAmount) / 100;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }

            return(dAmount);
        }
Example #2
0
        private void SkinPreviewList_PreviewKeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key != Key.Enter)
            {
                return;
            }

            ListViewItem     lbi  = (SkinPreviewList.ItemContainerGenerator.ContainerFromIndex(SkinPreviewList.SelectedIndex)) as ListViewItem;
            ContentPresenter cp   = WPFExtensions.FindVisualChild <ContentPresenter>(lbi);
            DataTemplate     dt   = lbi.ContentTemplate;
            SkinItem         item = (dt.FindName("ItemControl", cp)) as SkinItem;

            if (item != null && SkinPreviewList.IsKeyboardFocusWithin)
            {
                item.OpenContextMenu();
            }
        }
Example #3
0
        /// <summary>
        /// Search the Parts collection for matching Name
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddProductSearchParts_Click(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < dataCandidateParts.Items.Count; i++)
            {
                DataGridRow row  = (DataGridRow)dataCandidateParts.ItemContainerGenerator.ContainerFromIndex(i);
                var         cell = WPFExtensions.GetCell(dataCandidateParts, row, 1);
                TextBlock   tb   = (cell.Content as TextBlock);

                if (tb.Text.ToUpper().Contains(txtAddProductSearch.Text.ToUpper()))
                {
                    row.Background = new SolidColorBrush(Colors.Yellow);
                }
                else
                {
                    row.Background = new SolidColorBrush(Colors.White);
                }
            }
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();


            Editor.Style = WPFExtensions.SearchInMergedDictionaries <Style>("TextBoxStyle");

            BorderThickness = new Thickness(0);

            // Popup boder radius
            {
                var border = (Border)Popup.Child;

                border.CornerRadius = new CornerRadius(1);
            }

            if (IsTextAlignmentCenter)
            {
                Editor.TextAlignment = TextAlignment.Center;
            }
        }
Example #5
0
        private bool DoMux()
        {
            try
            {
                DoPlugin(PluginType.BeforeMux);

                int videoStream    = 0;
                int audioStream    = 0;
                int chapterStream  = 0;
                int subtitleStream = 0;

                foreach (StreamInfo si in demuxedStreamList.streams)
                {
                    if (si.streamType == StreamType.Video)
                    {
                        if (si.extraFileInfo.GetType() == typeof(VideoFileInfo))
                        {
                            if (((VideoFileInfo)si.extraFileInfo).encodedFile != "")
                            {
                                if (File.Exists(((VideoFileInfo)si.extraFileInfo).encodedFile))
                                {
                                    videoStream++;
                                }
                            }
                        }
                    }
                    else if (si.streamType == StreamType.Audio)
                    {
                        if (File.Exists(si.filename))
                        {
                            audioStream++;
                        }
                    }
                    else if (si.streamType == StreamType.Chapter)
                    {
                        chapterStream++;
                    }
                    else if (si.streamType == StreamType.Subtitle)
                    {
                        subtitleStream++;
                    }
                }
                if (!Directory.Exists(settings.targetFolder))
                {
                    logWindow.MessageDemux(Global.Res("ErrorTargetDirectory"));
                    if (!silent)
                    {
                        Global.ErrorMsg(Global.Res("ErrorTargetDirectory"));
                    }
                    return(false);
                }
                if (videoStream == 0)
                {
                    if (!silent)
                    {
                        Global.ErrorMsg(Global.Res("ErrorVideoFile"));
                    }
                    logWindow.MessageMux(Global.Res("ErrorVideoFile"));
                    return(false);
                }
                if (audioStream == 0)
                {
                    if (!silent)
                    {
                        Global.ErrorMsg(Global.Res("ErrorAudioFile"));
                    }
                    logWindow.MessageMux(Global.Res("ErrorAudioFile"));
                    return(false);
                }
                if (chapterStream > 0)
                {
                    bool error = false;
                    foreach (StreamInfo si in demuxedStreamList.streams)
                    {
                        if (si.streamType == StreamType.Chapter)
                        {
                            if (!File.Exists(si.filename))
                            {
                                error = true;
                            }
                        }
                    }
                    if (error)
                    {
                        if (!silent)
                        {
                            Global.ErrorMsg(Global.Res("ErrorChapterFile"));
                        }
                        logWindow.MessageMux(Global.Res("ErrorChapterFile"));
                        return(false);
                    }
                }
                if (subtitleStream > 0)
                {
                    bool error = false;
                    foreach (StreamInfo si in demuxedStreamList.streams)
                    {
                        if (si.streamType == StreamType.Subtitle)
                        {
                            if (si.extraFileInfo.GetType() == typeof(SubtitleFileInfo))
                            {
                                SubtitleFileInfo sfi = (SubtitleFileInfo)si.extraFileInfo;
                                if (sfi.forcedIdx != "")
                                {
                                    if (!File.Exists(sfi.forcedIdx))
                                    {
                                        error = true;
                                    }
                                }
                                if (sfi.forcedSub != "")
                                {
                                    if (!File.Exists(sfi.forcedSub))
                                    {
                                        error = true;
                                    }
                                }
                                if (sfi.forcedSup != "")
                                {
                                    if (!File.Exists(sfi.forcedSup))
                                    {
                                        error = true;
                                    }
                                }

                                if (sfi.normalIdx != "")
                                {
                                    if (!File.Exists(sfi.normalIdx))
                                    {
                                        error = true;
                                    }
                                }
                                if (sfi.normalSub != "")
                                {
                                    if (!File.Exists(sfi.normalSub))
                                    {
                                        error = true;
                                    }
                                }
                                if (sfi.normalSup != "")
                                {
                                    if (!File.Exists(sfi.normalSup))
                                    {
                                        error = true;
                                    }
                                }
                            }
                            else
                            {
                                error = false;
                            }
                        }
                    }
                    if (error)
                    {
                        if (!silent)
                        {
                            Global.ErrorMsg(Global.Res("ErrorSubtitleFile"));
                        }
                        logWindow.MessageMux(Global.Res("ErrorSubtitleFile"));
                        return(false);
                    }
                }

                progressBarMain.IsIndeterminate = false;
                progressBarMain.Maximum         = 100;
                progressBarMain.Minimum         = 0;
                maxProgressValue = 100;

                UpdateStatusBar(0);

                DisableControls();
                UpdateStatus(Global.Res("StatusBar") + " " + Global.Res("StatusBarMux"));

                mt            = new MuxTool(settings, demuxedStreamList);
                mt.OnInfoMsg += new ExternalTool.InfoEventHandler(MuxMsg);
                mt.OnLogMsg  += new ExternalTool.LogEventHandler(MuxMsg);
                mt.Start();
                mt.WaitForExit();

                DoPlugin(PluginType.AfterMux);

                if (mt == null)
                {
                    return(false);
                }
                else
                {
                    return(mt.Successfull);
                }
            }
            catch (Exception ex)
            {
                logWindow.MessageMux(Global.Res("ErrorException") + " " + ex.Message);
                return(false);
            }
            finally
            {
                progressBarMain.IsIndeterminate = true;
                if (isWindows7)
                {
                    WPFExtensions.SetTaskbarProgressState(this, Windows7Taskbar.ThumbnailProgressState.NoProgress);
                }

                EnableControls();
                UpdateStatus(Global.Res("StatusBar") + " " + Global.Res("StatusBarReady"));
            }
        }
Example #6
0
        private bool DoEncode()
        {
            try
            {
                if (!Directory.Exists(settings.workingDir))
                {
                    logWindow.MessageDemux(Global.Res("ErrorWorkingDirectory"));
                    if (!silent)
                    {
                        Global.ErrorMsg(Global.Res("ErrorWorkingDirectory"));
                    }
                    return(false);
                }
                if (settings.encodedMovieDir != "")
                {
                    if (!Directory.Exists(settings.encodedMovieDir))
                    {
                        logWindow.MessageDemux(Global.Res("ErrorEncodedMovieDirectory"));
                        if (!silent)
                        {
                            Global.ErrorMsg(Global.Res("ErrorEncodedMovieDirectory"));
                        }
                        return(false);
                    }
                }
                if (demuxedStreamList.streams.Count == 0)
                {
                    logWindow.MessageSubtitle(Global.Res("ErrorNoDemuxedStreams"));
                    if (!silent)
                    {
                        Global.ErrorMsg(Global.Res("ErrorNoDemuxedStreams"));
                    }
                    return(false);
                }

                VideoFileInfo vfi            = null;
                StreamInfo    vsi            = null;
                bool          suptitle       = false;
                bool          suptitleForced = false;
                StreamInfo    ssi            = null;

                foreach (StreamInfo si in demuxedStreamList.streams)
                {
                    if (si.streamType == StreamType.Video)
                    {
                        vsi = si;
                        if (si.extraFileInfo != null && si.extraFileInfo.GetType() == typeof(VideoFileInfo))
                        {
                            vfi = (VideoFileInfo)si.extraFileInfo;
                        }
                    }
                    else if (si.streamType == StreamType.Subtitle)
                    {
                        if (si.advancedOptions != null && si.advancedOptions.GetType() == typeof(AdvancedSubtitleOptions))
                        {
                            if (((AdvancedSubtitleOptions)si.advancedOptions).supTitle)
                            {
                                // take first hardcode track
                                if (!suptitle)
                                {
                                    suptitle       = true;
                                    suptitleForced = ((AdvancedSubtitleOptions)si.advancedOptions).supTitleOnlyForced;
                                    ssi            = si;
                                }
                            }
                        }
                    }
                }

                if (vfi == null || vfi.cropInfo == null)
                {
                    logWindow.MessageEncode(Global.Res("ErrorCropInfoNotSet"));
                    if (!silent)
                    {
                        Global.ErrorMsg(Global.Res("ErrorCropInfoNotSet"));
                    }
                    return(false);
                }
                else
                {
                    vfi.encodeAvs = settings.workingDir + "\\" + settings.filePrefix + "_encode.avs";

                    string filename = vsi.filename;

                    CropInfo cropInfo = vfi.cropInfo;

                    logWindow.MessageEncode("");
                    logWindow.MessageEncode(Global.ResFormat("InfoCropTop", cropInfo.cropTop));
                    logWindow.MessageEncode(Global.ResFormat("InfoCropBottom", cropInfo.cropBottom));
                    if (cropInfo.border)
                    {
                        logWindow.MessageEncode(Global.ResFormat("InfoBorderTop", cropInfo.borderTop));
                        logWindow.MessageEncode(Global.ResFormat("InfoBorderBottom", cropInfo.borderBottom));
                    }
                    if (cropInfo.resize)
                    {
                        logWindow.MessageEncode(Global.ResFormat("InfoResize", cropInfo.resizeX, cropInfo.resizeY));
                    }

                    string encode = "";
                    if (suptitle)
                    {
                        if (File.Exists(settings.suptitlePath))
                        {
                            encode += "LoadPlugin(\"" + settings.suptitlePath + "\")\r\n";
                        }
                    }
                    if (settings.encodeInput == 0)
                    {
                        encode = "DirectShowSource(\"" + filename + "\")\r\n";
                    }
                    else if (settings.encodeInput == 1)
                    {
                        string dlldir = System.IO.Path.GetDirectoryName(settings.ffmsindexPath);
                        if (File.Exists(dlldir + "\\ffms2.dll"))
                        {
                            encode += "LoadPlugin(\"" + dlldir + "\\ffms2.dll" + "\")\r\n";
                        }
                        encode += "FFVideoSource(\"" + filename + "\")\r\n";
                    }
                    else if (settings.encodeInput == 2)
                    {
                        string output = System.IO.Path.ChangeExtension(filename, "dgi");
                        string dlldir = System.IO.Path.GetDirectoryName(settings.dgindexnvPath);
                        if (File.Exists(dlldir + "\\DGDecodeNV.dll"))
                        {
                            encode += "LoadPlugin(\"" + dlldir + "\\DGDecodeNV.dll" + "\")\r\n";
                        }
                        encode += "DGSource(\"" + output + "\")\r\n";
                    }
                    if (cropInfo.cropTop != 0 || cropInfo.cropBottom != 0)
                    {
                        encode += "Crop(0," + cropInfo.cropTop.ToString() + ",-0,-" + cropInfo.cropBottom.ToString() + ")\r\n";
                    }
                    if (cropInfo.border)
                    {
                        encode += "AddBorders(0," + cropInfo.borderTop + ",0," + cropInfo.borderBottom + ")\r\n";
                    }
                    else
                    {
                        logWindow.MessageEncode(Global.Res("InfoNoBorder"));
                    }
                    if (suptitle && ssi != null)
                    {
                        if (!suptitleForced)
                        {
                            if (File.Exists(ssi.filename))
                            {
                                string forced = "false";
                                encode += "SupTitle(\"" + ssi.filename + "\", forcedOnly=" +
                                          forced + ", swapCbCr=false, relocate=true, relocOffset=\"0," +
                                          cropInfo.cropTop.ToString() + ",0," + cropInfo.cropBottom.ToString() + "\")\r\n";
                            }
                        }
                        else
                        {
                            if (File.Exists(ssi.filename))
                            {
                                string forced = "true";
                                encode += "SupTitle(\"" + ssi.filename + "\", forcedOnly=" +
                                          forced + ", swapCbCr=false, relocate=true, relocOffset=\"0," +
                                          cropInfo.cropTop.ToString() + ",0," + cropInfo.cropBottom.ToString() + "\")\r\n";
                            }
                        }
                    }
                    if (cropInfo.resize)
                    {
                        if (cropInfo.resizeMethod > -1 && cropInfo.resizeMethod < GlobalVars.resizeMethods.Count)
                        {
                            encode += GlobalVars.resizeMethods[cropInfo.resizeMethod] + "(" + cropInfo.resizeX.ToString() + "," + cropInfo.resizeY.ToString() + ")\r\n";
                        }
                        else
                        {
                            encode += "LanczosResize(" + cropInfo.resizeX.ToString() + "," + cropInfo.resizeY.ToString() + ")\r\n";
                        }
                    }
                    else
                    {
                        logWindow.MessageEncode(Global.Res("InfoNoResize"));
                    }

                    int index = settings.lastAvisynthProfile;
                    if (index > -1 && index < settings.avisynthSettings.Count)
                    {
                        string[] tmp = settings.avisynthSettings[index].commands.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string s in tmp)
                        {
                            encode += s.Trim() + "\r\n";
                        }
                    }

                    File.WriteAllText(settings.workingDir + "\\" + settings.filePrefix + "_encode.avs", encode);

                    logWindow.MessageEncode("");
                    logWindow.MessageEncode(Global.Res("InfoAvsContent"));
                    logWindow.MessageEncode("");
                    string[] tmpstr2 = encode.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string s in tmpstr2)
                    {
                        logWindow.MessageEncode(s);
                    }
                }


                if (vfi == null || vfi.encodeAvs == "")
                {
                    logWindow.MessageEncode(Global.Res("ErrorEncodeAvsNotSet"));
                    if (!silent)
                    {
                        Global.ErrorMsg(Global.Res("ErrorEncodeAvsNotSet"));
                    }
                    //return false;
                }

                int profile = settings.lastProfile;
                if (profile < 0)
                {
                    logWindow.MessageEncode(Global.Res("ErrorEncodingProfileNotSet"));
                    if (!silent)
                    {
                        Global.ErrorMsg(Global.Res("ErrorEncodingProfileNotSet"));
                    }
                    return(false);
                }

                UpdateStatus(Global.Res("StatusBar") + " " + Global.ResFormat("StatusBarEncode", ""));
                DisableControls();

                lastMsg    = "";
                secondPass = false;

                if (settings.use64bit && GetMaxFrames() > 0)
                {
                    if (!settings.encodingSettings[profile].pass2)
                    {
                        maxProgressValue = GetMaxFrames();
                    }
                    else
                    {
                        maxProgressValue = 2 * GetMaxFrames();
                    }
                    progressBarMain.IsIndeterminate = false;
                    progressBarMain.Maximum         = 100;
                    progressBarMain.Minimum         = 0;
                }
                else if (!settings.use64bit)
                {
                    if (!settings.encodingSettings[profile].pass2)
                    {
                        maxProgressValue = 100;
                    }
                    else
                    {
                        maxProgressValue = 200;
                    }
                    progressBarMain.IsIndeterminate = false;
                    progressBarMain.Maximum         = 100;
                    progressBarMain.Minimum         = 0;
                }

                UpdateStatusBar(0);

                et            = new EncodeTool(settings, demuxedStreamList, profile, false, vfi);
                et.OnInfoMsg += new ExternalTool.InfoEventHandler(EncodeMsg);
                et.OnLogMsg  += new ExternalTool.LogEventHandler(EncodeMsg);
                et.Start();
                et.WaitForExit();

                if (et == null || !et.Successfull)
                {
                    vfi.encodedFile = "";
                    logWindow.MessageEncode(Global.Res("ErrorEncodeFailed"));
                    return(false);
                }
                if (settings.encodingSettings[profile].pass2)
                {
                    secondPass    = true;
                    et            = new EncodeTool(settings, demuxedStreamList, profile, true, vfi);
                    et.OnInfoMsg += new ExternalTool.InfoEventHandler(EncodeMsg);
                    et.OnLogMsg  += new ExternalTool.LogEventHandler(EncodeMsg);
                    et.Start();
                    et.WaitForExit();
                    if (et == null || !et.Successfull)
                    {
                        vfi.encodedFile = "";
                        logWindow.MessageEncode(Global.Res("ErrorEncode2passFailed"));
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                logWindow.MessageEncode(Global.Res("ErrorException") + " " + ex.Message);
                return(false);
            }
            finally
            {
                progressBarMain.IsIndeterminate = true;
                if (isWindows7)
                {
                    WPFExtensions.SetTaskbarProgressState(this, Windows7Taskbar.ThumbnailProgressState.NoProgress);
                }

                TitleInfo.SaveStreamInfoFile(demuxedStreamList, settings.workingDir + "\\" + settings.filePrefix + "_streamInfo.xml");
                EnableControls();

                UpdateStatus(Global.Res("StatusBar") + " " + Global.Res("StatusBarReady"));
            }
        }
Example #7
0
 public static Color ToColor(this SKColor color)
 => WPFExtensions.ToColor(color);
Example #8
0
 public static SKColor ToSKColor(this Color color)
 => WPFExtensions.ToSKColor(color);