Exemple #1
0
        public void SetLine(CLine Line)
        {
            _Notes.Clear();

            _width = 0f;
            foreach (CNote note in Line.Notes)
            {
                SNote n = new SNote();

                n.Text      = note.Text;
                n.StartBeat = note.StartBeat;
                n.EndBeat   = note.EndBeat;
                n.Duration  = note.Duration;
                n.Type      = note.NoteType;

                _Text.Text  = note.Text;
                _Text.Style = EStyle.Bold;

                if (n.Type == ENoteType.Freestyle)
                {
                    _Text.Style = EStyle.BoldItalic;
                }

                RectangleF rect = CDraw.GetTextBounds(_Text);
                _width += rect.Width;
                _Notes.Add(n);
            }
        }
Exemple #2
0
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            HDC hdc = (HDC)User.GetDC(panel1.Handle);

            if (m_arrShape != null)
            {
                foreach (CShape t in m_arrShape)
                {
                    t.Draw(hdc);
                }
            }

            if (flag)
            {
                if (m_Shape.ToString() == "CPolygon" && m_arrPoint != null)
                {
                    POINT[] t = new POINT[2];
                    t[0].x = m_arrPoint[0].x - distance;
                    t[0].y = m_arrPoint[0].y - distance;
                    t[1].x = m_arrPoint[0].x + distance;
                    t[1].y = m_arrPoint[0].y + distance;
                    CRectangle rec = new CRectangle(t[0], t[1]);
                    rec.SetDrawMode(GDI.R2_COPYPEN);
                    rec.Draw(hdc);

                    POINT[] t1 = new POINT[2];
                    t1[1] = m_arrPoint[0];
                    CLine line = new CLine();
                    line.SetDrawMode(GDI.R2_COPYPEN);
                    Gan(line);
                    for (int i = 1; i < m_arrPoint.Length; ++i)
                    {
                        // Ve duong thang
                        t1[0] = t1[1];
                        t1[1] = m_arrPoint[i];
                        line.SetPoints(t1);
                        line.Draw(hdc);
                        // Ve o vuong nho tai cac dinh
                        t[0].x = m_arrPoint[i].x - distance;
                        t[0].y = m_arrPoint[i].y - distance;
                        t[1].x = m_arrPoint[i].x + distance;
                        t[1].y = m_arrPoint[i].y + distance;
                        rec.SetPoints(t);
                        rec.Draw(hdc);
                    }

                    // Ve duong thang
                    t1[0] = t1[1];
                    t1[1] = m_End;
                    line.SetPoints(t1);
                    line.Draw(hdc);
                }
                else
                {
                    m_Shape.Draw(hdc);
                }
            }

            User.ReleaseDC(panel1.Handle, hdc);
        }
Exemple #3
0
        public CLine GetLineW()
        {
            global::System.IntPtr cPtr = C4dApiPINVOKE.LineObject_GetLineW(swigCPtr);
            CLine ret = (cPtr == global::System.IntPtr.Zero) ? null : new CLine(cPtr, false);

            return(ret);
        }
    public CPath(Vector3[] waypoints, Vector3 startPos, float turnDist, float stoppingDistance)
    {
        lookPoints      = waypoints;
        turnBoundaries  = new CLine[lookPoints.Length];
        finishLineIndex = turnBoundaries.Length - 1;

        Vector2 previousPoint = V3ToV2(startPos);

        for (int i = 0; i < lookPoints.Length; i++)
        {
            Vector2 currentPoint      = V3ToV2(lookPoints[i]);
            Vector2 dirToCurrentPoint = (currentPoint - previousPoint).normalized;
            Vector2 turnBoundatyPoint = (i == finishLineIndex)?currentPoint : currentPoint - dirToCurrentPoint * turnDist;
            turnBoundaries[i] = new CLine(turnBoundatyPoint, previousPoint - dirToCurrentPoint * turnDist);
            previousPoint     = turnBoundatyPoint;
        }

        float distanceFromEndPoint = 0;

        for (int i = lookPoints.Length - 1; i > 0; i--)
        {
            distanceFromEndPoint += Vector3.Distance(lookPoints[i], lookPoints[i - 1]);
            if (distanceFromEndPoint > stoppingDistance)
            {
                slowDownIndex = i;
                break;
            }
        }
    }
Exemple #5
0
 public void BuildColName(CLine szLine)
 {
     m_mapColName.Clear();
     for (int nIdx = 0; nIdx < szLine.szCells.Count; nIdx++)
     {
         m_mapColName.Add(szLine.szCells[nIdx], nIdx);
     }
 }
Exemple #6
0
        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            toolStripStatusLabel1.Text = e.X.ToString() + " : " + e.Y.ToString();

            if (flag)
            {
                POINT[] T = new POINT[2];
                T[0] = m_Start;
                T[1] = m_End;
                HDC hdc = (HDC)User.GetDC(panel1.Handle);

                if (flag1 == false)
                {
                    if (m_Shape.ToString() == "CPolygon")
                    {
                        CShape shape = new CLine();
                        shape.SetPoints(T);
                        Gan(shape);
                        shape.Draw(hdc);
                    }
                    else
                    {
                        m_Shape.SetPoints(T);
                        m_Shape.Draw(hdc);
                    }
                }

                flag1 = false;
                if (m_Shape.ToString() == "CEllipse")
                {
                    int temp = Math.Min(Math.Abs(e.X - m_Start.x), Math.Abs(e.Y - m_Start.y));
                    m_End.x = m_Start.x + Math.Sign(e.X - m_Start.x) * temp;
                    m_End.y = m_Start.y + Math.Sign(e.Y - m_Start.y) * temp;
                }
                else
                {
                    m_End.x = e.X;
                    m_End.y = e.Y;
                }

                T[1] = m_End;
                if (m_Shape.ToString() == "CPolygon")
                {
                    CShape shape = new CLine();
                    shape.SetPoints(T);
                    Gan(shape);
                    shape.Draw(hdc);
                }
                else
                {
                    m_Shape.SetPoints(T);
                    m_Shape.Draw(hdc);
                }
            }
        }
 private void OperationLine(object sender, LineChangeEventArg e)
 {
     if (e.oper == Operations.ADD)
     {
         FrameworkElement obj = new CLine();
         this.tileCanvas.AddLineObject(e.Line.ToString(), obj, e.Line);
     }
     else if (e.oper == Operations.DEL)
     {
         this.tileCanvas.DelSubObject(e.Line.ToString());
     }
 }
        private void BTN_RECT_VERIFY_EDGE_REGION_FST_Click(object sender, EventArgs e)
        {
            uc_tunning_view.VIEW_Set_Clear_DispObject();

            int param_01_PeakCandidate     = Convert.ToInt32(TXT_RECT_CANDIDATE_COUNT.Value);
            int param_02_target_peak_index = Convert.ToInt32(CB_RECT_TARGET_INDEX_FST.Text);

            RDO_RECT_APD_FST.Checked = true;

            Bitmap bmp = uc_tunning_view.GetDisplay_Bmp();

            pm.SetImage(bmp);

            bool bool_horizontal_dir = RDO_RECT_TYPE_HOR.Checked == true ? true : false;

            // draw entire set
            List <PointF> listPeak = pm.GetPeakListSorted(param_01_PeakCandidate, bool_horizontal_dir);

            _ToUI_DrawPeakAnalysis(listPeak, bool_horizontal_dir);

            // get the selected peak and region
            PointF ptCurrent = pm.GetPeakDesinated(param_01_PeakCandidate, bool_horizontal_dir, param_02_target_peak_index);

            int nParse = 5;

            if (bool_horizontal_dir == true)
            {
                CLine line = new CLine(new PointF(0, ptCurrent.Y), new PointF(bmp.Width, ptCurrent.Y));

                CLine lineM = line.ShiftLine(0, -nParse);
                CLine lineP = line.ShiftLine(0, +nParse);

                uc_tunning_view.DrawLine(lineM, 1, Color.DeepSkyBlue);
                uc_tunning_view.DrawLine(line, 1, Color.LimeGreen);
                uc_tunning_view.DrawLine(lineP, 1, Color.DeepSkyBlue);
            }
            else if (bool_horizontal_dir == false)
            {
                CLine line = new CLine(new PointF(ptCurrent.X, 0), new PointF(ptCurrent.X, bmp.Height));

                CLine lineM = line.ShiftLine(-nParse, 0);
                CLine lineP = line.ShiftLine(+nParse, 0);

                uc_tunning_view.DrawLine(lineM, 1, Color.DeepSkyBlue);
                uc_tunning_view.DrawLine(line, 1, Color.LimeGreen);
                uc_tunning_view.DrawLine(lineP, 1, Color.DeepSkyBlue);
            }

            uc_tunning_view.Refresh();
        }
Exemple #9
0
    public virtual void AddCell(CCell value)
    {
        if (this.m_CurrentLine == null)
        {
            return;
        }
        CLine line = this.ContainLine(value);

        if (line != null)
        {
            line.RemoveCell(value);
        }
        this.m_CurrentLine.AddCell(value);
    }
Exemple #10
0
        public void drawLine(CLine line, EMMoving emMoving = EMMoving.FIXED)
        {
            string strCommand;

            float fX1, fY1, fX2, fY2;

            fX1 = (float)line.m_startPoint.m_dX;
            fY1 = (float)line.m_startPoint.m_dY;
            fX2 = (float)line.m_endPoint.m_dX;
            fY2 = (float)line.m_endPoint.m_dY;

            try
            {
                strCommand = "mi_addnode(" + fX1.ToString() + "," + fY1.ToString() + ")";
                sendCommand(strCommand);

                strCommand = "mi_addnode(" + fX2.ToString() + "," + fY2.ToString() + ")";
                sendCommand(strCommand);

                strCommand = "mi_addsegment(" + fX1.ToString() + "," + fY1.ToString() + "," + fX2.ToString() + "," + fY2.ToString() + ")";
                sendCommand(strCommand);

                /// 그룹을 지정하는 경우만 변경을 한다.
                if (emMoving == EMMoving.MOVING)
                {
                    /// 그룹 설정
                    ///  - Point 의 선택이 좌표계산 없이 바로 가능함
                    ///  - 또한 Point 만 그룹을 지정해도 이동이 가능하기 때문에 Point 만 설정함
                    strCommand = "mi_selectnode(" + fX1.ToString() + "," + fY1.ToString() + ")";
                    sendCommand(strCommand);

                    strCommand = "mi_selectnode(" + fX2.ToString() + "," + fY2.ToString() + ")";
                    sendCommand(strCommand);

                    strCommand = "mi_setgroup(" + MOVING_GROUP_NUM.ToString() + ")";
                    sendCommand(strCommand);

                    strCommand = "mi_clearselected()";
                    sendCommand(strCommand);
                }
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                return;
            }
        }
Exemple #11
0
    public virtual void AddLine(CCell value)
    {
        CLine line = this.ContainLine(value);

        if (line == null)
        {
            line = Instantiate(this.m_LinePrefab);
            this.m_Lines.Add(line);
            line.name = "Line " + (this.m_Lines.Count + 1);
        }
        else
        {
            line.Clear();
        }
        line.AddCell(value);
        line.transform.SetParent(this.transform);
        this.m_CurrentLine = line;
    }
Exemple #12
0
    public void BuildLineCell(string szLine, int nIdx)
    {
        string[] vals   = szLine.Split(new char[] { '\t' }, StringSplitOptions.None);
        int      nCount = vals.Length;
        CLine    Line   = new CLine();

        for (int n = 0; n < nCount; n++)
        {
            Line.szCells.Add(vals[n]);
        }

        if (nIdx == 0)
        {
            m_LineList.Clear();
            BuildColName(Line);
        }
        else
        {
            m_LineList.Add(Line);
        }
    }
Exemple #13
0
    public bool Check()
    {
        bool intersect = false;

        for (int i = 0; i < myLines.Length; ++i)
        {
            for (int j = i + 1; j < myLines.Length; ++j)
            {
                if (i != (myLines.Length - 1))
                {
                    intersect = CLine.SegmentIntersection(myLines[i], myLines[j]);
                    if (intersect)
                    {
                        Color2Line(i, j, Color.red);
                        return(intersect);
                    }
                    else
                    {
                        Color2Line(i, j, Color.black);
                    }
                }
                else
                {
                    intersect = CLine.SegmentIntersection(myLines[j], myLines[i]);
                    if (intersect)
                    {
                        Debug.Log("Check " + intersect);
                        Color2Line(i, j, Color.red);
                        return(intersect);
                    }
                    else
                    {
                        Color2Line(i, j, Color.black);
                    }
                }
            }
        }
        Debug.Log("Check " + intersect);
        return(intersect);
    }
Exemple #14
0
        static void Main(string[] args)
        {
            const int size = 42;

            var cline = new CLine(size);
            var sline = new SLine(size);

            PrintSize(cline, sline);

            const int newsize = 17;

            cline.Resize(newsize);
            sline.Resize(newsize);

            PrintSize(cline, sline);

            var isline = (IShape)sline;
            var icline = (IShape)cline;

            PrintSize(icline, isline);
            PrintSize(cline, sline);

            const int newnewsize = 7;

            icline.Resize(newnewsize);
            isline.Resize(newnewsize);

            // !
            PrintSize(icline, isline);
            PrintSize(cline, sline);

            var newicline = icline.ResizeImutable(newnewsize);
            var newisline = isline.ResizeImutable(newnewsize);

            PrintSize(newicline, newisline);
            Console.ReadLine();
        }
Exemple #15
0
 public virtual void EndLine(CCell value)
 {
     this.m_CurrentLine = null;
 }
Exemple #16
0
        public virtual void Draw(int ID, List <CLine> SingLine, int Player)
        {
            int n = FindPlayerLine(ID);

            if (n == -1)
            {
                return;
            }

            if (_PlayerNotes[n].LineNr == -1)
            {
                return;
            }

            if (_PlayerNotes[n].Lines == null)
            {
                return;
            }

            if (_PlayerNotes[n].Lines.Length <= _PlayerNotes[n].LineNr)
            {
                return;
            }

            CLine Line = _PlayerNotes[n].Lines[_PlayerNotes[n].LineNr];

            if (CConfig.DrawNoteLines == EOffOn.TR_CONFIG_ON)
            {
                DrawNoteLines(_PlayerNotes[n].Rect, new SColorF(0.5f, 0.5f, 0.5f, 0.5f * _PlayerNotes[n].Alpha));
            }

            if (Line.NoteCount == 0)
            {
                return;
            }

            float w  = _PlayerNotes[n].Rect.W;
            float h  = _PlayerNotes[n].Rect.H;
            float dh = h / CSettings.NumNoteLines * (2f - (int)CGame.Player[_PlayerNotes[n].PlayerNr].Difficulty) / 4f;

            float beats = Line.LastBeat - Line.FirstBeat + 1;

            if (beats == 0)
            {
                return;
            }

            SColorF color = new SColorF(
                _PlayerNotes[n].Color.R,
                _PlayerNotes[n].Color.G,
                _PlayerNotes[n].Color.B,
                _PlayerNotes[n].Color.A * _PlayerNotes[n].Alpha);

            float BaseLine = Line.BaseLine;
            int   Nr       = 1;

            foreach (CNote note in Line.Notes)
            {
                if (note.NoteType != ENoteType.Freestyle)
                {
                    float width = note.Duration / beats * w;

                    SRectF rect = new SRectF(
                        _PlayerNotes[n].Rect.X + (note.StartBeat - Line.FirstBeat) / beats * w,
                        _PlayerNotes[n].Rect.Y + (CSettings.NumNoteLines - 1 - (note.Tone - BaseLine) / 2) / CSettings.NumNoteLines * h - dh,
                        width,
                        h / CSettings.NumNoteLines + 2 * dh,
                        _PlayerNotes[n].Rect.Z
                        );

                    DrawNoteBG(rect, color, 1f, _PlayerNotes[n].Timer);
                    DrawNote(rect, new SColorF(5f, 5f, 5f, 0.7f * _PlayerNotes[n].Alpha), 0.7f);

                    if (note.NoteType == ENoteType.Golden)
                    {
                        AddGoldenNote(rect, n, Nr);
                        Nr++;
                    }
                }
            }

            if (CConfig.DrawToneHelper == EOffOn.TR_CONFIG_ON)
            {
                DrawToneHelper(n, (int)BaseLine, (CGame.MidBeatD - Line.FirstBeat) / beats * w);
            }

            int i = 0;

            while (i < _PlayerNotes[n].PerfectLineTwinkle.Count)
            {
                _PlayerNotes[n].PerfectLineTwinkle[i].Update();
                if (!_PlayerNotes[n].PerfectLineTwinkle[i].IsAlive)
                {
                    _PlayerNotes[n].PerfectLineTwinkle.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }

            foreach (CParticleEffect perfline in _PlayerNotes[n].PerfectLineTwinkle)
            {
                perfline.Draw();
            }

            if (SingLine == null || SingLine.Count == 0 || CGame.Player[Player].CurrentLine == -1 || SingLine.Count <= CGame.Player[Player].CurrentLine)
            {
                foreach (CParticleEffect stars in _PlayerNotes[n].GoldenStars)
                {
                    stars.Update();
                    stars.Alpha = _PlayerNotes[n].Alpha;
                    stars.Draw();
                }
                return;
            }

            foreach (CNote note in SingLine[CGame.Player[Player].CurrentLine].Notes)
            {
                if (note.StartBeat >= Line.FirstBeat && note.EndBeat <= Line.LastBeat)
                {
                    float width = note.Duration / beats * w;

                    if (note.EndBeat == CGame.ActBeatD)
                    {
                        width -= (1 - (CGame.MidBeatD - CGame.ActBeatD)) / beats * w;
                    }

                    SRectF rect = new SRectF(
                        _PlayerNotes[n].Rect.X + (note.StartBeat - Line.FirstBeat) / beats * w,
                        _PlayerNotes[n].Rect.Y + (CSettings.NumNoteLines - 1 - (note.Tone - BaseLine) / 2) / CSettings.NumNoteLines * h - dh,
                        width,
                        h / CSettings.NumNoteLines + 2 * dh,
                        _PlayerNotes[n].Rect.Z
                        );

                    float f = 0.7f;
                    if (!note.Hit)
                    {
                        f = 0.4f;
                    }

                    DrawNote(rect, color, f);

                    if (note.EndBeat >= CGame.ActBeatD && note.Hit && note.NoteType == ENoteType.Golden)
                    {
                        SRectF re = new SRectF(rect);
                        re.W = (CGame.MidBeatD - note.StartBeat) / beats * w;
                        AddFlare(re, n);
                    }

                    if (note.Perfect && note.EndBeat < CGame.ActBeatD)
                    {
                        AddPerfectNote(rect, n);
                        note.Perfect = false;
                    }
                }
            }

            int currentLine = CGame.Player[Player].SingLine.Count - 1;

            if (currentLine > 0)
            {
                if (CGame.Player[Player].SingLine[currentLine - 1].PerfectLine)
                {
                    AddPerfectLine(n);
                    CGame.Player[Player].SingLine[currentLine - 1].PerfectLine = false;
                }
            }

            i = 0;
            while (i < _PlayerNotes[n].Flares.Count)
            {
                _PlayerNotes[n].Flares[i].Update();
                if (!_PlayerNotes[n].Flares[i].IsAlive)
                {
                    _PlayerNotes[n].Flares.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }

            i = 0;
            while (i < _PlayerNotes[n].PerfectNoteEffect.Count)
            {
                _PlayerNotes[n].PerfectNoteEffect[i].Update();
                if (!_PlayerNotes[n].PerfectNoteEffect[i].IsAlive)
                {
                    _PlayerNotes[n].PerfectNoteEffect.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }



            foreach (CParticleEffect stars in _PlayerNotes[n].GoldenStars)
            {
                stars.Update();
                stars.Alpha = _PlayerNotes[n].Alpha;
                stars.Draw();
            }

            foreach (CParticleEffect flare in _PlayerNotes[n].Flares)
            {
                flare.Draw();
            }

            foreach (CParticleEffect perfnote in _PlayerNotes[n].PerfectNoteEffect)
            {
                perfnote.Draw();
            }
        }
Exemple #17
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //if (dot.Count > 0 && open != 1 && saved == 0)
            //{
            //    this.SaveChanges(this, e, "open");
            //}
            //else
            //{
            Stream         myStream        = null;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = Application.StartupPath + @"\saved";
            openFileDialog1.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                myStream = openFileDialog1.OpenFile();
                StreamReader reader = new StreamReader(myStream);
                try
                {
                    if (myStream != null)
                    {
                        using (myStream)
                        {
                            dot.Clear();
                            line.Clear();
                            int k = Convert.ToInt32(reader.ReadLine());
                            int p = Convert.ToInt32(reader.ReadLine());
                            for (int i = 0; i < k; i++)
                            {
                                MyPoint        = new control.CPoint();
                                MyPoint.mx     = Convert.ToInt32(reader.ReadLine());
                                MyPoint.my     = Convert.ToInt32(reader.ReadLine());
                                MyPoint.vertex = Convert.ToInt32(reader.ReadLine());
                                dot.Add(MyPoint);
                            }
                            for (int i = 0; i < p; i++)
                            {
                                MyLine      = new control.CLine();
                                MyLine.lx_1 = Convert.ToInt32(reader.ReadLine());
                                MyLine.ly_1 = Convert.ToInt32(reader.ReadLine());
                                MyLine.lx_2 = Convert.ToInt32(reader.ReadLine());
                                MyLine.ly_2 = Convert.ToInt32(reader.ReadLine());
                                MyLine.edge = Convert.ToInt32(reader.ReadLine());
                                line.Add(MyLine);
                            }
                            Graph1.count = dot[dot.Count - 1].vertex;
                        }
                        file_path = openFileDialog1.FileName;
                        for (int i = 0; i < file_path.Length; i++)
                        {
                            if (file_path[i] == '\\')
                            {
                                file_name = file_path.Remove(0, i + 1);
                            }
                        }
                        file_name = file_name.Remove(file_name.Length - 4, 4);
                        if (plug_name == null)
                        {
                            this.Text = Application.ProductName + " - " + file_name;
                        }
                        open  = 0;
                        saved = 1;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not read file from the disk! Original error:\n" + ex.Message,
                                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            //}
        }
Exemple #18
0
 public void GotoLineByIndex(int nIdx)
 {
     m_CurLine = m_LineList[nIdx];
 }
Exemple #19
0
        public override void Run()
        {
            // TAPI2_ADDITIONS
            for (int i = 0; i < MAXASYNCCALLS; i++) {
                ma_hCalls[i] = IntPtr.Zero;
            }
            // TAPI2_ADDITIONS.

            // provide default initialization for Tapi members
            m_friendlyAppName = "CTapi";
            //m_AppHandle = this.Handle;
            m_AppHandle = System.IntPtr.Zero;
            m_TapiVersion = 0x00020000;

            m_CTapi = new CTapi(m_friendlyAppName, m_TapiVersion, m_AppHandle, CTapi.LineInitializeExOptions.LINEINITIALIZEEXOPTION_USEEVENT);

            m_CTapi.AppNewCall += new CTapi.AppNewCallEventHandler(this.MyAppNewCallEventHandler);
            m_CTapi.CallStateEvent += new CTapi.CallStateEventHandler(this.MyCallStateEventHandler);
            m_CTapi.LineReplyEvent += new CTapi.LineReplyEventHandler(this.MyLineReplyEventHandler);
            m_CTapi.LineCallInfoEvent += new CTapi.LineCallInfoEventHandler(this.MyLineCallInfoEventHandler);
            m_CTapi.LineAddressStateEvent += new CTapi.LineAddressStateEventHandler(this.MyLineAddressStateEventHandler);
            m_CTapi.LineDevStateEvent += new CTapi.LineDevStateEventHandler(this.MyLineDevStateEventHandler);
            m_CTapi.LineCloseEvent += new CTapi.LineCloseEventHandler(this.MyLineCloseEventHandler);

            string sLineFilter;
            sLineFilter = GetConfigurationValue( "Provider" );
            if (sLineFilter == null)
                throw new DeviceNotRespondingException("Unable to identify TAPI provider - check config file?", new ApplicationException());
            m_CLine = m_CTapi.GetLineByFilter(sLineFilter, false,
                CTapi.LineCallPrivilege.LINECALLPRIVILEGE_OWNER | CTapi.LineCallPrivilege.LINECALLPRIVILEGE_MONITOR);
            if (m_CLine == null) {
                throw new DeviceNotRespondingException("Unable to identify TAPI line for provider #" + sLineFilter, new ApplicationException());
            }
            while (true) {
                Thread.Sleep(500);
            }
        }
Exemple #20
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CLine obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Exemple #21
0
        private void funcFitPolygon1(double[] x, double[] f, object obj)
        {
            f[0] = 0.0;
            f[1] = 0.0;

            int idx = 0;

            foreach (MyPolygon mp in this.polyList)
            {
                MyVector2[] vertices = new MyVector2[N];
                for (int i = 0; i < mp.CornerPoints2d.Count; i++)
                {
                    vertices[i] = center2d[idx] + (mp.CornerPoints2d[i] - center2d[idx]) * x[idx];
                }

                CLine[] segments = new CLine[N];
                for (int i = 0; i < mp.CornerPoints2d.Count; i++)
                {
                    segments[i] = new CLine(vertices[i], vertices[(i + 1) % N]);
                }

                foreach (MyVector2 mv2 in mp.SlicePoints2d)
                {
                    double minDis = double.MaxValue;
                    for (int i = 0; i < N; i++)
                    {
                        double disTmp = segments[i].GetDistance(mv2);
                        if (minDis > disTmp)
                        {
                            minDis = disTmp;
                        }
                    }
                    f[0] += minDis;
                }
                idx++;
            }

            // compute f[1]
            for (int i = 0; i < K; i++)
            {
                if (i == 0)
                {
                    f[1] += Math.Pow(x[i] - x[i + 1], 2);
                }
                else if (i == K - 1)
                {
                    f[1] += Math.Pow(x[i] - x[i - 1], 2);
                }
                else
                {
                    f[1] += Math.Pow(2 * x[i] - x[i - 1] - x[i + 1], 2);
                }
            }
            f[1] *= 1e-1;

            if (outputIdx == 0)
            {
                Console.WriteLine(f[0].ToString("0.000") + "\t" + f[1].ToString("0.000"));
            }
            outputIdx = (outputIdx + 1) % 1000;
        }
Exemple #22
0
        static void Main(string[] args)
        {
            /*
             * string XmlFile = @"C:\tmp\lost.xml";
             * File.Delete(XmlFile);
             *
             * List<DateTime> Gesehen1 = new List<DateTime>();
             * Gesehen1.Add(DateTime.Now);
             * Gesehen1.Add(DateTime.Now.AddDays(1));
             * Gesehen1.Add(DateTime.Now.AddDays(2));
             *
             * List<Folge> FStaffel1 = new List<Folge>();
             * FStaffel1.Add(new Folge(1));
             * FStaffel1.Add(new Folge(2, Gesehen1));
             * FStaffel1.Add(new Folge(3));
             * FStaffel1.Add(new Folge(4));
             *
             * List<Folge> FStaffel2 = new List<Folge>();
             * FStaffel2.Add(new Folge(1));
             * FStaffel2.Add(new Folge(2));
             * FStaffel2.Add(new Folge(3));
             * FStaffel2.Add(new Folge(4, Gesehen1));
             *
             * List<Staffel> LostStaffeln = new List<Staffel>();
             * LostStaffeln.Add(new Staffel(1, FStaffel1));
             * LostStaffeln.Add(new Staffel(2, FStaffel2));
             *
             * Serie CurrentSerie = new Serie("Lost", LostStaffeln);
             *
             * List<Folge> FStaffelX = new List<Folge>();
             * FStaffel1.Add(new Folge(1));
             * FStaffel1.Add(new Folge(2, Gesehen1));
             * FStaffel1.Add(new Folge(3));
             * FStaffel1.Add(new Folge(4));
             *
             * List<Staffel> HeroesStaffeln = new List<Staffel>();
             * LostStaffeln.Add(new Staffel(1, FStaffelX));
             *
             * Serie CurrentSerie2 = new Serie("Heroes", HeroesStaffeln);
             *
             *
             *
             * XDocument Doc = new XDocument();
             * Doc.Add(CurrentSerie.ToXML());
             * Doc.Save(XmlFile);
             *
             * XDocument DocLoad = XDocument.Load(XmlFile);
             * Serie Lost = SerieFactory.FromXElement(DocLoad.Root);
             *
             * */


            List <string> Parsed = new List <string>();

            string[] Content = File.ReadAllLines(@"C:\Users\j.roeding\Desktop\Watched.txt");

            int    Unmatched    = 0;
            string SearchSerie1 = @"(.+) [sS] ([0-9]+) ?[xX] ?([0-9]+[-\/]?[0-9]*)  ?\(([^)]+).*";
            string SearchSerie2 = @"(.+) [sS] ([0-9]+) ?[xX] ?([0-9]+[-\/]?[0-9]*)";



            string Date = string.Empty;

            foreach (string LineForeach in Content)
            {
                string Line = LineForeach;

                // Leere bzw. unrelevante Zeilen überspringen
                if (string.IsNullOrWhiteSpace(Line) || Line == "-" || Line == "?")
                {
                    continue;
                }

                // Zeile enthält Datumsangabe (Datum an dem nachfolgende Einträge gesehen wurden)
                if (Regex.IsMatch(Line, @"^[0-9]+\.[0-9]+\.[0-9]+"))
                {
                    // Datumsangabe merken
                    Date = Line;
                    // Zur nächsten Zeile
                    continue;
                }

                // Reguläre Serien ermitteln und anpassen
                if (Regex.IsMatch(Line, SearchSerie1))
                {
                    Line = Regex.Replace(Line, SearchSerie1, @"<Eintrag><Serie>$1</Serie><Staffel>$2</Staffel><Folgen>$3</Folgen><FolgenName>$4</FolgenName><Gesehen></Gesehen></Eintrag>");
                    Line = ParseGesehenText(Line, Date);
                }

                if (Regex.IsMatch(Line, SearchSerie2))
                {
                    Line = Regex.Replace(Line, SearchSerie2, @"<Eintrag><Serie>$1</Serie><Staffel>$2</Staffel><Folgen>$3</Folgen><FolgenName></FolgenName><Gesehen></Gesehen></Eintrag>");
                    Line = ParseGesehenText(Line, Date);
                }

                // Episoden 'Ausgaben' ermitteln und anpassen
                Get(ref Line, "E3", "E3 PK", Date);

                Get(ref Line, "Rocketbeans", "Almost Daily", Date);
                Get(ref Line, "Rocketbeans", @"Kino\+", Date);
                Get(ref Line, "Rocketbeans", @"Bohn Jour", Date);
                Get(ref Line, "Rocketbeans", @"#MoinMoin", Date);
                Get(ref Line, "Rocketbeans", @"Beans vs Halo", Date);
                Get(ref Line, "Rocketbeans", @"RocketBeans Gamescom", Date);
                Get(ref Line, "Rocketbeans", @"Zock'n'Talk", Date);
                Get(ref Line, "Rocketbeans", @"Super Investigativ", Date);
                Get(ref Line, "Rocketbeans", @"Philsofa", Date);

                Get(ref Line, "OR", @"Pelzig hält sich", Date);
                Get(ref Line, "OR", @"Heute Show", Date);
                Get(ref Line, "OR", @"Roche & Böhmermann", Date);
                Get(ref Line, "OR", @"Quarks & Co", Date);
                Get(ref Line, "OR", @"LateLine", Date);
                Get(ref Line, "OR", @"NEO MAGAZIN", Date);

                Get(ref Line, "Dragonball", @"DBZ", Date);
                Get(ref Line, "Dragonball", @"Dragonball", Date);

                Get(ref Line, "Giga", @"Radio Giga", Date);
                Get(ref Line, "Giga", @"Radio Giga Special", Date);
                Get(ref Line, "Giga", @"Radio Giga - Film", Date);
                Get(ref Line, "Giga", @"JFK", Date);
                Get(ref Line, "Giga", @"G-Log", Date);
                Get(ref Line, "Giga", @"Giga – Top 100 -", Date);
                Get(ref Line, "Giga", @"GIGA Mac Tech", Date);
                Get(ref Line, "Giga", @"Giga Web-TV", Date);



                Get(ref Line, "Game One", @"Plauschangriff", Date);
                Get(ref Line, "Game One", @"Game One", Date);

                Get(ref Line, "RPG Heaven", @"Ausgepackt", Date);
                Get(ref Line, "RPG Heaven", @"Gedankensprung", Date);
                Get(ref Line, "RPG Heaven", @"Weihnachts Gyros 2013", Date);

                Get(ref Line, "_Diverses", @"Random Encounter", Date);
                Get(ref Line, "_Diverses", @"\|\|Backup", Date);
                Get(ref Line, "_Diverses", @"AndroidTalk", Date);
                Get(ref Line, "_Diverses", @"CRIME Stammtisch", Date);
                Get(ref Line, "_Diverses", @"TechTalk", Date);
                Get(ref Line, "_Diverses", @"Stay Forever", Date);
                Get(ref Line, "_Diverses", @"FK\.TV", Date);
                Get(ref Line, "_Diverses", @"AreaCast", Date);
                Get(ref Line, "_Diverses", @"Konsolen & Konsorten", Date);
                Get(ref Line, "_Diverses", @"Postecke", Date);
                Get(ref Line, "_Diverses", @"TvTotal", Date);

                Get(ref Line, "_Hoerbuecher", @"Dan Brown – Inferno", Date);
                Get(ref Line, "_Hoerbuecher", @"Cory Doctorow – Little Brother", Date);

                Get(ref Line, "_Anime", @"Black Lagoon", Date);
                Get(ref Line, "_Anime", @"Detektiv Conan", Date);
                Get(ref Line, "_Anime", @"Highschool of the Dead", Date);
                Get(ref Line, "_Anime", @"Elfenlied", Date);
                Get(ref Line, "_Anime", @"Death Note", Date);

                Get(ref Line, "Kwobb", @"Kwappcast", Date);
                Get(ref Line, "Kwobb", @"Kwobbcast", Date);

                if (Line == LineForeach)
                {
                    Unmatched++;
                    Console.WriteLine(Date + "=>" + Line);
                }
                else
                {
                    Parsed.Add(Line);
                }
            }

            List <WatchedObj> Watched = new List <WatchedObj>();

            foreach (string CLine in Parsed)
            {
                XElement Current = XElement.Parse(CLine.Replace("&", "&amp;"));
                Watched.Add(new WatchedObj(
                                Current.Element("Serie").Value,
                                Current.Element("Staffel").Value,
                                Current.Element("Folgen").Value,
                                Current.Element("FolgenName").Value,
                                Current.Element("Gesehen").Value
                                ));
            }

            /*
             * List<WatchedObj> Custom = new List<WatchedObj>();
             * foreach (WatchedObj C in Watched) {
             *  for (int i = 0; i < C.Folgen.Count; i++) {
             *      Custom.Add(new WatchedObj(C.Serienname, C.Staffelnummer.ToString(), C.Folgen[i].ToString(), C.Folgenname, C.Gesehen.ToString("dd.MM.yyyy")));
             *  }
             * }*/

            List <Serie> Serien = new List <Serie>();

            int MehrfachGesehen = 0;

            foreach (var Current in Watched.GroupBy(Tmp => Tmp.Serienname))
            {
                //Console.WriteLine(Current.Key);

                List <Staffel> Staffeln = new List <Staffel>();

                foreach (var InnerCurrent in Current.GroupBy(Tmp => Tmp.StaffelGroupBy))
                {
                    //Console.WriteLine("   " + InnerCurrent.Key);

                    List <WatchedObj> WObjListe = InnerCurrent.ToList();
                    if (WObjListe.Count > 0)
                    {
                        List <Folge> FolgenUnbereinigt = new List <Folge>();

                        foreach (WatchedObj WOjb in WObjListe)
                        {
                            foreach (int CurrentNummer in WOjb.Folgen)
                            {
                                FolgenUnbereinigt.Add(new Folge(CurrentNummer, false, new DateTime[] { WOjb.Gesehen }, WOjb.Folgenname));
                            }
                            //Console.WriteLine("       " + WOjb.Gesehen);
                        }

                        List <Folge> FolgenBereinigt = new List <Folge>();

                        foreach (var Group in FolgenUnbereinigt.GroupBy(GroupCurrent => GroupCurrent.ToString() + WObjListe[0].Staffelbezeichnung))
                        {
                            if (Group.Count() > 1)
                            {
                                List <DateTime> Gesehen = new List <DateTime>();
                                foreach (Folge FCurrent in Group)
                                {
                                    Gesehen.Add(FCurrent.ZeitpunktGesehen.First());
                                }
                                //Console.WriteLine(Current.Key + " => " + WObjListe[0].Staffelnummer + " => " + Group.Key);
                                //MehrfachGesehen++;
                                Folge New = Group.First();
                                New.ZeitpunktGesehen = new System.Collections.ObjectModel.ObservableCollection <DateTime>(Gesehen);
                                FolgenBereinigt.Add(New);
                            }
                            else
                            {
                                FolgenBereinigt.Add(Group.First());
                            }
                        }

                        Staffeln.Add(new Staffel(WObjListe[0].Staffelnummer, FolgenBereinigt, WObjListe[0].Staffelbezeichnung));
                    }
                }

                Serien.Add(new Serie(Current.Key, Staffeln));
            }

            XmlStuff.Save(Serien);

            Console.WriteLine(Unmatched);
            //Console.WriteLine("Mehrfach ==>" + MehrfachGesehen);
            Console.WriteLine("Fertig");
            Console.ReadKey();
        }
Exemple #23
0
        static void Main(string[] args)
        {
            CPoint point1 = new CPoint()
            {
                X = 1, Y = 1
            };
            CPoint point2 = new CPoint()
            {
                X = 2, Y = 2
            };

            CLine line1 = new CLine()
            {
                StartPoint = point1, EndPoint = point2
            };

            Console.WriteLine(point1);
            Console.WriteLine(point2);
            Console.WriteLine(line1);

            CColoredPoint coloredPoint1 = new CColoredPoint()
            {
                X = 3, Y = 3, Color = ConsoleColor.Red
            };
            CColoredPoint coloredPoint2 = new CColoredPoint()
            {
                X = 4, Y = 4, Color = ConsoleColor.Blue
            };

            Console.ForegroundColor = coloredPoint1.Color;
            Console.WriteLine(coloredPoint1);
            Console.ForegroundColor = coloredPoint2.Color;
            Console.WriteLine(coloredPoint2);
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("------------------");

            CColoredLine coloredLine1 = new CColoredLine()
            {
                StartPoint = point1, EndPoint = point2, Color = ConsoleColor.Green
            };

            Console.ForegroundColor = coloredLine1.Color;
            Console.WriteLine(coloredLine1);
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("------------------");

            CPoliLine poliLine = new CPoliLine();

            poliLine.Lines.Add(line1);
            poliLine.Lines.Add(new CLine()
            {
                StartPoint = new CPoint()
                {
                    X = 5, Y = 5
                },
                EndPoint = new CPoint()
                {
                    X = 6, Y = 6
                }
            });

            Console.WriteLine(poliLine);
        }
Exemple #24
0
    public static bool SegmentIntersection(CLine l1, CLine l2)
    {
        Vector2 p1 = l1.origin.position;
        Vector2 p2 = l1.dest.position;
        Vector2 p3 = l2.origin.position;
        Vector2 p4 = l2.dest.position;


        //Vector2 a = l1.dest.position - l1.origin.position;
        //Vector2 b = l2.origin.position - l2.dest.position;
        //Vector2 c = l1.origin.position - l2.origin.position;

        Vector2 a = p2 - p1;
        Vector2 b = p3 - p4;
        Vector2 c = p1 - p3;

        float alphaNumerator   = b.y * c.x - b.x * c.y;
        float alphaDenominator = a.y * b.x - a.x * b.y;
        float betaNumerator    = a.x * c.y - a.y * c.x;
        float betaDenominator  = a.y * b.x - a.x * b.y;

        bool doIntersect = true;
        bool intersect   = false;


        if (alphaDenominator == 0 || betaDenominator == 0)
        {
            doIntersect = false;
        }
        else
        {
            if (alphaDenominator > 0 && (alphaNumerator < 0 || alphaNumerator > alphaDenominator))
            {
                doIntersect = false;
            }
            else if (alphaNumerator > 0 || alphaNumerator < alphaDenominator)
            {
                doIntersect = false;
            }

            if (betaDenominator > 0)
            {
                if (betaNumerator < 0 || betaNumerator > betaDenominator)
                {
                    doIntersect = false;
                }
                else if (betaNumerator > 0 || betaNumerator < betaDenominator)
                {
                    doIntersect = false;
                }
            }
        }

        if (doIntersect)
        {
            float numX = alphaNumerator * a.x; // numerator //

            float x = p1.x + numX / alphaDenominator;

            float numY = alphaNumerator * a.y;

            float y = p1.y + numY / alphaDenominator;


            if (((p1.x < x && p2.x > x) || (p1.y < y && p2.y > y)) ||
                ((p1.x > x && p2.x < x) || (p1.y > y && p2.y < y)))
            {
                if (((p3.x < x && p4.x > x) || (p3.y < y && p4.y > y)) ||
                    ((p3.x > x && p4.x < x) || (p3.y > y && p4.y < y)))
                {
                    intersect = true;
                }
            }
        }


        return(intersect);
    }