Esempio n. 1
0
        public override void Paint(Graphics graphics)
        {
            Point pointN  = SupplierElement.GetOutputLineConnectionPoint(Item);
            Point pointM  = ConsumerElement.GetInputLineConnectionPoint(Item);
            Point pointN2 = new Point(pointN.X, pointN.Y - Math.Max((int)((pointN.Y - pointM.Y) / 2), 40));
            Point pointM2 = new Point(pointM.X, pointM.Y + Math.Max((int)((pointN.Y - pointM.Y) / 2), 40));

            using (Pen pen = new Pen(DataCache.IconAverageColour(Item.Icon), 3f))
            {
                graphics.DrawBezier(pen, pointN, pointN2, pointM2, pointM);
            }
        }
Esempio n. 2
0
        public override void Paint(System.Drawing.Graphics graphics)
        {
            Point pointN = Parent.ScreenToGraph(Parent.PointToClient(Cursor.Position));
            Point pointM = pointN;

            if (SupplierElement != null)
            {
                pointN = SupplierElement.GetOutputLineConnectionPoint(Item);
            }
            if (ConsumerElement != null)
            {
                pointM = ConsumerElement.GetInputLineConnectionPoint(Item);
            }
            Point pointN2 = new Point(pointN.X, pointN.Y - Math.Max((int)((pointN.Y - pointM.Y) / 2), 40));
            Point pointM2 = new Point(pointM.X, pointM.Y + Math.Max((int)((pointN.Y - pointM.Y) / 2), 40));

            using (Pen pen = new Pen(DataCache.IconAverageColour(Item.Icon), 3f))
            {
                graphics.DrawBezier(pen, pointN, pointN2, pointM2, pointM);
            }
        }
Esempio n. 3
0
        public void Run(object sender, DoWorkEventArgs args)
        {
            while (alive)
            {
                mutex.WaitOne();
                mutex.Reset();

                if (!alive)
                {
                    return;
                }

                while (q.Count > 0)
                {
                    serializer.WaitOne();
                    serializer.Reset();

                    ConsumerElement element = q.Dequeue();

                    var fileName = "Shared/ShellContent/" + element.PhotoHash + ".jpg";

                    App.Current.RootFrame.Dispatcher.BeginInvoke(() => {
                        bool finished = false;

                        using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) {
                            if (isf.FileExists(fileName))
                            {
                                try {
                                    var file = isf.OpenFile(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

                                    if (file.Length == 0)
                                    {
                                        file.Close();
                                        isf.DeleteFile(fileName);
                                    }
                                    else
                                    {
                                        try {
                                            var PhotoUri = new BitmapImage();
                                            PhotoUri.SetSource(file);

                                            element.SuccessCallback(element.PhotoHash, PhotoUri);
                                            serializer.Set();

                                            file.Close();

                                            finished = true;
                                        } catch (Exception e) {
                                            System.Diagnostics.Debug.WriteLine(e);

                                            file.Close();
                                            isf.DeleteFile(fileName);
                                        }
                                    }
                                } catch (Exception e) {
                                    System.Diagnostics.Debug.WriteLine(e);
                                }
                            }
                        }

                        if (!finished)
                        {
                            App.Current.GtalkHelper.DownloadImage(
                                element.Contact,
                                () => App.Current.RootFrame.Dispatcher.BeginInvoke(() => {
                                using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) {
                                    try {
                                        using (var file = isf.OpenFile(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
                                            var PhotoUri = new BitmapImage();
                                            PhotoUri.SetSource(file);
                                            element.SuccessCallback(element.PhotoHash, PhotoUri);
                                            serializer.Set();
                                        }
                                    } catch (Exception e) {
                                        System.Diagnostics.Debug.WriteLine(e);
                                        element.ErrorCallback("");
                                        serializer.Set();
                                    }
                                }
                            }),
                                () => {
                                serializer.Set();
                                element.ErrorCallback("");
                            }
                                );
                        }
                    });
                }
            }
        }